Skip to content

Commit 7295e15

Browse files
Merge pull request #19 from arduino/check-workflows
Add CI workflow to validate GitHub Actions workflows
2 parents 45febb9 + 2bac9f4 commit 7295e15

File tree

5 files changed

+515
-0
lines changed

5 files changed

+515
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/master/workflow-templates/check-workflows-task.md
2+
name: Check Workflows
3+
4+
env:
5+
# See: https://github.com/actions/setup-node/#readme
6+
NODE_VERSION: 16.x
7+
8+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
9+
on:
10+
push:
11+
paths:
12+
- ".github/workflows/*.ya?ml"
13+
- "package.json"
14+
- "package-lock.json"
15+
- "Taskfile.ya?ml"
16+
pull_request:
17+
paths:
18+
- ".github/workflows/*.ya?ml"
19+
- "package.json"
20+
- "package-lock.json"
21+
- "Taskfile.ya?ml"
22+
schedule:
23+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
24+
- cron: "0 8 * * TUE"
25+
workflow_dispatch:
26+
repository_dispatch:
27+
28+
jobs:
29+
validate:
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: Checkout repository
34+
uses: actions/checkout@v3
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v3
38+
with:
39+
node-version: ${{ env.NODE_VERSION }}
40+
41+
- name: Install Task
42+
uses: arduino/setup-task@v1
43+
with:
44+
repo-token: ${{ secrets.GITHUB_TOKEN }}
45+
version: 3.x
46+
47+
- name: Validate workflows
48+
run: task --silent ci:validate

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# avrdude-packing
22

33
[![Check Markdown status](https://github.com/arduino/avrdude-packing/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/avrdude-packing/actions/workflows/check-markdown-task.yml)
4+
[![Check Workflows status](https://github.com/arduino/avrdude-packing/actions/workflows/check-workflows-task.yml/badge.svg)](https://github.com/arduino/avrdude-packing/actions/workflows/check-workflows-task.yml)
45

56
This repository contains the release pipeline to build statically avrdude

Taskfile.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)