Skip to content

Commit 99e4576

Browse files
authored
Setting up Clang Tidy linting (#47)
* added a workflow to run clang tidy on the codebase * it needs a cmake configure step to run the cmake target * added clang-tidy installation step cause clang-tidy was not installed on the runner... * removed unecessary sudo inside container (already root in container) * it was capturing the exit code of the tee command * bash shell
1 parent 5adde6c commit 99e4576

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

.github/workflows/clang_tidy.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Clang Tidy Linting
2+
3+
on:
4+
push:
5+
workflow_dispatch:
6+
7+
permissions:
8+
contents: read
9+
packages: read
10+
11+
jobs:
12+
clang-tidy-linting:
13+
runs-on: ubuntu-latest
14+
15+
container:
16+
image: ghcr.io/hardcode3/bitbishop-ubuntu:latest
17+
credentials:
18+
username: ${{ github.actor }}
19+
password: ${{ secrets.github_token }}
20+
21+
steps:
22+
- uses: actions/checkout@v4
23+
24+
- name: Install clang-tidy
25+
run: |
26+
apt-get update
27+
apt-get install -y clang-tidy
28+
29+
- name: Configure (clang_debug)
30+
run: cmake --preset clang_debug
31+
32+
- name: Run clang-tidy
33+
shell: bash
34+
run: |
35+
set +e
36+
cmake --build --preset clang_debug --target clang-tidy 2>&1 | tee clang_tidy_output.txt
37+
CLANG_TIDY_EXIT_CODE=${PIPESTATUS[0]} # Capture CMake exit code, not tee
38+
set -e
39+
40+
if [ $CLANG_TIDY_EXIT_CODE -eq 0 ]; then
41+
echo "<details><summary>🟢 Clang Tidy Results (click to expand)</summary>" >> $GITHUB_STEP_SUMMARY
42+
else
43+
echo "## 🔴 Clang Tidy Results" >> $GITHUB_STEP_SUMMARY
44+
fi
45+
echo '' >> $GITHUB_STEP_SUMMARY
46+
echo '```' >> $GITHUB_STEP_SUMMARY
47+
cat clang_tidy_output.txt >> $GITHUB_STEP_SUMMARY
48+
echo '```' >> $GITHUB_STEP_SUMMARY
49+
if [ $CLANG_TIDY_EXIT_CODE -eq 0 ]; then
50+
echo "</details>" >> $GITHUB_STEP_SUMMARY
51+
fi
52+
53+
exit $CLANG_TIDY_EXIT_CODE

0 commit comments

Comments
 (0)