From 083b059c65ca69598e338d1a281329f2627fdf58 Mon Sep 17 00:00:00 2001 From: Alexander Entinger Date: Thu, 18 Jan 2024 05:55:13 +0100 Subject: [PATCH] Add CI workflow to check for commonly misspelled words On every push, pull request, and periodically, use codespell to check for commonly misspelled words. In the event of a false positive, the problematic word should be added, in all lowercase, to the field of . Regardless of the case of the word in the false positive, it must be in all lowercase in the ignore list. The ignore list is comma-separated with no spaces. --- .codespellrc | 9 ++++ .github/workflows/spell-check-task.yml | 70 ++++++++++++++++++++++++++ README.md | 1 + Taskfile.yml | 31 ++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 .codespellrc create mode 100644 .github/workflows/spell-check-task.yml create mode 100644 Taskfile.yml diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..a8608a4 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,9 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc +# See: https://github.com/codespell-project/codespell#using-a-config-file +[codespell] +# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here: +ignore-words-list = , +skip = ./.git,./.licenses,__pycache__,node_modules,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock +builtin = clear,informal,en-GB_to_en-US +check-filenames = +check-hidden = diff --git a/.github/workflows/spell-check-task.yml b/.github/workflows/spell-check-task.yml new file mode 100644 index 0000000..f4d5cfe --- /dev/null +++ b/.github/workflows/spell-check-task.yml @@ -0,0 +1,70 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/spell-check-task.md +name: Spell Check + +env: + # See: https://github.com/actions/setup-python/tree/main#available-versions-of-python + PYTHON_VERSION: "3.9" + +# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows +on: + create: + push: + pull_request: + schedule: + # Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates. + - cron: "0 8 * * TUE" + workflow_dispatch: + repository_dispatch: + +jobs: + run-determination: + runs-on: ubuntu-latest + permissions: {} + outputs: + result: ${{ steps.determination.outputs.result }} + steps: + - name: Determine if the rest of the workflow should run + id: determination + run: | + RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" + # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead. + if [[ + "${{ github.event_name }}" != "create" || + "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX + ]]; then + # Run the other jobs. + RESULT="true" + else + # There is no need to run the other jobs. + RESULT="false" + fi + + echo "result=$RESULT" >> $GITHUB_OUTPUT + + spellcheck: + needs: run-determination + if: needs.run-determination.outputs.result == 'true' + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: ${{ env.PYTHON_VERSION }} + + - name: Install Poetry + run: pip install poetry + + - name: Install Task + uses: arduino/setup-task@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + version: 3.x + + - name: Spell check + run: task general:check-spelling diff --git a/README.md b/README.md index dd46470..24e1a04 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ `Arduino_10BASE_T1S` ==================== [![Compile Examples](https://github.com/bcmi-labs/Arduino_10BASE_T1S/workflows/Compile%20Examples/badge.svg)](https://github.com/bcmi-labs/Arduino_10BASE_T1S/actions?workflow=Compile+Examples) +[![Spell Check status](https://github.com/bcmi-labs/Arduino_10BASE_T1S/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/bcmi-labs/Arduino_10BASE_T1S/actions/workflows/spell-check-task.yml) **Note**: This library works for Arduino [Nano 33 IoT](https://store.arduino.cc/products/arduino-nano-33-iot), Arduino [Zero](https://store.arduino.cc/products/arduino-zero), Arduino [R4 WiFi](https://store.arduino.cc/products/uno-r4-wifi) and Arduino [R4 Minima](https://store.arduino.cc/products/uno-r4-minima). diff --git a/Taskfile.yml b/Taskfile.yml new file mode 100644 index 0000000..e5e5cb4 --- /dev/null +++ b/Taskfile.yml @@ -0,0 +1,31 @@ +# See: https://taskfile.dev/#/usage +version: "3" + +tasks: + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml + poetry:install-deps: + desc: Install dependencies managed by Poetry + cmds: + - poetry install --no-root + + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml + poetry:update-deps: + desc: Update all dependencies managed by Poetry to their newest versions + cmds: + - poetry update + + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml + general:check-spelling: + desc: Check for commonly misspelled words + deps: + - task: poetry:install-deps + cmds: + - poetry run codespell + + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml + general:correct-spelling: + desc: Correct commonly misspelled words where possible + deps: + - task: poetry:install-deps + cmds: + - poetry run codespell --write-changes