From 47b3f9587424834f0a44343a2c799facc5111c1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 8 May 2023 11:28:34 +0200 Subject: CI: Make codespell checks blocking, but only check changed files (cherry picked from commit b226f7e587c4b5093d7bf27a4b0ac687a2d1cd2e) --- .github/workflows/static_checks.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index 8dc5e0fbff..a13e761df8 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -36,6 +36,8 @@ jobs: fi echo "$files" >> changed.txt cat changed.txt + files=$(echo "$files" | tr '\n' ' ') + echo "CHANGED_FILES=$files" >> $GITHUB_ENV - name: File formatting checks (file_format.sh) run: | @@ -98,9 +100,10 @@ jobs: fi - name: Spell checks via codespell + if: github.event_name == 'pull_request' uses: codespell-project/actions-codespell@v1 with: skip: ./.*,./**/.*,./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json check_hidden: false - ignore_words_list: curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te - only_warn: true + ignore_words_list: curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te,vai + path: ${{ env.CHANGED_FILES }} -- cgit v1.2.3 From 9deaac5c60b37317fddbcb7e5be3c6c5394bb761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Mon, 8 May 2023 14:49:51 +0200 Subject: CI: Use gh-cli for changed files, and workaround codespell skip list bug For PRs, this should give a more accurate list, as the previous method would diff to the tip of the `master` branch, which could include new commits (and thus changed files) not present in the PR branch. codespell's `--skip` option doesn't work at all with folders when used together with an explicit list of paths to work with, so let's not use it. (cherry picked from commit b3bb92ae5ecae0389bbadd7c6933fbae39d74971) --- .github/workflows/static_checks.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index a13e761df8..72c2ee0f02 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -28,15 +28,17 @@ jobs: - name: Get changed files id: changed-files + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | if [ "${{ github.event_name }}" == "pull_request" ]; then - files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }} 2> /dev/null || true) + files=$(gh pr diff ${{ github.event.pull_request.number }} --name-only) elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true) fi echo "$files" >> changed.txt cat changed.txt - files=$(echo "$files" | tr '\n' ' ') + files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "./{}"' | tr '\n' ' ') echo "CHANGED_FILES=$files" >> $GITHUB_ENV - name: File formatting checks (file_format.sh) @@ -103,7 +105,6 @@ jobs: if: github.event_name == 'pull_request' uses: codespell-project/actions-codespell@v1 with: - skip: ./.*,./**/.*,./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json - check_hidden: false - ignore_words_list: curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te,vai + skip: "*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json" + ignore_words_list: "curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te,vai" path: ${{ env.CHANGED_FILES }} -- cgit v1.2.3 From 4d7336e70f4a2d284f774958428c082c6c708cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 10 May 2023 09:44:35 +0200 Subject: CI: Skip codespell check if `CHANGED_FILES` is empty This can happen when only thirdparty files are changed, since we grep them out. Re-add `bin` and `thirdparty` to the skip list for good measure. (cherry picked from commit c7a5ce656cb6cb7727c5ebd7616ebc1a8fd0bdad) --- .github/workflows/static_checks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to '.github/workflows') diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml index 72c2ee0f02..84066808c1 100644 --- a/.github/workflows/static_checks.yml +++ b/.github/workflows/static_checks.yml @@ -102,9 +102,9 @@ jobs: fi - name: Spell checks via codespell - if: github.event_name == 'pull_request' + if: github.event_name == 'pull_request' && env.CHANGED_FILES != '' uses: codespell-project/actions-codespell@v1 with: - skip: "*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json" + skip: "./bin,./thirdparty,*.desktop,*.gen.*,*.po,*.pot,*.rc,./AUTHORS.md,./COPYRIGHT.txt,./DONORS.md,./core/input/gamecontrollerdb.txt,./core/string/locales.h,./editor/project_converter_3_to_4.cpp,./misc/scripts/codespell.sh,./platform/android/java/lib/src/com,./platform/web/node_modules,./platform/web/package-lock.json" ignore_words_list: "curvelinear,doubleclick,expct,findn,gird,hel,inout,lod,nd,numer,ot,te,vai" path: ${{ env.CHANGED_FILES }} -- cgit v1.2.3