-
Notifications
You must be signed in to change notification settings - Fork 144
163 lines (142 loc) · 5.78 KB
/
Code_Coverage.yml
File metadata and controls
163 lines (142 loc) · 5.78 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# ─────────────────────────────────────────────────────────────────────────────
# CXXGraph – Code Coverage
#
# Generates an LCOV / gcovr HTML report and uploads to Codecov.
# Runs on: Ubuntu 24.04 + GCC 14 (latest stable toolchain with best gcov support)
#
# Two modes:
# • push → upload to Codecov (requires CODECOV_TOKEN secret)
# • PR → generate report & attach as artifact (no token needed)
# ─────────────────────────────────────────────────────────────────────────────
name: Code Coverage
on:
push:
branches: [master]
pull_request:
branches: [master]
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CPM_SOURCE_CACHE: ~/.cache/cpm
jobs:
coverage:
name: "Coverage · GCC 14 · C++17"
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 1
# ── Toolchain ─────────────────────────────────────────────────────
- name: Install dependencies
run: |
sudo apt-get update -q
sudo apt-get install -y --no-install-recommends \
gcc-14 g++-14 lcov gcovr ninja-build
- name: Install Ninja
uses: seanmiddleditch/gha-setup-ninja@v6
# ── CPM cache ─────────────────────────────────────────────────────
- name: Cache CPM packages
uses: actions/cache@v5
with:
path: ~/.cache/cpm
key: cpm-ubuntu-coverage-${{ hashFiles('**/CMakeLists.txt') }}
restore-keys: cpm-ubuntu-coverage-
# ── Configure ─────────────────────────────────────────────────────
- name: Configure CMake
env:
CC: gcc-14
CXX: g++-14
run: |
cmake -B build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_CXX_STANDARD=17 \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_CXX_EXTENSIONS=OFF \
-DTEST=ON \
-DCODE_COVERAGE=ON
# ── Build & run tests ─────────────────────────────────────────────
- name: Build
run: cmake --build build --parallel
- name: Run tests
working-directory: build/test
run: ./test_exe
# ── Generate LCOV report ──────────────────────────────────────────
- name: Capture coverage data
working-directory: build
run: |
lcov \
--capture \
--directory . \
--output-file coverage_raw.info \
--ignore-errors mismatch \
--gcov-tool gcov-14
- name: Remove noise (system / third-party headers)
working-directory: build
run: |
lcov \
--remove coverage_raw.info \
'/usr/*' \
'*/googletest/*' \
'*/googlemock/*' \
'*/zlib/*' \
'*/test/*' \
'*/benchmark/*' \
'*/CPM_packages/*' \
--output-file coverage.info \
--ignore-errors unused
- name: Show coverage summary
working-directory: build
run: lcov --summary coverage.info
# ── Generate browsable HTML report ────────────────────────────────
- name: Generate HTML report
working-directory: build
run: |
genhtml coverage.info \
--output-directory coverage_html \
--title "CXXGraph Coverage" \
--legend \
--show-details \
--highlight
# ── Also generate gcovr XML (for tooling / IDE integrations) ──────
- name: Generate gcovr XML
working-directory: build
run: |
gcovr \
--root .. \
--exclude '.*googletest.*' \
--exclude '.*googlemock.*' \
--exclude '.*zlib.*' \
--exclude '.*test.*' \
--exclude '.*CPM_packages.*' \
--xml coverage.xml \
--xml-pretty
# ── Upload to Codecov ─────────────────────────────────────────────
- name: Upload to Codecov
uses: codecov/codecov-action@v6
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: build/coverage.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
# ── Attach HTML report as artifact (always, useful on PRs) ────────
- name: Upload HTML coverage report
if: always()
uses: actions/upload-artifact@v7
with:
name: coverage-report-html
path: build/coverage_html/
retention-days: 14
- name: Upload LCOV file
if: always()
uses: actions/upload-artifact@v7
with:
name: coverage-lcov
path: build/coverage.info
retention-days: 14