From 8557c04dcbffd7858612623b4936d9380bfdb567 Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 6 Nov 2022 17:30:27 -0800 Subject: [PATCH 1/2] Install referenced schema in "Check npm" workflow The "Check npm" GitHub Actions workflow validates the repository's `package.json` npm manifest file against its JSON schema to catch any problems with its data format. In order to avoid duplication of content, JSON schemas may reference other schemas via the `$ref` keyword. The `package.json` schema was recently updated to share resources with the npm-badges configuration schema, which caused the validation to start failing: schema /home/runner/work/_temp/json-schema/package-json-schema.json is invalid error: can't resolve reference https://json.schemastore.org/npm-badges.json from id # The solution is to configure the workflow to download that schema as well and also to provide its path to the avj-cli validator via an `-r` flag. --- Taskfile.yml | 6 ++++++ workflow-templates/assets/check-npm-task/Taskfile.yml | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Taskfile.yml b/Taskfile.yml index 21fc920f..f01e298d 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -655,6 +655,10 @@ tasks: JSCPD_SCHEMA_URL: https://json.schemastore.org/jscpd.json JSCPD_SCHEMA_PATH: sh: task utility:mktemp-file TEMPLATE="jscpd-schema-XXXXXXXXXX.json" + # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/npm-badges.json + NPM_BADGES_SCHEMA_URL: https://json.schemastore.org/npm-badges.json + NPM_BADGES_SCHEMA_PATH: + sh: task utility:mktemp-file TEMPLATE="npm-badges-schema-XXXXXXXXXX.json" # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/prettierrc.json PRETTIERRC_SCHEMA_URL: https://json.schemastore.org/prettierrc.json PRETTIERRC_SCHEMA_PATH: @@ -677,6 +681,7 @@ tasks: - wget --quiet --output-document="{{.AVA_SCHEMA_PATH}}" {{.AVA_SCHEMA_URL}} - wget --quiet --output-document="{{.ESLINTRC_SCHEMA_PATH}}" {{.ESLINTRC_SCHEMA_URL}} - wget --quiet --output-document="{{.JSCPD_SCHEMA_PATH}}" {{.JSCPD_SCHEMA_URL}} + - wget --quiet --output-document="{{.NPM_BADGES_SCHEMA_PATH}}" {{.NPM_BADGES_SCHEMA_URL}} - wget --quiet --output-document="{{.PRETTIERRC_SCHEMA_PATH}}" {{.PRETTIERRC_SCHEMA_URL}} - wget --quiet --output-document="{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" {{.SEMANTIC_RELEASE_SCHEMA_URL}} - wget --quiet --output-document="{{.STYLELINTRC_SCHEMA_PATH}}" {{.STYLELINTRC_SCHEMA_URL}} @@ -688,6 +693,7 @@ tasks: -r "{{.AVA_SCHEMA_PATH}}" \ -r "{{.ESLINTRC_SCHEMA_PATH}}" \ -r "{{.JSCPD_SCHEMA_PATH}}" \ + -r "{{.NPM_BADGES_SCHEMA_PATH}}" \ -r "{{.PRETTIERRC_SCHEMA_PATH}}" \ -r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \ -r "{{.STYLELINTRC_SCHEMA_PATH}}" \ diff --git a/workflow-templates/assets/check-npm-task/Taskfile.yml b/workflow-templates/assets/check-npm-task/Taskfile.yml index 1bb051e9..0aeb6975 100644 --- a/workflow-templates/assets/check-npm-task/Taskfile.yml +++ b/workflow-templates/assets/check-npm-task/Taskfile.yml @@ -26,6 +26,10 @@ tasks: JSCPD_SCHEMA_URL: https://json.schemastore.org/jscpd.json JSCPD_SCHEMA_PATH: sh: task utility:mktemp-file TEMPLATE="jscpd-schema-XXXXXXXXXX.json" + # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/npm-badges.json + NPM_BADGES_SCHEMA_URL: https://json.schemastore.org/npm-badges.json + NPM_BADGES_SCHEMA_PATH: + sh: task utility:mktemp-file TEMPLATE="npm-badges-schema-XXXXXXXXXX.json" # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/prettierrc.json PRETTIERRC_SCHEMA_URL: https://json.schemastore.org/prettierrc.json PRETTIERRC_SCHEMA_PATH: @@ -48,6 +52,7 @@ tasks: - wget --quiet --output-document="{{.AVA_SCHEMA_PATH}}" {{.AVA_SCHEMA_URL}} - wget --quiet --output-document="{{.ESLINTRC_SCHEMA_PATH}}" {{.ESLINTRC_SCHEMA_URL}} - wget --quiet --output-document="{{.JSCPD_SCHEMA_PATH}}" {{.JSCPD_SCHEMA_URL}} + - wget --quiet --output-document="{{.NPM_BADGES_SCHEMA_PATH}}" {{.NPM_BADGES_SCHEMA_URL}} - wget --quiet --output-document="{{.PRETTIERRC_SCHEMA_PATH}}" {{.PRETTIERRC_SCHEMA_URL}} - wget --quiet --output-document="{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" {{.SEMANTIC_RELEASE_SCHEMA_URL}} - wget --quiet --output-document="{{.STYLELINTRC_SCHEMA_PATH}}" {{.STYLELINTRC_SCHEMA_URL}} @@ -59,6 +64,7 @@ tasks: -r "{{.AVA_SCHEMA_PATH}}" \ -r "{{.ESLINTRC_SCHEMA_PATH}}" \ -r "{{.JSCPD_SCHEMA_PATH}}" \ + -r "{{.NPM_BADGES_SCHEMA_PATH}}" \ -r "{{.PRETTIERRC_SCHEMA_PATH}}" \ -r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \ -r "{{.STYLELINTRC_SCHEMA_PATH}}" \ From 888fcbfefee4bc0af483f50610067c336ffd286e Mon Sep 17 00:00:00 2001 From: per1234 Date: Sun, 6 Nov 2022 17:31:13 -0800 Subject: [PATCH 2/2] Update URL of taskfile schema in "Check Taskfiles" workflow The "Check Taskfiles" template workflow validates the project's taskfiles against the official JSON schema. The contents of that schema was recently moved from the previous location in the Schema Store to the Task project repository: https://github.com/go-task/task/pull/910 An attempt was made to mitigate the impact of that move by replacing the content in the original schema with an external reference to the new one. However, the schema validator used by the workflow does not automatically follow external references, which caused the workflow to fail: schema /home/runner/work/_temp/taskfile-schema/taskfile.json is invalid error: can't resolve reference https://taskfile.dev/schema.json from id # Although this could be resolved by also downloading the referenced schema, since the original schema intentionally does not contain anything of value, the better fix is to simply use the real schema directly in the workflow. --- .github/workflows/check-taskfiles.yml | 4 ++-- workflow-templates/check-taskfiles.yml | 4 ++-- .../.github/workflows/check-taskfiles.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/check-taskfiles.yml b/.github/workflows/check-taskfiles.yml index 4484cfd5..e1b29030 100644 --- a/.github/workflows/check-taskfiles.yml +++ b/.github/workflows/check-taskfiles.yml @@ -51,8 +51,8 @@ jobs: id: download-schema uses: carlosperate/download-file-action@v2 with: - # See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json - file-url: https://json.schemastore.org/taskfile.json + # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json + file-url: https://taskfile.dev/schema.json location: ${{ runner.temp }}/taskfile-schema - name: Install JSON schema validator diff --git a/workflow-templates/check-taskfiles.yml b/workflow-templates/check-taskfiles.yml index 4484cfd5..e1b29030 100644 --- a/workflow-templates/check-taskfiles.yml +++ b/workflow-templates/check-taskfiles.yml @@ -51,8 +51,8 @@ jobs: id: download-schema uses: carlosperate/download-file-action@v2 with: - # See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json - file-url: https://json.schemastore.org/taskfile.json + # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json + file-url: https://taskfile.dev/schema.json location: ${{ runner.temp }}/taskfile-schema - name: Install JSON schema validator diff --git a/workflow-templates/dependabot/workflow-template-copies/.github/workflows/check-taskfiles.yml b/workflow-templates/dependabot/workflow-template-copies/.github/workflows/check-taskfiles.yml index 4484cfd5..e1b29030 100644 --- a/workflow-templates/dependabot/workflow-template-copies/.github/workflows/check-taskfiles.yml +++ b/workflow-templates/dependabot/workflow-template-copies/.github/workflows/check-taskfiles.yml @@ -51,8 +51,8 @@ jobs: id: download-schema uses: carlosperate/download-file-action@v2 with: - # See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json - file-url: https://json.schemastore.org/taskfile.json + # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json + file-url: https://taskfile.dev/schema.json location: ${{ runner.temp }}/taskfile-schema - name: Install JSON schema validator