Skip to content

Commit 5d650ce

Browse files
committed
Add CI workflow to validate Taskfiles
On every push or pull request that affects the repository's Taskfiles, and periodically, validate them against the JSON schema.
1 parent e2f30b0 commit 5d650ce

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

.github/workflows/check-taskfiles.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
2+
name: Check Taskfiles
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
paths:
8+
- ".github/workflows/check-taskfiles.ya?ml"
9+
- "**/Taskfile.ya?ml"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/check-taskfiles.ya?ml"
13+
- "**/Taskfile.ya?ml"
14+
schedule:
15+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
16+
- cron: "0 8 * * TUE"
17+
workflow_dispatch:
18+
repository_dispatch:
19+
20+
jobs:
21+
validate:
22+
name: Validate ${{ matrix.file }}
23+
runs-on: ubuntu-latest
24+
25+
strategy:
26+
fail-fast: false
27+
28+
matrix:
29+
file:
30+
# TODO: add paths to any additional Taskfiles here
31+
- ./**/Taskfile.yml
32+
33+
steps:
34+
- name: Checkout repository
35+
uses: actions/checkout@v2
36+
37+
- name: Download JSON schema for Taskfiles
38+
id: download-schema
39+
uses: carlosperate/[email protected]
40+
with:
41+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
42+
file-url: https://json.schemastore.org/taskfile.json
43+
location: ${{ runner.temp }}/taskfile-schema
44+
45+
- name: Install JSON schema validator
46+
run: |
47+
sudo npm install \
48+
--global \
49+
ajv-cli \
50+
ajv-formats
51+
52+
- name: Validate ${{ matrix.file }}
53+
run: |
54+
# See: https://github.com/ajv-validator/ajv-cli#readme
55+
ajv validate \
56+
--all-errors \
57+
--strict=false \
58+
-c ajv-formats \
59+
-s "${{ steps.download-schema.outputs.file-path }}" \
60+
-d "${{ matrix.file }}"

0 commit comments

Comments
 (0)