Skip to content

Report and publish code coverage

Roman Gilg requested to merge romangg/wrapland:coverage into master

Motivation

Code coverage is a KPI to show how well our autotest suite covers the code, i.e. how many relevant lines of code are executed when running the autotests in our CI pipeline. The code coverage is the percentage between executed instructions and non-executed ones.

The generation of this KPI can be automated through compiler instructions and the results be shown by GitLab in Merge Requests as well as being viewed in detail.

Solution

  • GCC provides the --coverage compiler and linker flags that unify -fprofile-arcs and -ftest-coverage compilation flags. We set the --coverage flags for the non-sanitized build.
  • With gcovr we calculate the total coverage ratio. This is logged to the CI pipeline output and can then be read out by GitLab for MRs and badge status.
  • Additionally we always create with gcovr a detailed HTML report that can be viewed from the job artifacts.
  • On master branch we publish this report via GitLab pages to https://kwinft.gitlab.io/wrapland/coverage. This way we can always view the latest coverage on master branch in detail. We will link to that report from the badge.

Future

In an MR we could fail the pipeline when the code coverage would decrease too much (1-5%) or at all. There is currently work going on for offering this directly in GitLab at gitlab-org/gitlab#15765 (closed). An alternative is to check this manually through a separate CI job, as shown here.

Closes #61 (closed)

Edited by Roman Gilg

Merge request reports