Commit 4c3fbafe authored by Lucas SCHMIDT's avatar Lucas SCHMIDT
Browse files

feat(ci): add code coverage to unit tests in CI

parent f1dafbf8
Pipeline #181152 failed with stages
in 1 second
......@@ -79,6 +79,7 @@ lint:sheldon:
-DSIGHT_ENABLE_PCH=OFF
-DSIGHT_DEPS_ROOT_DIRECTORY=/cache/.sight-deps
-DSIGHT_ENABLE_OPENVSLAM=ON
-DSIGHT_COVERAGE=${SIGHT_COVERAGE}
# Touch all generated files to improve CCache performance
- find . -type f -iname '*.?pp' -exec touch -t 197001010000 {} \;
# Build
......@@ -101,14 +102,22 @@ lint:sheldon:
ninja install
ninja package
fi
- >
if [ "${SIGHT_COVERAGE}" == "ON" ];then
mkdir coverage
gcovr -kr .. --filter ./libs --filter ./modules .
gcovr -gkr .. --filter ./libs --filter ./modules --html --html-details -o coverage/index.html .
gcovr -gr .. --filter ./libs --filter ./modules --xml -o coverage/cobertura-coverage.xml .
fi
artifacts:
artifacts: &linux_build_artifacts
when: always
paths:
- .build/ctest.log
- .build/Documentation/Doxygen/
- .build/SightViewer*.tar.zst
- .build/packages/sight-*.tar.zst
- .build/coverage
build:linux-21.04-debug-gcc:
extends: .linux_build
......@@ -150,6 +159,22 @@ build:linux-21.04-debug-clang:
CC: "/usr/lib/ccache/clang"
CXX: "/usr/lib/ccache/clang++"
build:linux-21.04-coverage-gcc:
extends: .linux_build
variables:
BUILD_TYPE: "Debug"
SIGHT_BUILD_DOC: "OFF"
SIGHT_BUILD_PACKAGE: "OFF"
SIGHT_COVERAGE: "ON"
SIGHT_IGNORE_UNSTABLE_TESTS: 1
CC: "/usr/lib/ccache/gcc"
CXX: "/usr/lib/ccache/g++"
coverage: /^TOTAL.*\s+(\d+\%)$/
artifacts:
<<: *linux_build_artifacts
reports:
cobertura: coverage/cobertura-coverage.xml
.linux_deploy:
image: "${SIGHT_CI_UBUNTU21_04}:dev"
variables:
......@@ -394,8 +419,10 @@ deploy:pages:
stage: deploy
dependencies:
- build:linux-21.04-release-gcc
- build:linux-21.04-coverage-gcc
script:
- mv .build/Documentation/Doxygen/html/ public/
- mv .build/coverage/ public/coverage
artifacts:
paths:
- public
......
......@@ -143,6 +143,10 @@ endif()
# We always need CppUnit, no need to put that in subdirectories
find_package(CppUnit QUIET REQUIRED)
if("${SIGHT_COVERAGE}" STREQUAL "ON" AND CMAKE_COMPILER_IS_GNUCXX)
link_libraries(gcov)
endif()
########################################################################################################################
# Default paths settings for libraries, modules and resources
########################################################################################################################
......
......@@ -17,6 +17,7 @@ add_compile_options(
"$<$<AND:$<CXX_COMPILER_ID:Clang>,$<CONFIG:Debug>>:-fno-limit-debug-info>" # Needed to debug STL classes
"$<$<CXX_COMPILER_ID:MSVC>:/favor:blend;/fp:precise;/Qfast_transcendentals;/arch:AVX;/MP;/bigobj>"
"$<$<CONFIG:Debug>:-DDEBUG;-D_DEBUG>"
"$<$<AND:$<CXX_COMPILER_ID:GNU>,$<STREQUAL:${SIGHT_COVERAGE},ON>>:--coverage>"
)
add_compile_definitions(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment