|
| 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 dependencies |
| 18 | + run: | |
| 19 | + sudo apt update |
| 20 | + sudo apt install -y clang clang-tidy cmake g++ ninja-build |
| 21 | +
|
| 22 | + - name: Configure project with CMake |
| 23 | + run: | |
| 24 | + cmake -S . -B build -G Ninja \ |
| 25 | + -DCMAKE_CXX_COMPILER=clang++ \ |
| 26 | + -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ |
| 27 | + -DCMAKE_BUILD_TYPE=Release |
| 28 | +
|
| 29 | + - name: Build project |
| 30 | + run: cmake --build build -j$(nproc) |
| 31 | + |
| 32 | + # 👇 This stage writes the .clang-tidy file |
| 33 | + - name: Create .clang-tidy config |
| 34 | + run: | |
| 35 | + cat <<'EOF' > .clang-tidy |
| 36 | + Checks: > |
| 37 | + -*, |
| 38 | + readability-string-compare, |
| 39 | + bugprone-suspicious-string-compare, |
| 40 | + bugprone-*, |
| 41 | + readability-implicit-bool-conversion, |
| 42 | + performance-inefficient-string-concatenation, |
| 43 | + modernize-use-nullptr, |
| 44 | + modernize-use-override, |
| 45 | + modernize-use-auto, |
| 46 | + misc-unused-parameters |
| 47 | + WarningsAsErrors: '*' |
| 48 | + HeaderFilterRegex: 'src/.*' |
| 49 | + FormatStyle: none |
| 50 | + CheckOptions: |
| 51 | + - key: readability-implicit-bool-conversion.AllowIntegerConditions |
| 52 | + value: 'false' |
| 53 | + EOF |
| 54 | +
|
| 55 | + - name: Run clang-tidy |
| 56 | + run: | |
| 57 | + echo "Running clang-tidy..." |
| 58 | + cp build/compile_commands.json . |
| 59 | + clang-tidy -p . $(find src -name '*.cpp') 2>&1 | tee clang-tidy.log |
| 60 | + if grep -E "warning:|error:" clang-tidy.log; then |
| 61 | + echo "❌ Clang-Tidy found issues." |
| 62 | + exit 1 |
| 63 | + else |
| 64 | + echo "✅ Clang-Tidy passed cleanly." |
| 65 | + fi |
0 commit comments