Skip to content

Commit 3a650b9

Browse files
authored
fik ci
fix ci and run for ubuntu 22 and 24
1 parent 1f4f683 commit 3a650b9

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

.github/workflows/test.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ on:
88

99
jobs:
1010
build:
11-
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
os: [ubuntu-22.04, ubuntu-24.04]
14+
runs-on: ${{ matrix.os }}
1215

1316
steps:
1417
- uses: actions/checkout@v3
@@ -19,13 +22,13 @@ jobs:
1922
sudo apt-get install -y cmake build-essential libgtest-dev lcov
2023
2124
- name: Configure & build (with coverage)
22-
run: cmake -S . -B build \
25+
run: |
26+
cmake -S . -B build \
2327
-DENABLE_COVERAGE=ON \
2428
-DBUILD_TESTING=ON \
2529
-DCMAKE_BUILD_TYPE=Debug
2630
27-
- name: Build
28-
run: cmake --build build --parallel
31+
cmake --build build --parallel
2932
3033
- name: Zero coverage counters
3134
run: lcov -d build -z
@@ -34,18 +37,18 @@ jobs:
3437
run: ctest --test-dir build --output-on-failure
3538

3639
- name: Capture coverage
37-
run: lcov -d build -c -o coverage.info
40+
run: lcov -c -d build/CMakeFiles/capancdt_proximity_sensor_lib.dir/src -o coverage.info
3841

3942
- name: Filter coverage
40-
run: lcov -r coverage.info '/usr/*' '*/test/*' -o coverage.filtered.info
43+
run: lcov --ignore-errors unused -r coverage.info '/usr/*' '*/test/*' -o coverage.filtered.info
4144

4245
- name: Generate HTML report
4346
run: genhtml coverage.filtered.info --output-directory coverage-report
4447

4548
- name: Upload coverage-report
4649
uses: actions/upload-artifact@v4
4750
with:
48-
name: coverage-report
51+
name: coverage-report-${{ matrix.os }}
4952
path: coverage-report
5053

5154
- name: Upload coverage reports to Codecov

CMakeLists.txt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ project(capancdt_proximity_sensor_lib LANGUAGES CXX)
33

44
option(ENABLE_COVERAGE "Enable coverage reporting" OFF)
55
if(ENABLE_COVERAGE)
6-
message(STATUS "Building with coverage support")
7-
# GCC/Clang coverage instrumentation
8-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -O0 -g")
9-
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -O0 -g")
10-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
11-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
6+
message(STATUS "Building with coverage instrumentation")
7+
set(COVERAGE_FLAGS "--coverage -O0 -g")
8+
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_FLAGS}")
9+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS}")
10+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
1211
endif()
1312

1413
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,15 @@ Install GTest and lcov for testing. On ubuntu you can do this with:
188188
sudo apt-get install libgtest-dev lcov
189189
```
190190

191+
You may need to build GTest:
192+
193+
```bash
194+
cd /usr/src/googletest
195+
sudo cmake .
196+
sudo make
197+
sudo make install
198+
```
199+
191200
Build the project:
192201

193202
```bash

0 commit comments

Comments
 (0)