Skip to content

Commit 89a7325

Browse files
authored
Merge pull request #219 from per1234/check-workflows
Sync GitHub Actions workflow validation CI workflow with template
2 parents f311399 + f8c83c7 commit 89a7325

File tree

4 files changed

+60
-38
lines changed

4 files changed

+60
-38
lines changed

Diff for: .github/workflows/check-workflows-task.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/master/workflow-templates/check-workflows-task.md
2+
name: Check Workflows
3+
4+
# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
paths:
8+
- ".github/workflows/*.ya?ml"
9+
- "Taskfile.ya?ml"
10+
pull_request:
11+
paths:
12+
- ".github/workflows/*.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+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v2
27+
28+
- name: Install Task
29+
uses: arduino/setup-task@v1
30+
with:
31+
repo-token: ${{ secrets.GITHUB_TOKEN }}
32+
version: 3.x
33+
34+
- name: Validate workflows
35+
run: task --silent ci:validate

Diff for: .github/workflows/lint-config.yml

-32
This file was deleted.

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
[![Codecov](https://codecov.io/gh/arduino/arduino-lint/branch/main/graph/badge.svg?token=nprqPQMbdh)](https://codecov.io/gh/arduino/arduino-lint)
99
[![Check Prettier Formatting status](https://github.com/arduino/arduino-lint/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-prettier-formatting-task.yml)
1010
[![Check General Formatting status](https://github.com/arduino/arduino-lint/actions/workflows/check-general-formatting-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-general-formatting-task.yml)
11+
[![Check Workflows status](https://github.com/arduino/arduino-lint/actions/workflows/check-workflows-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-workflows-task.yml)
1112
[![Check Shell Scripts status](https://github.com/arduino/arduino-lint/actions/workflows/check-shell-task.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-shell-task.yml)
1213
[![Check Certificates status](https://github.com/arduino/arduino-lint/actions/workflows/check-certificates.yml/badge.svg)](https://github.com/arduino/arduino-lint/actions/workflows/check-certificates.yml)
1314

Diff for: Taskfile.yml

+24-6
Original file line numberDiff line numberDiff line change
@@ -331,11 +331,31 @@ tasks:
331331
cmds:
332332
- task: workflow:validate
333333

334-
workflow:validate:
335-
desc: Validate GitHub Actions workflows against JSON schema
334+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml
335+
ci:validate:
336+
desc: Validate GitHub Actions workflows against their JSON schema
337+
vars:
338+
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
339+
WORKFLOW_SCHEMA_URL: https://json.schemastore.org/github-workflow
340+
WORKFLOW_SCHEMA_PATH:
341+
sh: mktemp -t workflow-schema-XXXXXXXXXX.json
342+
WORKFLOWS_DATA_PATH: "./.github/workflows/*.{yml,yaml}"
336343
cmds:
337-
- wget --output-document={{ .WORKFLOW_SCHEMA_PATH }} https://json.schemastore.org/github-workflow
338-
- npx ajv-cli validate --strict=false -s {{ .WORKFLOW_SCHEMA_PATH }} -d "./.github/workflows/*.{yml,yaml}"
344+
- |
345+
wget \
346+
--quiet \
347+
--output-document="{{.WORKFLOW_SCHEMA_PATH}}" \
348+
{{.WORKFLOW_SCHEMA_URL}}
349+
- |
350+
npx \
351+
--package=ajv-cli \
352+
--package=ajv-formats \
353+
ajv validate \
354+
--all-errors \
355+
--strict=false \
356+
-c ajv-formats \
357+
-s "{{.WORKFLOW_SCHEMA_PATH}}" \
358+
-d "{{.WORKFLOWS_DATA_PATH}}"
339359
340360
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-general-formatting-task/Taskfile.yml
341361
general:check-formatting:
@@ -396,7 +416,5 @@ vars:
396416

397417
398418

399-
WORKFLOW_SCHEMA_PATH: "$(mktemp -t gha-workflow-schema-XXXXXXXXXX.json)"
400-
401419
CODESPELL_SKIP_OPTION: '--skip "./.git,go.mod,go.sum,./arduino-lint,./arduino-lint.exe,./internal/rule/rulefunction/testdata/libraries/MisspelledSentenceParagraphValue/library.properties,./site"'
402420
CODESPELL_IGNORE_WORDS_OPTION: "--ignore-words ./etc/codespell-ignore-words-list.txt"

0 commit comments

Comments
 (0)