Skip to content

Commit

Permalink
Update infrastructure for spell checking project contents
Browse files Browse the repository at this point in the history
Arduino tooling projects use a standardized infrastructure. A centralized collection of reusable infrastructure assets
is maintained in a dedicated repository:

https://github.com/arduino/tooling-project-assets

Since the time this project's infrastructure was installed, some advancements have been made in the upstream "template"
assets. The project's infrastructure is hereby brought up to date with the state of the art upstream assets.

The significant changes:

- Migration to the use of the Task task runner to allow contributors to easily run the same operations locally as is
  done by the CI system on GitHub.
- Use of Poetry and Dependabot for controlled management of the dependencies.
  • Loading branch information
per1234 committed Mar 25, 2023
1 parent 8356c72 commit db75bcc
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 20 deletions.
9 changes: 9 additions & 0 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -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 =
66 changes: 66 additions & 0 deletions .github/workflows/spell-check-task.yml
Original file line number Diff line number Diff line change
@@ -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
16 changes: 0 additions & 16 deletions .github/workflows/spell-check.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
22 changes: 22 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions etc/codespell-ignore-words-list.txt

This file was deleted.

20 changes: 19 additions & 1 deletion poetry.lock

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

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit db75bcc

Please sign in to comment.