Skip to content

Commit 1b647aa

Browse files
committed
feat(silo): add clang tidy test to ci
1 parent 56f8621 commit 1b647aa

2 files changed

Lines changed: 63 additions & 100 deletions

File tree

.github/workflows/ci.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,69 @@ jobs:
116116
tags: ${{ env.DOCKER_IMAGE_NAME }}:commit-${{ env.HEAD_SHA }}-${{ matrix.arch }}
117117
build-args: |
118118
DEPENDENCY_IMAGE=${{ env.DOCKER_DEPENDENCY_IMAGE_NAME }}:commit-${{ env.HEAD_SHA }}-${{ matrix.arch }}
119+
120+
- name: Run clang-tidy inside builder
121+
run: |
122+
docker run --rm \
123+
-v "$GITHUB_WORKSPACE:/src" \
124+
-w /src \
125+
builder \
126+
bash -eo pipefail -c '
127+
# Install tools needed for the analysis (kept inside container)
128+
if command -v apt-get >/dev/null 2>&1; then
129+
apt-get update -y
130+
# clang-tidy + helpers. jq used to read compile_commands.json
131+
apt-get install -y --no-install-recommends clang clang-tidy jq python3
132+
fi
133+
134+
# 2a) Ensure deps are generated (your Makefile would do this, but do it here explicitly)
135+
conan --version >/dev/null 2>&1 || { echo "Conan missing in builder image"; exit 1; }
136+
137+
# Generate CMake files and compile_commands.json (explicitly set export flag)
138+
cmake -S . -B build/Debug \
139+
-D CMAKE_BUILD_TYPE=Debug \
140+
-D CMAKE_EXPORT_COMPILE_COMMANDS=ON
141+
142+
# Optional: build to materialize any generated headers if your project needs them
143+
cmake --build build/Debug -j "$(nproc)"
144+
145+
# Sanity check
146+
test -f build/Debug/compile_commands.json || { echo "compile_commands.json not found"; exit 2; }
147+
148+
# Choose checks. Start strict but practical.
149+
CHECKS="-*,bugprone-*,clang-analyzer-*,cppcoreguidelines-*,cert-*,performance-*,readability-*"
150+
# Treat every diagnostic as error to block merges
151+
WARNERR="*"
152+
153+
# Run clang-tidy over all TU paths from the compile database.
154+
# This avoids missing files and respects per-target flags.
155+
FILES=$(jq -r ".[].file" build/Debug/compile_commands.json | sort -u)
156+
if [ -z "$FILES" ]; then
157+
echo "No files in compile_commands.json"; exit 3;
158+
fi
159+
160+
# Use parallelism; fall back if run-clang-tidy isn’t present.
161+
if command -v run-clang-tidy >/dev/null 2>&1; then
162+
run-clang-tidy \
163+
-p build/Debug \
164+
-j "$(nproc)" \
165+
-header-filter="^src/|^include/" \
166+
-checks="$CHECKS" \
167+
-warnings-as-errors="$WARNERR"
168+
else
169+
# Manual loop if run-clang-tidy isn’t available
170+
failed=0
171+
for f in $FILES; do
172+
echo "=== clang-tidy: $f ==="
173+
clang-tidy "$f" \
174+
-p build/Debug \
175+
-checks="$CHECKS" \
176+
-warnings-as-errors="$WARNERR" \
177+
|| failed=1
178+
done
179+
exit $failed
180+
fi
181+
'
119182
120183
multiPlatformImages:
121184
name: Create multi-platform images

.github/workflows/clang-tidy.yml

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)