Skip to content

Commit 6472526

Browse files
author
Gonzalo Diaz
committed
[CONFIG] [Docker] [tools] gcovr tool (coverage) replaced by lcov.
1 parent 5af9d4b commit 6472526

File tree

5 files changed

+96
-15
lines changed

5 files changed

+96
-15
lines changed

.github/workflows/cpp-coverage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ jobs:
2121

2222
- name: Install Tools
2323
run: |
24-
pip install gcovr
24+
sudo apt-get install lcov
2525
2626
- name: Check Tools
2727
run: |
2828
make --version
2929
cmake --version
3030
vcpkg --version
31-
gcovr --version
31+
lcov --version
3232
3333
- name: Install dependencies
3434
run: |
@@ -54,6 +54,6 @@ jobs:
5454
uses: codecov/codecov-action@v4
5555
with:
5656
directory: ./coverage
57-
files: coverage.lcov
57+
files: coverage/lcov.info
5858
token: ${{ secrets.CODECOV_TOKEN }} # required
5959
verbose: true # optional (default = false)

.github/workflows/sonarcloud.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ jobs:
2222
fetch-depth: 0
2323
- name: Install Tools
2424
run: |
25+
sudo apt-get install lcov
2526
pip install gcovr
2627
2728
- name: Check Tools
2829
run: |
2930
make --version
3031
cmake --version
3132
vcpkg --version
33+
lcov --version
3234
gcovr --version
3335
3436
- name: Install dependencies
@@ -43,17 +45,13 @@ jobs:
4345
- name: Run build-wrapper
4446
run: |
4547
export VCPKG_ROOT=/usr/local/share/vcpkg
46-
cmake --preset debug -B build
47-
cmake --preset debug \
48-
-DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake \
49-
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
50-
build
51-
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} cmake --build build --verbose
48+
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make build
5249
# yamllint enable rule:line-length
5350

5451
- name: Run tests to generate coverage statistics
5552
run: |
5653
make coverage
54+
5755
- name: Collect coverage into one XML report
5856
run: |
5957
gcovr -e "src/tests/*" --sonarqube > coverage.xml

.lcovrc

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Example LCOV configuration file
2+
#
3+
# External style sheet file
4+
#genhtml_css_file = gcov.css
5+
6+
# Coverage rate limits for line coverage
7+
genhtml_hi_limit = 80
8+
genhtml_med_limit = 50
9+
10+
# Coverage rate limits for function coverage
11+
genhtml_function_hi_limit = 90
12+
genhtml_function_med_limit = 75
13+
14+
# Width of overview image
15+
genhtml_overview_width = 80
16+
17+
# Resolution of overview navigation
18+
genhtml_nav_resolution = 4
19+
20+
# Offset for source code navigation
21+
genhtml_nav_offset = 10
22+
23+
# Do not remove unused test descriptions if non-zero
24+
genhtml_keep_descriptions = 0
25+
26+
# Do not remove prefix from directory names if non-zero
27+
genhtml_no_prefix = 0
28+
29+
# Do not create source code view if non-zero
30+
genhtml_no_source = 0
31+
32+
# Specify size of tabs
33+
genhtml_num_spaces = 8
34+
35+
# Highlight lines with converted-only data if non-zero
36+
genhtml_highlight = 0
37+
38+
# Include color legend in HTML output if non-zero
39+
genhtml_legend = 0
40+
41+
# Include HTML file at start of HTML output
42+
#genhtml_html_prolog = prolog.html
43+
44+
# Include HTML file at end of HTML output
45+
#genhtml_html_epilog = epilog.html
46+
47+
# Use custom HTML file extension
48+
#genhtml_html_extension = html
49+
50+
# Compress all generated html files with gzip.
51+
#genhtml_html_gzip = 1
52+
53+
# Include sorted overview pages
54+
genhtml_sort = 1
55+
56+
# Include function coverage data display
57+
genhtml_function_coverage = 1
58+
59+
# Location of the gcov tool
60+
#geninfo_gcov_tool = gcov
61+
62+
# Adjust test names if non-zero
63+
#geninfo_adjust_testname = 0
64+
65+
# Calculate a checksum for each line if non-zero
66+
geninfo_checksum = 0
67+
68+
# Enable libtool compatibility mode if non-zero
69+
geninfo_compat_libtool = 0
70+
71+
# Directory containing gcov kernel files
72+
lcov_gcov_dir = /proc/gcov
73+
74+
# Location of the insmod tool
75+
lcov_insmod_tool = /sbin/insmod
76+
77+
# Location of the modprobe tool
78+
lcov_modprobe_tool = /sbin/modprobe
79+
80+
# Location of the rmmod tool
81+
lcov_rmmod_tool = /sbin/rmmod
82+
83+
# Location for temporary directories
84+
lcov_tmp_dir = /tmp

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ CMD ["make", "lint"]
9898
FROM development AS testing
9999

100100
RUN apt-get -y update && \
101-
apt-get -y install --no-install-recommends --no-install-suggests gcovr && \
101+
apt-get -y install --no-install-recommends --no-install-suggests lcov && \
102102
rm -rf /var/lib/apt/lists/*
103103

104104
COPY --from=builder ${WORKDIR}/build ${WORKDIR}/

Makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BUILDKIT_PROGRESS=plain
2424
DOCKER_COMPOSE=docker compose
2525

2626
# TOOLS
27-
COVERAGE_TOOL=gcovr -e "src/tests/*" -e "build/*" --exclude-throw-branches --exclude-unreachable-branches --exclude-noncode-lines --print-summary
27+
COVERAGE_TOOL_OPTS=--config-file .lcovrc --rc branch_coverage=1
2828

2929
# C++ specific
3030
SRC_DIR = src
@@ -94,11 +94,10 @@ test: env dependencies
9494
cd build && make test
9595

9696
coverage: test
97-
${COVERAGE_TOOL}
98-
${COVERAGE_TOOL} --lcov coverage/coverage.lcov
97+
lcov ${COVERAGE_TOOL_OPTS} -o coverage/lcov.info --no-external -c --exclude "build/vcpkg_installed" --exclude "test.cpp" -d .
9998

100-
coverage/html:
101-
${COVERAGE_TOOL} --html-details coverage/index.html
99+
coverage/html: coverage
100+
genhtml ${COVERAGE_TOOL_OPTS} -o coverage/ -s --legend coverage/lcov.info
102101
open coverage/index.html
103102

104103
outdated:

0 commit comments

Comments
 (0)