Skip to content

Commit 8601757

Browse files
Smit1603vgvassilev
authored andcommitted
Ensure code coverage is generated on PR
1 parent 21f0b76 commit 8601757

File tree

2 files changed

+63
-13
lines changed

2 files changed

+63
-13
lines changed

.codecov.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
codecov:
2+
require_ci_to_pass: no
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "70...100"
8+
9+
status:
10+
project: yes
11+
patch: yes
12+
changes: no
13+
14+
parsers:
15+
gcov:
16+
branch_detection:
17+
conditional: yes
18+
loop: yes
19+
method: no
20+
macro: no
21+
22+
comment:
23+
layout: "reach, diff, flags, tree, files"
24+
behavior: default
25+
require_changes: no

.github/workflows/ci.yml

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ jobs:
193193
llvm-project
194194
${{ matrix.cling=='On' && 'cling' || '' }}
195195
key: ${{ steps.cache.outputs.cache-primary-key }}
196+
- name: Setup code coverage
197+
if: ${{ success() && (matrix.coverage == true) }}
198+
run: |
199+
sudo apt install lcov
200+
echo "CODE_COVERAGE=1" >> $GITHUB_ENV
201+
echo "BUILD_TYPE=Debug" >> $GITHUB_ENV
196202
- name: Build and Test/Install CppInterOp
197203
run: |
198204
LLVM_DIR="$(realpath llvm-project)"
@@ -214,22 +220,24 @@ jobs:
214220
export CPPINTEROP_BUILD_DIR=$PWD
215221
cling_on="${{ matrix.cling }}"
216222
if [[ "${cling_on^^}" == "ON" ]]; then
217-
cmake -DCMAKE_BUILD_TYPE=Release \
218-
-DUSE_CLING=ON \
219-
-DUSE_REPL=OFF \
220-
-DCling_DIR=$LLVM_BUILD_DIR \
221-
-DLLVM_DIR=$LLVM_BUILD_DIR \
222-
-DLLVM_USE_LINKER=lld \
223-
-DBUILD_SHARED_LIBS=ON \
223+
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
224+
-DUSE_CLING=ON \
225+
-DUSE_REPL=OFF \
226+
-DCling_DIR=$LLVM_BUILD_DIR \
227+
-DLLVM_DIR=$LLVM_BUILD_DIR \
228+
-DLLVM_USE_LINKER=lld \
229+
-DBUILD_SHARED_LIBS=ON \
230+
-DCODE_COVERAGE=${CODE_COVERAGE} \
224231
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \
225232
../
226233
else
227-
cmake -DCMAKE_BUILD_TYPE=Release \
228-
-DUSE_CLING=OFF \
229-
-DUSE_REPL=ON \
230-
-DLLVM_DIR=$LLVM_BUILD_DIR \
231-
-DLLVM_USE_LINKER=lld \
232-
-DBUILD_SHARED_LIBS=ON \
234+
cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
235+
-DUSE_CLING=OFF \
236+
-DUSE_REPL=ON \
237+
-DLLVM_DIR=$LLVM_BUILD_DIR \
238+
-DLLVM_USE_LINKER=lld \
239+
-DBUILD_SHARED_LIBS=ON \
240+
-DCODE_COVERAGE=${CODE_COVERAGE} \
233241
-DCMAKE_INSTALL_PREFIX=$CPPINTEROP_DIR \
234242
../
235243
fi
@@ -357,3 +365,20 @@ jobs:
357365
uses: mxschmitt/action-tmate@v3
358366
# When debugging increase to a suitable value!
359367
timeout-minutes: ${{ github.event.pull_request && 1 || 20 }}
368+
369+
- name: Prepare code coverage report
370+
if: ${{ success() && (matrix.coverage == true) }}
371+
run: |
372+
# Create lcov report
373+
# capture coverage info
374+
vers="${CC#*-}"
375+
lcov --directory build/ --capture --output-file coverage.info --gcov-tool /usr/bin/gcov-${vers}
376+
lcov --remove coverage.info '/usr/*' "${HOME}"'/.cache/*' ${{ github.workspace }}'/llvm-project/*' --output-file coverage.info
377+
# output coverage data for debugging (optional)
378+
lcov --list coverage.info
379+
380+
- name: Upload to codecov.io
381+
if: ${{ success() && (matrix.coverage == true) }}
382+
uses: codecov/codecov-action@v3
383+
with:
384+
file: ./coverage.info

0 commit comments

Comments
 (0)