Skip to content

Commit 2b9ae98

Browse files
committed
Modernize spell check infrastructure
The codespell tool is used to detect commonly misspelled words in the files of the project. Infrastructure is provided for running the tool locally and a GitHub Actions workflow also runs it automatically when files are changed and periodically. Previously the infrastructure was very outdated. It is hereby updated to the state of the art: - codespell dependency managed by Poetry and dependabot - Task-based to allow contributors to run the same check as done by the CI system via a standardized interface - Use standard codespell configuration file - Use codespell's official GitHub Actions instead of Arduino's action (deprecated in favor of the official action)
1 parent b3f056b commit 2b9ae98

File tree

7 files changed

+117
-20
lines changed

7 files changed

+117
-20
lines changed

.codespellrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc
2+
# See: https://github.com/codespell-project/codespell#using-a-config-file
3+
[codespell]
4+
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
5+
ignore-words-list = ,
6+
skip = ./.git,./.licenses,__pycache__,node_modules,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock
7+
builtin = clear,informal,en-GB_to_en-US
8+
check-filenames =
9+
check-hidden =
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/spell-check-task.md
2+
name: Spell Check
3+
4+
env:
5+
# See: https://github.com/actions/setup-python/tree/main#available-versions-of-python
6+
PYTHON_VERSION: "3.11"
7+
8+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
9+
on:
10+
create:
11+
push:
12+
pull_request:
13+
schedule:
14+
# Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates.
15+
- cron: "0 8 * * TUE"
16+
workflow_dispatch:
17+
repository_dispatch:
18+
19+
jobs:
20+
run-determination:
21+
runs-on: ubuntu-latest
22+
permissions: {}
23+
outputs:
24+
result: ${{ steps.determination.outputs.result }}
25+
steps:
26+
- name: Determine if the rest of the workflow should run
27+
id: determination
28+
run: |
29+
RELEASE_BRANCH_REGEX="^refs/heads/v[0-9]+$"
30+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
31+
if [[
32+
"${{ github.event_name }}" != "create" ||
33+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
34+
]]; then
35+
# Run the other jobs.
36+
RESULT="true"
37+
else
38+
# There is no need to run the other jobs.
39+
RESULT="false"
40+
fi
41+
42+
echo "result=$RESULT" >> $GITHUB_OUTPUT
43+
44+
spellcheck:
45+
needs: run-determination
46+
if: needs.run-determination.outputs.result == 'true'
47+
runs-on: ubuntu-latest
48+
permissions:
49+
contents: read
50+
51+
steps:
52+
- name: Checkout repository
53+
uses: actions/checkout@v4
54+
55+
- name: Install Python
56+
uses: actions/setup-python@v5
57+
with:
58+
python-version: ${{ env.PYTHON_VERSION }}
59+
60+
- name: Install Poetry
61+
run: pip install poetry
62+
63+
- name: Install Task
64+
uses: arduino/setup-task@v1
65+
with:
66+
repo-token: ${{ secrets.GITHUB_TOKEN }}
67+
version: 3.x
68+
69+
- name: Spell check
70+
run: task general:check-spelling

.github/workflows/spell-check.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Check Taskfiles status](https://github.com/arduino/report-size-deltas/actions/workflows/check-taskfiles.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/check-taskfiles.yml)
55
[![Tests](https://github.com/arduino/report-size-deltas/workflows/libraries/report-size-deltas%20workflow/badge.svg)](https://github.com/arduino/report-size-deltas/actions?workflow=libraries/report-size-deltas+workflow)
66
[![Integration Tests](https://github.com/arduino/report-size-deltas/actions/workflows/test-integration.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/test-integration.yml)
7-
[![Spell Check](https://github.com/arduino/report-size-deltas/workflows/Spell%20Check/badge.svg)](https://github.com/arduino/report-size-deltas/actions?workflow=Spell+Check)
7+
[![Spell Check status](https://github.com/arduino/report-size-deltas/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/spell-check-task.yml)
88
[![Sync Labels status](https://github.com/arduino/report-size-deltas/actions/workflows/sync-labels-npm.yml/badge.svg)](https://github.com/arduino/report-size-deltas/actions/workflows/sync-labels-npm.yml)
99
[![codecov](https://codecov.io/gh/arduino/report-size-deltas/branch/master/graph/badge.svg)](https://codecov.io/gh/arduino/report-size-deltas)
1010

Taskfile.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,22 @@ tasks:
1111
deps:
1212
- task: npm:validate
1313

14+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml
15+
general:check-spelling:
16+
desc: Check for commonly misspelled words
17+
deps:
18+
- task: poetry:install-deps
19+
cmds:
20+
- poetry run codespell
21+
22+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml
23+
general:correct-spelling:
24+
desc: Correct commonly misspelled words where possible
25+
deps:
26+
- task: poetry:install-deps
27+
cmds:
28+
- poetry run codespell --write-changes
29+
1430
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/npm-task/Taskfile.yml
1531
npm:install-deps:
1632
desc: Install dependencies managed by npm
@@ -82,6 +98,12 @@ tasks:
8298
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
8399
-d "{{.PROJECT_FOLDER}}/{{.INSTANCE_PATH}}"
84100
101+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml
102+
poetry:install-deps:
103+
desc: Install dependencies managed by Poetry
104+
cmds:
105+
- poetry install --no-root
106+
85107
# Make a temporary file named according to the passed TEMPLATE variable and print the path passed to stdout
86108
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
87109
utility:mktemp-file:

etc/codespell-ignore-words-list.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[tool.poetry]
2+
name = "arduino/report-size-deltas"
3+
version = "0.0.0"
4+
description = ""
5+
authors = ["Arduino <[email protected]>"]
6+
7+
[tool.poetry.dependencies]
8+
python = "3.11.*"
9+
10+
[tool.poetry.group.dev.dependencies]
11+
codespell = "2.2.5"
12+
13+
[build-system]
14+
requires = ["poetry-core"]
15+
build-backend = "poetry.core.masonry.api"

0 commit comments

Comments
 (0)