Skip to content

Commit 73d0458

Browse files
committed
ci(pre-commit): run checks only on changed files in PR
1 parent 61cbfbd commit 73d0458

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

.github/workflows/pre-commit.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,17 @@ jobs:
2626
run: pip install codespell
2727

2828
- name: Run pre-commit checks
29-
run: pre-commit run --all-files
29+
run: |
30+
BASE_SHA=${{ github.event.pull_request.base.sha }}
31+
HEAD_SHA=${{ github.event.pull_request.head.sha }}
32+
CHANGED_FILES=$(git diff --name-only $BASE_SHA $HEAD_SHA | grep -E '\.(py|c|h|md|rst|yml)$' || true)
33+
echo "Changed files:"
34+
echo "$CHANGED_FILES" | tr ' ' '\n'
35+
if [ -n "$CHANGED_FILES" ]; then
36+
pre-commit run --files $CHANGED_FILES -v
37+
else
38+
echo "No matching files changed."
39+
fi
3040
3141
- name: Validate commit messages
3242
run: |

0 commit comments

Comments
 (0)