From 498a832e878f692a762f4712e75376e1bbf9233c Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Fri, 6 Sep 2024 19:52:13 +0200 Subject: [PATCH] ci: Add code coverage job for GitLab --- .../custom-modules/ns3-coverage.cmake | 6 ++-- utils/tests/gitlab-ci-scheduled.yml | 30 +++++++++++++++++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/build-support/custom-modules/ns3-coverage.cmake b/build-support/custom-modules/ns3-coverage.cmake index 2662d7296d..b5c4598d92 100644 --- a/build-support/custom-modules/ns3-coverage.cmake +++ b/build-support/custom-modules/ns3-coverage.cmake @@ -54,8 +54,10 @@ if(${NS3_COVERAGE}) else() add_custom_target( coverage_cobertura - COMMAND lcov_cobertura ns3.info --output cobertura.xml --demangle - WORKING_DIRECTORY ${CMAKE_OUTPUT_DIRECTORY}/coverage + COMMAND + lcov_cobertura ${CMAKE_OUTPUT_DIRECTORY}/coverage/ns3.info --output + ${CMAKE_OUTPUT_DIRECTORY}/coverage/cobertura.xml --demangle + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} DEPENDS coverage_gcc ) endif() diff --git a/utils/tests/gitlab-ci-scheduled.yml b/utils/tests/gitlab-ci-scheduled.yml index b3fef4ee3d..0b12fd5511 100644 --- a/utils/tests/gitlab-ci-scheduled.yml +++ b/utils/tests/gitlab-ci-scheduled.yml @@ -13,10 +13,11 @@ - pacman-key --init - pacman -Syu --noconfirm base-devel cmake ninja ccache valgrind - python + python python-pip python-distutils-extra binutils lcov boost gsl gtk3 openmpi glibc-debug openssh git + - pip install lcov_cobertura --break-system-packages script: - mkdir -p $CCACHE_BASEDIR_VALUE - export CCACHE_BASEDIR=${PWD} @@ -25,7 +26,7 @@ # missing the flag --disable-python - ./ns3 configure -d $MODE -GNinja --enable-examples --enable-tests --enable-mpi --disable-gtk $EXTRA_OPTIONS - if [[ "$CI_JOB_STAGE" == "build" ]]; - then ./ns3 build; + then ./ns3 build $TARGET; fi - if [[ "$CI_JOB_STAGE" == "test" ]] || [[ "$FORCE_TESTS" == "Force" ]]; then ./test.py -n $VALGRIND_FLAG $FULLNESS; @@ -237,3 +238,28 @@ weekly-build-test-takes-forever-optimized: tags: - nsnam - linux + +# Code coverage scanning +weekly-build-coverage: + extends: .base-test + rules: + - if: $RELEASE == "weekly" + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + allow_failure: true + stage: build + needs: ["weekly-slow-jobs"] + dependencies: [] + variables: + MODE: debug + EXTRA_OPTIONS: "--enable-gcov --disable-asserts --disable-logs" + TARGET: coverage_cobertura + artifacts: + paths: + - build/coverage/cobertura.xml + reports: + coverage_report: + coverage_format: cobertura + path: build/coverage/cobertura.xml + tags: + - nsnam + - linux