@@ -84,3 +84,66 @@ tasks:
8484 desc : Install dependencies managed by npm
8585 cmds :
8686 - npm install
87+
88+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml
89+ ci:validate :
90+ desc : Validate GitHub Actions workflows against their JSON schema
91+ vars :
92+ # Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
93+ WORKFLOW_SCHEMA_URL : https://json.schemastore.org/github-workflow
94+ WORKFLOW_SCHEMA_PATH :
95+ sh : task utility:mktemp-file TEMPLATE="workflow-schema-XXXXXXXXXX.json"
96+ WORKFLOWS_DATA_PATH : " ./.github/workflows/*.{yml,yaml}"
97+ deps :
98+ - task : npm:install-deps
99+ cmds :
100+ - |
101+ wget \
102+ --quiet \
103+ --output-document="{{.WORKFLOW_SCHEMA_PATH}}" \
104+ {{.WORKFLOW_SCHEMA_URL}}
105+ - |
106+ npx \
107+ --package=ajv-cli \
108+ --package=ajv-formats \
109+ ajv validate \
110+ --all-errors \
111+ --strict=false \
112+ -c ajv-formats \
113+ -s "{{.WORKFLOW_SCHEMA_PATH}}" \
114+ -d "{{.WORKFLOWS_DATA_PATH}}"
115+
116+ # Make a temporary file named according to the passed TEMPLATE variable and print the path passed to stdout
117+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
118+ utility:mktemp-file :
119+ vars :
120+ RAW_PATH :
121+ sh : mktemp --tmpdir "{{.TEMPLATE}}"
122+ cmds :
123+ - task : utility:normalize-path
124+ vars :
125+ RAW_PATH : " {{.RAW_PATH}}"
126+
127+ # Make a temporary folder named according to the passed TEMPLATE variable and print the path passed to stdout
128+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
129+ utility:mktemp-folder :
130+ vars :
131+ RAW_PATH :
132+ sh : mktemp --directory --tmpdir "{{.TEMPLATE}}"
133+ cmds :
134+ - task : utility:normalize-path
135+ vars :
136+ RAW_PATH : " {{.RAW_PATH}}"
137+
138+ # Print a normalized version of the path passed via the RAW_PATH variable to stdout
139+ # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
140+ utility:normalize-path :
141+ cmds :
142+ - |
143+ if [[ "{{.OS}}" == "Windows_NT" ]] && which cygpath &>/dev/null; then
144+ # Even though the shell handles POSIX format absolute paths as expected, external applications do not.
145+ # So paths passed to such applications must first be converted to Windows format.
146+ cygpath -w "{{.RAW_PATH}}"
147+ else
148+ echo "{{.RAW_PATH}}"
149+ fi
0 commit comments