Skip to content

Commit a226f59

Browse files
Merge pull request #789 from ldorau/Add_Coverage
Add code coverage to CI
2 parents 38a0e79 + c041412 commit a226f59

17 files changed

+323
-29
lines changed

.github/workflows/basic.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ env:
1111
UMF_VERSION: 0.10.0
1212
BUILD_DIR : "${{github.workspace}}/build"
1313
INSTL_DIR : "${{github.workspace}}/../install-dir"
14+
COVERAGE_DIR : "${{github.workspace}}/coverage"
15+
COVERAGE_NAME : "exports-coverage-basic"
1416

1517
jobs:
1618
ubuntu-build:
@@ -122,8 +124,8 @@ jobs:
122124
- name: Install apt packages
123125
run: |
124126
sudo apt-get update
125-
sudo apt-get install -y clang cmake libnuma-dev libjemalloc-dev
126-
127+
sudo apt-get install -y clang cmake libnuma-dev libjemalloc-dev lcov
128+
127129
- name: Install TBB apt package
128130
if: matrix.install_tbb == 'ON'
129131
run: |
@@ -167,6 +169,7 @@ jobs:
167169
-DUMF_TESTS_FAIL_ON_SKIP=ON
168170
-DUMF_DISABLE_HWLOC=${{matrix.disable_hwloc}}
169171
-DUMF_LINK_HWLOC_STATICALLY=${{matrix.link_hwloc_statically}}
172+
${{ matrix.build_type == 'Debug' && matrix.compiler.c == 'gcc' && '-DUMF_USE_COVERAGE=ON' || '' }}
170173
171174
- name: Build UMF
172175
run: |
@@ -177,7 +180,23 @@ jobs:
177180
working-directory: ${{env.BUILD_DIR}}
178181
run: |
179182
${{ matrix.compiler.cxx == 'icpx' && '. /opt/intel/oneapi/setvars.sh' || true }}
180-
ctest --output-on-failure --test-dir test
183+
ctest --output-on-failure # run all tests for better coverage
184+
185+
- name: Check coverage
186+
if: ${{ matrix.build_type == 'Debug' && matrix.compiler.c == 'gcc' }}
187+
working-directory: ${{env.BUILD_DIR}}
188+
run: |
189+
export COVERAGE_FILE_NAME=${{env.COVERAGE_NAME}}-${{matrix.os}}-shared-${{matrix.shared_library}}-no_hwloc-${{matrix.disable_hwloc}}
190+
echo "COVERAGE_FILE_NAME: $COVERAGE_FILE_NAME"
191+
../scripts/coverage/coverage_capture.sh $COVERAGE_FILE_NAME
192+
mkdir -p ${{env.COVERAGE_DIR}}
193+
mv ./$COVERAGE_FILE_NAME ${{env.COVERAGE_DIR}}
194+
195+
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
196+
if: ${{ matrix.build_type == 'Debug' && matrix.compiler.c == 'gcc' }}
197+
with:
198+
name: ${{env.COVERAGE_NAME}}-${{matrix.os}}-shared-${{matrix.shared_library}}-no_hwloc-${{matrix.disable_hwloc}}
199+
path: ${{env.COVERAGE_DIR}}
181200

182201
- name: Remove the installation directory
183202
run: rm -rf ${{env.INSTL_DIR}}

.github/workflows/coverage.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Coverage build
2+
name: Coverage
3+
4+
on: workflow_call
5+
6+
permissions:
7+
contents: read
8+
9+
env:
10+
COVERAGE_DIR : "${{github.workspace}}/coverage"
11+
12+
jobs:
13+
Coverage:
14+
name: Coverage build
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Install dependencies (ubuntu-latest)
24+
run: |
25+
sudo apt-get update
26+
sudo apt-get install -y lcov
27+
28+
- name: Download all coverage artifacts
29+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
30+
with:
31+
pattern: exports-coverage-*
32+
path: coverage
33+
merge-multiple: true
34+
35+
- name: Compute coverage
36+
working-directory: ${{env.COVERAGE_DIR}}
37+
run: |
38+
echo "DIR: $(pwd)" && ls -al
39+
../scripts/coverage/merge_coverage_files.sh exports-coverage total_coverage
40+
genhtml --no-function-coverage -o html_report total_coverage 2>&1 | tee output.txt
41+
mkdir coverage_report
42+
mv html_report ./coverage_report/
43+
tail -n2 output.txt >> $GITHUB_STEP_SUMMARY
44+
45+
- name: Upload coverage report
46+
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
47+
with:
48+
name: coverage_html_report
49+
path: coverage/coverage_report

