Skip to content

Commit

Permalink
Migrate to Task-based spell check system
Browse files Browse the repository at this point in the history
A task is added to check for commonly misspelled words in the project files.

On every push and pull request that affects relevant files, this task will be executed by the GitHub Actions workflow.

The updated system makes it easy for contributors to run the same checking operation locally as will be done by the CI
system, using the Task task runner tool.
  • Loading branch information
per1234 committed Oct 16, 2023
1 parent 2b63f7d commit 7401efa
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 23 deletions.
4 changes: 3 additions & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,7 +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 = ameba
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 =
skip = ./.git
70 changes: 70 additions & 0 deletions .github/workflows/spell-check-task.yml
Original file line number Diff line number Diff line change
@@ -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@v4
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
22 changes: 0 additions & 22 deletions .github/workflows/spell-check.yml

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Check License status](https://github.com/per1234/inoplatforms/actions/workflows/check-license.yml/badge.svg)](https://github.com/per1234/inoplatforms/actions/workflows/check-license.yml)
[![Check npm status](https://github.com/per1234/inoplatforms/actions/workflows/check-npm-task.yml/badge.svg)](https://github.com/per1234/inoplatforms/actions/workflows/check-npm-task.yml)
[![Check Prettier Formatting status](https://github.com/per1234/inoplatforms/actions/workflows/check-prettier-formatting-task.yml/badge.svg)](https://github.com/per1234/inoplatforms/actions/workflows/check-prettier-formatting-task.yml)
[![Spell Check status](https://github.com/per1234/inoplatforms/actions/workflows/spell-check-task.yml/badge.svg)](https://github.com/per1234/inoplatforms/actions/workflows/spell-check-task.yml)

A list of all known [Arduino](http://arduino.cc) hardware packages.

Expand Down
24 changes: 24 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ tasks:
desc: Check for problems with the project
deps:
- task: general:check-formatting
- task: general:check-spelling
- task: npm:validate

fix:
desc: Make automated corrections to the project's files
deps:
- task: general:correct-spelling
- task: general:format-prettier
- task: go:fix
- task: go:format
Expand All @@ -40,6 +42,22 @@ tasks:
github.com/editorconfig-checker/editorconfig-checker/cmd/editorconfig-checker
- editorconfig-checker

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check-task/Taskfile.yml

Check warning on line 45 in Taskfile.yml

View workflow job for this annotation

GitHub Actions / check

45:121 [line-length] line too long (127 > 120 characters)
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

Check warning on line 53 in Taskfile.yml

View workflow job for this annotation

GitHub Actions / check

53:121 [line-length] line too long (127 > 120 characters)
general:correct-spelling:
desc: Correct commonly misspelled words where possible
deps:
- task: poetry:install-deps
cmds:
- poetry run codespell --write-changes

# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-prettier-formatting-task/Taskfile.yml

Check warning on line 61 in Taskfile.yml

View workflow job for this annotation

GitHub Actions / check

61:121 [line-length] line too long (141 > 120 characters)
general:format-prettier:
desc: Format all supported files with Prettier
Expand Down Expand Up @@ -156,6 +174,12 @@ tasks:
-r "{{.STYLELINTRC_SCHEMA_PATH}}" \
-d "{{.PROJECT_FOLDER}}/{{.INSTANCE_PATH}}"
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/poetry-task/Taskfile.yml

Check warning on line 177 in Taskfile.yml

View workflow job for this annotation

GitHub Actions / check

177:121 [line-length] line too long (122 > 120 characters)
poetry:install-deps:
desc: Install dependencies managed by Poetry
cmds:
- poetry install --no-root

# Make a temporary file named according to the passed TEMPLATE variable and print the path passed to stdout
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/windows-task/Taskfile.yml
utility:mktemp-file:
Expand Down
23 changes: 23 additions & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "inoplatforms"
version = "0.0.0"
description = ""
authors = ["per1234 <nope@example.com>"]

[tool.poetry.dependencies]
python = "^3.12"

[tool.poetry.group.dev.dependencies]
codespell = "2.2.5"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

0 comments on commit 7401efa

Please sign in to comment.