From 9cabc41a3700255c4c35668c10806c7217e40ab3 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 17 Feb 2022 22:22:17 +0100 Subject: ci: Add repo-sanity check It is somewhat easy to dismiss failed build images as errors in the pipeline rather than errors in the repository configuration. Make a separate check in the review stage testing that the user repository is in a state able to run the rest of CI (e.g. generating or storing images in its own container registry, since this is necessary with ci-templates). The error message is made known through both junit and CI job output. --- .gitlab-ci.yml | 17 +++++++++++++++++ .gitlab-ci/simple-junit-report.sh | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100755 .gitlab-ci/simple-junit-report.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c7ab6deb5..6e698a2a8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -32,6 +32,18 @@ stages: reports: junit: check-junit-report.xml +repo-sanity: + stage: review + script: + - > + if [[ -z "$CI_REGISTRY_IMAGE" ]] ; + then + .gitlab-ci/simple-junit-report.sh check-junit-report.xml \ + repo-sanity "The container registry should be enabled in the project general settings panel at $CI_PROJECT_URL/edit" ; + exit 1 ; + fi + <<: *check + check-commit-log: variables: GIT_DEPTH: "100" @@ -130,6 +142,7 @@ build-fedora-container@x86_64: variables: GIT_STRATEGY: none needs: + - repo-sanity - check-commit-log - check-merge-request @@ -142,6 +155,7 @@ build-fedora-rawhide-container@x86_64: GIT_STRATEGY: none allow_failure: true needs: + - repo-sanity - check-commit-log - check-merge-request @@ -153,6 +167,7 @@ build-fedora-container@aarch64: variables: GIT_STRATEGY: none needs: + - repo-sanity - check-commit-log - check-merge-request @@ -164,6 +179,7 @@ build-ubuntu-container@x86_64: variables: GIT_STRATEGY: none needs: + - repo-sanity - check-commit-log - check-merge-request @@ -175,6 +191,7 @@ build-alpine-container@x86_64: variables: GIT_STRATEGY: none needs: + - repo-sanity - check-commit-log - check-merge-request diff --git a/.gitlab-ci/simple-junit-report.sh b/.gitlab-ci/simple-junit-report.sh new file mode 100755 index 000000000..120c325f1 --- /dev/null +++ b/.gitlab-ci/simple-junit-report.sh @@ -0,0 +1,17 @@ +OUTFILE=$1 +NAME=$2 +MESSAGE=$3 + +cat >$OUTFILE < + + + + + + + +EOF + +# Also echo the message in stdout for good measure +echo $MESSAGE -- cgit v1.2.1 From b5d4fae5ef123907fc4cfa98406224fd6c408539 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Fri, 18 Feb 2022 15:34:35 +0100 Subject: ci: Declare variable in general block This variable is also useful in other jobs, so move it outside to the general declarations. --- .gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6e698a2a8..8138a8279 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -5,6 +5,7 @@ include: - remote: 'https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/80f87b3058efb75a1faae11826211375fba77e7f/templates/ubuntu.yml' variables: + FDO_UPSTREAM_REPO: GNOME/tracker MESON_TEST_TIMEOUT_MULTIPLIER: 3 # These can be used to see verbose log output from the functional-tests. # See HACKING.md for more information. @@ -73,7 +74,6 @@ check-merge-request: .tracker.fedora@common: variables: BASE_TAG: '2022-02-10.0' - FDO_UPSTREAM_REPO: GNOME/tracker FDO_DISTRIBUTION_PACKAGES: 'clang clang-analyzer gcovr git libasan libubsan python3-gobject python3-pip umockdev-devel xmlto uncrustify patch diffutils cmake python-devel' FDO_DISTRIBUTION_EXEC: | dnf install -y 'dnf-command(builddep)' 'dnf-command(download)' && @@ -88,7 +88,6 @@ check-merge-request: .tracker.ubuntu@common: variables: BASE_TAG: '2021-05-15.5' - FDO_UPSTREAM_REPO: GNOME/tracker FDO_DISTRIBUTION_PACKAGES: 'python3-tap umockdev libumockdev-dev upower asciidoc-base git' FDO_DISTRIBUTION_EXEC: | export DEBIAN_FRONTEND=noninteractive && @@ -99,7 +98,6 @@ check-merge-request: .tracker.alpine@common: variables: BASE_TAG: '2022-02-19.0' - FDO_UPSTREAM_REPO: GNOME/tracker FDO_DISTRIBUTION_PACKAGES: 'alpine-sdk asciidoc bash-completion dbus dbus-dev git glib-dev gobject-introspection-dev gtk-doc icu-dev json-glib-dev libsoup-dev libxml2-dev meson py3-gobject3 py3-setuptools py3-tappy sqlite-dev vala' .tracker.fedora:35@x86_64: -- cgit v1.2.1 From 56cf628e473a4b4c125dd7750be2b0572779e1e8 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 19 Feb 2022 10:50:15 +0100 Subject: ci: Run check-commits job in normal pipelines too Make it non-failable there though, so contributors can check the errors before filing a merge request, but still being able to run the rest of the pipeline. --- .gitlab-ci.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8138a8279..0db9745f6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,12 +50,16 @@ check-commit-log: GIT_DEPTH: "100" stage: review script: - - if [[ x"$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" != "x" ]] ; + - ci-fairy check-commits --junit-xml=check-junit-report.xml && exit 0; + if [[ -z "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]] ; then - ci-fairy check-commits --junit-xml=check-junit-report.xml ; - else - echo "Not a merge request" ; - fi + echo "'ci-fairy check-commits' found commit messages with unexpected format, see https://wiki.gnome.org/Git/CommitMessages for the recommended guidelines. Please fix those before filing a merge request, this will be handled as a pipeline failure there." ; + exit 255 ; + fi ; + exit 1 + allow_failure: + exit_codes: + - 255 <<: *check check-merge-request: -- cgit v1.2.1 From 3cf7b1613fb51e0558cfd3d088063f0ca55e0524 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 19 Feb 2022 10:54:39 +0100 Subject: ci: Enable detached merge request pipelines The check jobs are relying on environment variables that are only set on merge request pipelines, so they've been kinda ineffective so far. Enable the detached merge request pipelines as documented at https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html so that these work. Since we want all jobs to run in merge pipelines, using "workflow" is good for us. --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0db9745f6..c62329ad4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,11 @@ stages: - analysis - website +workflow: + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_PIPELINE_SOURCE == 'push' + .check-template: &check extends: - .fdo.ci-fairy -- cgit v1.2.1 From ca35a190e5aff1bafeae05f586ae098ad3a5762b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Sat, 19 Feb 2022 11:36:42 +0100 Subject: ci: Add some additional commit formatting rules For ci-fairy check-commits to pick it up. These are mostly cosmetic: - Require that the commit subject has a prefix - Prevent commits from having links to the merge request itself (should be already there via merge commits) - Ensure commit subjects are properly capitalized - Avoid code filenames in commit subject We could add some further things in the future, like enforcing a set of prefixes to use in commit log subjects. --- .gitlab-ci/commit-rules.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .gitlab-ci/commit-rules.yml diff --git a/.gitlab-ci/commit-rules.yml b/.gitlab-ci/commit-rules.yml new file mode 100644 index 000000000..fbd78a35d --- /dev/null +++ b/.gitlab-ci/commit-rules.yml @@ -0,0 +1,13 @@ +patterns: + require: + - regex: '^[^:]+: +[^ ]' + message: "Commit message subject must have a prefix. E.g. 'tests: '" + deny: + - regex: '^$CI_MERGE_REQUEST_PROJECT_URL/(-/)?merge_requests/$CI_MERGE_REQUEST_IID$' + message: "Commit message must not contain a link to its own merge request" + - regex: '^[^:]+: [a-z]' + message: "Commit message subject should be properly Capitalized. E.g. 'cli: Fix help subcommand'" + where: subject + - regex: '^\S*\.[ch]:' + message: Commit message subject prefix should not include .c, .h, etc. + where: subject -- cgit v1.2.1 From ffb127248ce65fad6d57072c36862c21221b2142 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 7 Mar 2022 13:26:12 +0100 Subject: ci: Include gcovr in Ubuntu/Alpine images And bump tag to rebuild these images. --- .gitlab-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c62329ad4..f575877d1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -96,8 +96,8 @@ check-merge-request: .tracker.ubuntu@common: variables: - BASE_TAG: '2021-05-15.5' - FDO_DISTRIBUTION_PACKAGES: 'python3-tap umockdev libumockdev-dev upower asciidoc-base git' + BASE_TAG: '2022-03-07.0' + FDO_DISTRIBUTION_PACKAGES: 'python3-tap umockdev libumockdev-dev upower asciidoc-base git gcovr' FDO_DISTRIBUTION_EXEC: | export DEBIAN_FRONTEND=noninteractive && sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list && @@ -106,8 +106,8 @@ check-merge-request: .tracker.alpine@common: variables: - BASE_TAG: '2022-02-19.0' - FDO_DISTRIBUTION_PACKAGES: 'alpine-sdk asciidoc bash-completion dbus dbus-dev git glib-dev gobject-introspection-dev gtk-doc icu-dev json-glib-dev libsoup-dev libxml2-dev meson py3-gobject3 py3-setuptools py3-tappy sqlite-dev vala' + BASE_TAG: '2022-03-07.0' + FDO_DISTRIBUTION_PACKAGES: 'alpine-sdk asciidoc bash-completion dbus dbus-dev git glib-dev gobject-introspection-dev gtk-doc icu-dev json-glib-dev libsoup-dev libxml2-dev meson py3-gobject3 py3-setuptools py3-tappy sqlite-dev vala gcovr' .tracker.fedora:35@x86_64: extends: .tracker.fedora@common -- cgit v1.2.1 From 0a07d77d376b44c7ea95f97db7f9a0188e80638b Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 7 Mar 2022 12:10:31 +0100 Subject: ci: Run coverage on all test jobs And have the coverage job merge all results. So far this is mostly repeated work with maybe some slight timing-related variances in code paths, but this may be useful to get an unified coverage report for different compilation flags in the future. So far, Ubuntu seems to have an old gcovr version that generates a different JSON intermediate file. Since gcovr requires that all JSON versions match, Ubuntu is so far kept out. --- .gitlab-ci.yml | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f575877d1..ea1feb96a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -218,7 +218,7 @@ check-code-style: .build-template: &build stage: build script: - - meson . build -Ddocs=$([ -z "$NO_DOCS" ] && echo "true" || echo "false") -Db_lto=true -Dsystemd_user_services=false -Dtests_tap_protocol=true --prefix /usr + - meson . build -Ddocs=$([ -z "$NO_DOCS" ] && echo "true" || echo "false") -Db_coverage=true -Db_lto=true -Dsystemd_user_services=false -Dtests_tap_protocol=true --prefix /usr - ninja -C build - | if [ -z "$NO_DOCS" ]; then ninja -C build docs/reference/libtracker-sparql/Tracker-doc; fi @@ -287,6 +287,13 @@ build-alpine-latest@x86_64: unset $(env|grep -o '^CI_[^=]*') env LANG=C.UTF-8 LC_ALL=C.UTF-8 dbus-run-session meson test --print-errorlogs ${MESON_TEST_EXTRA_ARGS} after_script: + - pushd build + - gcovr --root=.. --filter='\.\./src/' + --exclude=../utils --exclude=../examples --exclude=../docs/reference + --exclude='\.\./build/.*\.[ch]$' --exclude='.*/tests/.*\.[ch]$' + --exclude='\.\./src/.*\.vala$' + --json --output=../coverage-${CI_JOB_NAME}.json 2>/dev/null + - popd - | echo "Distribution: " echo @@ -304,6 +311,7 @@ build-alpine-latest@x86_64: when: always paths: - build + - coverage-*.json reports: junit: "build/meson-logs/testlog.junit.xml" @@ -372,26 +380,26 @@ test-website: needs: - build-fedora-container@x86_64 -coverage-analysis: +coverage: extends: - .fdo.distribution-image@fedora - .tracker.fedora:35@x86_64 stage: analysis allow_failure: true script: - - meson build -Db_coverage=true -Ddocs=false -Dsystemd_user_services=false -Dtests_tap_protocol=true --prefix /usr - - cd build - - ninja - - env LANG=C.UTF-8 LC_ALL=C.UTF-8 dbus-run-session meson test --print-errorlogs ${MESON_TEST_EXTRA_ARGS} - - mkdir -p coveragereport - - gcovr --html-details --print-summary --root=.. --exclude=../docs/reference --exclude=../tests --exclude=../utils --exclude=../examples --exclude=.*_gresources\.c --exclude=.*enum-types\.c --output coveragereport/index.html + - mkdir coveragereport + - gcovr --add-tracefile 'coverage-*.json' + --html-details --print-summary --output coveragereport/index.html coverage: '/^lines: (\d+\.\d+\%)/' artifacts: when: always paths: - - build/coveragereport + - coveragereport needs: - - build-fedora-container@x86_64 + - test-fedora@x86_64 + - test-fedora-rawhide@x86_64 + - test-fedora@aarch64 + - test-alpine@x86_64 coverity: extends: -- cgit v1.2.1 From 5b4410c791f056991d3ffec7cef15818cae8b169 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 7 Mar 2022 17:50:48 +0100 Subject: ci: Work around rawhide failures by using crun runners With a combination of recent glib, and old runc/seccomp in the runners, we run into the error messages described at: https://gitlab.gnome.org/Infrastructure/GitLab/-/issues/545 So far, the advised workaround is to use the `crun` tag to use runners that don't run that combination of software. Add this specifically for the rawhide test job. --- .gitlab-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ea1feb96a..668b62592 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -330,6 +330,11 @@ test-fedora-rawhide@x86_64: needs: - build-fedora-rawhide@x86_64 allow_failure: true + tags: + # There is a mismatch between syscalls and seccomp rules in + # some runners, using `crun` is advised in the mean time, see + # https://gitlab.gnome.org/Infrastructure/GitLab/-/issues/545 + - crun <<: *test test-fedora@aarch64: -- cgit v1.2.1 From 36742e8e110cc56cf3c0ead1f1bd71cd6e55eaaa Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Mon, 7 Mar 2022 18:24:38 +0100 Subject: ci: Manually apply test timeout multiplier This was mistakenly set, but never passed to meson. This should give enough time for slow runners to finish. --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 668b62592..31fd39fea 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -285,7 +285,7 @@ build-alpine-latest@x86_64: # whole environment for every failed test, and that gives a whole # screenful of junk each time unless we strip these. unset $(env|grep -o '^CI_[^=]*') - env LANG=C.UTF-8 LC_ALL=C.UTF-8 dbus-run-session meson test --print-errorlogs ${MESON_TEST_EXTRA_ARGS} + env LANG=C.UTF-8 LC_ALL=C.UTF-8 dbus-run-session meson test -t $MESON_TEST_TIMEOUT_MULTIPLIER --print-errorlogs ${MESON_TEST_EXTRA_ARGS} after_script: - pushd build - gcovr --root=.. --filter='\.\./src/' -- cgit v1.2.1