Skip to content

Commit 88d0d36

Browse files
committed
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 base 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/base.json#/definitions/license from id https://json.schemastore.org/package.json# 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 a `-r` flag.
1 parent f06d527 commit 88d0d36

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

.github/workflows/check-npm.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,16 @@ jobs:
5252
location: ${{ runner.temp }}/json-schema
5353
file-name: ava.json
5454

55+
# This schema is referenced by the package.json schema, so must also be accessible.
56+
- name: Download base JSON schema
57+
id: download-base-schema
58+
uses: carlosperate/download-file-action@v2
59+
with:
60+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/base.json
61+
file-url: https://json.schemastore.org/base.json
62+
location: ${{ runner.temp }}/json-schema
63+
file-name: base.json
64+
5565
# This schema is referenced by the package.json schema, so must also be accessible.
5666
- name: Download JSON schema for eslintrc.json
5767
id: download-eslintrc-schema
@@ -132,6 +142,7 @@ jobs:
132142
ajv validate \
133143
-s "${{ steps.download-schema.outputs.file-path }}" \
134144
-r "${{ steps.download-ava-schema.outputs.file-path }}" \
145+
-r "${{ steps.download-base-schema.outputs.file-path }}" \
135146
-r "${{ steps.download-eslintrc-schema.outputs.file-path }}" \
136147
-r "${{ steps.download-jscpd-schema.outputs.file-path }}" \
137148
-r "${{ steps.download-npm-badges-schema.outputs.file-path }}" \

0 commit comments

Comments
 (0)