diff --git a/.github/workflows/check-spelling.yml b/.github/workflows/check-spelling.yml new file mode 100644 index 0000000000..7d6ae166fd --- /dev/null +++ b/.github/workflows/check-spelling.yml @@ -0,0 +1,45 @@ +name: Checks - spelling + +on: + pull_request: + workflow_dispatch: + push: + +jobs: + spelling_check: + runs-on: ubuntu-latest + steps: + - name: Install python3 + run: | + apt update + apt install -y --no-install-recommends python3-pip + + - name: Install codespell + run: pip install codespell + + - name: Print codespell version + run: codespell --version + + - name: Check out repository code + uses: actions/checkout@v4 + with: + submodules: true + + - name: Run codespell + run: | + ./scripts/spelling.sh + + - name: Run git diff to see if anything changed + run: /usr/bin/git diff --name-only --exit-code + + - name: Run git diff if we failed + if: failure() + run: /usr/bin/git diff > spelling.patch + + - name: Archive diff as a patch if we failed + uses: actions/upload-artifact@v3 + if: failure() + with: + name: spelling.patch + path: | + ${{ github.workspace }}/spelling.patch diff --git a/scripts/spelling.sh b/scripts/spelling.sh new file mode 100755 index 0000000000..f22be4d61c --- /dev/null +++ b/scripts/spelling.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# --------------------------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2024, Lawrence Livermore National Security +# and Southern Methodist University. +# All rights reserved. +# +# See the top-level LICENSE and NOTICE files for details. +# +# SPDX-License-Identifier: BSD-3-Clause +# SUNDIALS Copyright End +# --------------------------------------------------------------------------------- +# This script will use codespell to check for common misspellings +# --------------------------------------------------------------------------------- + +codespell \ + --skip="*.git,*.bib,*.eps,*.pdf,*/fmod_int*,*/_themes" \ + -L "inout,ans" \ + --write-changes