Skip to content

Commit a8d009f

Browse files
Add release and debug build presets + setup CodeCov integration (#2)
* Use debug-full and release presets for CI, create CMakePresets.json that is NOT overwritten with "conan install", and add code coverage threshold of 80% * Fix referenced Conan-generated paths in CMakePresets.json * Fix 2 issues causing CI to fail * Add workflow_dispatch to ci.yml * Fix value for Standard in .clang-format * Fix more issues causing CI failure * Attempt to fix issue with ReflowComments value * Add version to the --ignore-errors flag in both lcov commands * Fix gcov version mismatch by using compiler-matched gcov tool * Fix lcov issues causing CI to fail * Use target_compile_features per target and CI verification for C++23 Standard * Force C++23 for all dependencies in conanfile.py + explicitly pass C++23 to Conan install step in ci.yml * Set C++23 in conan build profile * Revert "Set C++23 in conan build profile" This reverts commit 43aad86. * Add explicit step to install GCC13 on linux * Revert "Add explicit step to install GCC13 on linux" This reverts commit 9cfa3d3. * Restrict lcov to only scan project's source and test directories, excluding Conan dependency build artifacts that may have mismatched gcov versions * Update gtest to 1.17.0 * Update root CMakeLists.txt to enforce strict C++23 * Separate build job and coverage job for CI to prevent conflicts between coverage and sanitizer * Remove command that destroyed data before it was ready + add ignore empty error * Add fix attempts * ci: use gcc for coverage job so lcov finds .gcda files
1 parent 4e8755d commit a8d009f

16 files changed

Lines changed: 908 additions & 184 deletions

‎.clang-format‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
Language: Cpp
33
BasedOnStyle: LLVM
4-
Standard: c++23
4+
Standard: Auto
55

66
IndentWidth: 4
77
TabWidth: 4
@@ -14,7 +14,7 @@ IndentGotoLabels: true
1414
NamespaceIndentation: None
1515
AccessModifierOffset: -4
1616

17-
AlignAfterOpenBracket: Align
17+
AlignAfterOpenBracket: true
1818
AlignConsecutiveAssignments: None
1919
AlignConsecutiveDeclarations: None
2020
AlignConsecutiveMacros: None

‎.github/workflows/ci.yml‎

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
workflow_dispatch:
89

910
jobs:
1011
build:
@@ -13,7 +14,7 @@ jobs:
1314
matrix:
1415
os: [ubuntu-latest, macos-latest]
1516
compiler: [gcc, clang]
16-
build_type: [Release, Debug]
17+
preset: [release-strict, debug-sanitizers]
1718
exclude:
1819
- os: macos-latest
1920
compiler: gcc
@@ -31,16 +32,83 @@ jobs:
3132
run: conan profile detect --force
3233

3334
- name: Install dependencies
34-
run: conan install . --build=missing -s build_type=${{ matrix.build_type }}
35+
run: |
36+
BUILD_TYPE=$(echo "${{ matrix.preset }}" | grep -q "release" && echo "Release" || echo "Debug")
37+
conan install . --build=missing -s build_type=$BUILD_TYPE -s compiler.cppstd=23
3538
3639
- name: Configure CMake
37-
run: cmake --preset conan-${{ matrix.build_type == 'Release' && 'release' || 'debug' }}
40+
run: cmake --preset ${{ matrix.preset }}
3841
env:
3942
CC: ${{ matrix.compiler == 'gcc' && 'gcc' || 'clang' }}
4043
CXX: ${{ matrix.compiler == 'gcc' && 'g++' || 'clang++' }}
4144

45+
- name: Verify C++23 standard
46+
run: |
47+
echo "=== Compiler Information ==="
48+
${{ matrix.compiler == 'gcc' && 'g++' || 'clang++' }} --version
49+
echo ""
50+
echo "=== Checking C++ standard in compile commands ==="
51+
if [ -f "build/${{ matrix.preset }}/compile_commands.json" ]; then
52+
# Extract and display C++ standard flags
53+
grep -o '\-std=[^ " ]*' "build/${{ matrix.preset }}/compile_commands.json" | sort -u || echo "No -std flag found"
54+
# Verify C++23 is being used
55+
if grep -q '\-std=c++2[3b]' "build/${{ matrix.preset }}/compile_commands.json"; then
56+
echo "✓ C++23 standard verified"
57+
else
58+
echo "✗ C++23 standard NOT found in compile commands"
59+
exit 1
60+
fi
61+
else
62+
echo "Warning: compile_commands.json not found"
63+
fi
64+
65+
- name: Build
66+
run: cmake --build --preset ${{ matrix.preset }}
67+
68+
- name: Test
69+
run: ctest --preset ${{ matrix.preset }} --output-on-failure
70+
71+
coverage:
72+
runs-on: ubuntu-latest
73+
needs: build
74+
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Install Conan
80+
run: pipx install conan
81+
82+
- name: Install lcov
83+
run: sudo apt-get install -y lcov
84+
85+
- name: Configure Conan profile
86+
run: conan profile detect --force
87+
88+
- name: Install dependencies
89+
run: conan install . --build=missing -s build_type=Debug -s compiler.cppstd=23
90+
91+
- name: Configure CMake
92+
run: cmake --preset debug-coverage
93+
env:
94+
CC: gcc
95+
CXX: g++
96+
4297
- name: Build
43-
run: cmake --build --preset conan-${{ matrix.build_type == 'Release' && 'release' || 'debug' }}
98+
run: |
99+
find build -name "*.gcda" -delete 2>/dev/null || true
100+
find build -name "*.gcno" -delete 2>/dev/null || true
101+
cmake --build --preset debug-coverage
44102
45103
- name: Test
46-
run: ctest --preset conan-${{ matrix.build_type == 'Release' && 'release' || 'debug' }} --output-on-failure
104+
run: ctest --preset debug-coverage --output-on-failure
105+
106+
- name: Generate coverage report
107+
run: cmake --build --preset debug-coverage --target coverage
108+
109+
- name: Upload coverage to Codecov
110+
uses: codecov/codecov-action@v4
111+
with:
112+
files: ./build/debug-coverage/coverage/coverage_filtered.info
113+
fail_ci_if_error: true
114+
verbose: true

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ CMakeFiles/
3838
cmake_install.cmake
3939
Makefile
4040
compile_commands.json
41+
CMakeUserPresets.json
4142

4243
# OS files
4344
.DS_Store

‎CMakeLists.txt‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ project(
99

1010
set(CMAKE_CXX_STANDARD 23)
1111
set(CMAKE_CXX_STANDARD_REQUIRED ON)
12-
set(CMAKE_CXX_EXTENSIONS OFF)
12+
set(CMAKE_CXX_EXTENSIONS OFF) # Ensures strict C++23 standard
13+
14+
# Force gtest targets to compile with the same C++23 standard
15+
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
16+
set(BUILD_GTEST ON CACHE BOOL "" FORCE)
1317
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
1418

1519
if(MSVC)
@@ -19,10 +23,11 @@ else()
1923
endif()
2024

2125
include(cmake/ConanSetup.cmake)
22-
include(cmake/LintTargets.cmake)
2326
include(cmake/CodeCoverage.cmake)
2427
include(cmake/Sanitizers.cmake)
2528

2629
enable_testing()
2730
add_subdirectory(src)
2831
add_subdirectory(tests)
32+
33+
include(cmake/LintTargets.cmake)

‎CMakePresets.json‎

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
{
2+
"version": 6,
3+
"cmakeMinimumRequired": {
4+
"major": 3,
5+
"minor": 27,
6+
"patch": 0
7+
},
8+
"configurePresets": [
9+
{
10+
"name": "base",
11+
"hidden": true,
12+
"binaryDir": "${sourceDir}/build/${presetName}",
13+
"cacheVariables": {
14+
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
15+
}
16+
},
17+
{
18+
"name": "release",
19+
"displayName": "Release",
20+
"description": "Optimized release build",
21+
"inherits": "base",
22+
"cacheVariables": {
23+
"CMAKE_BUILD_TYPE": "Release",
24+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build/Release/generators/conan_toolchain.cmake"
25+
}
26+
},
27+
{
28+
"name": "debug",
29+
"displayName": "Debug",
30+
"description": "Debug build with full symbols",
31+
"inherits": "base",
32+
"cacheVariables": {
33+
"CMAKE_BUILD_TYPE": "Debug",
34+
"CMAKE_TOOLCHAIN_FILE": "${sourceDir}/build/Debug/generators/conan_toolchain.cmake"
35+
}
36+
},
37+
{
38+
"name": "debug-sanitizers",
39+
"displayName": "Debug with Sanitizers",
40+
"description": "Debug build with AddressSanitizer and UndefinedBehaviorSanitizer",
41+
"inherits": "debug",
42+
"cacheVariables": {
43+
"ENABLE_SANITIZERS": "ON"
44+
}
45+
},
46+
{
47+
"name": "debug-coverage",
48+
"displayName": "Debug with Coverage",
49+
"description": "Debug build with code coverage instrumentation",
50+
"inherits": "debug",
51+
"cacheVariables": {
52+
"ENABLE_COVERAGE": "ON"
53+
}
54+
},
55+
{
56+
"name": "debug-full",
57+
"displayName": "Debug Full Check",
58+
"description": "Debug build with sanitizers, coverage, and linting",
59+
"inherits": "debug",
60+
"cacheVariables": {
61+
"ENABLE_SANITIZERS": "ON",
62+
"ENABLE_COVERAGE": "ON",
63+
"ENABLE_LINTING": "ON"
64+
}
65+
},
66+
{
67+
"name": "release-strict",
68+
"displayName": "Release with Strict Linting",
69+
"description": "Release build with linting enforced during compilation",
70+
"inherits": "release",
71+
"cacheVariables": {
72+
"ENABLE_LINTING": "ON"
73+
}
74+
}
75+
],
76+
"buildPresets": [
77+
{
78+
"name": "release",
79+
"configurePreset": "release"
80+
},
81+
{
82+
"name": "debug",
83+
"configurePreset": "debug"
84+
},
85+
{
86+
"name": "debug-sanitizers",
87+
"configurePreset": "debug-sanitizers"
88+
},
89+
{
90+
"name": "debug-coverage",
91+
"configurePreset": "debug-coverage"
92+
},
93+
{
94+
"name": "debug-full",
95+
"configurePreset": "debug-full"
96+
},
97+
{
98+
"name": "release-strict",
99+
"configurePreset": "release-strict"
100+
}
101+
],
102+
"testPresets": [
103+
{
104+
"name": "release",
105+
"configurePreset": "release",
106+
"output": {
107+
"outputOnFailure": true
108+
}
109+
},
110+
{
111+
"name": "debug",
112+
"configurePreset": "debug",
113+
"output": {
114+
"outputOnFailure": true
115+
}
116+
},
117+
{
118+
"name": "debug-sanitizers",
119+
"configurePreset": "debug-sanitizers",
120+
"output": {
121+
"outputOnFailure": true
122+
}
123+
},
124+
{
125+
"name": "debug-coverage",
126+
"configurePreset": "debug-coverage",
127+
"output": {
128+
"outputOnFailure": true
129+
}
130+
},
131+
{
132+
"name": "debug-full",
133+
"configurePreset": "debug-full",
134+
"output": {
135+
"outputOnFailure": true
136+
}
137+
},
138+
{
139+
"name": "release-strict",
140+
"configurePreset": "release-strict",
141+
"output": {
142+
"outputOnFailure": true
143+
}
144+
}
145+
]
146+
}

0 commit comments

Comments
 (0)