Skip to content

Commit b3b2b08

Browse files
committed
Add coverage test
1 parent b10696c commit b3b2b08

File tree

1 file changed

+22
-288
lines changed

1 file changed

+22
-288
lines changed

.github/workflows/tests-ubuntu.yaml

Lines changed: 22 additions & 288 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ jobs:
6666
strategy:
6767
fail-fast: false
6868
matrix:
69-
image: ['oldest', 'latest']
70-
backend: ['cpu', 'cuda', 'hip']
69+
image: ['latest']
70+
backend: ['cpu']
7171
needs: id_repo
7272
runs-on: ubuntu-latest
7373
steps:
@@ -111,196 +111,7 @@ jobs:
111111
path: ${{matrix.image}}_${{matrix.backend}}.tar
112112
retention-days: 1
113113

114-
test:
115-
if: github.ref_name != 'main'
116-
strategy:
117-
fail-fast: false
118-
matrix:
119-
image: ['oldest', 'latest']
120-
backend:
121-
- name: 'cpu'
122-
c_compiler: 'gcc'
123-
cxx_compiler: 'g++'
124-
ddc_extra_cxx_flags: '-Wextra-semi -Wold-style-cast'
125-
kokkos_extra_cmake_flags: ''
126-
- name: 'cpu'
127-
c_compiler: 'clang'
128-
cxx_compiler: 'clang++'
129-
ddc_extra_cxx_flags: '-Wextra-semi -Wextra-semi-stmt -Wold-style-cast'
130-
kokkos_extra_cmake_flags: ''
131-
- name: 'cuda'
132-
c_compiler: '${CUDA_GCC}'
133-
cxx_compiler: '${CUDA_GXX}'
134-
ddc_extra_cxx_flags: ''
135-
kokkos_extra_cmake_flags: '-DKokkos_ENABLE_CUDA=ON -DKokkos_ENABLE_CUDA_CONSTEXPR=ON -DKokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE=ON -DKokkos_ARCH_AMPERE80=ON'
136-
- name: 'hip'
137-
c_compiler: 'hipcc'
138-
cxx_compiler: 'hipcc'
139-
ddc_extra_cxx_flags: ''
140-
kokkos_extra_cmake_flags: '-DKokkos_ENABLE_HIP=ON -DKokkos_ENABLE_HIP_RELOCATABLE_DEVICE_CODE=ON -DKokkos_ENABLE_ROCTHRUST=OFF -DKokkos_ARCH_AMD_GFX90A=ON'
141-
cxx_version: ['17', '20', '23']
142-
cmake_build_type: ['Debug', 'Release']
143-
exclude:
144-
- image: 'oldest' # nvcc 11 only supports C++-17
145-
backend:
146-
name: 'cuda'
147-
cxx_version: '20'
148-
- image: 'oldest' # nvcc 11 only supports C++-17
149-
backend:
150-
name: 'cuda'
151-
cxx_version: '23'
152-
- image: 'oldest' # clang bug with multidimensional bracket operator and parameter packs
153-
backend:
154-
name: 'hip'
155-
cxx_version: '23'
156-
- image: 'latest' # nvcc 12 only supports C++-20
157-
backend:
158-
name: 'cuda'
159-
cxx_version: '23'
160-
runs-on: ubuntu-latest
161-
needs: [docker-build, id_repo]
162-
steps:
163-
- name: Free Disk Space (Ubuntu)
164-
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
165-
with: {tool-cache: true, large-packages: false}
166-
- name: Checkout built branch
167-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
168-
with: {submodules: true}
169-
- name: Collect image artifact
170-
if: needs.id_repo.outputs.in_base_repo == 'false'
171-
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
172-
with:
173-
name: |
174-
${{matrix.image}}_${{matrix.backend.name}}-artifact
175-
- name: Load image artifact into docker
176-
if: needs.id_repo.outputs.in_base_repo == 'false'
177-
run: |
178-
docker load < ${{matrix.image}}_${{matrix.backend.name}}.tar
179-
rm ${{matrix.image}}_${{matrix.backend.name}}.tar
180-
- name: Test
181-
id: test
182-
run: |
183-
cat<<-'EOF' > run.sh
184-
set -xe
185-
git config --global --add safe.directory '*'
186-
187-
export benchmark_ROOT=$PWD/opt/benchmark
188-
export DDC_ROOT=$PWD/opt/ddc
189-
export GTest_ROOT=$PWD/opt/gtest
190-
export Kokkos_ROOT=$PWD/opt/kokkos
191-
export KokkosFFT_ROOT=$PWD/opt/kokkos-fft
192-
export KokkosKernels_ROOT=$PWD/opt/kokkos-kernels
193-
194-
export CMAKE_BUILD_PARALLEL_LEVEL=4
195-
export CMAKE_BUILD_TYPE=${{matrix.cmake_build_type}}
196-
197-
export CC=${{matrix.backend.c_compiler}}
198-
export CXX=${{matrix.backend.cxx_compiler}}
199-
200-
cmake \
201-
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
202-
-DBENCHMARK_ENABLE_GTEST_TESTS=OFF \
203-
-DBENCHMARK_ENABLE_TESTING=OFF \
204-
-DBENCHMARK_INSTALL_DOCS=OFF \
205-
-DBENCHMARK_USE_BUNDLED_GTEST=OFF \
206-
-B build \
207-
-S /src/vendor/benchmark
208-
cmake --build build
209-
cmake --install build --prefix $benchmark_ROOT
210-
rm -rf build
211-
212-
cmake \
213-
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
214-
-B build \
215-
-S /src/vendor/googletest
216-
cmake --build build
217-
cmake --install build --prefix $GTest_ROOT
218-
rm -rf build
219-
220-
cmake \
221-
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
222-
-DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \
223-
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
224-
-DKokkos_ENABLE_SERIAL=ON \
225-
${{matrix.backend.kokkos_extra_cmake_flags}} \
226-
-B build \
227-
-S /src/vendor/kokkos
228-
cmake --build build
229-
cmake --install build --prefix $Kokkos_ROOT
230-
rm -rf build
231-
232-
cmake \
233-
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
234-
-DKokkosFFT_ENABLE_HOST_AND_DEVICE=ON \
235-
-B build \
236-
-S /src/vendor/kokkos-fft
237-
cmake --build build
238-
cmake --install build --prefix $KokkosFFT_ROOT
239-
rm -rf build
240-
241-
cmake \
242-
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
243-
-DKokkosKernels_ADD_DEFAULT_ETI=OFF \
244-
-DKokkosKernels_ENABLE_ALL_COMPONENTS=OFF \
245-
-DKokkosKernels_ENABLE_COMPONENT_BLAS=ON \
246-
-DKokkosKernels_ENABLE_COMPONENT_BATCHED=ON \
247-
-DKokkosKernels_ENABLE_COMPONENT_LAPACK=OFF \
248-
-DKokkosKernels_ENABLE_TPL_BLAS=OFF \
249-
-DKokkosKernels_ENABLE_TPL_CUSOLVER=OFF \
250-
-DKokkosKernels_ENABLE_TPL_LAPACK=OFF \
251-
-B build \
252-
-S /src/vendor/kokkos-kernels
253-
cmake --build build
254-
cmake --install build --prefix $KokkosKernels_ROOT
255-
rm -rf build
256-
257-
cmake \
258-
-DCMAKE_CXX_FLAGS="-Werror -Wall -Wextra -Wpedantic -Wno-sign-compare -pedantic-errors ${{matrix.backend.ddc_extra_cxx_flags}}" \
259-
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
260-
-DDDC_BUILD_BENCHMARKS=ON \
261-
-DDDC_benchmark_DEPENDENCY_POLICY=INSTALLED \
262-
-DDDC_GTest_DEPENDENCY_POLICY=INSTALLED \
263-
-DDDC_Kokkos_DEPENDENCY_POLICY=INSTALLED \
264-
-DDDC_KokkosFFT_DEPENDENCY_POLICY=INSTALLED \
265-
-B build \
266-
-S /src
267-
cmake --build build
268-
if [ 'xcpu' = 'x${{matrix.backend.name}}' ]
269-
then
270-
ctest --test-dir build --output-on-failure --timeout 10 --output-junit tests.xml
271-
cp build/tests.xml .
272-
./build/examples/characteristics_advection
273-
./build/examples/game_of_life
274-
./build/examples/heat_equation_spectral
275-
./build/examples/heat_equation
276-
./build/examples/non_uniform_heat_equation
277-
./build/examples/uniform_heat_equation
278-
fi
279-
cmake --install build --prefix $DDC_ROOT
280-
rm -rf build
281-
282-
cmake \
283-
-B build \
284-
-S /src/install_test
285-
cmake --build build
286-
EOF
287-
288-
docker run \
289-
--cidfile='docker.cid' \
290-
--volume ${PWD}:/src:ro \
291-
ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend.name}}:${GITHUB_SHA:0:7} \
292-
bash /src/run.sh
293-
if docker cp "$(cat docker.cid)":/data/tests.xml ${{github.workspace}}/tests.xml
294-
then echo "with_report=true" >> "$GITHUB_OUTPUT"
295-
else echo "with_report=false" >> "$GITHUB_OUTPUT"
296-
fi
297-
- name: Publish Test Report
298-
uses: mikepenz/action-junit-report@cf701569b05ccdd861a76b8607a66d76f6fd4857 # v5.5.1
299-
if: ( success() || failure() ) && steps.test.outputs.with_report == 'true' # always run even if the previous step fails
300-
with:
301-
report_paths: '${{github.workspace}}/tests.xml'
302-
303-
test-with-sanitizer:
114+
coverage-test:
304115
if: github.ref_name != 'main'
305116
strategy:
306117
fail-fast: false
@@ -312,7 +123,6 @@ jobs:
312123
cxx_compiler: 'g++'
313124
cxx_version: ['17']
314125
cmake_build_type: ['Debug']
315-
sanitizer: ['address', 'undefined']
316126
runs-on: ubuntu-latest
317127
needs: [docker-build, id_repo]
318128
steps:
@@ -333,18 +143,10 @@ jobs:
333143
run: |
334144
docker load < ${{matrix.image}}_${{matrix.backend.name}}.tar
335145
rm ${{matrix.image}}_${{matrix.backend.name}}.tar
336-
- name: Generate undefined sanitizer environment
337-
if: ${{matrix.sanitizer}} == 'undefined'
146+
- name: Install gcovr
338147
run: |
339-
cat<<-'UBSAN_SUPP_EOF' > ubsan.supp
340-
vptr:ginkgo/core/solver/solver_base.hpp
341-
UBSAN_SUPP_EOF
342-
343-
cat<<-'SANITIZER_ENV_EOF' > sanitizer_env.sh
344-
export UBSAN_OPTIONS=print_stacktrace=1,halt_on_error=1,suppressions=/src/ubsan.supp
345-
SANITIZER_ENV_EOF
346-
- name: Test
347-
id: test
148+
pipx install gcovr
149+
- name: clang-tidy
348150
run: |
349151
cat<<-'EOF' > run.sh
350152
set -xe
@@ -357,102 +159,34 @@ jobs:
357159
export CXX=${{matrix.backend.cxx_compiler}}
358160
359161
cmake \
360-
-DCMAKE_CXX_FLAGS="-fsanitize=${{matrix.sanitizer}} -fno-omit-frame-pointer" \
361162
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
362-
-DDDC_BUILD_BENCHMARKS=ON \
163+
-DCMAKE_CXX_FLAGS="--coverage -fprofile-update=atomic" \
164+
-DDDC_BUILD_KERNELS_SPLINES=OFF \
165+
-DDDC_BUILD_BENCHMARKS=OFF \
166+
-DDDC_BUILD_EXAMPLES=OFF \
363167
-DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \
364168
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
365169
-B build \
366-
-S /src
367-
cmake --build build
368-
369-
if [ -f /src/sanitizer_env.sh ];
370-
then
371-
. /src/sanitizer_env.sh
372-
fi
170+
-S ${{github.workspace}}
373171
374-
ctest --test-dir build --output-on-failure --timeout 10 --output-junit tests.xml
375-
cp build/tests.xml .
376-
./build/examples/characteristics_advection
377-
./build/examples/game_of_life
378-
./build/examples/heat_equation_spectral
379-
./build/examples/heat_equation
380-
./build/examples/non_uniform_heat_equation
381-
./build/examples/uniform_heat_equation
172+
cmake --build build
173+
ctest --test-dir build
382174
EOF
383175
384176
docker run \
385177
--cidfile='docker.cid' \
386-
-v ${PWD}:/src:ro \
178+
-v ${PWD}:${{github.workspace}}:ro \
387179
ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend.name}}:${GITHUB_SHA:0:7} \
388-
bash /src/run.sh
389-
if docker cp "$(cat docker.cid)":/data/tests.xml ${{github.workspace}}/tests.xml
180+
bash ${{github.workspace}}/run.sh
181+
if docker cp "$(cat docker.cid)":/data/build ${{github.workspace}}/build
390182
then echo "with_report=true" >> "$GITHUB_OUTPUT"
391183
else echo "with_report=false" >> "$GITHUB_OUTPUT"
392184
fi
393-
- name: Publish Test Report
394-
uses: mikepenz/action-junit-report@cf701569b05ccdd861a76b8607a66d76f6fd4857 # v5.5.1
395-
if: ( success() || failure() ) && steps.test.outputs.with_report == 'true' # always run even if the previous step fails
396-
with:
397-
report_paths: '${{github.workspace}}/tests.xml'
398185
399-
clang-tidy-test:
400-
if: github.ref_name != 'main'
401-
strategy:
402-
fail-fast: false
403-
matrix:
404-
image: ['latest']
405-
backend:
406-
- name: 'cpu'
407-
c_compiler: 'clang'
408-
cxx_compiler: 'clang++'
409-
cxx_version: ['17']
410-
cmake_build_type: ['Release']
411-
runs-on: ubuntu-latest
412-
needs: [docker-build, id_repo]
413-
steps:
414-
- name: Free Disk Space (Ubuntu)
415-
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
416-
with: {tool-cache: true, large-packages: false}
417-
- name: Checkout built branch
418-
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
419-
with: {submodules: true}
420-
- name: Collect image artifact
421-
if: needs.id_repo.outputs.in_base_repo == 'false'
422-
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
186+
gcovr --filter ${{github.workspace}}/include/ddc --lcov coverage.lcov --merge-mode-functions=merge-use-line-0 build
187+
- name: Upload coverage reports to Codecov with GitHub Action
188+
uses: codecov/codecov-action@ad3126e916f78f00edff4ed0317cf185271ccc2d # v5.4.2
423189
with:
424-
name: |
425-
${{matrix.image}}_${{matrix.backend.name}}-artifact
426-
- name: Load image artifact into docker
427-
if: needs.id_repo.outputs.in_base_repo == 'false'
428-
run: |
429-
docker load < ${{matrix.image}}_${{matrix.backend.name}}.tar
430-
rm ${{matrix.image}}_${{matrix.backend.name}}.tar
431-
- name: clang-tidy
432-
run: |
433-
cat<<-'EOF' > run.sh
434-
set -xe
435-
git config --global --add safe.directory '*'
436-
437-
export CMAKE_BUILD_PARALLEL_LEVEL=4
438-
export CMAKE_BUILD_TYPE=${{matrix.cmake_build_type}}
439-
440-
export CC=${{matrix.backend.c_compiler}}
441-
export CXX=${{matrix.backend.cxx_compiler}}
442-
443-
cmake \
444-
-DCMAKE_CXX_STANDARD=${{matrix.cxx_version}} \
445-
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
446-
-DDDC_BUILD_BENCHMARKS=ON \
447-
-DKokkos_ENABLE_DEPRECATED_CODE_4=OFF \
448-
-DKokkos_ENABLE_DEPRECATION_WARNINGS=OFF \
449-
-B build \
450-
-S /src
451-
452-
find /src/benchmarks /src/examples /src/tests -name '*.cpp' -exec clang-tidy -p build -header-filter="(/src/include/ddc/.*|/src/tests/.*)" '{}' '+'
453-
EOF
454-
455-
docker run \
456-
-v ${PWD}:/src:ro \
457-
ghcr.io/cexa-project/ddc/${{matrix.image}}_${{matrix.backend.name}}:${GITHUB_SHA:0:7} \
458-
bash /src/run.sh
190+
files: coverage.lcov
191+
token: ${{secrets.CODECOV_TOKEN}}
192+
verbose: true

0 commit comments

Comments
 (0)