-
-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (89 loc) · 3.53 KB
/
coverage.yml
File metadata and controls
102 lines (89 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
name: "Code Coverage"
on:
push:
paths:
- 'include/**.hpp'
- 'test/**.cpp'
- '**.cmake'
- '.gitmodules'
- 'CMakeLists.txt'
- 'test/CMakeLists.txt'
- '.github/workflows/coverage.yml'
pull_request:
paths:
- 'include/**.hpp'
- 'test/**.cpp'
- '**.cmake'
- '.gitmodules'
- 'CMakeLists.txt'
- 'test/CMakeLists.txt'
- '.github/workflows/coverage.yml'
jobs:
coverage:
name: Ubuntu ${{matrix.compiler.cc}} Coverage
runs-on: ubuntu-20.04
env:
build-directory: build
strategy:
matrix:
compiler:
- { cc: clang, cxx: clang++, version: "10" }
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: true
- name: Prepare Environment
run: |
sudo apt-get install -y ninja-build ${{matrix.compiler.cxx}}-${{matrix.compiler.version}}
if [["${{matrix.compiler.cc}}" = "clang"]]; then
sudo apt-get install -y llvm-${{matrix.compiler.version}}
fi
sudo apt-get install lcov
cmake -E make_directory ${{env.build-directory}}
- name: Configure
working-directory: ${{env.build-directory}}
env:
CC: ${{matrix.compiler.cc}}-${{matrix.compiler.version}}
CXX: ${{matrix.compiler.cxx}}-${{matrix.compiler.version}}
run: |
cmake .. \
-GNinja \
-DCMAKE_BUILD_TYPE=Debug \
-DDELEGATE_COMPILE_UNIT_TESTS=On \
-DCMAKE_CXX_FLAGS="--coverage" \
- name: Build
working-directory: ${{env.build-directory}}
run: cmake --build .
- name: Test
working-directory: ${{env.build-directory}}
run: ctest --output-on-failure
- name: Process Coverage Data
working-directory: ${{env.build-directory}}
run: |
# Create a script for which gcov to use (needed for lcov)
echo "#!/bin/bash" > gcov-executable.sh
if [[ "${{matrix.compiler.cc}}" =~ "gcc" ]]; then
echo 'gcov $@' >> gcov-executable.sh
else
echo 'llvm-cov-${{matrix.compiler.version}} gcov $@' >> gcov-executable.sh
fi
chmod +x gcov-executable.sh
./gcov-executable.sh $(find $(pwd) -name '*.o' -type f)
# Generate coverage information
lcov --capture \
--gcov-tool $(pwd)/gcov-executable.sh \
--directory . \
--output-file coverage_unfiltered.info
# Strip symbols from 'test' directory
lcov --remove coverage_unfiltered.info -o coverage.info \
--gcov-tool $(pwd)/gcov-executable.sh \
"/usr/*" \
"$(pwd)/*" \
"*/test/*" \
"*/third_party/*"
- name: Generate Coverage
uses: coverallsapp/github-action@v1.1.2
with:
github-token: ${{secrets.GITHUB_TOKEN}}
path-to-lcov: ${{env.build-directory}}/coverage.info