Skip to content

Commit 13fe018

Browse files
Merge pull request #7 from arduino/check-taskfiles
Add CI workflow to validate Taskfiles
2 parents d716344 + f85e78d commit 13fe018

File tree

5 files changed

+637
-0
lines changed

5 files changed

+637
-0
lines changed

.github/workflows/check-taskfiles.yml

+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
2+
name: Check Taskfiles
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+
create:
11+
push:
12+
paths:
13+
- ".github/workflows/check-taskfiles.ya?ml"
14+
- "package.json"
15+
- "package-lock.json"
16+
- "**/Taskfile.ya?ml"
17+
pull_request:
18+
paths:
19+
- ".github/workflows/check-taskfiles.ya?ml"
20+
- "package.json"
21+
- "package-lock.json"
22+
- "**/Taskfile.ya?ml"
23+
schedule:
24+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
25+
- cron: "0 8 * * TUE"
26+
workflow_dispatch:
27+
repository_dispatch:
28+
29+
jobs:
30+
run-determination:
31+
runs-on: ubuntu-latest
32+
permissions: {}
33+
outputs:
34+
result: ${{ steps.determination.outputs.result }}
35+
steps:
36+
- name: Determine if the rest of the workflow should run
37+
id: determination
38+
run: |
39+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
40+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
41+
if [[
42+
"${{ github.event_name }}" != "create" ||
43+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
44+
]]; then
45+
# Run the other jobs.
46+
RESULT="true"
47+
else
48+
# There is no need to run the other jobs.
49+
RESULT="false"
50+
fi
51+
52+
echo "result=$RESULT" >> $GITHUB_OUTPUT
53+
54+
validate:
55+
name: Validate ${{ matrix.file }}
56+
needs: run-determination
57+
if: needs.run-determination.outputs.result == 'true'
58+
runs-on: ubuntu-latest
59+
permissions:
60+
contents: read
61+
62+
strategy:
63+
fail-fast: false
64+
65+
matrix:
66+
file:
67+
# TODO: add paths to any additional Taskfiles here
68+
- ./**/Taskfile.yml
69+
70+
steps:
71+
- name: Checkout repository
72+
uses: actions/checkout@v3
73+
74+
- name: Setup Node.js
75+
uses: actions/setup-node@v3
76+
with:
77+
node-version: ${{ env.NODE_VERSION }}
78+
79+
- name: Download JSON schema for Taskfiles
80+
id: download-schema
81+
uses: carlosperate/download-file-action@v2
82+
with:
83+
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
84+
file-url: https://taskfile.dev/schema.json
85+
location: ${{ runner.temp }}/taskfile-schema
86+
87+
- name: Install JSON schema validator
88+
run: npm install
89+
90+
- name: Validate ${{ matrix.file }}
91+
run: |
92+
# See: https://github.com/ajv-validator/ajv-cli#readme
93+
npx \
94+
--package=ajv-cli \
95+
--package=ajv-formats \
96+
ajv validate \
97+
--all-errors \
98+
--strict=false \
99+
-c ajv-formats \
100+
-s "${{ steps.download-schema.outputs.file-path }}" \
101+
-d "${{ matrix.file }}"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules/

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
[![Check Go status](https://github.com/arduino/fwuploader-plugin-helper/actions/workflows/check-go-task.yml/badge.svg)](https://github.com/arduino/fwuploader-plugin-helper/actions/workflows/check-go-task.yml)
77
[![Sync Labels status](https://github.com/arduino/fwuploader-plugin-helper/actions/workflows/sync-labels.yml/badge.svg)](https://github.com/arduino/fwuploader-plugin-helper/actions/workflows/sync-labels.yml)
88
[![Check Go Dependencies status](https://github.com/arduino/fwuploader-plugin-helper/actions/workflows/check-go-dependencies-task.yml/badge.svg)](https://github.com/arduino/fwuploader-plugin-helper/actions/workflows/check-go-dependencies-task.yml)
9+
[![Check Taskfiles status](https://github.com/arduino/fwuploader-plugin-helper/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/fwuploader-plugin-helper/actions/workflows/check-taskfiles.yml)
910

1011
<!--[![Test Go status](https://github.com/arduino/fwuploader-plugin-helper/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/arduino/fwuploader-plugin-helper/actions/workflows/test-go-task.yml)-->
1112
<!--[![Codecov](https://codecov.io/gh/arduino/fwuploader-plugin-helper/branch/main/graph/badge.svg)](https://codecov.io/gh/arduino/fwuploader-plugin-helper)-->

0 commit comments

Comments
 (0)