diff --git a/.gitlab/artifacts.yml b/.gitlab/artifacts.yml index f11706c016..0046779115 100644 --- a/.gitlab/artifacts.yml +++ b/.gitlab/artifacts.yml @@ -62,6 +62,12 @@ - ${CMAKE_CI_BUILD_DIR}/DartConfiguration.tcl - ${CMAKE_CI_BUILD_DIR}/CTestCustom.cmake - ${CMAKE_CI_BUILD_DIR}/cdash-build-id + + # CTest coverage files. + - ${CMAKE_CI_BUILD_DIR}/CMakeFiles/TargetDirectories.txt + - ${CMAKE_CI_BUILD_DIR}/**/*.gcno + - ${CMAKE_CI_BUILD_DIR}/Source/QtDialog/moc_*.cpp + - ${CMAKE_CI_BUILD_DIR}/Source/QtDialog/ui_*.h reports: annotations: - ${CMAKE_CI_BUILD_DIR}/annotations.json @@ -167,6 +173,32 @@ # Take the install tree. - ${CMAKE_CI_BUILD_DIR}/install/ +.cmake_coverage_artifacts: + artifacts: + expire_in: 1d + # External testing can be useful even if test jobs fail. + when: always + reports: + junit: + - ${CMAKE_CI_BUILD_DIR}/junit.xml + annotations: + - ${CMAKE_CI_BUILD_DIR}/annotations.json + paths: + # Generated sources. + - ${CMAKE_CI_BUILD_DIR}/Source/QtDialog/moc_*.cpp + - ${CMAKE_CI_BUILD_DIR}/Source/QtDialog/ui_*.h + + # CTest coverage files. + - ${CMAKE_CI_BUILD_DIR}/CMakeFiles/TargetDirectories.txt + - ${CMAKE_CI_BUILD_DIR}/**/*.gcno + - ${CMAKE_CI_BUILD_DIR}/**/*.gcda + + # CTest/CDash information. + - ${CMAKE_CI_BUILD_DIR}/Testing/ + - ${CMAKE_CI_BUILD_DIR}/DartConfiguration.tcl + - ${CMAKE_CI_BUILD_DIR}/CTestCustom.cmake + - ${CMAKE_CI_BUILD_DIR}/cdash-build-id + .cmake_doc_artifacts: artifacts: expire_in: 1d diff --git a/.gitlab/ci/ctest_coverage.cmake b/.gitlab/ci/ctest_coverage.cmake new file mode 100644 index 0000000000..c8bcd0aac4 --- /dev/null +++ b/.gitlab/ci/ctest_coverage.cmake @@ -0,0 +1,29 @@ +cmake_minimum_required(VERSION 3.29) + +include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake") + +# Read the files from the build directory. +ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}") + +# Pick up from where the configure left off. +ctest_start(APPEND) + +find_program(GCOV NAMES gcov) +set(CTEST_COVERAGE_COMMAND "${GCOV}") +set(CTEST_COVERAGE_EXTRA_FLAGS + --hash-filenames + --long-file-names) +string(REPLACE ";" " " CTEST_COVERAGE_EXTRA_FLAGS "${CTEST_COVERAGE_EXTRA_FLAGS}") +ctest_coverage( + RETURN_VALUE coverage_result) +ctest_submit(PARTS Coverage) + +include("${CMAKE_CURRENT_LIST_DIR}/ctest_annotation.cmake") +ctest_annotation_report("${CTEST_BINARY_DIRECTORY}/annotations.json" + "Coverage Report" "https://open.cdash.org/viewCoverage.php?buildid=${build_id}" +) + +if (coverage_result) + message(FATAL_ERROR + "Failed to gather coverage") +endif () diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index 341050fd4a..69c6f7a495 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -727,6 +727,16 @@ interruptible: true +.cmake_coverage_linux: + stage: test + + script: + - *before_script_linux + - "$LAUNCHER ctest --output-on-failure -V -S .gitlab/ci/ctest_coverage.cmake" + coverage: '/Percentage Coverage: \d+.\d+%/' + + interruptible: true + .cmake_build_linux_release: stage: build