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