Skip to content

Commit 0cd37b7

Browse files
committed
Add clang-tidy support to template
CLANG-TIDY PRESET: - Added clang-tidy configure preset with comprehensive check set - Added clang-tidy build preset - Added clang-tidy test preset - Configured sensible check exclusions (fuchsia, google, llvm, etc.) CLANG-TIDY CI: - Added dedicated clang-tidy job to CI template - Installs clang-tidy on Ubuntu - Runs full build and test cycle with static analysis - Provides early feedback on code quality issues USAGE: cmake --preset=clang-tidy cmake --build --preset=clang-tidy ctest --preset=clang-tidy
1 parent 3ce5cba commit 0cd37b7

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

templates/.github/workflows/ci.yml.in

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,32 @@ jobs:
3838
- name: Test
3939
run: ctest --preset=test
4040

41+
clang-tidy:
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- uses: actions/checkout@v4
46+
47+
- name: Setup Ninja
48+
uses: ashutoshvarma/setup-ninja@master
49+
50+
- name: Setup Clang
51+
uses: egor-tensin/setup-clang@v1
52+
with:
53+
version: latest
54+
55+
- name: Install clang-tidy
56+
run: sudo apt-get update && sudo apt-get install -y clang-tidy
57+
58+
- name: Configure CMake with clang-tidy
59+
run: cmake --preset=clang-tidy
60+
61+
- name: Build with clang-tidy
62+
run: cmake --build --preset=clang-tidy
63+
64+
- name: Run tests with clang-tidy
65+
run: ctest --preset=clang-tidy
66+
4167
docs:
4268
runs-on: ubuntu-latest
4369
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

templates/CMakePresets.json.in

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,26 @@
3333
"cacheVariables": {
3434
"BUILD_DOCS": "ON"
3535
}
36+
},
37+
{
38+
"name": "clang-tidy",
39+
"displayName": "Clang-Tidy Configuration",
40+
"description": "Configuration for running clang-tidy static analysis",
41+
"binaryDir": "${sourceDir}/build/clang-tidy",
42+
"inherits": "test",
43+
"cacheVariables": {
44+
"CMAKE_CXX_CLANG_TIDY": "clang-tidy;-checks=*,-fuchsia-*,-google-*,-zircon-*,-abseil-*,-llvm-*,-llvmlibc-*,-altera-*,-android-*,-darwin-*,-objc-*,-openmp-*"
45+
}
3646
}
3747
],
3848
"buildPresets": [
3949
{ "name": "default", "displayName": "Default Build", "configurePreset": "default" },
4050
{ "name": "test", "displayName": "Build Tests", "configurePreset": "test" },
41-
{ "name": "docs", "displayName": "Build Docs", "configurePreset": "docs", "targets": ["docs"] }
51+
{ "name": "docs", "displayName": "Build Docs", "configurePreset": "docs", "targets": ["docs"] },
52+
{ "name": "clang-tidy", "displayName": "Build with Clang-Tidy", "configurePreset": "clang-tidy" }
4253
],
4354
"testPresets": [
44-
{ "name": "test", "displayName": "Run All Tests", "configurePreset": "test", "output": { "outputOnFailure": true } }
55+
{ "name": "test", "displayName": "Run All Tests", "configurePreset": "test", "output": { "outputOnFailure": true } },
56+
{ "name": "clang-tidy", "displayName": "Run Tests with Clang-Tidy", "configurePreset": "clang-tidy", "output": { "outputOnFailure": true } }
4557
]
4658
}

0 commit comments

Comments
 (0)