From 06df78cd5db4f3ce16a45db0eb49e95af599034d Mon Sep 17 00:00:00 2001 From: John Bampton Date: Wed, 9 Nov 2022 19:52:15 +1000 Subject: [PATCH] gha: add `codespell` with `pre-commit` Add customm dictionary `codespell.txt` We are only checking the `docs` folders https://github.com/codespell-project/codespell https://pre-commit.com/ --- .github/workflows/lint.yml | 21 +++++++++++++++++++++ .pre-commit-config.yaml | 20 ++++++++++++++++++++ codespell.txt | 4 ++++ 3 files changed, 45 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 codespell.txt diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 683f80cbc..dc6ee7aa7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -43,3 +43,24 @@ jobs: run: | # return non-zero exit code on warnings yamllint --strict . + pre-commit: + name: Run pre-commit # https://pre-commit.com/ + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 # https://www.python.org/ + with: + python-version: '3.x' # Version range or exact version of a Python version to use, using SemVer's version range syntax + architecture: 'x64' # optional x64 or x86. Defaults to x64 if not specified + - name: Install dependencies # https://pip.pypa.io/en/stable/ + run: | + python -m pip install --upgrade pip + pip install pre-commit + - name: Set PY + run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV + - uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Run pre-commit + run: pre-commit run --all-files diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..8faf5aa5d --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,20 @@ +--- +# https://pre-commit.com/#installation +default_stages: [commit, push] +default_language_version: + # force all unspecified Python hooks to run python3 + python: python3 +minimum_pre_commit_version: '2.18.1' +repos: + - repo: meta + hooks: + - id: identity + - id: check-hooks-apply + - repo: https://github.com/codespell-project/codespell + rev: v2.2.2 + hooks: + - id: codespell + name: Run codespell + description: Check spelling with codespell + entry: codespell --ignore-words=codespell.txt + files: ^docs/.*$ diff --git a/codespell.txt b/codespell.txt new file mode 100644 index 000000000..22b0445a1 --- /dev/null +++ b/codespell.txt @@ -0,0 +1,4 @@ +iif +inout +intervall +ist