mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
3ddfb10b0b
gitlab has coverage integration in MRs, but we need a cobertura formatted XML files (each must be less than 10 MB [1]) to show it, so generate it using a python script and inform gitlab about it. See https://docs.gitlab.com/ee/ci/testing/test_coverage_visualization.html [1] https://gitlab.com/gitlab-org/gitlab/-/issues/328772#note_840831654
44 lines
1.2 KiB
Bash
Executable File
44 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# Fixup Windows paths
|
|
python3 ./.gitlab-ci/fixup-cov-paths.py _coverage/*.lcov
|
|
|
|
for path in _coverage/*.lcov; do
|
|
# Remove coverage from generated code in the build directory
|
|
lcov --config-file .lcovrc -r "${path}" '*/_build/*' -o "$(pwd)/${path}"
|
|
# Remove any coverage from system files
|
|
lcov --config-file .lcovrc -e "${path}" "$(pwd)/*" -o "$(pwd)/${path}"
|
|
|
|
# Convert to cobertura format for gitlab integration
|
|
cobertura_base="${path/.lcov}-cobertura"
|
|
cobertura_xml="${cobertura_base}.xml"
|
|
lcov_cobertura "${path}" --output "${cobertura_xml}"
|
|
mkdir -p "${cobertura_base}"
|
|
cobertura-split-by-package.py "${cobertura_xml}" "${cobertura_base}"
|
|
rm -f "${cobertura_xml}"
|
|
done
|
|
|
|
genhtml \
|
|
--ignore-errors=source \
|
|
--config-file .lcovrc \
|
|
_coverage/*.lcov \
|
|
-o _coverage/coverage
|
|
|
|
cd _coverage
|
|
rm -f ./*.lcov
|
|
|
|
cat >index.html <<EOL
|
|
<html>
|
|
<body>
|
|
<ul>
|
|
<li><a href="coverage/index.html">Coverage</a></li>
|
|
</ul>
|
|
</body>
|
|
</html>
|
|
EOL
|
|
|
|
# Print a handy link to the coverage report
|
|
echo "Coverage report at: https://${CI_PROJECT_NAMESPACE}.pages.gitlab.gnome.org/-/${CI_PROJECT_NAME}/-/jobs/${CI_BUILD_ID}/artifacts/_coverage/coverage/index.html"
|