diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..17c575c --- /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 = afterall,clude +skip = ./.git,./.licenses,.pytest_cache,__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..20a3958 --- /dev/null +++ b/.github/workflows/spell-check-task.yml @@ -0,0 +1,66 @@ +# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/spell-check-task.md +name: Spell Check + +# 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 + 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 + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install Python + uses: actions/setup-python@v4 + with: + python-version-file: .python-version + + - name: Install Poetry + run: | + pipx install \ + --python "$(which python)" \ + 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/.github/workflows/spell-check.yml b/.github/workflows/spell-check.yml deleted file mode 100644 index cddb949..0000000 --- a/.github/workflows/spell-check.yml +++ /dev/null @@ -1,16 +0,0 @@ -name: Spell Check - -on: [push, pull_request] - -jobs: - spellcheck: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Spell check - uses: arduino/actions/libraries/spell-check@master - with: - ignore-words-list: etc/codespell-ignore-words-list.txt diff --git a/README.md b/README.md index 12f4e19..9bc1020 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Check Action Metadata status](https://github.com/arduino/compile-sketches/actions/workflows/check-action-metadata-task.yml/badge.svg)](https://github.com/arduino/compile-sketches/actions/workflows/check-action-metadata-task.yml) [![Tests](https://github.com/arduino/compile-sketches/workflows/Test%20Python%20code/badge.svg)](https://github.com/arduino/compile-sketches/actions?workflow=Test+Python+code) [![Check Python status](https://github.com/arduino/compile-sketches/actions/workflows/check-python-task.yml/badge.svg)](https://github.com/arduino/compile-sketches/actions/workflows/check-python-task.yml) -[![Spell Check](https://github.com/arduino/compile-sketches/workflows/Spell%20Check/badge.svg)](https://github.com/arduino/compile-sketches/actions?workflow=Spell+Check) +[![Spell Check status](https://github.com/arduino/compile-sketches/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/arduino/compile-sketches/actions/workflows/spell-check-task.yml) [![codecov](https://codecov.io/gh/arduino/compile-sketches/branch/main/graph/badge.svg?token=Uv6f1ebMZ4)](https://codecov.io/gh/arduino/compile-sketches) This action checks whether [Arduino](https://www.arduino.cc/) sketches compile and produces a report of data from the compilations. diff --git a/Taskfile.yml b/Taskfile.yml index 41a0727..99abfb1 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -6,11 +6,13 @@ tasks: desc: Check for problems with the project deps: - task: action:validate + - task: general:check-spelling - task: python:lint fix: desc: Make automated corrections to the project's files deps: + - task: general:correct-spelling - task: python:format # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-action-metadata-task/Taskfile.yml @@ -35,6 +37,26 @@ tasks: -s "{{.ACTION_METADATA_SCHEMA_PATH}}" \ -d "action.yml" + # 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 + vars: + POETRY_GROUPS: dev + 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 + vars: + POETRY_GROUPS: dev + cmds: + - poetry run codespell --write-changes + # Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml npm:install-deps: desc: Install dependencies managed by npm diff --git a/etc/codespell-ignore-words-list.txt b/etc/codespell-ignore-words-list.txt deleted file mode 100644 index bef1c14..0000000 --- a/etc/codespell-ignore-words-list.txt +++ /dev/null @@ -1,2 +0,0 @@ -afterall -clude diff --git a/poetry.lock b/poetry.lock index ecb51cb..d3750a1 100644 --- a/poetry.lock +++ b/poetry.lock @@ -256,6 +256,24 @@ files = [ [package.dependencies] colorama = {version = "*", markers = "platform_system == \"Windows\""} +[[package]] +name = "codespell" +version = "2.2.4" +description = "Codespell" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "codespell-2.2.4-py3-none-any.whl", hash = "sha256:7d984b8130108e6f82524b7d09f8b7bf2fb1e398c5d4b37d9e2bd310145b3e29"}, + {file = "codespell-2.2.4.tar.gz", hash = "sha256:0b4620473c257d9cde1ff8998b26b2bb209a35c2b7489f5dc3436024298ce83a"}, +] + +[package.extras] +dev = ["Pygments", "build", "chardet", "flake8", "flake8-pyproject", "pytest", "pytest-cov", "pytest-dependency", "tomli"] +hard-encoding-detection = ["chardet"] +toml = ["tomli"] +types = ["chardet (>=5.1.0)", "mypy", "pytest", "pytest-cov", "pytest-dependency"] + [[package]] name = "colorama" version = "0.4.6" @@ -874,4 +892,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "3.11.2" -content-hash = "c975d20f32852d848f235549d9dd58b6870a2e744226a479d39f75832e5fd82f" +content-hash = "8907a887cd8e83e4387e3b601da1d616577abcf736b2605f514316d5d410b002" diff --git a/pyproject.toml b/pyproject.toml index cd23db1..3825f34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,6 +16,7 @@ semver = "2.13.0" [tool.poetry.group.dev.dependencies] black = "23.1.0" +codespell = "2.2.4" coverage = "7.2.2" pytest = "7.2.2" pytest-mock = "3.10.0"