.github/workflows/dax.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ env:
2828
UMF_TESTS_FSDAX_PATH: "/mnt/pmem1/file"
2929
BUILD_DIR : "${{github.workspace}}/build"
3030
INSTL_DIR : "${{github.workspace}}/../install-dir"
31+
COVERAGE_DIR : "${{github.workspace}}/coverage"
32+
COVERAGE_NAME : "exports-coverage-dax"
3133

3234
jobs:
3335
dax:
@@ -83,6 +85,7 @@ jobs:
8385
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
8486
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
8587
-DUMF_TESTS_FAIL_ON_SKIP=ON
88+
${{ matrix.build_type == 'Debug' && '-DUMF_USE_COVERAGE=ON' || '' }}
8689
8790
- name: Build UMF
8891
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j $(nproc)
@@ -100,3 +103,19 @@ jobs:
100103
UMF_TESTS_FSDAX_PATH=${{env.UMF_TESTS_FSDAX_PATH}} ctest -C ${{matrix.build_type}} -R umf-provider_file_memory -V
101104
UMF_TESTS_FSDAX_PATH=${{env.UMF_TESTS_FSDAX_PATH}} ctest -C ${{matrix.build_type}} -R umf_example_dram_and_fsdax -V
102105
UMF_TESTS_FSDAX_PATH=${{env.UMF_TESTS_FSDAX_PATH}} ctest -C ${{matrix.build_type}} -R umf-ipc_file_prov_fsdax -V
106+
107+
- name: Check coverage
108+
if: ${{ matrix.build_type == 'Debug' }}
109+
working-directory: ${{env.BUILD_DIR}}
110+
run: |
111+
export COVERAGE_FILE_NAME=${{env.COVERAGE_NAME}}-shared-${{matrix.shared_library}}
112+
echo "COVERAGE_FILE_NAME: $COVERAGE_FILE_NAME"
113+
../scripts/coverage/coverage_capture.sh $COVERAGE_FILE_NAME
114+
mkdir -p ${{env.COVERAGE_DIR}}
115+
mv ./$COVERAGE_FILE_NAME ${{env.COVERAGE_DIR}}
116+
117+
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
118+
if: ${{ matrix.build_type == 'Debug' }}
119+
with:
120+
name: ${{env.COVERAGE_NAME}}-shared-${{matrix.shared_library}}
121+
path: ${{env.COVERAGE_DIR}}

.github/workflows/gpu.yml

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,31 @@ permissions:
1212
env:
1313
BUILD_DIR : "${{github.workspace}}/build"
1414
INSTL_DIR : "${{github.workspace}}/../install-dir"
15+
COVERAGE_DIR : "${{github.workspace}}/coverage"
1516

1617
jobs:
1718
gpu:
1819
name: Build
1920
env:
20-
BUILD_TYPE: Release
2121
VCPKG_PATH: "${{github.workspace}}/../../../../vcpkg/packages/hwloc_x64-windows;${{github.workspace}}/../../../../vcpkg/packages/tbb_x64-windows;${{github.workspace}}/../../../../vcpkg/packages/jemalloc_x64-windows"
22+
COVERAGE_NAME : "exports-coverage-gpu"
2223
# run only on upstream; forks will not have the HW
2324
if: github.repository == 'oneapi-src/unified-memory-framework'
2425
strategy:
2526
matrix:
2627
shared_library: ['ON', 'OFF']
2728
os: ['Ubuntu', 'Windows']
29+
build_type: ['Debug', 'Release']
2830
include:
2931
- os: 'Ubuntu'
3032
compiler: {c: gcc, cxx: g++}
3133
number_of_processors: '$(nproc)'
3234
- os: 'Windows'
3335
compiler: {c: cl, cxx: cl}
3436
number_of_processors: '$Env:NUMBER_OF_PROCESSORS'
37+
exclude:
38+
- os: 'Windows'
39+
build_type: 'Debug'
3540

