Skip to content

Commit 88351dd

Browse files
committed
Add coverage test
1 parent 661bf7a commit 88351dd

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

.github/workflows/tests-ubuntu.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,87 @@ jobs:
116116
path: ${{matrix.image}}_${{matrix.backend}}.tar
117117
retention-days: 1
118118

119+
coverage-test:
120+
if: github.ref_name != 'main'
121+
strategy:
122+
fail-fast: false
123+
matrix:
124+
image: ['latest']
125+
backend:
126+
- name: 'cpu'
127+
c_compiler: 'gcc'
128+
cxx_compiler: 'g++'
129+
cxx_version: ['17']
130+
cmake_build_type: ['Debug']
131+
runs-on: ubuntu-latest
132+
needs: [docker-build, id_repo]
133+
steps:
134+
- name: Free Disk Space (Ubuntu)
135+
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
136+
with: {tool-cache: true, large-packages: false}
137+
- name: Checkout built branch
138+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
139+
with:
140+
submodules: true
141+
- name: Collect image artifact
142+
if: needs.id_repo.outputs.in_base_repo == 'false'
143+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
144+
with:
145+
name: |
146+
${{matrix.image}}_${{matrix.backend.name}}-artifact
147+
- name: Load image artifact into docker
148+
if: needs.id_repo.outputs.in_base_repo == 'false'
149+
run: |
150+
docker load < ${{matrix.image}}_${{matrix.backend.name}}.tar
151+
rm ${{matrix.image}}_${{matrix.backend.name}}.tar
152+
- name: Install gcovr
153+
run: |
154+
pipx install gcovr
155+
- name: clang-tidy
156+
run: |
157+
cat<<-'EOF' > run.sh
158+
set -xe
159+
git config --global --add safe.directory '*'
160+
161+
export CMAKE_BUILD_PARALLEL_LEVEL=4
162+
export CMAKE_BUILD_TYPE=${{matrix.cmake_build_type}}
163+
164+
export CC=${{matrix.backend.c_compiler}}
165+
export CXX=${{matrix.backend.cxx_compiler}}
166+
167+
cmake \
168+
-D CMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
169+
-D CMAKE_CXX_FLAGS="--coverage -fprofile-update=atomic" \
170+
-D DDC_BUILD_KERNELS_SPLINES=OFF \
171+
-D DDC_BUILD_BENCHMARKS=OFF \
172+
-D DDC_BUILD_EXAMPLES=OFF \
173+
-D Kokkos_ENABLE_DEPRECATED_CODE_4=OFF \
174+
-D Kokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
175+
-B build
176+
177+
cmake --build build
178+
ctest --test-dir build
179+
EOF
180+
181+
docker run \
182+
--workdir ${{github.workspace}} \
183+
--volume ${{github.workspace}}:${{github.workspace}} \
184+
ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend.name}}:${GITHUB_SHA:0:7} \
185+
bash run.sh
186+
187+
gcovr \
188+
--exclude-throw-branches \
189+
--filter include/ddc \
190+
--lcov coverage.lcov \
191+
--merge-mode-functions=merge-use-line-0 \
192+
build
193+
- name: Upload coverage reports to Codecov with GitHub Action
194+
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
195+
with:
196+
files: coverage.lcov
197+
disable_search: true
198+
token: ${{secrets.CODECOV_TOKEN}}
199+
119200
test:
120201
if: github.ref_name != 'main'
121202
strategy:

codecov.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (C) The DDC development team, see COPYRIGHT.md file
2+
#
3+
# SPDX-License-Identifier: MIT
4+
5+
---
6+
coverage:
7+
status:
8+
project:
9+
default:
10+
target: auto # auto compares coverage to the previous base commit
11+
patch:
12+
default:
13+
target: 100%

0 commit comments

Comments
 (0)