diff --git a/.github/workflows/check-workflows-task.yml b/.github/workflows/check-workflows-task.yml new file mode 100644 index 00000000..5d433c42 --- /dev/null +++ b/.github/workflows/check-workflows-task.yml @@ -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 diff --git a/.github/workflows/lint-config.yml b/.github/workflows/lint-config.yml deleted file mode 100644 index 6e7dd0f7..00000000 --- a/.github/workflows/lint-config.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Lint configuration files - -on: - push: - paths: - - ".github/workflows/lint-config.yml" - - "Taskfile.yml" - - ".github/workflows/*.yml" - pull_request: - paths: - - ".github/workflows/lint-config.yml" - - "Taskfile.yml" - - ".github/workflows/*.yml" - schedule: - # Run every Tuesday at 03:00 UTC to catch breakage caused by changes to the GitHub Actions workflow schema - - cron: "0 3 * * 2" - -jobs: - lint: - runs-on: ubuntu-latest - steps: - - name: Checkout local repository - uses: actions/checkout@v2 - - - name: Install Taskfile - uses: arduino/setup-task@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - version: 3.x - - - name: Lint configuration files - run: task config:lint diff --git a/README.md b/README.md index 7e8f6e46..416b24be 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/Taskfile.yml b/Taskfile.yml index 05a34530..07a8ae50 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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: @@ -396,7 +416,5 @@ vars: PRETTIER: prettier@2.1.2 - 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"