Skip to content

Force use of unmanaged ajv-cli version as required #245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 29 additions & 8 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
version: "3"

vars:
# Last version of ajv-cli with support for the JSON schema "Draft 4" specification
SCHEMA_DRAFT_4_AJV_CLI_VERSION: 3.3.0

tasks:
check:
desc: Check for problems with the project
Expand Down Expand Up @@ -110,20 +114,23 @@ tasks:
dependabot:validate:
desc: Validate Dependabot configuration files against their JSON schema
vars:
# Last version with support for draft-04, used by Dependabot schema
AJV_CLI_VERSION: 3.3.0
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/dependabot-2.0.json
SCHEMA_URL: https://json.schemastore.org/dependabot-2.0
SCHEMA_PATH:
sh: task utility:mktemp-file TEMPLATE="dependabot-schema-XXXXXXXXXX.json"
DATA_PATH: "**/dependabot.yml"
PROJECT_FOLDER:
sh: pwd
WORKING_FOLDER:
sh: task utility:mktemp-folder TEMPLATE="dependabot-validate-XXXXXXXXXX"
cmds:
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
- |
npx ajv-cli@{{.AJV_CLI_VERSION}} validate \
cd "{{.WORKING_FOLDER}}" # Workaround for https://github.com/npm/cli/issues/3210
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
--all-errors \
-s "{{.SCHEMA_PATH}}" \
-d "{{.DATA_PATH}}"
-d "{{.PROJECT_FOLDER}}/{{.DATA_PATH}}"

dependabot:sync:
desc: Sync workflow duplicates for dependabot checks
Expand Down Expand Up @@ -342,8 +349,6 @@ tasks:
npm:validate:
desc: Validate npm configuration files against their JSON schema
vars:
# Last version with support for draft-04, used by the `package.json` schema
AJV_CLI_VERSION: 3.3.0
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
SCHEMA_URL: https://json.schemastore.org/package.json
SCHEMA_PATH:
Expand Down Expand Up @@ -373,6 +378,10 @@ tasks:
STYLELINTRC_SCHEMA_PATH:
sh: task utility:mktemp-file TEMPLATE="stylelintrc-schema-XXXXXXXXXX.json"
INSTANCE_PATH: "**/package.json"
PROJECT_FOLDER:
sh: pwd
WORKING_FOLDER:
sh: task utility:mktemp-folder TEMPLATE="dependabot-validate-XXXXXXXXXX"
cmds:
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
- wget --quiet --output-document="{{.AVA_SCHEMA_PATH}}" {{.AVA_SCHEMA_URL}}
Expand All @@ -382,7 +391,8 @@ tasks:
- wget --quiet --output-document="{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" {{.SEMANTIC_RELEASE_SCHEMA_URL}}
- wget --quiet --output-document="{{.STYLELINTRC_SCHEMA_PATH}}" {{.STYLELINTRC_SCHEMA_URL}}
- |
npx ajv-cli@{{.AJV_CLI_VERSION}} validate \
cd "{{.WORKING_FOLDER}}" # Workaround for https://github.com/npm/cli/issues/3210
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
--all-errors \
-s "{{.SCHEMA_PATH}}" \
-r "{{.AVA_SCHEMA_PATH}}" \
Expand All @@ -391,7 +401,7 @@ tasks:
-r "{{.PRETTIERRC_SCHEMA_PATH}}" \
-r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
-d "{{.INSTANCE_PATH}}"
-d "{{.PROJECT_FOLDER}}/{{.INSTANCE_PATH}}"

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
poetry:install-deps:
Expand Down Expand Up @@ -514,6 +524,17 @@ tasks:
vars:
RAW_PATH: "{{.RAW_PATH}}"

# Make a temporary folder named according to the passed TEMPLATE variable and print the path passed to stdout
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
utility:mktemp-folder:
vars:
RAW_PATH:
sh: mktemp --directory --tmpdir "{{.TEMPLATE}}"
cmds:
- task: utility:normalize-path
vars:
RAW_PATH: "{{.RAW_PATH}}"

# Print a normalized version of the path passed via the RAW_PATH variable to stdout
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
utility:normalize-path:
Expand Down
15 changes: 11 additions & 4 deletions workflow-templates/assets/check-npm-task/Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
# See: https://taskfile.dev/#/usage
version: "3"

vars:
# Last version of ajv-cli with support for the JSON schema "Draft 4" specification
SCHEMA_DRAFT_4_AJV_CLI_VERSION: 3.3.0

tasks:
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-npm-task/Taskfile.yml
npm:validate:
desc: Validate npm configuration files against their JSON schema
vars:
# Last version with support for draft-04, used by the `package.json` schema
AJV_CLI_VERSION: 3.3.0
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/package.json
SCHEMA_URL: https://json.schemastore.org/package.json
SCHEMA_PATH:
Expand Down Expand Up @@ -37,6 +39,10 @@ tasks:
STYLELINTRC_SCHEMA_PATH:
sh: task utility:mktemp-file TEMPLATE="stylelintrc-schema-XXXXXXXXXX.json"
INSTANCE_PATH: "**/package.json"
PROJECT_FOLDER:
sh: pwd
WORKING_FOLDER:
sh: task utility:mktemp-folder TEMPLATE="dependabot-validate-XXXXXXXXXX"
cmds:
- wget --quiet --output-document="{{.SCHEMA_PATH}}" {{.SCHEMA_URL}}
- wget --quiet --output-document="{{.AVA_SCHEMA_PATH}}" {{.AVA_SCHEMA_URL}}
Expand All @@ -46,7 +52,8 @@ tasks:
- wget --quiet --output-document="{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" {{.SEMANTIC_RELEASE_SCHEMA_URL}}
- wget --quiet --output-document="{{.STYLELINTRC_SCHEMA_PATH}}" {{.STYLELINTRC_SCHEMA_URL}}
- |
npx ajv-cli@{{.AJV_CLI_VERSION}} validate \
cd "{{.WORKING_FOLDER}}" # Workaround for https://github.com/npm/cli/issues/3210
npx ajv-cli@{{.SCHEMA_DRAFT_4_AJV_CLI_VERSION}} validate \
--all-errors \
-s "{{.SCHEMA_PATH}}" \
-r "{{.AVA_SCHEMA_PATH}}" \
Expand All @@ -55,4 +62,4 @@ tasks:
-r "{{.PRETTIERRC_SCHEMA_PATH}}" \
-r "{{.SEMANTIC_RELEASE_SCHEMA_PATH}}" \
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
-d "{{.INSTANCE_PATH}}"
-d "{{.PROJECT_FOLDER}}/{{.INSTANCE_PATH}}"
11 changes: 11 additions & 0 deletions workflow-templates/assets/windows-task/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ tasks:
vars:
RAW_PATH: "{{.RAW_PATH}}"

# Make a temporary folder named according to the passed TEMPLATE variable and print the path passed to stdout
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
utility:mktemp-folder:
vars:
RAW_PATH:
sh: mktemp --directory --tmpdir "{{.TEMPLATE}}"
cmds:
- task: utility:normalize-path
vars:
RAW_PATH: "{{.RAW_PATH}}"

# Print a normalized version of the path passed via the RAW_PATH variable to stdout
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
utility:normalize-path:
Expand Down