summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2021-11-23 01:30:43 +0000
committerEmmanuele Bassi <ebassi@gnome.org>2021-11-23 01:30:43 +0000
commit0d4280a3d26b68104f46db64c8f4539bf8614a41 (patch)
tree122f7ca0e58687375bb6744c53bd0cfdf15b338e
parent60714a52aa4e09f8d53d5fa1a46cedc6208341de (diff)
downloadlibgweather-0d4280a3d26b68104f46db64c8f4539bf8614a41.tar.gz
ci: Generate a coverage HTML report
Using the lcov report and its genhtml tool.
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--.gitlab-ci/gen-coverage.sh30
2 files changed, 32 insertions, 0 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 892ee2e..20c50dd 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -289,6 +289,8 @@ coverage:
- lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --initial --output-file "_coverage/${CI_JOB_NAME}-baseline.lcov"
- meson test -C _build
- lcov --config-file .gitlab-ci/lcovrc --directory _build --capture --output-file "_coverage/${CI_JOB_NAME}.lcov"
+ - bash -x .gitlab-ci/gen-coverage.sh
+ coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/'
artifacts:
name: "gweather-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}"
when: always
diff --git a/.gitlab-ci/gen-coverage.sh b/.gitlab-ci/gen-coverage.sh
new file mode 100644
index 0000000..c15fe29
--- /dev/null
+++ b/.gitlab-ci/gen-coverage.sh
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+set -e
+
+for path in _coverage/*.lcov; do
+ lcov --config-file .gitlab-ci/lcovrc -r "${path}" '*/_build/*' -o "$(pwd)/${path}"
+ lcov --config-file .gitlab-ci/lcovrc -e "${path}" "$(pwd)/*" -o "$(pwd)/${path}"
+done
+
+genhtml \
+ --ignore-errors=source \
+ --config-file .gitlab-ci/lcovrc \
+ _coverage/*.lcov \
+ -o _coverage/coverage
+
+cd _coverage
+rm -f ./*.lcov
+
+cat >index.html <<EOL
+<html>
+<head><title>GWeather Coverage</title></head>
+<body>
+<div>
+<ul>
+<li><a href="coverage/index.html">Coverage report</a></li>
+</ul>
+</div>
+</body>
+</html>
+EOL