From 49e1643d42abe9201689aa42e431cba3f6723778 Mon Sep 17 00:00:00 2001 From: hauks96 Date: Fri, 2 May 2025 11:28:07 +0000 Subject: [PATCH 1/9] debugging ci --- .github/workflows/test.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b70a275..767dd32 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -34,7 +34,13 @@ jobs: run: ctest --test-dir build --output-on-failure - name: Capture coverage - run: lcov -d build -c -o coverage.info + run: | + cd build + # TODO: remove + find . -name '*.gcda' + lcov -d . -c -o coverage.info + # move the report back up so the next steps can find it + mv coverage.info .. - name: Filter coverage run: lcov -r coverage.info '/usr/*' '*/test/*' -o coverage.filtered.info From 9f9bfb128f9b1d788415503d155b9f9b2f2a63b5 Mon Sep 17 00:00:00 2001 From: hauks96 Date: Fri, 2 May 2025 15:00:06 +0000 Subject: [PATCH 2/9] attempt fixing ci --- .github/workflows/test.yml | 12 +++++------- CMakeLists.txt | 10 ++++------ README.md | 9 +++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 767dd32..d02761f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,6 +17,10 @@ jobs: run: | sudo apt-get update sudo apt-get install -y cmake build-essential libgtest-dev lcov + cd /usr/src/googletest + sudo cmake . + sudo make + sudo make install - name: Configure & build (with coverage) run: cmake -S . -B build \ @@ -34,13 +38,7 @@ jobs: run: ctest --test-dir build --output-on-failure - name: Capture coverage - run: | - cd build - # TODO: remove - find . -name '*.gcda' - lcov -d . -c -o coverage.info - # move the report back up so the next steps can find it - mv coverage.info .. + run: lcov -d build -c -o coverage.info - name: Filter coverage run: lcov -r coverage.info '/usr/*' '*/test/*' -o coverage.filtered.info diff --git a/CMakeLists.txt b/CMakeLists.txt index a3565ad..bc4337a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,12 +3,10 @@ project(capancdt_proximity_sensor_lib LANGUAGES CXX) option(ENABLE_COVERAGE "Enable coverage reporting" OFF) if(ENABLE_COVERAGE) -message(STATUS "Building with coverage support") -# GCC/Clang coverage instrumentation -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -O0 -g") -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -O0 -g") -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") -set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage") + message(STATUS "Building with coverage instrumentation") + # apply to *all* subsequent targets + add_compile_options(--coverage -O0 -g) + add_link_options(--coverage) endif() set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) diff --git a/README.md b/README.md index 5d846ce..fb75c8c 100644 --- a/README.md +++ b/README.md @@ -188,6 +188,15 @@ Install GTest and lcov for testing. On ubuntu you can do this with: sudo apt-get install libgtest-dev lcov ``` +You may need to build GTest: + +```bash +cd /usr/src/googletest +sudo cmake . +sudo make +sudo cp *.a /usr/lib +``` + Build the project: ```bash From 8959c561b88b3f58e7e9102addc4c1f21cd0828a Mon Sep 17 00:00:00 2001 From: hauks96 Date: Fri, 2 May 2025 15:06:54 +0000 Subject: [PATCH 3/9] coverage flags --- CMakeLists.txt | 5 ++--- README.md | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bc4337a..ca4986a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,9 +4,8 @@ project(capancdt_proximity_sensor_lib LANGUAGES CXX) option(ENABLE_COVERAGE "Enable coverage reporting" OFF) if(ENABLE_COVERAGE) message(STATUS "Building with coverage instrumentation") - # apply to *all* subsequent targets - add_compile_options(--coverage -O0 -g) - add_link_options(--coverage) + add_compile_options(-fprofile-arcs -ftest-coverage -O0 -g) + add_link_options(-fprofile-arcs -ftest-coverage) endif() set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) diff --git a/README.md b/README.md index fb75c8c..609cb53 100644 --- a/README.md +++ b/README.md @@ -194,7 +194,7 @@ You may need to build GTest: cd /usr/src/googletest sudo cmake . sudo make -sudo cp *.a /usr/lib +sudo make install ``` Build the project: From 3ce5169ba5dc8475a5a5b8074a4837e893be2f6e Mon Sep 17 00:00:00 2001 From: hauks96 Date: Fri, 2 May 2025 15:34:45 +0000 Subject: [PATCH 4/9] more debugging --- .github/workflows/test.yml | 19 +++++++++++++------ CMakeLists.txt | 6 ++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d02761f..29ae0d3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 @@ -18,18 +18,18 @@ jobs: sudo apt-get update sudo apt-get install -y cmake build-essential libgtest-dev lcov cd /usr/src/googletest - sudo cmake . - sudo make + cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug + make --build build sudo make install - name: Configure & build (with coverage) - run: cmake -S . -B build \ + run: | + cmake -S . -B build \ -DENABLE_COVERAGE=ON \ -DBUILD_TESTING=ON \ -DCMAKE_BUILD_TYPE=Debug - - name: Build - run: cmake --build build --parallel + cmake --build build --parallel - name: Zero coverage counters run: lcov -d build -z @@ -37,6 +37,13 @@ jobs: - name: Run tests run: ctest --test-dir build --output-on-failure + - name: Debug coverage output + run: | + echo "=== .gcno files in build ===" + find build -type f -name '*.gcno' || echo "(none)" + echo "=== .gcda files anywhere ===" + find . -type f -name '*.gcda' || echo "(none)" + - name: Capture coverage run: lcov -d build -c -o coverage.info diff --git a/CMakeLists.txt b/CMakeLists.txt index ca4986a..18ceb5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,8 +4,10 @@ project(capancdt_proximity_sensor_lib LANGUAGES CXX) option(ENABLE_COVERAGE "Enable coverage reporting" OFF) if(ENABLE_COVERAGE) message(STATUS "Building with coverage instrumentation") - add_compile_options(-fprofile-arcs -ftest-coverage -O0 -g) - add_link_options(-fprofile-arcs -ftest-coverage) + set(COVERAGE_FLAGS "--coverage -O0 -g") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COVERAGE_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COVERAGE_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") endif() set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) From e28190fc98352f27531dfc2e9b14ad6704cb59b5 Mon Sep 17 00:00:00 2001 From: hauks96 Date: Fri, 2 May 2025 15:37:52 +0000 Subject: [PATCH 5/9] why no running --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 29ae0d3..1bc088f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ on: jobs: build: - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 44fc1b419f16d700e552fa163a239e68044638a3 Mon Sep 17 00:00:00 2001 From: hauks96 Date: Fri, 2 May 2025 15:38:52 +0000 Subject: [PATCH 6/9] remove install --- .github/workflows/test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1bc088f..4a9e0db 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,10 +17,6 @@ jobs: run: | sudo apt-get update sudo apt-get install -y cmake build-essential libgtest-dev lcov - cd /usr/src/googletest - cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug - make --build build - sudo make install - name: Configure & build (with coverage) run: | From b3eebb83383b207323d7791e69c536eb8bc05066 Mon Sep 17 00:00:00 2001 From: hauks96 Date: Fri, 2 May 2025 15:54:58 +0000 Subject: [PATCH 7/9] matrix workflow --- .github/workflows/test.yml | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a9e0db..9f114f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,10 @@ on: jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + os: [ubuntu-22.04, ubuntu-24.04] + runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -33,31 +36,21 @@ jobs: - name: Run tests run: ctest --test-dir build --output-on-failure - - name: Debug coverage output - run: | - echo "=== .gcno files in build ===" - find build -type f -name '*.gcno' || echo "(none)" - echo "=== .gcda files anywhere ===" - find . -type f -name '*.gcda' || echo "(none)" - - name: Capture coverage - run: lcov -d build -c -o coverage.info - - - name: Filter coverage - run: lcov -r coverage.info '/usr/*' '*/test/*' -o coverage.filtered.info + run: lcov -c -d build/CMakeFiles/capancdt_proximity_sensor_lib.dir/src -o coverage.info - name: Generate HTML report - run: genhtml coverage.filtered.info --output-directory coverage-report + run: genhtml coverage.info --output-directory coverage-report - name: Upload coverage-report uses: actions/upload-artifact@v4 with: - name: coverage-report + name: coverage-report-${{ matrix.os }} path: coverage-report - name: Upload coverage reports to Codecov uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} - files: coverage.filtered.info + files: coverage.info fail_ci_if_error: true From b622ec39fab9c154aca7f525e856176765db8b6b Mon Sep 17 00:00:00 2001 From: hauks96 Date: Fri, 2 May 2025 16:02:08 +0000 Subject: [PATCH 8/9] filter coverage --- .github/workflows/test.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9f114f2..798d189 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,8 +39,11 @@ jobs: - name: Capture coverage run: lcov -c -d build/CMakeFiles/capancdt_proximity_sensor_lib.dir/src -o coverage.info + - name: Filter coverage + run: lcov -r coverage.info '/usr/*' '*/test/*' -o coverage.filtered.info + - name: Generate HTML report - run: genhtml coverage.info --output-directory coverage-report + run: genhtml coverage.filtered.info --output-directory coverage-report - name: Upload coverage-report uses: actions/upload-artifact@v4 @@ -52,5 +55,5 @@ jobs: uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} - files: coverage.info + files: coverage.filtered.info fail_ci_if_error: true From c1d324642cd16e35bfe551619923192da3d2e764 Mon Sep 17 00:00:00 2001 From: hauks96 Date: Fri, 2 May 2025 16:06:58 +0000 Subject: [PATCH 9/9] ignore unused error --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 798d189..ef15e94 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,7 +40,7 @@ jobs: run: lcov -c -d build/CMakeFiles/capancdt_proximity_sensor_lib.dir/src -o coverage.info - name: Filter coverage - run: lcov -r coverage.info '/usr/*' '*/test/*' -o coverage.filtered.info + run: lcov --ignore-errors unused -r coverage.info '/usr/*' '*/test/*' -o coverage.filtered.info - name: Generate HTML report run: genhtml coverage.filtered.info --output-directory coverage-report