Skip to content

Commit

Permalink
Install referenced schema in "dependabot:validate" task
Browse files Browse the repository at this point in the history
The "dependabot:validate" task 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
Dependabot configuration schema was recently updated to share resources with the "base" configuration schema, which
caused the validation to start failing:

schema /tmp/dependabot-schema-CuMFs6bqY1.json is invalid
error: can't resolve reference https://json.schemastore.org/base.json#/definitions/timezone from id https://json.schemastore.org/timezone

The solution is to configure the task to download that schema as well and also to provide its path to the avj-cli
validator via a `-r` flag.
  • Loading branch information
per1234 committed Jan 31, 2024
1 parent c4393b0 commit ccecf30
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,10 @@ tasks:
SCHEMA_URL: https://json.schemastore.org/dependabot-2.0
SCHEMA_PATH:
sh: task utility:mktemp-file TEMPLATE="dependabot-schema-XXXXXXXXXX.json"
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/base.json
BASE_SCHEMA_URL: https://json.schemastore.org/base.json
BASE_SCHEMA_PATH:
sh: task utility:mktemp-file TEMPLATE="base-schema-XXXXXXXXXX.json"
# The Dependabot configuration file for the repository.
DATA_PATH: ".github/dependabot.yml"
# The asset Dependabot configuration files.
Expand All @@ -372,17 +376,20 @@ tasks:
sh: task utility:mktemp-folder TEMPLATE="dependabot-validate-XXXXXXXXXX"
cmds:
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
- wget --quiet --output-document="{{.BASE_SCHEMA_PATH}}" {{.BASE_SCHEMA_URL}}
- |
npx ajv-cli validate \
--all-errors \
--strict=false \
-s "{{.SCHEMA_PATH}}" \
-r "{{.BASE_SCHEMA_PATH}}" \
-d "{{.DATA_PATH}}"
- |
npx ajv-cli validate \
--all-errors \
--strict=false \
-s "{{.SCHEMA_PATH}}" \
-r "{{.BASE_SCHEMA_PATH}}" \
-d "{{.ASSETS_DATA_PATH}}"
docs:generate:
Expand Down

0 comments on commit ccecf30

Please sign in to comment.