-
Notifications
You must be signed in to change notification settings - Fork 1
38 lines (32 loc) · 1.05 KB
/
formatting.yml
File metadata and controls
38 lines (32 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
name: Code Formatting
on:
push:
branches: [main, development]
pull_request:
branches: [main, development]
jobs:
format:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [macos-latest]
steps:
- uses: actions/checkout@v5
# Install clang-format if needed
- name: Install clang-format (Linux)
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get update && sudo apt-get install -y clang-format
- name: Install clang-format (macOS)
if: matrix.os == 'macos-latest'
run: brew install clang-format || true
# Check formatting
- name: Check C/C++ formatting
run: |
misformatted=$(find . -name '*.c' -o -name '*.h' -print0 | xargs -0 clang-format -style=file -output-replacements-xml | grep "<replacement " || true)
if [ -n "$misformatted" ]; then
echo "ERROR: Some files are not properly formatted. Run clang-format -i."
exit 1
else
echo "All files are properly formatted."
exit 0
fi