From 834af544d01ad729a1f74a2e018ccd8584f73ff8 Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 8 Apr 2021 21:52:11 -0700 Subject: [PATCH 1/3] Add CI workflow to validate GitHub Actions workflows On every push or pull request that affects the repository's GitHub Actions workflows, and periodically, validate them against the JSON schema. --- .github/workflows/check-workflows.yml | 58 +++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 .github/workflows/check-workflows.yml diff --git a/.github/workflows/check-workflows.yml b/.github/workflows/check-workflows.yml new file mode 100644 index 000000000..d6646c9b8 --- /dev/null +++ b/.github/workflows/check-workflows.yml @@ -0,0 +1,58 @@ +name: Check Workflows + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/*.yaml" + - ".github/workflows/*.yml" + pull_request: + paths: + - ".github/workflows/*.yaml" + - ".github/workflows/*.yml" + 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: Download JSON schema for GitHub Actions workflows + id: download-schema + uses: carlosperate/download-file-action@v1.0.3 + with: + # See: https://github.com/SchemaStore/schemastore/blob/master/src/schemas/json/github-workflow.json + file-url: https://json.schemastore.org/github-workflow + location: ${{ runner.temp }}/github-workflow-schema + file-name: github-workflow.json + + - name: Get week number for use in cache key + id: get-date + run: | + echo "::set-output name=week-number::$(date --utc '+%V')" + + - name: Load dependencies cache + uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-ajv-cli-${{ steps.get-date.outputs.week-number }} + restore-keys: | + ${{ runner.os }}-node-ajv-cli- + + - name: Install JSON schema validator + run: sudo npm install --global ajv-cli + + - name: Validate GitHub Actions workflows + run: | + # See: https://github.com/ajv-validator/ajv-cli#readme + ajv validate \ + --strict=false \ + -s "${{ steps.download-schema.outputs.file-path }}" \ + -d "./.github/workflows/*.{yml,yaml}" From 30aeffc9b05e938ac4ce15a0d90ab99e9825fced Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 8 Apr 2021 21:52:41 -0700 Subject: [PATCH 2/3] Add CI workflow to lint YAML files On every push and pull request that affects relevant files, and periodically, run yamllint to check the YAML files of the repository for issues. The .yamllint.yml file is used to configure yamllint: https://yamllint.readthedocs.io/en/stable/configuration.html --- .github/.yamllint.yml | 73 ++++++++++++++++++++++++++++++ .github/workflows/check-yaml.yml | 78 ++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 .github/.yamllint.yml create mode 100644 .github/workflows/check-yaml.yml diff --git a/.github/.yamllint.yml b/.github/.yamllint.yml new file mode 100644 index 000000000..d2036e700 --- /dev/null +++ b/.github/.yamllint.yml @@ -0,0 +1,73 @@ +# See: https://yamllint.readthedocs.io/en/stable/configuration.html +# The code style defined in this file is the official standardized style to be used in all Arduino projects and should +# not be modified. +# Note: Rules disabled solely because they are redundant to Prettier are marked with a "Prettier" comment. + +rules: + braces: + level: error + forbid: non-empty + min-spaces-inside: -1 # Prettier + max-spaces-inside: -1 # Prettier + min-spaces-inside-empty: -1 # Prettier + max-spaces-inside-empty: -1 # Prettier + brackets: + level: error + forbid: non-empty + min-spaces-inside: -1 # Prettier + max-spaces-inside: -1 # Prettier + min-spaces-inside-empty: -1 # Prettier + max-spaces-inside-empty: -1 # Prettier + colons: disable # Prettier + commas: disable # Prettier + comments: disable # Prettier + comments-indentation: disable # Prettier + document-end: disable # Prettier + document-start: disable + empty-lines: disable # Prettier + empty-values: disable + hyphens: disable # Prettier + indentation: disable # Prettier + key-duplicates: disable # Prettier + key-ordering: disable + line-length: + level: warning + max: 120 + allow-non-breakable-words: true + allow-non-breakable-inline-mappings: true + new-line-at-end-of-file: disable # Prettier + new-lines: disable # Prettier + octal-values: + level: warning + forbid-implicit-octal: true + forbid-explicit-octal: false + quoted-strings: disable + trailing-spaces: disable # Prettier + truthy: + level: error + allowed-values: + - "true" + - "false" + - "on" # Used by GitHub Actions as a workflow key. + check-keys: true + +yaml-files: + # Source: https://github.com/ikatyang/linguist-languages/blob/master/data/YAML.json (used by Prettier) + - ".clang-format" + - ".clang-tidy" + - ".gemrc" + - ".yamllint" + - "glide.lock" + - "*.yml" + - "*.mir" + - "*.reek" + - "*.rviz" + - "*.sublime-syntax" + - "*.syntax" + - "*.yaml" + - "*.yaml-tmlanguage" + - "*.yaml.sed" + - "*.yml.mysql" + +ignore: | + /.git/ diff --git a/.github/workflows/check-yaml.yml b/.github/workflows/check-yaml.yml new file mode 100644 index 000000000..4756ae191 --- /dev/null +++ b/.github/workflows/check-yaml.yml @@ -0,0 +1,78 @@ +name: Check YAML + +# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows +on: + push: + paths: + - ".github/workflows/check-yaml.yml" + - ".yamllint*" + # Source: https://github.com/ikatyang/linguist-languages/blob/master/data/YAML.json (used by Prettier) + - "**/.clang-format" + - "**/.clang-tidy" + - "**/.gemrc" + - "**/glide.lock" + - "**.yml" + - "**.mir" + - "**.reek" + - "**.rviz" + - "**.sublime-syntax" + - "**.syntax" + - "**.yaml" + - "**.yaml-tmlanguage" + - "**.yaml.sed" + - "**.yml.mysql" + pull_request: + paths: + - ".github/workflows/check-yaml.yml" + - ".yamllint*" + - "**/.clang-format" + - "**/.clang-tidy" + - "**/.gemrc" + - "**/glide.lock" + - "**.yml" + - "**.mir" + - "**.reek" + - "**.rviz" + - "**.sublime-syntax" + - "**.syntax" + - "**.yaml" + - "**.yaml-tmlanguage" + - "**.yaml.sed" + - "**.yml.mysql" + schedule: + # Run every Tuesday at 8 AM UTC to catch breakage caused by changes to yamllint. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + check: + name: ${{ matrix.configuration.name }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + configuration: + - name: Generate problem matcher output + # yamllint's "github" output type produces annotated diffs, but is not useful to humans reading the log. + format: github + # The other matrix job is used to set the result, so this job is configured to always pass. + continue-on-error: true + - name: Check formatting + # yamllint's "colored" output type is most suitable for humans reading the log. + format: colored + continue-on-error: false + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Check YAML + continue-on-error: ${{ matrix.configuration.continue-on-error }} + run: | + yamllint \ + --config-file "${{ github.workspace }}/.github/.yamllint.yml" \ + --format ${{ matrix.configuration.format }} \ + . From 0c09834a08711d1c9efd0a9f756bd2fa9c37106e Mon Sep 17 00:00:00 2001 From: per1234 Date: Thu, 8 Apr 2021 22:59:47 -0700 Subject: [PATCH 3/3] Bring workflow into compliance with the JSON schema --- .github/workflows/spell-check.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml index 8f7b71ade..3cf53c77a 100644 --- a/.github/workflows/spell-check.yml +++ b/.github/workflows/spell-check.yml @@ -25,7 +25,7 @@ jobs: uses: codespell-project/actions-codespell@master with: # In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: - ignore_words_list: + ignore_words_list: "" builtin: clear,informal,en-GB_to_en-US check_filenames: true check_hidden: true