Skip to content

Commit bdc0316

Browse files
committed
Merge pull request #91835 from akien-mga/ci-static-checks-readd-CHANGED_FILES-logic
CI: Re-add `CHANGED_FILES` logic for pre-commit checks
2 parents 10471a4 + 734f820 commit bdc0316

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.github/workflows/static_checks.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,20 @@ jobs:
2626
pip3 install pytest==7.1.2
2727
git config diff.wsErrorHighlight all
2828
29+
- name: Get changed files
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
if [ "${{ github.event_name }}" == "pull_request" ]; then
34+
files=$(git diff-tree --no-commit-id --name-only -r HEAD^1..HEAD 2> /dev/null || true)
35+
elif [ "${{ github.event_name }}" == "push" -a "${{ github.event.forced }}" == "false" -a "${{ github.event.created }}" == "false" ]; then
36+
files=$(git diff-tree --no-commit-id --name-only -r ${{ github.event.before }}..${{ github.event.after }} 2> /dev/null || true)
37+
fi
38+
echo "$files" >> changed.txt
39+
cat changed.txt
40+
files=$(echo "$files" | grep -v 'thirdparty' | xargs -I {} sh -c 'echo "./{}"' | tr '\n' ' ')
41+
echo "CHANGED_FILES=$files" >> $GITHUB_ENV
42+
2943
# This needs to happen before Python and npm execution; it must happen before any extra files are written.
3044
- name: .gitignore checks (gitignore_check.sh)
3145
run: |
@@ -34,7 +48,7 @@ jobs:
3448
- name: Style checks via pre-commit
3549
uses: pre-commit/[email protected]
3650
with:
37-
extra_args: --verbose
51+
extra_args: --verbose --files ${{ env.CHANGED_FILES }}
3852

3953
- name: Python builders checks via pytest
4054
run: |

0 commit comments

Comments
 (0)