Skip to content

Commit 472a357

Browse files
authored
Merge pull request #25 from cortex-command-community/improve-ci-formatting
Improve CI formatting
2 parents fb98727 + 6501bff commit 472a357

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-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: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,42 @@ 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+
# if any changes were made, fail the build
63+
if ! git diff --quiet ; then
64+
echo "::error::Code misformatted. Run clang-format or apply the patch (printed below and attached to job summary) to fix."
65+
# Print the changes to the console
66+
cat clang-format-changes.patch
67+
exit 1
68+
fi
69+
- name: Upload artifacts
70+
uses: actions/upload-artifact@v4
71+
# Only upload the patch file if the build failed, meaning that the code was not properly formatted
72+
if: failure()
73+
with:
74+
name: clang-format-changes.patch
75+
path: |
76+
clang-format-changes.patch

0 commit comments

Comments
 (0)