Skip to content

Commit

Permalink
Add Codecov coverage using gcovr
Browse files Browse the repository at this point in the history
Uses QMC_COMPLEX=1 and deterministic tests
Enable Codecov configuration
Install gcovr in docker container
  • Loading branch information
williamfgc committed Mar 30, 2021
1 parent 71eb71f commit 91cf123
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/ci-github-actions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,19 @@ jobs:
matrix:
jobname: [
clang-openmpi-ubsan, # undefined behavior sanitizer
coverage, # run code coverage and upload to codecov
]
include:

- jobname: clang-openmpi-ubsan
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
Expand All @@ -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)
13 changes: 13 additions & 0 deletions codecov.yaml
Original file line number Diff line number Diff line change
@@ -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/::"
21 changes: 19 additions & 2 deletions tests/test_automation/github-actions/ci/run_step.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 91cf123

Please sign in to comment.