glib/.gitlab-ci/coverage-docker.sh
Marco Trevisan (Treviño) 2c94349e79 ci: Ignore lcov errors on source missing
When using dtrace some temporary files may be leaked as source files and
this may lead to build issues such as

  geninfo: ERROR: unable to open
    /builds/GNOME/glib/_build/.dtrace-temp.ed1c5ba9.c:
    No such file or directory

AFAIK there's no way to keep these temporary files around, so the only
thing we can do is making lcov less strict about missing files.

We can drop the special option from genhtml since it's using the same
lcovrc file
2024-08-02 03:39:47 +02:00

49 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
set -ex
# 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}"
# Remove coverage from the fuzz tests, since they are run on a separate CI system
lcov --config-file .lcovrc -r "${path}" "*/fuzzing/*" -o "$(pwd)/${path}"
# Remove coverage from copylibs and subprojects
for lib in xdgmime libcharset gnulib; do
lcov --config-file .lcovrc -r "${path}" "*/${lib}/*" -o "$(pwd)/${path}"
done
# 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 \
--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"