Skip to content

Sync GitHub Actions workflow validation CI workflow with template #219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Aug 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/check-workflows-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/master/workflow-templates/check-workflows-task.md
name: Check Workflows

# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/*.ya?ml"
- "Taskfile.ya?ml"
pull_request:
paths:
- ".github/workflows/*.ya?ml"
- "Taskfile.ya?ml"
schedule:
# Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema.
- cron: "0 8 * * TUE"
workflow_dispatch:
repository_dispatch:

jobs:
validate:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Validate workflows
run: task --silent ci:validate
32 changes: 0 additions & 32 deletions .github/workflows/lint-config.yml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[![Codecov](https://codecov.io/gh/arduino/arduino-lint/branch/main/graph/badge.svg?token=nprqPQMbdh)](https://codecov.io/gh/arduino/arduino-lint)
[![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)
[![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)
[![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)
[![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)
[![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)

Expand Down
30 changes: 24 additions & 6 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,31 @@ tasks:
cmds:
- task: workflow:validate

workflow:validate:
desc: Validate GitHub Actions workflows against JSON schema
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml
ci:validate:
desc: Validate GitHub Actions workflows against their JSON schema
vars:
# Source: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json
WORKFLOW_SCHEMA_URL: https://json.schemastore.org/github-workflow
WORKFLOW_SCHEMA_PATH:
sh: mktemp -t workflow-schema-XXXXXXXXXX.json
WORKFLOWS_DATA_PATH: "./.github/workflows/*.{yml,yaml}"
cmds:
- wget --output-document={{ .WORKFLOW_SCHEMA_PATH }} https://json.schemastore.org/github-workflow
- npx ajv-cli validate --strict=false -s {{ .WORKFLOW_SCHEMA_PATH }} -d "./.github/workflows/*.{yml,yaml}"
- |
wget \
--quiet \
--output-document="{{.WORKFLOW_SCHEMA_PATH}}" \
{{.WORKFLOW_SCHEMA_URL}}
- |
npx \
--package=ajv-cli \
--package=ajv-formats \
ajv validate \
--all-errors \
--strict=false \
-c ajv-formats \
-s "{{.WORKFLOW_SCHEMA_PATH}}" \
-d "{{.WORKFLOWS_DATA_PATH}}"

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-general-formatting-task/Taskfile.yml
general:check-formatting:
Expand Down Expand Up @@ -396,7 +416,5 @@ vars:

PRETTIER: [email protected]

WORKFLOW_SCHEMA_PATH: "$(mktemp -t gha-workflow-schema-XXXXXXXXXX.json)"

CODESPELL_SKIP_OPTION: '--skip "./.git,go.mod,go.sum,./arduino-lint,./arduino-lint.exe,./internal/rule/rulefunction/testdata/libraries/MisspelledSentenceParagraphValue/library.properties,./site"'
CODESPELL_IGNORE_WORDS_OPTION: "--ignore-words ./etc/codespell-ignore-words-list.txt"