Skip to content

Commit df96ec8

Browse files
kkaeferclaude
andcommitted
Add Clang Format job to enforce code formatting standards
- Check all C++ files (*.hpp, *.cpp) in include/ and test/ directories - Fail CI if code is not formatted according to clang-format style - Generate and upload formatting patch as artifact when issues found - Show patch content in CI logs for easy review - Helps maintain consistent code style across the project 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent ad6991e commit df96ec8

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/build.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,48 @@ jobs:
203203
ASAN_OPTIONS: detect_leaks=1:abort_on_error=1
204204
UBSAN_OPTIONS: halt_on_error=1:abort_on_error=1
205205

206+
Format:
207+
runs-on: ubuntu-latest
208+
209+
permissions:
210+
contents: read
211+
212+
steps:
213+
- name: Checkout repository
214+
uses: actions/checkout@v5
215+
216+
- name: Install clang-format
217+
run: |
218+
sudo apt-get update
219+
sudo apt-get install -y clang-format
220+
clang-format --version
221+
222+
- name: Check code formatting
223+
run: |
224+
# Find all C++ files and check formatting
225+
find include test -name "*.hpp" -o -name "*.cpp" | xargs clang-format --dry-run --Werror
226+
227+
- name: Generate formatting patch
228+
if: failure()
229+
run: |
230+
# Create patch with correct formatting
231+
find include test -name "*.hpp" -o -name "*.cpp" | xargs clang-format -i
232+
git diff > formatting.patch
233+
234+
# Show the patch content
235+
echo "=== Formatting issues found ==="
236+
cat formatting.patch
237+
238+
# Reset changes
239+
git checkout .
240+
241+
- name: Upload formatting patch
242+
if: failure()
243+
uses: actions/upload-artifact@v4
244+
with:
245+
name: formatting-patch
246+
path: formatting.patch
247+
206248
MacOS:
207249
strategy:
208250
fail-fast: false

0 commit comments

Comments
 (0)