Skip to content

Commit f9cc103

Browse files
committed
Add check that all PR commits are formatted
* Checking compilation would be prohibitively expensive, but formatting can be feasibly checked.
1 parent ec64c18 commit f9cc103

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
steps:
7070
- uses: actions/checkout@v6
7171
with:
72-
fetch-depth: 5
72+
fetch-depth: 0
7373
- name: Run clang-format
7474
run: |
7575
bash ./util/clang_format_all.sh
@@ -83,6 +83,24 @@ jobs:
8383
git diff;) | tr '\n' '\001' | sed -e 's#\x01#%0A#g';
8484
exit 1;
8585
)
86+
- name: Check commit messages (PR)
87+
if: ${{ github.event_name == 'pull_request' }}
88+
run: |
89+
git log --oneline origin/${{github.base_ref}}.. > a
90+
echo "Changing individual clang-format commits:"
91+
cat a
92+
awk '{print $1}' a > b
93+
for COMMIT in $(cat b); do
94+
git checkout $COMMIT
95+
./util/clang_format_all.sh --head-commit
96+
git diff --quiet || (
97+
(echo -n "::error::";
98+
echo "commit $COMMIT has clang-format issues. See CONTRIBUTING.md for more information.";
99+
echo;
100+
git diff;) | tr '\n' '\001' | sed -e 's#\x01#%0A#g';
101+
exit 1;
102+
)
103+
done
86104
cmake-minimum:
87105
name: Baseline cmake check
88106
needs: [commit-msg, clang-format]

0 commit comments

Comments
 (0)