Skip to content

Commit 27e0b6a

Browse files
authored
Merge pull request #13 from per1234/check-taskfiles
Add template workflow to validate Taskfiles
2 parents a9a6bc5 + 610d9e8 commit 27e0b6a

File tree

6 files changed

+205
-0
lines changed

6 files changed

+205
-0
lines changed

.github/workflows/check-taskfiles.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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: sudo npm install --global ajv-cli
47+
48+
- name: Validate ${{ matrix.file }}
49+
run: |
50+
# See: https://github.com/ajv-validator/ajv-cli#readme
51+
ajv validate \
52+
--strict=false \
53+
-s "${{ steps.download-schema.outputs.file-path }}" \
54+
-d "${{ matrix.file }}"

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
[![Check Configuration Files Sync status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-config-sync.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-config-sync.yml)
99
[![Check Markdown status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-markdown-task.yml)
1010
[![Check Prettier Formatting status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-prettier-formatting-task.yml)
11+
[![Check Taskfiles status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-taskfiles.yml)
12+
1113

1214
The [Arduino](https://www.arduino.cc/) Tooling Team's collection of reusable project infrastructure assets.
1315

Taskfile.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ tasks:
4545
"{{.WORKFLOW_TEMPLATES_PATH}}/check-general-formatting-task.yml" \
4646
"{{.WORKFLOW_TEMPLATES_PATH}}/check-markdown-task.yml" \
4747
"{{.WORKFLOW_TEMPLATES_PATH}}/check-prettier-formatting-task.yml" \
48+
"{{.WORKFLOW_TEMPLATES_PATH}}/check-taskfiles.yml" \
4849
"{{.WORKFLOWS_PATH}}"
4950
5051
config:sync:

workflow-templates/check-taskfiles.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# "Check Taskfiles" workflow
2+
3+
Workflow file: [check-taskfiles.yml](check-taskfiles.yml)
4+
5+
Validate the repository's [Taskfiles](https://taskfile.dev/#/usage) against the JSON schema.
6+
7+
## Readme badge
8+
9+
Markdown badge:
10+
11+
```markdown
12+
[![Check Taskfiles status](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/check-taskfiles.yml)
13+
```
14+
15+
Replace the `REPO_OWNER` and `REPO_NAME` placeholders in the URLs with the final repository owner and name ([example](https://raw.githubusercontent.com/arduino-libraries/ArduinoIoTCloud/master/README.md)).
16+
17+
---
18+
19+
Asciidoc badge:
20+
21+
```adoc
22+
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-taskfiles.yml/badge.svg["Check Taskfiles status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/check-taskfiles.yml"]
23+
```
24+
25+
Define the `{repository-owner}` and `{repository-name}` attributes and use them throughout the readme ([example](https://raw.githubusercontent.com/arduino-libraries/WiFiNINA/master/README.adoc)).
26+
27+
## Commit message
28+
29+
```
30+
Add CI workflow to validate Taskfiles
31+
32+
On every push or pull request that affects the repository's Taskfiles, and periodically, validate them
33+
against the JSON schema.
34+
```
35+
36+
## PR message
37+
38+
```markdown
39+
On every push or pull request that affects the repository's [Taskfiles](https://taskfile.dev/#/usage), and periodically, validate them against the JSON schema.
40+
```
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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: sudo npm install --global ajv-cli
47+
48+
- name: Validate ${{ matrix.file }}
49+
run: |
50+
# See: https://github.com/ajv-validator/ajv-cli#readme
51+
ajv validate \
52+
--strict=false \
53+
-s "${{ steps.download-schema.outputs.file-path }}" \
54+
-d "${{ matrix.file }}"
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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: sudo npm install --global ajv-cli
47+
48+
- name: Validate ${{ matrix.file }}
49+
run: |
50+
# See: https://github.com/ajv-validator/ajv-cli#readme
51+
ajv validate \
52+
--strict=false \
53+
-s "${{ steps.download-schema.outputs.file-path }}" \
54+
-d "${{ matrix.file }}"

0 commit comments

Comments
 (0)