From 91cf1239de568ab227362c2fa85cdf905085efd7 Mon Sep 17 00:00:00 2001 From: William F Godoy Date: Tue, 30 Mar 2021 15:31:00 -0400 Subject: [PATCH] Add Codecov coverage using gcovr Uses QMC_COMPLEX=1 and deterministic tests Enable Codecov configuration Install gcovr in docker container --- .github/workflows/ci-github-actions.yaml | 19 +++++++++++++++++ codecov.yaml | 13 ++++++++++++ .../github-actions/ci/run_step.sh | 21 +++++++++++++++++-- 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 codecov.yaml diff --git a/.github/workflows/ci-github-actions.yaml b/.github/workflows/ci-github-actions.yaml index 835511a80c..ef7837ce7d 100644 --- a/.github/workflows/ci-github-actions.yaml +++ b/.github/workflows/ci-github-actions.yaml @@ -53,6 +53,7 @@ jobs: matrix: jobname: [ clang-openmpi-ubsan, # undefined behavior sanitizer + coverage, # run code coverage and upload to codecov ] include: @@ -60,6 +61,11 @@ jobs: container: image: williamfgc/qmcpack-ci:ubuntu20-openmpi options: -u 1001 + + - jobname: coverage + container: + image: williamfgc/qmcpack-ci:ubuntu20-openmpi + options: -u 1001 steps: - name: Checkout Action @@ -73,3 +79,16 @@ jobs: - name: Test run: tests/test_automation/github-actions/ci/run_step.sh test + + - name: Coverage + if: contains(matrix.jobname, 'coverage') + run: tests/test_automation/github-actions/ci/run_step.sh coverage + + - name: Upload Coverage + if: contains(matrix.jobname, 'coverage') + uses: codecov/codecov-action@v1 + with: + file: ../qmcpack-build/coverage.xml + flags: QMC_COMPLEX-deterministic # optional + name: codecov-QMCPACK # optional + fail_ci_if_error: true # optional (default = false) diff --git a/codecov.yaml b/codecov.yaml new file mode 100644 index 0000000000..5f5f1563be --- /dev/null +++ b/codecov.yaml @@ -0,0 +1,13 @@ +# Configuration file for codecov reporting code coverage + +# Disable codecov comments in every PR +comment: off + +# Ignore testing directory itself +ignore: + - "tests" + +# Fixes report prefix paths from CI dynamic coverage action +# from https://docs.codecov.io/docs/fixing-paths +fixes: + - "/__w/::" diff --git a/tests/test_automation/github-actions/ci/run_step.sh b/tests/test_automation/github-actions/ci/run_step.sh index 22d595557c..bb2bf64c3f 100755 --- a/tests/test_automation/github-actions/ci/run_step.sh +++ b/tests/test_automation/github-actions/ci/run_step.sh @@ -39,6 +39,12 @@ case "$1" in -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_SANITIZER=msan \ ${GITHUB_WORKSPACE} ;; + *"coverage"*) + echo 'Configure for code coverage with gcc and gcovr' + cmake -GNinja -DMPI_C_COMPILER=mpicc -DMPI_CXX_COMPILER=mpicxx \ + -DCMAKE_BUILD_TYPE=Debug -DENABLE_GCOV=TRUE -DQMC_COMPLEX=1 \ + ${GITHUB_WORKSPACE} + ;; # Configure with default compilers *) echo 'Configure for default system compilers and options' @@ -59,7 +65,7 @@ case "$1" in cd ${GITHUB_WORKSPACE}/../qmcpack-build # Enable oversubscription in OpenMPI - if [[ "${GH_JOBNAME}" =~ (openmpi) ]] + if [[ "${GH_JOBNAME}" =~ (openmpi|coverage) ]] then echo "Enabling OpenMPI oversubscription" export OMPI_MCA_rmaps_base_oversubscribe=1 @@ -76,7 +82,18 @@ case "$1" in # Run only deterministic tests (reasonable for CI) ctest -L deterministic ;; - + + # Generate coverage reports + coverage) + cd ${GITHUB_WORKSPACE}/../qmcpack-build + sudo apt-get install gcovr -y + # filter unreachable branches with gcovr + # see https://gcovr.com/en/stable/faq.html#why-does-c-code-have-so-many-uncovered-branches + gcovr --exclude-unreachable-branches --exclude-throw-branches --root=${GITHUB_WORKSPACE}/.. --xml-pretty -o coverage.xml + du -hs coverage.xml + cat coverage.xml + ;; + # Install the library (not triggered at the moment) install) cd ${GITHUB_WORKSPACE}/../qmcpack-build