Skip to content

Commit 812e15e

Browse files
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 9ede82c commit 812e15e

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

.github/workflows/check-taskfiles.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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: 12.x
7+
8+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
9+
on:
10+
push:
11+
paths:
12+
- ".github/workflows/check-taskfiles.ya?ml"
13+
- "package.json"
14+
- "package-lock.json"
15+
- "**/Taskfile.ya?ml"
16+
pull_request:
17+
paths:
18+
- ".github/workflows/check-taskfiles.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+
name: Validate ${{ matrix.file }}
31+
runs-on: ubuntu-latest
32+
33+
strategy:
34+
fail-fast: false
35+
36+
matrix:
37+
file:
38+
- ./**/Taskfile.yml
39+
40+
steps:
41+
- name: Checkout repository
42+
uses: actions/checkout@v3
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v3
46+
with:
47+
node-version: ${{ env.NODE_VERSION }}
48+
49+
- name: Download JSON schema for Taskfiles
50+
id: download-schema
51+
uses: carlosperate/download-file-action@v1
52+
with:
53+
# See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/taskfile.json
54+
file-url: https://json.schemastore.org/taskfile.json
55+
location: ${{ runner.temp }}/taskfile-schema
56+
57+
- name: Install JSON schema validator
58+
run: npm install
59+
60+
- name: Validate ${{ matrix.file }}
61+
run: |
62+
# See: https://github.com/ajv-validator/ajv-cli#readme
63+
npx \
64+
--package=ajv-cli \
65+
--package=ajv-formats \
66+
ajv validate \
67+
--all-errors \
68+
--strict=false \
69+
-c ajv-formats \
70+
-s "${{ steps.download-schema.outputs.file-path }}" \
71+
-d "${{ matrix.file }}"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Sync Labels status](https://github.com/arduino/setup-protoc/actions/workflows/sync-labels-npm.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/sync-labels-npm.yml)
66
[![Check Markdown status](https://github.com/arduino/setup-protoc/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-markdown-task.yml)
77
[![Check License status](https://github.com/arduino/setup-protoc/actions/workflows/check-license.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-license.yml)
8+
[![Check Taskfiles status](https://github.com/arduino/setup-protoc/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/setup-protoc/actions/workflows/check-taskfiles.yml)
89

910
This action makes the `protoc` compiler available to Workflows.
1011

0 commit comments

Comments
 (0)