From d11552c2d9885e0edf9e64b17931e905dc1a6dc6 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 21 Jan 2025 16:49:51 -0500 Subject: [PATCH] codespell: Exclude paths by patterns following pre-commit check conventions In order to share `.codespellrc` between our CI checks and `pre-commit` checks, we need to match paths without the leading `./`. Convert to a `bash` script so we can use `dotglob` to pass paths explicitly. Unfortunately this means we can no longer run `codespell` manually with no arguments. Instead we can run `.gitlab/ci/codespell.bash`. --- .codespellrc | 23 +++++++++++---------- .gitlab/ci/{codespell.sh => codespell.bash} | 6 +++++- .gitlab/os-linux.yml | 2 +- 3 files changed, 18 insertions(+), 13 deletions(-) rename .gitlab/ci/{codespell.sh => codespell.bash} (67%) diff --git a/.codespellrc b/.codespellrc index 445e98dde0..adc007f68b 100644 --- a/.codespellrc +++ b/.codespellrc @@ -5,18 +5,19 @@ check-hidden = quiet-level = 2 builtin = clear,rare,en-GB_to_en-US +# Skip paths matching fnmatch glob patterns. skip = - */.git, - */build, - */Copyright.txt, - */CTestCustom.cmake.in, - */Modules/Internal/CPack/NSIS.template.in, - */Source/CursesDialog/form/*, - */Source/kwsys/*, - */Tests/RunCMake/CPack/tests/DMG_SLA/German.*, - */Tests/RunCMake/ParseImplicitData/*.input, - */Tests/StringFileTest/test.utf8, - */Utilities/cm*, + .git, + build, + Copyright.txt, + CTestCustom.cmake.in, + Modules/Internal/CPack/NSIS.template.in, + Source/CursesDialog/form/*, + Source/kwsys/*, + Tests/RunCMake/CPack/tests/DMG_SLA/German.*, + Tests/RunCMake/ParseImplicitData/*.input, + Tests/StringFileTest/test.utf8, + Utilities/cm*, *.pfx, ignore-words-list = diff --git a/.gitlab/ci/codespell.sh b/.gitlab/ci/codespell.bash similarity index 67% rename from .gitlab/ci/codespell.sh rename to .gitlab/ci/codespell.bash index fff0b3650d..bbaffd231f 100755 --- a/.gitlab/ci/codespell.sh +++ b/.gitlab/ci/codespell.bash @@ -4,8 +4,12 @@ set -e result=0 +# 'codespell' with no arguments adds a leading './' to all paths. +# Avoid that by globbing top-level entries explicitly. +shopt -s dotglob echo "Running 'codespell' on source code..." -codespell || result=1 +codespell * || result=1 +shopt -u dotglob if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then for COMMIT in $(git rev-list "^$CI_MERGE_REQUEST_DIFF_BASE_SHA" "$CI_COMMIT_SHA"); do diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index f36b05cf72..be612953b6 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -584,7 +584,7 @@ stage: build extends: .fedora41 script: - - .gitlab/ci/codespell.sh + - .gitlab/ci/codespell.bash interruptible: true .cmake_build_linux: