Skip to content

Commit d0d9da2

Browse files
committed
Install referenced schemas 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 `.stylelintrc` and semantic-release configuration schemas, 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/stylelintrc.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.
1 parent 6a3c55e commit d0d9da2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

.github/workflows/check-npm.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,26 @@ jobs:
7272
location: ${{ runner.temp }}/json-schema
7373
file-name: prettierrc-schema.json
7474

75+
# This schema is referenced by the package.json schema, so must also be accessible.
76+
- name: Download JSON schema for semantic-release
77+
id: download-semantic-release-schema
78+
uses: carlosperate/download-file-action@v1
79+
with:
80+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/semantic-release.json
81+
file-url: https://json.schemastore.org/semantic-release.json
82+
location: ${{ runner.temp }}/json-schema
83+
file-name: semantic-release-schema.json
84+
85+
# This schema is referenced by the package.json schema, so must also be accessible.
86+
- name: Download JSON schema for .stylelintrc
87+
id: download-stylelintrc-schema
88+
uses: carlosperate/download-file-action@v1
89+
with:
90+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/stylelintrc.json
91+
file-url: https://json.schemastore.org/stylelintrc.json
92+
location: ${{ runner.temp }}/json-schema
93+
file-name: stylelintrc-schema.json
94+
7595
- name: Install JSON schema validator
7696
# package.json schema is draft-04, which is not supported by ajv-cli >=4.
7797
run: sudo npm install --global [email protected]
@@ -84,6 +104,8 @@ jobs:
84104
-r "${{ steps.download-ava-schema.outputs.file-path }}" \
85105
-r "${{ steps.download-eslintrc-schema.outputs.file-path }}" \
86106
-r "${{ steps.download-prettierrc-schema.outputs.file-path }}" \
107+
-r "${{ steps.download-semantic-release-schema.outputs.file-path }}" \
108+
-r "${{ steps.download-stylelintrc-schema.outputs.file-path }}" \
87109
-d "./**/package.json"
88110
89111
check-sync:

0 commit comments

Comments
 (0)