Skip to content

Commit 8ec809e

Browse files
committed
Add CI workflow to validate configuration files against JSON schema
Some of the assets used by the template workflows have JSON schema that defines the data structure in a machine readable way. Validating the assets against the schema whenever they are modified ensures that no problems are introduced. It is especially important to ensure the assets hosted in this repository are correct, since they will be distributed from here to many other projects.
1 parent a01cc3d commit 8ec809e

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

.github/workflows/check-configs.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Check Configuration Files
2+
3+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+
on:
5+
push:
6+
paths:
7+
- ".github/workflows/check-configs.yml"
8+
- "Taskfile.ya?ml"
9+
- "**/dependabot.yml"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/check-configs.yml"
13+
- "Taskfile.ya?ml"
14+
- "**/dependabot.yml"
15+
schedule:
16+
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
17+
- cron: "0 8 * * TUE"
18+
workflow_dispatch:
19+
repository_dispatch:
20+
21+
jobs:
22+
validate:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v2
28+
29+
- name: Install Task
30+
uses: arduino/setup-task@v1
31+
with:
32+
repo-token: ${{ secrets.GITHUB_TOKEN }}
33+
version: 3.x
34+
35+
- name: Validate configuration files
36+
run: task config:validate

Taskfile.yml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: "3"
2+
3+
tasks:
4+
check:
5+
desc: Check for problems with the project
6+
deps:
7+
- task: config:validate
8+
9+
config:validate:
10+
desc: Validate configuration files against their JSON schema
11+
vars:
12+
# Last version with support for draft-04, used by Dependabot schema
13+
AJV_CLI_VERSION: 3.3.0
14+
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/dependabot-2.0.json
15+
DEPENDABOT_SCHEMA_URL: https://json.schemastore.org/dependabot-2.0
16+
DEPENDABOT_SCHEMA_PATH:
17+
sh: mktemp -t dependabot-schema-XXXXXXXXXX.json
18+
DEPENDABOT_DATA_PATH: "**/dependabot.yml"
19+
cmds:
20+
- wget --quiet --output-document="{{.DEPENDABOT_SCHEMA_PATH}}" {{.DEPENDABOT_SCHEMA_URL}}
21+
- npx ajv-cli@{{.AJV_CLI_VERSION}} validate -s "{{.DEPENDABOT_SCHEMA_PATH}}" -d "{{.DEPENDABOT_DATA_PATH}}"

0 commit comments

Comments
 (0)