summary refs log tree commit diff
path: root/.gitlab-ci
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2024-05-05 00:07:30 +0200
committerMichael Biebl <biebl@debian.org>2024-05-05 00:07:30 +0200
commit34bb501be08aa2b313d88e67d6e0a7e0a3f9cfa6 (patch)
tree4e6220877828be4c6f261de09ec0cb2d80e32389 /.gitlab-ci
parentbba2e4b4de668db525cbfdfc35292e5a0b51671a (diff)
New upstream version 1.47.90 upstream/1.47.90
Diffstat (limited to '.gitlab-ci')
-rw-r--r--.gitlab-ci/README.md29
-rwxr-xr-x.gitlab-ci/alpine-install.sh7
-rw-r--r--.gitlab-ci/ci.template245
-rw-r--r--.gitlab-ci/config.yml74
-rwxr-xr-x.gitlab-ci/debian-install.sh50
-rwxr-xr-x.gitlab-ci/fedora-install.sh66
-rwxr-xr-x.gitlab-ci/run-test.sh216
7 files changed, 687 insertions, 0 deletions
diff --git a/.gitlab-ci/README.md b/.gitlab-ci/README.md
new file mode 100644
index 00000000..5619a418
--- /dev/null
+++ b/.gitlab-ci/README.md
@@ -0,0 +1,29 @@
+.gitlab-ci
+==========
+
+We run tests in the gitlab-ci pipeline at
+https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/pipelines
+
+This directory contains a template for generating [.gitlab-ci.yml](../.gitlab-ci.yml).
+
+It uses [ci-templates](https://gitlab.freedesktop.org/freedesktop/ci-templates/) project.
+
+To get the right version of ci-templates, see the "Regenerate with" comment in
+[.gitlab-ci.yml](../.gitlab-ci.yml).  It shows how to install ci-fairy via
+python pip.  The exact version to be used is hard-coded as `.templates_sha`
+variable in ci.template file.
+
+Whenever changing relevant files, .gitlab-ci.yml must be regenerated.
+Regenerate the yml by running `ci-fairy generate-template`.
+
+There are also tests for checking that the yml is correct:
+
+1) run `tools/check-gitlab-ci.sh`
+2) run `make check-local-gitlab-ci`, which runs 1). This also
+  runs as part of `make check`.
+
+In both cases, the test is skipped if `ci-fairy` is not in the path.
+Install the correct `ci-fairy` version.
+
+In gitlab-ci pipeline, the "check-tree" test also checks that .gitlab-ci.yml
+is up to date.
diff --git a/.gitlab-ci/alpine-install.sh b/.gitlab-ci/alpine-install.sh
new file mode 100755
index 00000000..8df82ce1
--- /dev/null
+++ b/.gitlab-ci/alpine-install.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+set -ex
+
+./contrib/alpine/REQUIRED_PACKAGES
+
+ln -snf elogind/systemd /usr/include/systemd
diff --git a/.gitlab-ci/ci.template b/.gitlab-ci/ci.template
new file mode 100644
index 00000000..f88c0a08
--- /dev/null
+++ b/.gitlab-ci/ci.template
@@ -0,0 +1,245 @@
+# vim: set expandtab shiftwidth=2 tabstop=8 textwidth=0 filetype=yaml:
+
+{# You're looking at the template here, so you can ignore the below
+   warning. This is the right file to edit #}
+########################################
+#                                      #
+# THIS FILE IS GENERATED, DO NOT EDIT  #
+# Edit .gitlab-ci/ci.template instead  #
+#                                      #
+# Regenerate with:
+#   TEMPLATE_SHA="$(sed -n 's/^.templates_sha: *\&template_sha *\([0-9a-f]\+\)$/\1/p' ./.gitlab-ci/ci.template)"
+#   pip3 install "git+http://gitlab.freedesktop.org/freedesktop/ci-templates@$TEMPLATE_SHA"
+#   ci-fairy generate-template
+#
+########################################
+
+
+# see https://docs.gitlab.com/ee/ci/yaml/#includefile
+.templates_sha: &template_sha 184ca628f89f3193c249b4e34e45afee2773a833
+
+{# Group distros by their common (name,) tuples.#}
+{% set distro_groups = [] %}
+{% for distro in distributions %}
+  {% set g = {'name':distro.name} %}
+  {% if g not in distro_groups %}
+  {%   do distro_groups.append(g) %}
+  {% endif %}
+{% endfor %}
+
+{# The "default_distro" builds our pages and is used for check-{tree,patch} tests. It is the first distro with tier 1. #}
+{% set default_distro = [] %}
+{% for distro in distributions %}
+  {% if distro.tier == 1 and default_distro|length == 0 %}
+    {% do default_distro.append(distro) %}
+  {% endif %}
+{% endfor %}
+{% set default_distro = default_distro[0] %}
+
+include:
+{% for distro_group in distro_groups|sort(attribute='name') %}
+  # {{ distro_group.name.capitalize() }} container builder template
+  - project: 'freedesktop/ci-templates'
+    ref: *template_sha
+    file: '/templates/{{distro_group.name}}.yml'
+{% endfor %}
+
+stages:
+  - prep
+  - tier1
+  - tier2
+  - tier3
+  - deploy
+  - triage
+
+variables:
+  FDO_UPSTREAM_REPO: NetworkManager/NetworkManager
+  GIT_DEPTH: 1
+  # These tags should be updated each time the list of packages is updated
+  # changing these will force rebuilding the associated image
+  # Note: these tags have no meaning and are not tied to a particular NM version
+  #
+  # This is done by running `ci-fairy generate-template` and possibly bumping
+  # ".default_tag".
+{% for distro_group in distro_groups|sort(attribute='name') %}
+  {{"%-13s"| format(distro_group.name.upper() + '_TAG:')}}'tag-{{
+    (ci_fairy.hashfiles('./.gitlab-ci/config.yml',
+                        './.gitlab-ci/ci.template',
+                        './.gitlab-ci/' + base_types[distro_group.name] + '-install.sh',
+                        './contrib/' + base_types[distro_group.name] + '/REQUIRED_PACKAGES'))[0:12]
+  }}'
+{% endfor %}
+
+{% for distro_group in distro_groups|sort(attribute='name') %}
+  {{"%-13s"| format(distro_group.name.upper() + '_EXEC:')}}'bash .gitlab-ci/{{base_types[distro_group.name]}}-install.sh'
+{% endfor %}
+
+.nm_artifacts:
+  variables:
+    NM_BUILD_TARBALL: 1
+  artifacts:
+    expire_in: 5 days
+    when: always
+    paths:
+      - docs-html
+      - NetworkManager-1*.tar.xz
+      - NetworkManager-1*.src.rpm
+      - nm-test.log
+
+.nm_artifacts_debug:
+  artifacts:
+    expire_in: 5 days
+    when: always
+    paths:
+      - nm-test.log
+
+#################################################################
+#                                                               #
+# prep stage                                                    #
+#                                                               #
+#################################################################
+
+# Build a container for each distribution + version. The ci-templates
+# will re-use the containers if the tag doesn't change.
+{% for distro in distributions %}
+{% for version in distro.versions %}
+
+tier{{distro.tier}}:{{distro.name}}:{{version}}@prep:
+  extends:
+    - .fdo.container-build@{{distro.name}}
+  stage: prep
+  variables:
+    GIT_STRATEGY: none
+    FDO_DISTRIBUTION_VERSION: '{{version}}'
+    FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
+    FDO_DISTRIBUTION_EXEC: ${{distro.name.upper()}}_EXEC
+{% if distro.tier > 1 %}
+  when: manual
+{% endif %}
+{% endfor %}
+{% endfor %}
+
+#################################################################
+#                                                               #
+# tierN stage                                                   #
+#                                                               #
+#################################################################
+
+.build@template:
+  script:
+    - env
+    - r=0
+    - .gitlab-ci/run-test.sh 2>&1 | tee /tmp/nm-test.log || r=$?
+    - mv /tmp/nm-test.log .
+    - exit $r
+  dependencies: []
+
+{% for distro in distributions %}
+{% for version in distro.versions %}
+
+t_{{distro.name}}:{{version}}:
+  extends:
+    - .build@template
+    - .fdo.distribution-image@{{distro.name}}
+{% if distro == default_distro %}
+    - .nm_artifacts
+{% else %}
+    - .nm_artifacts_debug
+{% endif %}
+  stage: tier{{distro.tier}}
+{% if distro.tier <= 1 %}
+  parallel:
+    matrix:
+      - NM_TEST_SELECT_RUN:
+        - autotools+gcc+docs+valgrind
+        - meson+gcc+docs+valgrind
+        - autotools+clang
+        - meson+clang
+        - rpm+autotools
+        - rpm+meson
+        - tarball+autotools
+        - tarball+meson
+        - tarball
+        - subtree
+{% endif %}
+  variables:
+    FDO_DISTRIBUTION_VERSION: '{{version}}'
+    FDO_DISTRIBUTION_TAG: ${{distro.name.upper()}}_TAG
+    {# Where we have extra_variables defined, add them to the list #}
+    {% if distro.build is defined and distro.build.extra_variables is defined %}
+    {% for var in distro.build.extra_variables %}
+    {{var}}
+    {% endfor %}
+    {% endif %}
+  needs:
+    - "tier{{distro.tier}}:{{distro.name}}:{{version}}@prep"
+{% endfor %}
+{% endfor %}
+
+#################################################################
+#                                                               #
+# specific jobs                                                 #
+#                                                               #
+#################################################################
+
+check-patch:
+  extends:
+    - .fdo.distribution-image@{{default_distro.name}}
+  variables:
+    FDO_DISTRIBUTION_VERSION: '{{default_distro.versions[0]}}'
+    FDO_DISTRIBUTION_TAG: ${{default_distro.name.upper()}}_TAG
+  needs:
+    - "tier{{default_distro.tier}}:{{default_distro.name}}:{{default_distro.versions[0]}}@prep"
+  stage: tier1
+  script:
+    - date '+%Y%m%d-%H%M%S'; NM_CHECKPATCH_FETCH_UPSTREAM=1 contrib/scripts/checkpatch-feature-branch.sh
+  allow_failure: true
+
+check-tree:
+  extends:
+    - .fdo.distribution-image@{{default_distro.name}}
+  variables:
+    FDO_DISTRIBUTION_VERSION: '{{default_distro.versions[0]}}'
+    FDO_DISTRIBUTION_TAG: ${{default_distro.name.upper()}}_TAG
+  needs:
+    - "tier{{default_distro.tier}}:{{default_distro.name}}:{{default_distro.versions[0]}}@prep"
+  stage: tier1
+  script:
+    - date '+%Y%m%d-%H%M%S'; clang-format --version
+    - date '+%Y%m%d-%H%M%S'; black --version
+    - date '+%Y%m%d-%H%M%S'; contrib/scripts/nm-python-black-format.sh --check
+    - date '+%Y%m%d-%H%M%S'; git ls-files -z -- 'po/*.po' | xargs -0 -n1 msgfmt -vc
+    - date '+%Y%m%d-%H%M%S'; contrib/scripts/nm-code-format.sh -n
+    - date '+%Y%m%d-%H%M%S'; ci-fairy generate-template && git diff --exit-code
+    - date '+%Y%m%d-%H%M%S'; ./autogen.sh && [ "$(LANG=C make -C po update-po 2>&1 1>/dev/null | grep -c 'warning:')" = 0 ]
+
+pages:
+  stage: deploy
+  script:
+    - mv docs-html public
+  artifacts:
+    expire_in: 20 days
+    paths:
+      - public
+  only:
+    - main
+  dependencies:
+    - "t_{{default_distro.name}}:{{default_distro.versions[0]}}: [autotools+gcc+docs+valgrind]"
+  needs:
+    - "t_{{default_distro.name}}:{{default_distro.versions[0]}}: [autotools+gcc+docs+valgrind]"
+
+triage:issues:
+  stage: triage
+  image: ruby:2.7
+  script:
+    - gem install gitlab-triage
+    - gitlab-triage -d --token $API_TOKEN --source-id $SOURCE_ID
+  only:
+    - schedules
+
+# Have detached MR pipeline (https://docs.gitlab.com/ee/ci/pipelines/merge_request_pipelines.html)
+# https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/540#what-it-means-for-me-a-maintainer-of-a-project-part-of-gitlabfreedesktoporg
+workflow:
+  rules:
+    - if: $CI_PIPELINE_SOURCE == 'merge_request_event'
+    - if: $CI_PIPELINE_SOURCE == 'push'
diff --git a/.gitlab-ci/config.yml b/.gitlab-ci/config.yml
new file mode 100644
index 00000000..4e97ecf1
--- /dev/null
+++ b/.gitlab-ci/config.yml
@@ -0,0 +1,74 @@
+# This file contains the configuration for the gitlab ci.
+#
+# To recreate the .gitlab-ci.yml file, run
+#   ci-fairy generate-template
+#
+# The ci-fairy tool is part of
+# https://gitlab.freedesktop.org/freedesktop/ci-templates
+#
+
+# Some distros are fairly similar, and we reuse similar scripts.
+# The base type maps the distro name to their base.
+base_types:
+  fedora: fedora
+  centos: fedora
+  debian: debian
+  ubuntu: debian
+  alpine: alpine
+
+# The list of all distributions we want to create job for.
+distributions:
+  # TIER 1: CI run for all MRs.
+  # The first tier:1 in the list is used to build the pages and check-{tree,patch}.
+  - name: fedora
+    tier: 1
+    versions:
+      - '40'
+      - rawhide
+  - name: centos
+    tier: 1
+    versions:
+      - 'stream9'
+
+  # TIER 2: distribution versions that will or might use the current NM version.
+  # Run when doing a release.
+  - name: debian
+    tier: 2
+    versions:
+      - sid
+      - testing
+  - name: ubuntu
+    tier: 2
+    versions:
+      - devel
+  - name: alpine
+    tier: 2
+    versions:
+      - edge
+  
+  # TIER 3: distribution versions not in EOL but don't use the current NM version.
+  # Run when doing a release, but a failure won't be blocking for the release.
+  - name: fedora
+    tier: 3
+    versions:
+      - '39'
+  - name: ubuntu
+    tier: 3
+    versions:
+      - '20.04'
+      - '22.04'
+      - '24.04'
+      - 'rolling' # latest non-LTS
+  - name: debian
+    tier: 3
+    versions:
+      - 'stable'
+      - 'oldstable'
+  - name: centos
+    tier: 3
+    versions:
+      - 'stream8'
+  - name: alpine
+    tier: 3
+    versions:
+      - 'latest'
diff --git a/.gitlab-ci/debian-install.sh b/.gitlab-ci/debian-install.sh
new file mode 100755
index 00000000..737d4052
--- /dev/null
+++ b/.gitlab-ci/debian-install.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+set -ex
+
+IS_DEBIAN_9=0
+IS_UBUNTU_18_04=0
+grep -q '^VERSION=.\(9 (stretch)\)' /etc/os-release && IS_DEBIAN_9=1
+grep -q '^VERSION=.\(18.04.[0-9]\+ LTS\)' /etc/os-release && IS_UBUNTU_18_04=1
+
+if [ $IS_DEBIAN_9 = 1 ]; then
+    cat > /etc/apt/sources.list <<EOF
+deb http://archive.debian.org/debian/ stretch main non-free contrib
+deb-src http://archive.debian.org/debian/ stretch main non-free contrib
+deb http://archive.debian.org/debian-security/ stretch/updates main non-free contrib
+deb-src http://archive.debian.org/debian-security/ stretch/updates main non-free contrib
+EOF
+fi
+
+if [ $IS_DEBIAN_9 = 1 -o $IS_UBUNTU_18_04 = 1 ]; then
+    # pam is hosted on this release to the point chfn doesn't work.
+    # It's okay on Ubuntu 16.04 and 20.04 though, so keep this version specific.
+    #
+    # Setting up systemd (237-3ubuntu10.53) ...
+    # ...
+    # chfn: PAM: System error
+    # adduser: `/usr/bin/chfn -f systemd Network Management systemd-network' returned error code 1. Exiting.
+    # dpkg: error processing package systemd (--configure):
+    #  installed systemd package post-installation script subprocess returned error exit status 1
+    # Errors were encountered while processing:
+    #  systemd
+    ln -sf /bin/true /usr/bin/chfn
+fi
+
+DEBIAN_FRONTEND=noninteractive apt-get update
+DEBIAN_FRONTEND=noninteractive NM_INSTALL="apt-get --yes install" bash -x ./contrib/debian/REQUIRED_PACKAGES
+
+dbus-uuidgen --ensure
+
+sed -i 's/^# \(pl_PL.UTF-8 .*\)$/\1/p' /etc/locale.gen || true
+locale-gen pl_PL.UTF-8
+
+# Debian 12 and later requires --break-system-packages
+pip3 install meson || pip3 install --break-system-packages meson
+
+# iproute2 5.2.0 on debian:sid causes our unit tests to fail.
+# Downgrade to a working version. See https://www.spinics.net/lists/netdev/msg584916.html
+if dpkg -s iproute2 | grep -q '^Version[:] 5.2.0-1\(ubuntu1\)\?$' ; then
+    curl 'http://ftp.debian.org/debian/pool/main/i/iproute2/iproute2_4.20.0-2_amd64.deb' --output /tmp/iproute2_4.20.0-2_amd64.deb
+    dpkg -i /tmp/iproute2_4.20.0-2_amd64.deb
+fi
diff --git a/.gitlab-ci/fedora-install.sh b/.gitlab-ci/fedora-install.sh
new file mode 100755
index 00000000..5ffb461c
--- /dev/null
+++ b/.gitlab-ci/fedora-install.sh
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+set -ex
+
+IS_FEDORA=0
+IS_CENTOS=0
+CENTOS_VERSION=0
+grep -q '^NAME=.*\(CentOS\)' /etc/os-release && IS_CENTOS=1
+grep -q '^NAME=.*\(Fedora\)' /etc/os-release && IS_FEDORA=1
+if [ $IS_CENTOS = 1 ]; then
+    if grep -q '^VERSION_ID=.*\<8\>' /etc/os-release ; then
+        CENTOS_VERSION=8
+    elif grep -q '^VERSION_ID=.*\<9\>' /etc/os-release ; then
+        CENTOS_VERSION=9
+    else
+        exit 1
+    fi
+    if grep -q "^NAME.*Stream" /etc/os-release ; then
+        CENTOS_VERSION="stream$CENTOS_VERSION"
+    fi
+fi
+
+ if [ "$IS_CENTOS" = 1 ]; then
+    if [ "$CENTOS_VERSION" = stream8 ]; then
+        dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
+        dnf install -y 'dnf-command(config-manager)'
+        dnf config-manager --set-enabled powertools || \
+          dnf config-manager --set-enabled PowerTools
+        curl https://copr.fedorainfracloud.org/coprs/nmstate/nm-build-deps/repo/epel-8/nmstate-nm-build-deps-epel-8.repo > /etc/yum.repos.d/nmstate-nm-build-deps-epel-8.repo
+    elif [ "$CENTOS_VERSION" = stream9 ]; then
+        dnf install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm
+        dnf install -y 'dnf-command(config-manager)'
+        dnf config-manager --set-enabled crb
+        curl https://copr.fedorainfracloud.org/coprs/nmstate/nm-build-deps/repo/epel-9/nmstate-nm-build-deps-epel-9.repo > /etc/yum.repos.d/nmstate-nm-build-deps-epel-9.repo
+    else
+        exit 1
+    fi
+fi
+
+
+NM_NO_EXTRA=1 NM_INSTALL="yum install -y" ./contrib/fedora/REQUIRED_PACKAGES
+yum install -y glibc-langpack-pl ccache clang
+
+# containers have "tsflags=nodocs" in /etc/dnf/dnf.conf. We need /usr/shared/gtk-doc/html
+# to generate proper documentation.
+yum reinstall -y --setopt='tsflags=' glib2-doc
+
+if command -v dnf &>/dev/null; then
+    dnf install -y python3-dnf-plugins-core
+    dnf debuginfo-install -y glib2
+else
+    debuginfo-install -y glib2
+fi
+
+contrib/scripts/nm-ci-patch-gtkdoc.sh || true
+
+if [ -x /usr/bin/ninja ] && ! [ -x /usr/bin/ninja-build ]; then
+    ln -s /usr/bin/ninja-build /usr/bin/ninja
+fi
+
+if [ $IS_FEDORA = 1 ]; then
+    TEMPLATE_SHA="$(sed -n 's/^.templates_sha: *\&template_sha *\([0-9a-f]\+\)$/\1/p' ./.gitlab-ci/ci.template)"
+    test -n "$TEMPLATE_SHA"
+    dnf install -y python3-pip
+    pip3 install "git+http://gitlab.freedesktop.org/freedesktop/ci-templates@$TEMPLATE_SHA"
+fi
diff --git a/.gitlab-ci/run-test.sh b/.gitlab-ci/run-test.sh
new file mode 100755
index 00000000..cd122203
--- /dev/null
+++ b/.gitlab-ci/run-test.sh
@@ -0,0 +1,216 @@
+#!/bin/bash
+
+set -ex
+
+die() {
+    printf "%s\n" "$*" >&2
+    exit 1
+}
+
+export PAGER=cat
+export OMP_NUM_THREADS=1
+
+IS_FEDORA=0
+IS_CENTOS=0
+IS_ALPINE=0
+grep -q '^NAME=.*\(CentOS\)' /etc/os-release && IS_CENTOS=1
+grep -q '^NAME=.*\(Fedora\)' /etc/os-release && IS_FEDORA=1
+grep -q '^NAME=.*\(Alpine\)' /etc/os-release && IS_ALPINE=1
+
+IS_CENTOS_7=0
+if [ $IS_CENTOS = 1 ]; then
+    if grep -q '^VERSION_ID=.*\<7\>' /etc/os-release ; then
+        IS_CENTOS_7=1
+    fi
+fi
+
+do_clean() {
+    git clean -fdx
+
+    git status
+    git diff --exit-code
+}
+
+ARTIFACT_DIR=/tmp/nm-artifact
+rm -rf "$ARTIFACT_DIR"
+mkdir -p "$ARTIFACT_DIR"
+
+uname -a
+! command -v locale &>/dev/null || locale -a
+meson --version
+
+! command -v dpkg &>/dev/null || dpkg -l
+! command -v yum  &>/dev/null || yum list installed
+! command -v apk  &>/dev/null || apk -v info
+
+# We have a unit test that check that `ci-fairy generate-template`
+# is equal to our .gitlab-ci.yml file. However, on gitlab-ci we
+# also have a dedicate test for the same thing. We don't need
+# to run that test as part of the build. Disable it.
+export NMTST_SKIP_CHECK_GITLAB_CI=1
+
+# Assert that "$1" is one of the valid values for NM_TEST_SELECT_RUN. die() otherwise.
+check_run_assert() {
+    { set +x; } 2>/dev/null
+    local run="$1"
+    local a
+
+    # These are the supported $NM_TEST_SELECT_RUN values.
+    local _CHECK_RUN_LIST=(
+        autotools+gcc+docs+valgrind
+        meson+gcc+docs+valgrind
+        autotools+clang
+        meson+clang
+        rpm+autotools
+        rpm+meson
+        tarball+autotools
+        tarball+meson
+        tarball
+        subtree
+
+        all
+        none
+    )
+
+    if [ "$run" = all ] ; then
+        set -x
+        return 0
+    fi
+
+    for a in "${_CHECK_RUN_LIST[@]}" ; do
+        if [ "$a" = "$run" ] ; then
+            set -x
+            return 0
+        fi
+    done
+    die "invalid NM_TEST_SELECT_RUN value \"$1\""
+}
+
+[ -z "$NM_TEST_SELECT_RUN" ] && NM_TEST_SELECT_RUN=all
+check_run_assert "$NM_TEST_SELECT_RUN"
+
+check_run() {
+    local test_no="$1"
+
+    check_run_assert "$test_no"
+
+    # Usually, we run the build several times. However, for testing
+    # the build script manually, it can be useful to explicitly select
+    # one step to run. For example, if step 3 is known to fail, you
+    # can still manually run step A by setting NM_TEST_SELECT_RUN=A.
+
+    test "$NM_TEST_SELECT_RUN" = all -o "$NM_TEST_SELECT_RUN" = "$test_no"
+}
+
+check_run_clean() {
+    if ! check_run "$1" ; then
+        return 1
+    fi
+    do_clean
+    return 0
+}
+
+if check_run_clean autotools+gcc+docs+valgrind ; then
+    BUILD_TYPE=autotools CC=gcc WITH_DOCS=1 WITH_VALGRIND=1 contrib/scripts/nm-ci-run.sh
+    mv build/INST/share/gtk-doc/html "$ARTIFACT_DIR/docs-html"
+fi
+
+check_run_clean meson+gcc+docs+valgrind && BUILD_TYPE=meson     CC=gcc   WITH_DOCS=1 WITH_VALGRIND=1 contrib/scripts/nm-ci-run.sh
+check_run_clean autotools+clang         && BUILD_TYPE=autotools CC=clang WITH_DOCS=0                 contrib/scripts/nm-ci-run.sh
+check_run_clean meson+clang             && BUILD_TYPE=meson     CC=clang WITH_DOCS=0                 contrib/scripts/nm-ci-run.sh
+
+check_run_clean rpm+autotools && test $IS_FEDORA = 1 -o $IS_CENTOS = 1 && ./contrib/fedora/rpm/build_clean.sh -g -w crypto_gnutls -w debug -w iwd -w test -W meson
+check_run_clean rpm+meson     && test $IS_FEDORA = 1                   && ./contrib/fedora/rpm/build_clean.sh -g -w crypto_gnutls -w debug -w iwd -w test -w meson
+
+if check_run_clean tarball && [ "$NM_BUILD_TARBALL" = 1 ]; then
+    SIGN_SOURCE=0 ./contrib/fedora/rpm/build_clean.sh -r
+    mv ./build/meson-dist/NetworkManager-1*.tar.xz "$ARTIFACT_DIR/"
+    mv ./contrib/fedora/rpm/latest/SRPMS/NetworkManager-1*.src.rpm "$ARTIFACT_DIR/"
+    do_clean
+fi
+
+if check_run_clean tarball+autotools; then
+    BUILD_TYPE=autotools CC=gcc WITH_DOCS=1 CONFIGURE_ONLY=1 contrib/scripts/nm-ci-run.sh
+    pushd ./build
+        # dist & build with autotools
+        make distcheck -j$(nproc)
+
+        # build with meson
+        DISTSRC="./distsrc-$RANDOM"
+        mkdir $DISTSRC
+        tar xvf ./NetworkManager-1*.tar.xz -C $DISTSRC --strip-components=1
+        pushd $DISTSRC
+            BUILD_TYPE=meson CC=gcc WITH_DOCS=1 ../../contrib/scripts/nm-ci-run.sh
+        popd
+    popd
+    do_clean
+fi
+
+if check_run_clean tarball+meson; then
+    BUILD_TYPE=meson CC=gcc WITH_DOCS=1 CONFIGURE_ONLY=1 contrib/scripts/nm-ci-run.sh
+    pushd ./build
+        # dist with meson/ninja
+        ninja dist
+
+        # build with autotools
+        DISTSRC="./distsrc-$RANDOM"
+        mkdir $DISTSRC
+        tar xvf ./meson-dist/NetworkManager-1*.tar.xz -C $DISTSRC --strip-components=1
+        pushd $DISTSRC
+            BUILD_TYPE=autotools CC=gcc WITH_DOCS=1 ../../contrib/scripts/nm-ci-run.sh
+        popd
+        rm -rf $DISTSRC
+    popd
+    do_clean
+fi
+
+
+###############################################################################
+
+test_subtree() {
+    local d="$1"
+    local cc="$2"
+
+    if meson --version | grep -q '^0\.[0-5][0-9]\.' ; then
+        # These subprojects require a newer meson than NetworkManager. Skip the test.
+        return 0
+    fi
+
+    do_clean
+    pushd ./src/$d
+
+    ARGS=()
+    if [ "$d" = n-acd ]; then
+        ARGS+=('-Debpf=false')
+    fi
+
+    CC="$cc" CFLAGS="-Werror -Wall" meson build "${ARGS[@]}"
+    ninja -v -C build test
+
+    popd
+}
+
+if check_run_clean subtree; then
+    for d in c-list c-rbtree c-siphash c-stdaux n-acd n-dhcp4 ; do
+        for cc in gcc clang; do
+            test_subtree "$d" "$cc"
+        done
+    done
+fi
+
+###############################################################################
+
+if [ "$NM_BUILD_TARBALL" = 1 ]; then
+    do_clean
+    if check_run autotools+gcc+docs+valgrind ; then
+        mv "$ARTIFACT_DIR/docs-html/" ./
+    fi
+    if check_run tarball ; then
+        mv \
+           "$ARTIFACT_DIR"/NetworkManager-1*.tar.xz \
+           "$ARTIFACT_DIR"/NetworkManager-1*.src.rpm \
+           ./
+    fi
+fi
+
+echo "BUILD SUCCESSFUL!!"