Skip to content

Commit 1373770

Browse files
committed
Make CI add EOL to files which need it and post patch with changes
1 parent 5399b4d commit 1373770

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

.github/scripts/add-eol.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
sed -e '$a\' "$@"

.github/workflows/clang-format.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,44 @@ jobs:
3535

3636
- name: Run clang-format
3737
run: |
38-
.github/scripts/run-clang-format.py -r Source Data/Base.rte/Shaders \
38+
.github/scripts/run-clang-format.py \
39+
-i \
40+
-r Source Data/Base.rte/Shaders \
3941
--exclude Source/System/Base64 \
4042
--exclude Source/System/BitMask \
4143
--exclude Source/System/glad \
4244
--exclude Source/System/MicroPather \
4345
--exclude Source/System/Semver200 \
4446
--exclude Source/System/StackWalker
47+
- name: Add missing newlines
48+
run: |
49+
.github/scripts/run-clang-format.py \
50+
-i --clang-format-executable .github/scripts/add-eol.sh \
51+
-r Source Data/Base.rte/Shaders \
52+
--exclude Source/System/Base64 \
53+
--exclude Source/System/BitMask \
54+
--exclude Source/System/glad \
55+
--exclude Source/System/MicroPather \
56+
--exclude Source/System/Semver200 \
57+
--exclude Source/System/StackWalker
58+
- name: Report changes
59+
run: |
60+
# Store the changes in a patch file first
61+
git diff > clang-format-changes.patch
62+
# Print the changes to the console
63+
cat clang-format-changes.patch
64+
# if any changes were made, fail the build
65+
if git diff --quiet ; then
66+
# If no changes were made, delete the (empty) patch file, so it doesn't get posted as an artifact
67+
rm -f clang-format-changes.patch
68+
else
69+
echo "Code misformatted. Run clang-format or apply the patch to fix."
70+
exit 1
71+
fi
72+
- name: Upload artifacts
73+
uses: actions/upload-artifact@v4
74+
if: always()
75+
with:
76+
name: clang-format-changes.patch
77+
path: |
78+
clang-format-changes.patch

0 commit comments

Comments
 (0)