diff --git a/Taskfile.yml b/Taskfile.yml index fe14f207..01378209 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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 @@ -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 @@ -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: @@ -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}} @@ -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}}" \ @@ -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: @@ -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: diff --git a/workflow-templates/assets/check-npm-task/Taskfile.yml b/workflow-templates/assets/check-npm-task/Taskfile.yml index 58a26b21..1bb051e9 100644 --- a/workflow-templates/assets/check-npm-task/Taskfile.yml +++ b/workflow-templates/assets/check-npm-task/Taskfile.yml @@ -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: @@ -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}} @@ -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}}" \ @@ -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}}" diff --git a/workflow-templates/assets/windows-task/Taskfile.yml b/workflow-templates/assets/windows-task/Taskfile.yml index 59a4d393..9ef3df0f 100644 --- a/workflow-templates/assets/windows-task/Taskfile.yml +++ b/workflow-templates/assets/windows-task/Taskfile.yml @@ -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: