Skip to content

Commit

Permalink
Install referenced schema in "Check npm" workflow
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
per1234 committed Oct 31, 2022
1 parent 3190bbe commit 988bd0d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/check-npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,16 @@ jobs:
location: ${{ runner.temp }}/json-schema
file-name: jscpd-schema.json

# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download JSON schema for Prettier configuration file
id: download-npm-badges-schema
uses: carlosperate/download-file-action@v2
with:
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/npm-badges.json
file-url: https://json.schemastore.org/npm-badges.json
location: ${{ runner.temp }}/json-schema
file-name: npm-badges-schema.json

# This schema is referenced by the package.json schema, so must also be accessible.
- name: Download JSON schema for Prettier configuration file
id: download-prettierrc-schema
Expand Down Expand Up @@ -114,6 +124,7 @@ jobs:
-r "${{ steps.download-ava-schema.outputs.file-path }}" \
-r "${{ steps.download-eslintrc-schema.outputs.file-path }}" \
-r "${{ steps.download-jscpd-schema.outputs.file-path }}" \
-r "${{ steps.download-npm-badges-schema.outputs.file-path }}" \
-r "${{ steps.download-prettierrc-schema.outputs.file-path }}" \
-r "${{ steps.download-semantic-release-schema.outputs.file-path }}" \
-r "${{ steps.download-stylelintrc-schema.outputs.file-path }}" \
Expand Down

0 comments on commit 988bd0d

Please sign in to comment.