Skip to content

Commit 3645b75

Browse files
authored
Merge pull request lagadic#1785 from SamFlt/pixi_coverage
Add coverage task with gcovr, add coverage CI
2 parents 2ea68aa + a6d6223 commit 3645b75

File tree

8 files changed

+1496
-222
lines changed

8 files changed

+1496
-222
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: CI - Coverage via Pixi
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, reopened, synchronize]
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
visp-pixi:
13+
name: ${{ matrix.os }} - Env ${{ matrix.environment }} ${{ matrix.build_type }} ${{ matrix.compiler }}
14+
runs-on: ${{ matrix.os }}
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
os: [ubuntu-latest, macos-latest, macos-13]
20+
environment: [full-ci-coverage]
21+
build_type: [Release]
22+
23+
steps:
24+
- uses: actions/checkout@v4
25+
26+
- uses: prefix-dev/[email protected]
27+
with:
28+
cache: true
29+
environments: ${{ matrix.environment }}
30+
31+
- name: Clone visp-images
32+
env:
33+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
34+
# https://remarkablemark.org/blog/2022/09/25/check-git-branch-exists-in-remote-repository/
35+
run: |
36+
git clone --depth 1 https://github.com/lagadic/visp-images ${HOME}/visp-images
37+
echo "VISP_INPUT_IMAGE_PATH=$HOME/visp-images" >> $GITHUB_ENV
38+
echo ${VISP_INPUT_IMAGE_PATH}
39+
40+
- name: Build Visp [MacOS/Linux/Windows]
41+
shell: bash -el {0}
42+
env:
43+
VISP_BUILD_TYPE: ${{ matrix.build_type }}
44+
run: |
45+
pixi run -e ${{ matrix.environment }} build
46+
47+
- name: Generate coverage file [MacOS/Linux/Windows]
48+
shell: bash -el {0}
49+
run: |
50+
pixi run -e ${{ matrix.environment }} coverage
51+
52+
- name: Export coverage file location [MacOS/Linux/Windows]
53+
shell: bash -el {0}
54+
run: |
55+
COVERAGE_PATH=`pixi run -e ${{ matrix.environment }} echo-coverage-path`
56+
echo "VISP_COVERAGE_FILE=$COVERAGE_PATH" >> $GITHUB_ENV
57+
58+
- name: Upload report to Codecov
59+
uses: codecov/codecov-action@v5
60+
env:
61+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
62+
with:
63+
files: ${{ env.VISP_COVERAGE_FILE }}
64+
disable_search: true
65+
fail_ci_if_error: true
66+
verbose: true

.github/workflows/coverage.yml

Lines changed: 0 additions & 86 deletions
This file was deleted.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ VP_OPTION(BUILD_APPS "" "" "Build utility applications (used for example for cal
482482
VP_OPTION(BUILD_EXAMPLES "" "" "Build ViSP examples" "" ON)
483483
# Build examples as an option.
484484
VP_OPTION(BUILD_TESTS "" "" "Build ViSP tests" "" ON)
485-
VP_OPTION(BUILD_COVERAGE "" "" "Enables test coverage" "" OFF IF (BUILD_TESTS AND CMAKE_COMPILER_IS_GNUCXX))
485+
VP_OPTION(BUILD_COVERAGE "" "" "Enables test coverage" "" OFF IF (BUILD_TESTS AND (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGCXX)))
486486

487487
# Build java as an option
488488
VP_OPTION(BUILD_JAVA "" "" "Enable Java support" "" (ANDROID OR NOT CMAKE_CROSSCOMPILING) IF (ANDROID OR (NOT APPLE_FRAMEWORK AND NOT WINRT)) )

cmake/AddExtraCompilationFlags.cmake

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,14 @@ elseif((VISP_CXX_STANDARD EQUAL VISP_CXX_STANDARD_17) AND CXX17_CXX_FLAGS)
153153
endif()
154154

155155
if(BUILD_COVERAGE)
156-
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} gcov)
157-
add_extra_compiler_options("-ftest-coverage -fprofile-arcs -lgcov")
156+
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
157+
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} gcov)
158+
add_extra_compiler_options("-ftest-coverage -fprofile-arcs -lgcov")
159+
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Clang or AppleClang (see CMP0025)
160+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
161+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
162+
add_extra_compiler_options("--coverage")
163+
endif()
158164
endif()
159165

160166
if(CMAKE_COMPILER_IS_GNUCXX)

development/scripts/pixi/activation.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,5 @@ if not defined VISP_BUILD_EXAMPLES (set VISP_BUILD_EXAMPLES=OFF)
1616
if not defined VISP_USE_MATHJAX (set VISP_USE_MATHJAX=OFF)
1717
if not defined VISP_BUILD_TUTORIALS (set VISP_BUILD_TUTORIALS=OFF)
1818
if not defined VISP_ENABLE_TEST_WITHOUT_DISPLAY (set VISP_ENABLE_TEST_WITHOUT_DISPLAY=ON)
19+
if not defined VISP_BUILD_COVERAGE (set VISP_BUILD_COVERAGE=OFF)
20+
if not defined VISP_BUILD_DEPRECATED_FUNCTIONS (set VISP_BUILD_DEPRECATED_FUNCTIONS=ON)

development/scripts/pixi/activation.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ export VISP_BUILD_TESTS=${VISP_BUILD_TESTS:=OFF}
1717
export VISP_BUILD_EXAMPLES=${VISP_BUILD_EXAMPLES:=OFF}
1818
export VISP_BUILD_TUTORIALS=${VISP_BUILD_TUTORIALS:=OFF}
1919
export VISP_ENABLE_TEST_WITHOUT_DISPLAY=${VISP_ENABLE_TEST_WITHOUT_DISPLAY:=ON}
20+
export VISP_BUILD_COVERAGE=${VISP_BUILD_COVERAGE:=OFF}
21+
export VISP_BUILD_DEPRECATED_FUNCTIONS=${VISP_BUILD_DEPRECATED_FUNCTIONS:=ON}

0 commit comments

Comments
 (0)