Skip to content

Commit d2ec2bf

Browse files
committed
Use project version of ajv-cli in validation tasks
The "ajv-cli" command line tool is used for validating data files against their JSON schema. The tool is used to validate the project's Dependabot and ESLint configuration files. In general, it is preferable (and for some schemas even mandatory) to use the modern versions of ajv-cli. However, support for the "Draft-04" schema specification was dropped in ajv-cli version 4.0.0. So when working with JSON schemas that specify that draft, it is necessary to use ajv-cli 3.3.0, the last compatible version. Previously, the Dependabot and ESLint schema specified the "Draft-04" specification. For this reason, the `dependabot:validate` and `eslint:validate` tasks were configured to use ajv-cli@3.3.0. The schemas have now been updated to use "Draft-07". So the code for using ajv-cli@3.3.0 is removed from these tasks, and they will now use the standard project level version of ajv-cli.
1 parent ce81472 commit d2ec2bf

File tree

1 file changed

+31
-24
lines changed

1 file changed

+31
-24
lines changed

Taskfile.yml

Lines changed: 31 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ tasks:
357357
358358
dependabot:validate:
359359
desc: Validate Dependabot configuration files against their JSON schema
360+
deps:
361+
- task: npm:install-deps
360362
vars:
361363
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/dependabot-2.0.json
362364
SCHEMA_URL: https://json.schemastore.org/dependabot-2.0
@@ -370,25 +372,29 @@ tasks:
370372
DATA_PATH: ".github/dependabot.yml"
371373
# The asset Dependabot configuration files.
372374
ASSETS_DATA_PATH: "workflow-templates/assets/dependabot/**/dependabot.yml"
373-
WORKING_FOLDER:
374-
sh: task utility:mktemp-folder TEMPLATE="dependabot-validate-XXXXXXXXXX"
375375
cmds:
376376
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
377377
- wget --quiet --output-document="{{.BASE_SCHEMA_PATH}}" {{.BASE_SCHEMA_URL}}
378378
- |
379-
npx ajv-cli validate \
380-
--all-errors \
381-
--strict=false \
382-
-s "{{.SCHEMA_PATH}}" \
383-
-r "{{.BASE_SCHEMA_PATH}}" \
384-
-d "{{.DATA_PATH}}"
379+
npx \
380+
--package=ajv-cli \
381+
--package=ajv-formats \
382+
ajv validate \
383+
--all-errors \
384+
--strict=false \
385+
-s "{{.SCHEMA_PATH}}" \
386+
-r "{{.BASE_SCHEMA_PATH}}" \
387+
-d "{{.DATA_PATH}}"
385388
- |
386-
npx ajv-cli validate \
387-
--all-errors \
388-
--strict=false \
389-
-s "{{.SCHEMA_PATH}}" \
390-
-r "{{.BASE_SCHEMA_PATH}}" \
391-
-d "{{.ASSETS_DATA_PATH}}"
389+
npx \
390+
--package=ajv-cli \
391+
--package=ajv-formats \
392+
ajv validate \
393+
--all-errors \
394+
--strict=false \
395+
-s "{{.SCHEMA_PATH}}" \
396+
-r "{{.BASE_SCHEMA_PATH}}" \
397+
-d "{{.ASSETS_DATA_PATH}}"
392398
393399
docs:generate:
394400
desc: Create all generated documentation content
@@ -397,6 +403,8 @@ tasks:
397403

398404
eslint:validate:
399405
desc: Validate ESLint configuration file against its JSON schema
406+
deps:
407+
- task: npm:install-deps
400408
vars:
401409
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/eslintrc.json
402410
SCHEMA_URL: https://json.schemastore.org/eslintrc.json
@@ -409,20 +417,19 @@ tasks:
409417
DATA_PATH: workflow-templates/assets/check-javascript/.eslintrc.yml
410418
# ajv-cli identifies YAML-format data files by their file extension, so renaming is required:
411419
# https://github.com/ajv-validator/ajv-cli/issues/117
412-
PROJECT_FOLDER:
413-
sh: pwd
414-
WORKING_FOLDER:
415-
sh: task utility:mktemp-folder TEMPLATE="eslintrc-validate-XXXXXXXXXX"
416420
cmds:
417421
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
418422
- wget --quiet --output-document="{{.PARTIAL_ESLINT_PLUGINS_PATH}}" {{.PARTIAL_ESLINT_PLUGINS_SCHEMA_URL}}
419423
- |
420-
cd "{{.WORKING_FOLDER}}" # Workaround for https://github.com/npm/cli/issues/3210
421-
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
422-
--all-errors \
423-
-s "{{.SCHEMA_PATH}}" \
424-
-r "{{.PARTIAL_ESLINT_PLUGINS_PATH}}" \
425-
-d "{{.PROJECT_FOLDER}}/{{.DATA_PATH}}"
424+
npx \
425+
--package=ajv-cli \
426+
--package=ajv-formats \
427+
ajv validate \
428+
--all-errors \
429+
--strict=false \
430+
-s "{{.SCHEMA_PATH}}" \
431+
-r "{{.PARTIAL_ESLINT_PLUGINS_PATH}}" \
432+
-d "{{.DATA_PATH}}"
426433
427434
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-files-task/Taskfile.yml
428435
general:check-filenames:

0 commit comments

Comments
 (0)