feat: clang formatter

This commit is contained in:
GameTec_live
2025-09-02 19:26:01 +02:00
parent 212a9ceccd
commit e0790f677b
4 changed files with 49 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
BreakBeforeBinaryOperators: All
ColumnLimit: 120
BasedOnStyle: Google
BreakBeforeBraces: Stroustrup
IndentWidth: 4
+35
View File
@@ -0,0 +1,35 @@
name: clang-format Check
on:
pull_request:
paths:
- '**.c'
- '**.h'
- '**.cpp'
workflow_dispatch:
jobs:
check-format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install clang-format
run: sudo apt install -y clang-format
- name: Get files and check format
run: |
exit_code=0
while IFS= read -r -d '' f; do
if ! diff -u "$f" <(clang-format "$f"); then
echo "Formatting issue in $f"
exit_code=1
fi
done < <(find . -type f \( -name '*.c' -o -name '*.h' \) ! -path './firmware/nrf52_sdk/*' ! -path './firmware/nrf52_sdk/**' -print0)
if [ $exit_code -ne 0 ]; then
echo "Clang-format check failed."
exit 1
else
echo "All files are properly formatted."
fi
+1
View File
@@ -5,6 +5,7 @@ on:
paths:
- "software/**"
- ".github/workflows/**"
- "**.py"
workflow_dispatch:
jobs:
+8
View File
@@ -0,0 +1,8 @@
#!/bin/env bash
# Make it a bit less prone to breaking
cd "$(dirname "$0")/.." || exit
while IFS= read -r -d '' f; do
clang-format --verbose -i "$f"
done < <(find . -type f \( -name '*.c' -o -name '*.h' \) ! -path './firmware/nrf52_sdk/*' ! -path './firmware/nrf52_sdk/**' -print0)