Skip to content

Commit ccecf30

Browse files
committed
Install referenced schema in "dependabot:validate" task
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.
1 parent c4393b0 commit ccecf30

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Taskfile.yml

+7
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ tasks:
364364
SCHEMA_URL: https://json.schemastore.org/dependabot-2.0
365365
SCHEMA_PATH:
366366
sh: task utility:mktemp-file TEMPLATE="dependabot-schema-XXXXXXXXXX.json"
367+
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/base.json
368+
BASE_SCHEMA_URL: https://json.schemastore.org/base.json
369+
BASE_SCHEMA_PATH:
370+
sh: task utility:mktemp-file TEMPLATE="base-schema-XXXXXXXXXX.json"
367371
# The Dependabot configuration file for the repository.
368372
DATA_PATH: ".github/dependabot.yml"
369373
# The asset Dependabot configuration files.
@@ -372,17 +376,20 @@ tasks:
372376
sh: task utility:mktemp-folder TEMPLATE="dependabot-validate-XXXXXXXXXX"
373377
cmds:
374378
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
379+
- wget --quiet --output-document="{{.BASE_SCHEMA_PATH}}" {{.BASE_SCHEMA_URL}}
375380
- |
376381
npx ajv-cli validate \
377382
--all-errors \
378383
--strict=false \
379384
-s "{{.SCHEMA_PATH}}" \
385+
-r "{{.BASE_SCHEMA_PATH}}" \
380386
-d "{{.DATA_PATH}}"
381387
- |
382388
npx ajv-cli validate \
383389
--all-errors \
384390
--strict=false \
385391
-s "{{.SCHEMA_PATH}}" \
392+
-r "{{.BASE_SCHEMA_PATH}}" \
386393
-d "{{.ASSETS_DATA_PATH}}"
387394
388395
docs:generate:

0 commit comments

Comments
 (0)