3641
runs-on: ["DSS-LEVEL_ZERO", "DSS-${{matrix.os}}"]
3742
steps:
@@ -51,7 +56,7 @@ jobs:
5156
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
5257
-B ${{env.BUILD_DIR}}
5358
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
54-
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
59+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
5560
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
5661
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
5762
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
@@ -73,7 +78,7 @@ jobs:
7378
cmake
7479
-B ${{env.BUILD_DIR}}
7580
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
76-
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
81+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
7782
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
7883
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
7984
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
@@ -88,31 +93,49 @@ jobs:
8893
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=ON
8994
-DUMF_BUILD_CUDA_PROVIDER=OFF
9095
-DUMF_TESTS_FAIL_ON_SKIP=ON
96+
${{ matrix.build_type == 'Debug' && '-DUMF_USE_COVERAGE=ON' || '' }}
9197
9298
- name: Build UMF
93-
run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} -j ${{matrix.number_of_processors}}
99+
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j ${{matrix.number_of_processors}}
94100

95101
- name: Run tests
96102
working-directory: ${{env.BUILD_DIR}}
97-
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure --test-dir test
103+
run: ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test
98104

99105
- name: Run examples
100106
working-directory: ${{env.BUILD_DIR}}
101-
run: ctest --output-on-failure --test-dir examples -C ${{env.BUILD_TYPE}}
107+
run: ctest --output-on-failure --test-dir examples -C ${{matrix.build_type}}
102108

103109
- name: Run benchmarks
104110
working-directory: ${{env.BUILD_DIR}}
105-
run: ctest --output-on-failure --test-dir benchmark -C ${{env.BUILD_TYPE}} --exclude-regex umf-bench-multithreaded
111+
run: ctest --output-on-failure --test-dir benchmark -C ${{matrix.build_type}} --exclude-regex umf-bench-multithreaded
112+
113+
- name: Check coverage
114+
if: ${{ matrix.build_type == 'Debug' && matrix.os == 'Ubuntu' }}
115+
working-directory: ${{env.BUILD_DIR}}
116+
run: |
117+
export COVERAGE_FILE_NAME=${{env.COVERAGE_NAME}}-shared-${{matrix.shared_library}}
118+
echo "COVERAGE_FILE_NAME: $COVERAGE_FILE_NAME"
119+
../scripts/coverage/coverage_capture.sh $COVERAGE_FILE_NAME
120+
mkdir -p ${{env.COVERAGE_DIR}}
121+
mv ./$COVERAGE_FILE_NAME ${{env.COVERAGE_DIR}}
122+
123+
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
124+
if: ${{ matrix.build_type == 'Debug' && matrix.os == 'Ubuntu' }}
125+
with:
126+
name: ${{env.COVERAGE_NAME}}-shared-${{matrix.shared_library}}
127+
path: ${{env.COVERAGE_DIR}}
106128

