Files
federated-calendar/.gitlab-ci/gen-coverage.sh
T
Federico Mena Quintero 9c7315a66a CI: Add a test coverage job
This uses grcov internally to generate the HTML report.  We use grcov
instead of, say, lcov, because grcov actually generates accessible
pages.

We use the gnome-build-meta:core-nightly container image.  It doesn't
contain grcov by default, but we download the binary from its github
page.  We can change this later to build a custom container image for
gnome-calendar's own CI.

This will publish the report on

  https://gnome.pages.gitlab.gnome.org/gnome-calendar/coverage/
2025-05-26 18:13:55 -06:00

15 lines
644 B
Bash
Executable File

#!/bin/sh
set -eux -o pipefail
mkdir -p public
grcov _build --source-dir ./ --prefix-dir ../ --output-type cobertura --branch --ignore-not-existing -o public/coverage.xml
grcov _build --source-dir ./ --prefix-dir ../ --output-type html --branch --ignore-not-existing -o public/coverage
# Print "Coverage: 42.42" so .gitlab-ci.yml will pick it up with a regex
#
# We scrape this from the HTML report, not the JSON summary, because coverage.json
# uses no decimal places, just something like "42%".
grep -Eo 'abbr title.* %' public/coverage/index.html | head -n 1 | grep -Eo '[0-9.]+ %' | grep -Eo '[0-9.]+' | awk '{ print "Coverage:", $1 }'