Skip to content

Commit 4af3618

Browse files
committed
add clang tidy sanitizer
1 parent fcdbe1f commit 4af3618

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

.github/workflows/clang-tidy.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Clang-Tidy CI
2+
3+
on:
4+
push:
5+
branches: ['**']
6+
pull_request:
7+
branches: ['**']
8+
9+
jobs:
10+
clang-tidy:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 #v4
16+
17+
- name: Install clang tidy dependencies
18+
run: |
19+
sudo apt update
20+
sudo apt install -y clang clang-tidy cmake g++ ninja-build
21+
22+
- name: Install SDK dependencies
23+
run: |
24+
sudo apt update
25+
sudo apt-get install -qq build-essential xorg-dev libgl1-mesa-dev libglu1-mesa-dev libglew-dev libglm-dev;
26+
sudo apt-get install -qq libusb-1.0-0-dev;
27+
sudo apt-get install -qq libgtk-3-dev;
28+
sudo apt-get install libglfw3-dev libglfw3;
29+
30+
31+
- name: Configure project with CMake
32+
run: |
33+
cmake -S . -B build \
34+
-DCMAKE_CXX_COMPILER=clang++ \
35+
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
36+
-DCHECK_FOR_UPDATES=OFF \
37+
-DCMAKE_BUILD_TYPE=Release
38+
39+
- name: Build project
40+
run: cmake --build build -j$(nproc)
41+
42+
# 👇 This stage writes the .clang-tidy file
43+
- name: Create .clang-tidy config
44+
run: |
45+
cat <<'EOF' > .clang-tidy
46+
Checks: >
47+
-*,
48+
readability-string-compare,
49+
bugprone-suspicious-string-compare,
50+
bugprone-*,
51+
readability-implicit-bool-conversion,
52+
performance-inefficient-string-concatenation,
53+
modernize-use-nullptr,
54+
modernize-use-override,
55+
modernize-use-auto,
56+
misc-unused-parameters
57+
WarningsAsErrors: '*'
58+
HeaderFilterRegex: 'src/.*'
59+
FormatStyle: none
60+
CheckOptions:
61+
- key: readability-implicit-bool-conversion.AllowIntegerConditions
62+
value: 'false'
63+
EOF
64+
65+
- name: Run clang-tidy
66+
run: |
67+
echo "Running clang-tidy..."
68+
cp build/compile_commands.json .
69+
clang-tidy -p . $(find src -name '*.cpp') 2>&1 | tee clang-tidy.log
70+
if grep -E "warning:|error:" clang-tidy.log; then
71+
echo "❌ Clang-Tidy found issues."
72+
exit 1
73+
else
74+
echo "✅ Clang-Tidy passed cleanly."
75+
fi

0 commit comments

Comments
 (0)