107129
gpu-CUDA:
108130
name: Build
109131
env:
110-
BUILD_TYPE: Release
132+
COVERAGE_NAME : "exports-coverage-gpu-CUDA"
111133
# run only on upstream; forks will not have the HW
112134
if: github.repository == 'oneapi-src/unified-memory-framework'
113135
strategy:
114136
matrix:
115137
shared_library: ['ON', 'OFF']
138+
build_type: ['Debug', 'Release']
116139
# TODO add windows
117140
os: ['Ubuntu']
118141
include:
@@ -136,7 +159,7 @@ jobs:
136159
run: >
137160
cmake -B ${{env.BUILD_DIR}}
138161
-DCMAKE_INSTALL_PREFIX="${{env.INSTL_DIR}}"
139-
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
162+
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
140163
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
141164
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
142165
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
@@ -151,18 +174,35 @@ jobs:
151174
-DUMF_BUILD_LEVEL_ZERO_PROVIDER=OFF
152175
-DUMF_BUILD_CUDA_PROVIDER=ON
153176
-DUMF_TESTS_FAIL_ON_SKIP=ON
177+
${{ matrix.build_type == 'Debug' && '-DUMF_USE_COVERAGE=ON' || '' }}
154178
155179
- name: Build UMF
156-
run: cmake --build ${{env.BUILD_DIR}} --config ${{env.BUILD_TYPE}} -j ${{matrix.number_of_processors}}
180+
run: cmake --build ${{env.BUILD_DIR}} --config ${{matrix.build_type}} -j ${{matrix.number_of_processors}}
157181

158182
- name: Run tests
159183
working-directory: ${{env.BUILD_DIR}}
160-
run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure --test-dir test
184+
run: ctest -C ${{matrix.build_type}} --output-on-failure --test-dir test
161185

162186
- name: Run examples
163187
working-directory: ${{env.BUILD_DIR}}
164-
run: ctest --output-on-failure --test-dir examples -C ${{env.BUILD_TYPE}}
188+
run: ctest --output-on-failure --test-dir examples -C ${{matrix.build_type}}
165189

166190
- name: Run benchmarks
167191
working-directory: ${{env.BUILD_DIR}}
168-
run: ctest --output-on-failure --test-dir benchmark -C ${{env.BUILD_TYPE}} --exclude-regex umf-bench-multithreaded
192+
run: ctest --output-on-failure --test-dir benchmark -C ${{matrix.build_type}} --exclude-regex umf-bench-multithreaded
193+
194+
- name: Check coverage
195+
if: ${{ matrix.build_type == 'Debug' && matrix.os == 'Ubuntu' }}
196+
working-directory: ${{env.BUILD_DIR}}
197+
run: |
198+
export COVERAGE_FILE_NAME=${{env.COVERAGE_NAME}}-shared-${{matrix.shared_library}}
199+
echo "COVERAGE_FILE_NAME: $COVERAGE_FILE_NAME"
200+
../scripts/coverage/coverage_capture.sh $COVERAGE_FILE_NAME
201+
mkdir -p ${{env.COVERAGE_DIR}}
202+
mv ./$COVERAGE_FILE_NAME ${{env.COVERAGE_DIR}}
203+
204+
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
205+
if: ${{ matrix.build_type == 'Debug' && matrix.os == 'Ubuntu' }}
206+
with:
207+
name: ${{env.COVERAGE_NAME}}-shared-${{matrix.shared_library}}
208+
path: ${{env.COVERAGE_DIR}}

.github/workflows/multi_numa.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on: [workflow_call]
66
permissions:
77
contents: read
88

9+
env:
10+
BUILD_DIR : "${{github.workspace}}/build"
11+
COVERAGE_DIR : "${{github.workspace}}/coverage"
12+
COVERAGE_NAME : "exports-coverage-multinuma"
13+
914
jobs:
1015
multi_numa:
1116
name: ${{matrix.os}}
@@ -40,6 +45,7 @@ jobs:
4045
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
4146
-DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON
4247
-DUMF_TESTS_FAIL_ON_SKIP=ON
48+
${{ matrix.os == 'ubuntu-22.04' && '-DUMF_USE_COVERAGE=ON' || '' }}
4349
4450
- name: Build UMF
4551
run: cmake --build ${{github.workspace}}/build -j $(nproc)
@@ -59,3 +65,19 @@ jobs:
5965
ctest --output-on-failure --test-dir test -E "umf-provider_os_memory_multiple_numa_nodes"
6066
./test/umf_test-provider_os_memory_multiple_numa_nodes \
6167
--gtest_filter="-*checkModeLocal/*:*checkModePreferredEmptyNodeset/*:testNuma.checkModeInterleave"
68+
69+
- name: Check coverage
70+
if: matrix.os == 'ubuntu-22.04'
71+
working-directory: ${{env.BUILD_DIR}}
72+
run: |
73+
export COVERAGE_FILE_NAME=${{env.COVERAGE_NAME}}-os-${{matrix.os}}
74+
echo "COVERAGE_FILE_NAME: $COVERAGE_FILE_NAME"
75+
../scripts/coverage/coverage_capture.sh $COVERAGE_FILE_NAME
76+
mkdir -p ${{env.COVERAGE_DIR}}
77+
mv ./$COVERAGE_FILE_NAME ${{env.COVERAGE_DIR}}
78+
79+
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
80+
if: matrix.os == 'ubuntu-22.04'
81+
with:
82+
name: ${{env.COVERAGE_NAME}}-os-${{matrix.os}}
83+
path: ${{env.COVERAGE_DIR}}

