Skip to content

Commit 037f90f

Browse files
committed
Add template 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 ignore-words-list field of ./.codespellrc. 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.
1 parent e8fdccc commit 037f90f

File tree

11 files changed

+266
-1
lines changed

11 files changed

+266
-1
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 = licence,ot
6+
builtin = clear,informal,en-GB_to_en-US
7+
check-filenames =
8+
check-hidden =
9+
skip = ./.git,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/spell-check-task.md
2+
name: Spell Check
3+
4+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
pull_request:
8+
schedule:
9+
# Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates.
10+
- cron: "0 8 * * TUE"
11+
workflow_dispatch:
12+
repository_dispatch:
13+
14+
jobs:
15+
spellcheck:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
- name: Install Python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: "3.9"
26+
27+
- name: Install Poetry
28+
run: pip install poetry
29+
30+
- name: Install Task
31+
uses: arduino/setup-task@v1
32+
with:
33+
repo-token: ${{ secrets.GITHUB_TOKEN }}
34+
version: 3.x
35+
36+
- name: Spell check
37+
run: task general:check-spelling

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
[![Check YAML status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-yaml-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-yaml-task.yml)
1313
[![Sync Labels status](https://github.com/arduino/tooling-project-assets/actions/workflows/sync-labels.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/sync-labels.yml)
1414
[![Check Workflows status](https://github.com/arduino/tooling-project-assets/actions/workflows/check-workflows-task.yml/badge.svg)](https://github.com/arduino/tooling-project-assets/actions/workflows/check-workflows-task.yml)
15+
[![Spell Check status](https://github.com/arduino/tooling-project-assets/actions/workflows/spell-check-task.yml/badge.svg)](https:/github.com/arduino/tooling-project-assets/actions/workflows/spell-check-task.yml)
1516

1617
The [Arduino](https://www.arduino.cc/) Tooling Team's collection of reusable project infrastructure assets.
1718

Taskfile.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ tasks:
99
- task: dependabot:sync
1010
- task: markdown:fix
1111
- task: general:format-prettier
12+
- task: general:correct-spelling
1213

1314
check:
1415
desc: Check for problems with the project
1516
deps:
1617
- task: general:check-formatting
1718
- task: ci:validate
19+
- task: general:check-spelling
1820
- task: config:validate
1921
- task: markdown:lint
2022
- task: markdown:check-links
@@ -37,6 +39,22 @@ tasks:
3739
fi
3840
- ec
3941

42+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml
43+
general:check-spelling:
44+
desc: Check for commonly misspelled words
45+
deps:
46+
- task: poetry:install-deps
47+
cmds:
48+
- poetry run codespell
49+
50+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml
51+
general:correct-spelling:
52+
desc: Correct commonly misspelled words where possible
53+
deps:
54+
- task: poetry:install-deps
55+
cmds:
56+
- poetry run codespell --write-changes
57+
4058
ci:sync:
4159
desc: Sync CI workflows from templates
4260
vars:
@@ -51,6 +69,7 @@ tasks:
5169
"{{.WORKFLOW_TEMPLATES_PATH}}/check-taskfiles.yml" \
5270
"{{.WORKFLOW_TEMPLATES_PATH}}/check-yaml-task.yml" \
5371
"{{.WORKFLOW_TEMPLATES_PATH}}/sync-labels.yml" \
72+
"{{.WORKFLOW_TEMPLATES_PATH}}/spell-check-task.yml" \
5473
"{{.WORKFLOWS_PATH}}"
5574
5675
config:sync:
@@ -61,6 +80,7 @@ tasks:
6180
cmds:
6281
- |
6382
cp \
83+
"{{.WORKFLOW_TEMPLATE_ASSETS_PATH}}/spell-check/.codespellrc" \
6484
"{{.WORKFLOW_TEMPLATE_ASSETS_PATH}}/shared/.editorconfig" \
6585
"{{.WORKFLOW_TEMPLATE_ASSETS_PATH}}/check-markdown/.markdown-link-check.json" \
6686
"{{.WORKFLOW_TEMPLATE_ASSETS_PATH}}/check-markdown/.markdownlint.yml" \

poetry.lock

Lines changed: 17 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ python = "^3.9"
99

1010
[tool.poetry.dev-dependencies]
1111
yamllint = "^v1.26.1"
12+
codespell = "^2.1.0"
1213

1314
[build-system]
1415
requires = ["poetry-core>=1.0.0"]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# See: https://taskfile.dev/#/usage
2+
version: "3"
3+
4+
tasks:
5+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml
6+
general:check-spelling:
7+
desc: Check for commonly misspelled words
8+
deps:
9+
- task: poetry:install-deps
10+
cmds:
11+
- poetry run codespell
12+
13+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml
14+
general:correct-spelling:
15+
desc: Correct commonly misspelled words where possible
16+
deps:
17+
- task: poetry:install-deps
18+
cmds:
19+
- poetry run codespell --write-changes
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+
builtin = clear,informal,en-GB_to_en-US
7+
check-filenames =
8+
check-hidden =
9+
skip = ./.git,./go.mod,./go.sum,./package-lock.json,./poetry.lock,./yarn.lock
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/spell-check-task.md
2+
name: Spell Check
3+
4+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
pull_request:
8+
schedule:
9+
# Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates.
10+
- cron: "0 8 * * TUE"
11+
workflow_dispatch:
12+
repository_dispatch:
13+
14+
jobs:
15+
spellcheck:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
- name: Install Python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: "3.9"
26+
27+
- name: Install Poetry
28+
run: pip install poetry
29+
30+
- name: Install Task
31+
uses: arduino/setup-task@v1
32+
with:
33+
repo-token: ${{ secrets.GITHUB_TOKEN }}
34+
version: 3.x
35+
36+
- name: Spell check
37+
run: task general:check-spelling
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# "Spell Check" workflow (Task)
2+
3+
Workflow file: [spell-check-task.yml](spell-check-task.yml)
4+
5+
Use [codespell](https://github.com/codespell-project/codespell) to check for commonly misspelled words in the repository files.
6+
7+
This is the version of the workflow for projects using the [Task](https://taskfile.dev/#/) task runner tool.
8+
9+
## Installation
10+
11+
The `codespell` tool dependency is managed by [Poetry](https://python-poetry.org/).
12+
13+
Install Poetry by following these instructions:<br />
14+
https://python-poetry.org/docs/#installation
15+
16+
If your project does not already use Poetry, you can initialize the [`pyproject.toml`](https://python-poetry.org/docs/pyproject/) file using these commands:
17+
18+
```
19+
poetry init --python="^3.9" --dev-dependency="codespell@^2.1.0"
20+
poetry install
21+
```
22+
23+
If already using Poetry, add the tool using this command:
24+
25+
```
26+
poetry add --dev "codespell@^2.1.0"
27+
```
28+
29+
Make sure to commit the resulting `pyproject.toml` and `poetry.lock` files.
30+
31+
## Assets
32+
33+
- [.codespellrc](assets/spell-check/.codespellrc) - codespell configuration file.
34+
- Install to: repository root
35+
- [`Taskfile.yml`](assets/spell-check-task/Taskfile.yml] - spell check and spelling correction tasks.
36+
- Install to: repository root (or add the `general:general:check-spelling` and `general:correct-spelling` tasks into the existing `Taskfile.yml`)
37+
- [`Taskfile.yml`](assets/shared/Taskfile.yml] - Installation task.
38+
- Add the `poetry:install-deps` task into the existing `Taskfile.yml`
39+
40+
## Readme badge
41+
42+
Markdown badge:
43+
44+
```markdown
45+
[![Spell Check status](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/REPO_OWNER/REPO_NAME/actions/workflows/spell-check-task.yml)
46+
```
47+
48+
Replace the `REPO_OWNER` and `REPO_NAME` placeholders in the URLs with the final repository owner and name ([example](https://raw.githubusercontent.com/arduino-libraries/ArduinoIoTCloud/master/README.md)).
49+
50+
---
51+
52+
Asciidoc badge:
53+
54+
```adoc
55+
image:https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check-task.yml/badge.svg["Spell Check status", link="https://github.com/{repository-owner}/{repository-name}/actions/workflows/spell-check-task.yml"]
56+
```
57+
58+
Define the `{repository-owner}` and `{repository-name}` attributes and use them throughout the readme ([example](https://raw.githubusercontent.com/arduino-libraries/WiFiNINA/master/README.adoc)).
59+
60+
## Commit message
61+
62+
```
63+
Add CI workflow to check for commonly misspelled words
64+
65+
On every push, pull request, and periodically, use the codespell to check for commonly
66+
misspelled words.
67+
68+
In the event of a false positive, the problematic word should be added, in all lowercase, to the ignore-words-list field
69+
of ./.codespellrc. Regardless of the case of the word in the false positive, it must be in all lowercase in the ignore
70+
list. The ignore list is comma-separated with no spaces.
71+
```
72+
73+
## PR message
74+
75+
```markdown
76+
On every push, pull request, and periodically, use [codespell](https://github.com/codespell-project/codespell) to check for commonly misspelled words.
77+
78+
In the event of a false positive, the problematic word should be added, in all lowercase, to the `ignore-words-list` field of `./.codespellrc`. 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.
79+
```
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/spell-check-task.md
2+
name: Spell Check
3+
4+
# See: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
5+
on:
6+
push:
7+
pull_request:
8+
schedule:
9+
# Run every Tuesday at 8 AM UTC to catch new misspelling detections resulting from dictionary updates.
10+
- cron: "0 8 * * TUE"
11+
workflow_dispatch:
12+
repository_dispatch:
13+
14+
jobs:
15+
spellcheck:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v2
21+
22+
- name: Install Python
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: "3.9"
26+
27+
- name: Install Poetry
28+
run: pip install poetry
29+
30+
- name: Install Task
31+
uses: arduino/setup-task@v1
32+
with:
33+
repo-token: ${{ secrets.GITHUB_TOKEN }}
34+
version: 3.x
35+
36+
- name: Spell check
37+
run: task general:check-spelling

0 commit comments

Comments
 (0)