extras: ci: change source path for cobertura output

Gitlab has some constraints[^1] regarding the cobertura output to have
the coverage results displayed on the merge request:

 - Files in the diff view must appear in the cobertura file to have the
   coverage enabled for them.

 - <filename> must be absolute or <source> must typically have an
   absolute path to the project directory.

 - Pipeline must have completed to show the results.

  - The coverage report must not exceed the limits (10MiB and 100
    sources node).

The second point on absolute filename was not valid given that meson
gcovr setup the <source> with `.`, leading to the only <source> element
referencing `.` instead of ${CI_PROJECT_DIR}.

This commit patches the generated coverage to ensure it's relative to
the root directory, enabling diff coverage.

[^1]: https://docs.gitlab.com/ee/ci/testing/test_coverage_visualization.html#test-coverage-visualization-not-displayed
This commit is contained in:
Alexandre Janniaux 2024-02-22 14:55:47 +01:00 committed by Thomas Guillem
parent 2cbc35cf86
commit a80d692b5c
1 changed files with 4 additions and 0 deletions

View File

@ -373,6 +373,10 @@ debian-meson:
--xml="cobertura.xml"
--html="html-coverage/vlc.html"
--html-details -s -j$NCPU
- |
# Ensure that sources are reported from CI_PROJECT_DIR directory so
# that gitlab can associate the files correctly.
sed -i 's,<source>.*</source>,<source>'"${CI_PROJECT_DIR}"'</source>,' cobertura.xml
allow_failure: true
variables: *variables-debian