From 22f5016303a958afeab5d3ebd3c4284548c4580d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 14 Jul 2022 21:51:51 +0200 Subject: ci: Expose the coverage report as link in the MR's It's making handier to check how changes are tested. --- .gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f1e511b8..684afddb2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -93,6 +93,7 @@ fedora-x86_64: when: always expire_in: 1 week paths: + - "_build/docs/reference/" - "_build/config.h" - "_build/glib/glibconfig.h" - "_build/meson-logs" @@ -477,8 +478,10 @@ coverage: artifacts: name: "glib-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}" expire_in: 1 week + expose_as: 'Coverage Report' paths: - - _coverage/ + - _coverage/coverage/index.html + - _coverage before_script: - bash .gitlab-ci/show-execution-environment.sh script: -- cgit v1.2.1 From 29cf6b2b65556aa53b32563f9cad8c458ff606ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 15 Sep 2022 02:22:41 +0200 Subject: ci: Install lcov-cobertura and cobertura-split script in coverage images These are needed to be able to get cobertura reports in gitlab. --- .gitlab-ci/fedora.Dockerfile | 3 +++ .gitlab-ci/install-gitlab-cobertura-tools.sh | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100755 .gitlab-ci/install-gitlab-cobertura-tools.sh diff --git a/.gitlab-ci/fedora.Dockerfile b/.gitlab-ci/fedora.Dockerfile index 2506f9386..85f910cb9 100644 --- a/.gitlab-ci/fedora.Dockerfile +++ b/.gitlab-ci/fedora.Dockerfile @@ -76,6 +76,9 @@ RUN dnf -y update \ RUN pip3 install meson==0.60.3 +COPY install-gitlab-cobertura-tools.sh . +RUN ./install-gitlab-cobertura-tools.sh + # Set /etc/machine-id as it’s needed for some D-Bus tests RUN systemd-machine-id-setup diff --git a/.gitlab-ci/install-gitlab-cobertura-tools.sh b/.gitlab-ci/install-gitlab-cobertura-tools.sh new file mode 100755 index 000000000..59ec251e9 --- /dev/null +++ b/.gitlab-ci/install-gitlab-cobertura-tools.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -e + +# We need cobertura reports for gitlab-ci coverage_report, +# so this scripts helps us doing that until we switch to gcovr +pip3 install lcov-cobertura==2.0.2 + +# We need to split the coverage files, see: +# https://gitlab.com/gitlab-org/gitlab/-/issues/328772#note_840831654 +SPLIT_COBERTURA_SHA512="8388ca3928a27f2ef945a7d45f1dec7253c53742a0dd1f6a3b4a07c0926b24d77f8b5c51fc7920cb07320879b7b89b0e0e13d2101117403b8c052c72e28dbcb7" +wget -O /usr/local/bin/cobertura-split-by-package.py \ + https://gitlab.com/gitlab-org/gitlab/uploads/9d31762a33a10158f5d79d46f4102dfb/split-by-package.py +echo "${SPLIT_COBERTURA_SHA512} /usr/local/bin/cobertura-split-by-package.py" | sha512sum -c +chmod +x /usr/local/bin/cobertura-split-by-package.py +sed -i "s,\(/usr/bin/env python\).*,\13," \ + /usr/local/bin/cobertura-split-by-package.py -- cgit v1.2.1 From 3ddfb10b0b050992328955cc5f426bce1a35050e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 21 Jul 2022 01:05:42 +0200 Subject: ci: Generate Cobertura XML and use it to feed gitlab for MR integration 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 --- .gitlab-ci.yml | 6 +++++- .gitlab-ci/coverage-docker.sh | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 684afddb2..3b6f44ea6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -10,7 +10,7 @@ cache: - _ccache/ variables: - FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v18" + FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/glib/fedora:v19" COVERITY_IMAGE: "registry.gitlab.gnome.org/gnome/glib/coverity:v7" DEBIAN_IMAGE: "registry.gitlab.gnome.org/gnome/glib/debian-stable:v13" MINGW_IMAGE: "registry.gitlab.gnome.org/gnome/glib/mingw:v9" @@ -482,6 +482,10 @@ coverage: paths: - _coverage/coverage/index.html - _coverage + reports: + coverage_report: + coverage_format: cobertura + path: _coverage/*-cobertura/cobertura-*.xml before_script: - bash .gitlab-ci/show-execution-environment.sh script: diff --git a/.gitlab-ci/coverage-docker.sh b/.gitlab-ci/coverage-docker.sh index df3273fa0..0b9abc017 100755 --- a/.gitlab-ci/coverage-docker.sh +++ b/.gitlab-ci/coverage-docker.sh @@ -10,6 +10,14 @@ for path in _coverage/*.lcov; do 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 \ -- cgit v1.2.1 From d6a378afa708918db3f19d3078278334e35c7099 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Thu, 15 Sep 2022 02:58:26 +0200 Subject: run-docker: Do not require sudo if the user is part of docker group --- .gitlab-ci/run-docker.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci/run-docker.sh b/.gitlab-ci/run-docker.sh index 56b2b0a7d..33a0ae5d1 100755 --- a/.gitlab-ci/run-docker.sh +++ b/.gitlab-ci/run-docker.sh @@ -23,6 +23,8 @@ if docker -v |& grep -q podman; then # is incompatible with some of the dockerd instances on GitLab # CI runners. export BUILDAH_FORMAT=docker +elif getent group docker | grep -q "\b${USER}\b"; then + SUDO_CMD="" fi set -e -- cgit v1.2.1