Skip to content

Commit

Permalink
Migrate to Task-based workflow check system
Browse files Browse the repository at this point in the history
A task is added to validate GitHub Actions workflows.

On every push and pull request that affects relevant files, this task will be executed by the GitHub Actions workflow.

The updated system makes it easy for contributors to run the same checking operation locally as will be done by the CI
system, using the Task task runner tool.
  • Loading branch information
per1234 committed Oct 16, 2023
1 parent eed60f0 commit d71ba39
Show file tree
Hide file tree
Showing 6 changed files with 343 additions and 48 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/check-workflows-task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-workflows-task.md
name: Check Workflows

# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
on:
push:
paths:
- ".github/workflows/*.ya?ml"
- "package.json"
- "package-lock.json"
- "Taskfile.ya?ml"
pull_request:
paths:
- ".github/workflows/*.ya?ml"
- "package.json"
- "package-lock.json"
- "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
permissions:
contents: read

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

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version-file: package.json

- 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
48 changes: 0 additions & 48 deletions .github/workflows/check-workflows.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 @@ -6,6 +6,7 @@
[![Check Markdown status](https://github.com/per1234/inoplatforms/actions/workflows/check-markdown-task.yml/badge.svg)](https://github.com/per1234/inoplatforms/actions/workflows/check-markdown-task.yml)
[![Check npm status](https://github.com/per1234/inoplatforms/actions/workflows/check-npm-task.yml/badge.svg)](https://github.com/per1234/inoplatforms/actions/workflows/check-npm-task.yml)
[![Check Prettier Formatting status](https://github.com/per1234/inoplatforms/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/per1234/inoplatforms/actions/workflows/check-prettier-formatting-task.yml)
[![Check Workflows status](https://github.com/per1234/inoplatforms/actions/workflows/check-workflows-task.yml/badge.svg)](https://github.com/per1234/inoplatforms/actions/workflows/check-workflows-task.yml)
[![Spell Check status](https://github.com/per1234/inoplatforms/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/per1234/inoplatforms/actions/workflows/spell-check-task.yml)

A list of all known [Arduino](http://arduino.cc) hardware packages.
Expand Down
29 changes: 29 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ tasks:
check:
desc: Check for problems with the project
deps:
- task: ci:validate
- task: general:check-formatting
- task: general:check-spelling
- task: markdown:check-links
Expand All @@ -37,6 +38,34 @@ tasks:
- task: markdown:fix
- task: poetry:sync

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml

Check warning on line 41 in Taskfile.yml

View workflow job for this annotation

GitHub Actions / check

41:121 [line-length] line too long (131 > 120 characters)
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: task utility:mktemp-file TEMPLATE="workflow-schema-XXXXXXXXXX.json"
WORKFLOWS_DATA_PATH: "./.github/workflows/*.{yml,yaml}"
deps:
- task: npm:install-deps
cmds:
- |
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

Check warning on line 69 in Taskfile.yml

View workflow job for this annotation

GitHub Actions / check

69:121 [line-length] line too long (140 > 120 characters)
general:check-formatting:
desc: Check basic formatting style of all files
Expand Down
Loading

0 comments on commit d71ba39

Please sign in to comment.