Skip to content

Commit dd2f46d

Browse files
committed
Use a global workflow variable to define the "Draft 4" compatible version of ajv-cli
The ajv-cli tool is used for validation of data files against their JSON schema. In general, it is preferable, and for some schemas even mandatory, to use the modern versions of ajv-cli. However, support for the "Draft 4" 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. Such schemas are relatively common, likely partly due to the Schema Store's policy that "Draft 4" be used whenever possible. Having this version defined in a single place makes taskfiles with multiple tasks subject to this somewhat esoteric (and thus requiring an explanatory comment) information a bit cleaner.
1 parent 313bcd2 commit dd2f46d

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

Taskfile.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
version: "3"
22

3+
vars:
4+
# Last version of ajv-cli with support for the JSON schema "Draft 4" specification
5+
SCHEMA_DRAFT_4_AJV_CLI_VERSION: 3.3.0
6+
37
tasks:
48
check:
59
desc: Check for problems with the project
@@ -110,8 +114,6 @@ tasks:
110114
dependabot:validate:
111115
desc: Validate Dependabot configuration files against their JSON schema
112116
vars:
113-
# Last version with support for draft-04, used by Dependabot schema
114-
AJV_CLI_VERSION: 3.3.0
115117
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/dependabot-2.0.json
116118
SCHEMA_URL: https://json.schemastore.org/dependabot-2.0
117119
SCHEMA_PATH:
@@ -120,7 +122,7 @@ tasks:
120122
cmds:
121123
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
122124
- |
123-
npx ajv-cli@{{.AJV_CLI_VERSION}} validate \
125+
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
124126
--all-errors \
125127
-s "{{.SCHEMA_PATH}}" \
126128
-d "{{.DATA_PATH}}"
@@ -342,8 +344,6 @@ tasks:
342344
npm:validate:
343345
desc: Validate npm configuration files against their JSON schema
344346
vars:
345-
# Last version with support for draft-04, used by the `package.json` schema
346-
AJV_CLI_VERSION: 3.3.0
347347
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
348348
SCHEMA_URL: https://json.schemastore.org/package.json
349349
SCHEMA_PATH:
@@ -382,7 +382,7 @@ tasks:
382382
- wget --quiet --output-document="{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" {{.SEMANTIC_RELEASE_SCHEMA_URL}}
383383
- wget --quiet --output-document="{{.STYLELINTRC_SCHEMA_PATH}}" {{.STYLELINTRC_SCHEMA_URL}}
384384
- |
385-
npx ajv-cli@{{.AJV_CLI_VERSION}} validate \
385+
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
386386
--all-errors \
387387
-s "{{.SCHEMA_PATH}}" \
388388
-r "{{.AVA_SCHEMA_PATH}}" \

workflow-templates/assets/check-npm-task/Taskfile.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# See: https://taskfile.dev/#/usage
22
version: "3"
33

4+
vars:
5+
# Last version of ajv-cli with support for the JSON schema "Draft 4" specification
6+
SCHEMA_DRAFT_4_AJV_CLI_VERSION: 3.3.0
7+
48
tasks:
59
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml
610
npm:validate:
711
desc: Validate npm configuration files against their JSON schema
812
vars:
9-
# Last version with support for draft-04, used by the `package.json` schema
10-
AJV_CLI_VERSION: 3.3.0
1113
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
1214
SCHEMA_URL: https://json.schemastore.org/package.json
1315
SCHEMA_PATH:
@@ -46,7 +48,7 @@ tasks:
4648
- wget --quiet --output-document="{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" {{.SEMANTIC_RELEASE_SCHEMA_URL}}
4749
- wget --quiet --output-document="{{.STYLELINTRC_SCHEMA_PATH}}" {{.STYLELINTRC_SCHEMA_URL}}
4850
- |
49-
npx ajv-cli@{{.AJV_CLI_VERSION}} validate \
51+
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
5052
--all-errors \
5153
-s "{{.SCHEMA_PATH}}" \
5254
-r "{{.AVA_SCHEMA_PATH}}" \

0 commit comments

Comments
 (0)