.github/workflows/pr_push.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,6 @@ jobs:
110110
MultiNuma:
111111
needs: [Build]
112112
uses: ./.github/workflows/multi_numa.yml
113+
Coverage:
114+
needs: [Build, DevDax, GPU, MultiNuma, Qemu, ProxyLib]
115+
uses: ./.github/workflows/coverage.yml

.github/workflows/proxy_lib.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ permissions:
99
env:
1010
BUILD_DIR : "${{github.workspace}}/build"
1111
INSTL_DIR : "${{github.workspace}}/../install-dir"
12+
COVERAGE_DIR : "${{github.workspace}}/coverage"
13+
COVERAGE_NAME : "exports-coverage-proxy"
1214

1315
jobs:
1416
proxy-ubuntu:
@@ -30,7 +32,7 @@ jobs:
3032
- name: Install apt packages
3133
run: |
3234
sudo apt-get update
33-
sudo apt-get install -y cmake libhwloc-dev libjemalloc-dev libtbb-dev
35+
sudo apt-get install -y cmake libhwloc-dev libjemalloc-dev libtbb-dev lcov
3436
3537
- name: Set ptrace value for IPC test
3638
run: sudo bash -c "echo 0 > /proc/sys/kernel/yama/ptrace_scope"
@@ -52,6 +54,7 @@ jobs:
5254
-DUMF_BUILD_LIBUMF_POOL_DISJOINT=ON
5355
-DUMF_TESTS_FAIL_ON_SKIP=ON
5456
-DUMF_PROXY_LIB_BASED_ON_POOL=${{matrix.proxy_lib_pool}}
57+
${{ matrix.build_type == 'Debug' && '-DUMF_USE_COVERAGE=ON' || '' }}
5558
5659
- name: Build UMF
5760
run: cmake --build ${{env.BUILD_DIR}} -j $(nproc)
@@ -71,3 +74,19 @@ jobs:
7174
- name: Run "/usr/bin/date" with proxy library
7275
working-directory: ${{env.BUILD_DIR}}
7376
run: UMF_PROXY="page.disposition=shared-shm" LD_PRELOAD=./lib/libumf_proxy.so /usr/bin/date
77+
78+
- name: Check coverage
79+
if: ${{ matrix.build_type == 'Debug' }}
80+
working-directory: ${{env.BUILD_DIR}}
81+
run: |
82+
export COVERAGE_FILE_NAME=${{env.COVERAGE_NAME}}-proxy_lib_pool-${{matrix.proxy_lib_pool}}
83+
echo "COVERAGE_FILE_NAME: $COVERAGE_FILE_NAME"
84+
../scripts/coverage/coverage_capture.sh $COVERAGE_FILE_NAME
85+
mkdir -p ${{env.COVERAGE_DIR}}
86+
mv ./$COVERAGE_FILE_NAME ${{env.COVERAGE_DIR}}
87+
88+
- uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
89+
if: ${{ matrix.build_type == 'Debug' }}
90+
with:
91+
name: ${{env.COVERAGE_NAME}}-proxy_lib_pool-${{matrix.proxy_lib_pool}}
92+
path: ${{env.COVERAGE_DIR}}

0 commit comments

Comments
 (0)