ci: Revamp the CI to make more efficient use of ci-templates

The main changes:

- add the meson-build.sh helper script because it produces nicer output
  and more consistent behavior across jobs. Use that script together with
  MESON_ARGS as variables so the per-job configuration is easier
  visible.
- use the FDO_* variables for debian too and rely on ci-templates for
  images based on those variables
- always create containers, the ci-templates will skip creating those
  anyway if they already exist
- always install the extra deps we need for libgudev, this removes our
  exposure to distribution updates changing our test environment
- use a parallel:matrix for the backend jobs
- debian no longer installs the build-dep, let's use explicitly listed
  deps only

There is no more real need for scheduled pipelines, so the checks for
those have been removd.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer 2026-05-28 15:18:56 +10:00
commit 991fa101f0
2 changed files with 317 additions and 190 deletions

145
.ci/meson-build.sh Executable file
View file

@ -0,0 +1,145 @@
#!/usr/bin/env bash
#
# This script is sourced from here:
# https://gitlab.freedesktop.org/whot/meson-helper
#
# SPDX-License-Identifier: MIT
#
# Usage:
# meson-build.sh
# [-C directory] ... change to directory before doing anything
# [--skip-build] ... skip the compilation
# [--skip-test|--run-test] ... skip or explicitly run meson test
# [--skip-dist|--run-dist] ... skip or explicitly run meson dist
# [--skip-install|--run-install] ... skip or explicitly run meson install
#
#
# Environment variables:
# If the .meson_environment file exists in $PWD, it is sourced at the start of the script.
# This file is sourced before the -C directory option takes effect.
#
# MESON_BUILDDIR
# MESON_ARGS, MESON_EXTRA_ARGS:
# Args passed to meson setup. The MESON_EXTRA_ARGS exist to make it easier for
# callers to have a default set of arguments and a variable set of arguments.
# MESON_TEST_ARGS, MESON_DIST_ARGS, MESON_INSTALL_ARGS:
# Args passed directly to the respective meson command. If these args are set it implies
# --run-$cmd. Use --skip-$cmd to skip.
# NINJA_ARGS - args passed to ninja via meson compile
set -x
if [[ -f .meson_environment ]]; then
. .meson_environment
fi
# If test args are set, we assume we want to run the tests
MESON_RUN_TEST="$MESON_TEST_ARGS"
MESON_RUN_INSTALL="$MESON_INSTALL_ARGS"
MESON_RUN_DIST="$MESON_DIST_ARGS"
while [[ $# -gt 0 ]]; do
case $1 in
-C)
directory=$2
shift 2
pushd "$directory" || exit 1
;;
--skip-setup)
shift
MESON_SKIP_SETUP="1"
;;
--skip-build)
shift
MESON_SKIP_BUILD="1"
;;
--skip-test)
shift
MESON_RUN_TEST=""
;;
--run-test)
shift
MESON_RUN_TEST="1"
;;
--skip-dist)
shift
MESON_RUN_DIST=""
;;
--run-dist)
shift
MESON_RUN_DIST="1"
;;
--skip-install)
shift
MESON_RUN_INSTALL=""
;;
--run-install)
shift
MESON_RUN_INSTALL="1"
;;
*)
echo "Unknow commandline argument $1"
exit 1
;;
esac
done
if [[ -z "$MESON_BUILDDIR" ]]; then
echo "\$MESON_BUILDDIR undefined."
exit 1
fi
# emulate a few gitlab variables to make it easier to
# run and debug locally.
if [[ -z "$CI_JOB_ID" ]] || [[ -z "$CI_JOB_NAME" ]]; then
echo "Missing \$CI_JOB_ID or \$CI_JOB_NAME".
CI_PROJECT_NAME=$(basename "$PWD")
CI_JOB_ID=$(date +%s)
CI_JOB_NAME="$CI_PROJECT_NAME-job-local"
echo "Simulating gitlab environment: "
echo " CI_JOB_ID=$CI_JOB_ID"
echo " CI_JOB_NAME=$CI_JOB_NAME"
fi
if [[ -n "$FDO_CI_CONCURRENT" ]]; then
jobcount="-j$FDO_CI_CONCURRENT"
export MESON_TESTTHREADS="$FDO_CI_CONCURRENT"
fi
if [[ -n "$MESON_EXTRA_ARGS" ]]; then
MESON_ARGS="$MESON_ARGS $MESON_EXTRA_ARGS"
fi
echo "*************************************************"
echo "builddir: $MESON_BUILDDIR"
echo "meson args: $MESON_ARGS"
echo "ninja args: $NINJA_ARGS"
echo "meson test args: $MESON_TEST_ARGS"
echo "job count: ${jobcount-0}"
echo "*************************************************"
set -e
if [[ -z "$MESON_SKIP_SETUP" ]]; then
rm -rf "$MESON_BUILDDIR"
meson setup "$MESON_BUILDDIR" $MESON_ARGS
fi
meson configure --no-pager "$MESON_BUILDDIR"
if [[ -z "$MESON_SKIP_BUILD" ]]; then
if [[ -n "$NINJA_ARGS" ]]; then
ninja_args="--ninja-args $NINJA_ARGS"
fi
meson compile -v -C "$MESON_BUILDDIR" $jobcount $ninja_args
fi
if [[ -n "$MESON_RUN_TEST" ]]; then
meson test -C "$MESON_BUILDDIR" --print-errorlogs $MESON_TEST_ARGS
fi
if [[ -n "$MESON_RUN_INSTALL" ]]; then
meson install --no-rebuild -C "$MESON_BUILDDIR" $MESON_INSTALL_ARGS
fi
if [[ -n "$MESON_RUN_DIST" ]]; then
meson dist -C "$MESON_BUILDDIR" $MESON_DIST_ARGS
fi

View file

@ -7,11 +7,13 @@ include:
- '/templates/ci-fairy.yml'
variables:
FDO_DISTRIBUTION_TAG: latest
FDO_DISTRIBUTION_VERSION: rawhide
FEDORA_VERSION: 44
DEBIAN_VERSION: trixie
# Opaque tag without meaning. Change whenever we want our images to be rebuilt
FDO_DISTRIBUTION_TAG: "2026-05-28.7"
FDO_UPSTREAM_REPO: "upower/$CI_PROJECT_NAME"
FEDORA_IMAGE: "$CI_REGISTRY/upower/$CI_PROJECT_NAME/fedora/$FDO_DISTRIBUTION_VERSION:$FDO_DISTRIBUTION_TAG"
DEPENDENCIES:
FDO_DISTRIBUTION_EXEC: curl https://gitlab.freedesktop.org/hadess/check-abi/-/raw/main/contrib/check-abi-fedora.sh | bash
FEDORA_DEPENDENCIES:
gtk-doc
meson
gettext-devel
@ -35,7 +37,67 @@ variables:
python3-packaging
git
clang
LAST_ABI_BREAK: "9058d45685d1c7c08d52fb64c393fed9eeed542b"
glibc-langpack-fr
umockdev-devel
# Needed for libgudev from git and for pre-commit
FEDORA_EXTRA_DEPENDENCIES:
git
glibc-langpack-fr
umockdev-devel
libatomic
pre-commit
DEBIAN_DEPENDENCIES:
autoconf
automake
autopoint
autotools-dev
binutils
binutils-common
binutils-x86-64-linux-gnu
bsdextrautils
build-essential
bzip2
ca-certificates
cpp
cpp-14
cpp-14-x86-64-linux-gnu
cpp-x86-64-linux-gnu
curl
debhelper
git
g++
g++-14
g++-14-x86-64-linux-gnu
g++-x86-64-linux-gnu
gcc
gcc-14
gcc-14-x86-64-linux-gnu
gcc-x86-64-linux-gnu
libgirepository-1.0-dev
libimobiledevice-dev
m4
make
meson
systemd-dev
gobject-introspection
python3-dbus
python3-packaging
python3-dbusmock
gir1.2-upowerglib-1.0
libpolkit-gobject-1-dev
xsltproc
gtk-doc-tools
# Needed for libgudev from git
DEBIAN_EXTRA_DEPENDENCIES:
git
umockdev
libgudev-1.0-dev
libumockdev-dev
libumockdev0
libsystemd-dev
systemd
MESON_BUILDDIR: 'build'
LAST_ABI_BREAK: '9058d45685d1c7c08d52fb64c393fed9eeed542b'
workflow:
rules:
@ -46,13 +108,42 @@ workflow:
- if: $CI_PIPELINE_SOURCE == 'schedule'
stages:
- container-prep
- pre-commit
- check-source
- build
- test
- deploy
image: $FEDORA_IMAGE
.fedora-defaults:
extends:
- .fdo.distribution-image@fedora
variables:
FDO_DISTRIBUTION_VERSION: $FEDORA_VERSION
.debian-defaults:
extends:
- .fdo.distribution-image@debian
variables:
FDO_DISTRIBUTION_VERSION: $DEBIAN_VERSION
container_fedora_build:
extends:
- .fedora-defaults
- .fdo.container-build@fedora
stage: container-prep
variables:
GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
FDO_DISTRIBUTION_PACKAGES: $FEDORA_DEPENDENCIES $FEDORA_EXTRA_DEPENDENCIES
container_debian_build:
extends:
- .debian-defaults
- .fdo.container-build@debian
stage: container-prep
variables:
GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
FDO_DISTRIBUTION_PACKAGES: $DEBIAN_DEPENDENCIES $DEBIAN_EXTRA_DEPENDENCIES
verify_signoff:
extends:
@ -69,99 +160,82 @@ verify_signoff:
junit: results.xml
pre_commit:
extends:
- .fedora-defaults
stage: pre-commit
script:
- dnf install -y libatomic
- dnf install -y pre-commit
- pre-commit run --all-files
needs:
- container_fedora_build
test_nut_hwdb:
extends:
- .fedora-defaults
stage: check-source
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
allow_failure: true
script:
- curl https://raw.githubusercontent.com/networkupstools/nut/master/scripts/upower/95-upower-hid.hwdb >rules/95-upower-hid.hwdb
- git diff --exit-code
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
needs:
- container_fedora_build
build:
# We should really cache this between jobs but a quick clone shouldn't hurt us
.install_libgudev_from_git: &install_libgudev_from_git
- git -c http.sslVerify=false clone --depth=1 https://gitlab.gnome.org/GNOME/libgudev.git libgudev-"$CI_JOB_ID"
- cd libgudev-"$CI_JOB_ID"
- meson "$MESON_BUILDDIR" -Dprefix=/usr
- ninja -C "$MESON_BUILDDIR" install
- cd ..
.build:
stage: build
before_script:
- git clone https://gitlab.gnome.org/GNOME/libgudev.git
- cd libgudev
- dnf install -y glibc-langpack-fr umockdev-devel
- meson _build -Dprefix=/usr
- ninja -C _build install
- cd ..
- *install_libgudev_from_git
script:
- meson _build -Dintrospection=enabled -Dman=true -Dgtk-doc=true -Didevice=enabled
- ninja -C _build
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
- .ci/meson-build.sh --skip-test
# avoid recompiling in test stage
artifacts:
name: untracked
paths:
- "${CI_PROJECT_DIR}"
expire_in: 3h30min
variables:
MESON_ARGS: '-Dintrospection=enabled -Dman=true -Dgtk-doc=true -Didevice=enabled'
needs:
- container_fedora_build
build_fedora:
extends:
- .fedora-defaults
- .build
needs:
- container_fedora_build
build_debian:
stage: build
image: registry.freedesktop.org/upower/upower/debian/trixie:latest
before_script:
- apt update
- apt install -y git
- git -c http.sslVerify=false clone https://gitlab.gnome.org/GNOME/libgudev.git
- cd libgudev
- apt install -y umockdev libumockdev-dev libumockdev0 libsystemd-dev systemd
- meson _debian_build -Dprefix=/usr
- ninja -C _debian_build install
- cd ..
script:
- meson _debian_build -Dintrospection=enabled -Dman=true -Dgtk-doc=true -Didevice=enabled
- ninja -C _debian_build
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
# avoid recompiling in test stage
artifacts:
name: untracked
paths:
- "${CI_PROJECT_DIR}"
expire_in: 3h30min
extends:
- .debian-defaults
- .build
needs:
- container_debian_build
# Compile test the other backends (they don't have extra dependencies currently)
.build_backend_template: &build_backend
build_backend:
parallel:
matrix:
- BACKEND: [dummy, freebsd, openbsd]
extends:
- .fedora-defaults
stage: build
script:
- CFLAGS=-DUPOWER_CI_DISABLE_PLATFORM_CODE=1 meson _build -Dos_backend=$backend
- ninja -C _build
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
build_dummy:
- .ci/meson-build.sh --skip-test
variables:
backend: dummy
<<: *build_backend
CFLAGS: '-DUPOWER_CI_DISABLE_PLATFORM_CODE=1'
MESON_ARGS: '-Dos_backend=$BACKEND'
build_freebsd:
variables:
backend: freebsd
<<: *build_backend
build_openbsd:
variables:
backend: openbsd
<<: *build_backend
test:
.test:
stage: test
dependencies:
- build
before_script:
- git clone https://github.com/zatrazz/glibc-tools.git
- cd glibc-tools
@ -169,150 +243,58 @@ test:
- make install
- cd ..
script:
- meson _build -Dintrospection=enabled -Dman=true -Dgtk-doc=true -Didevice=enabled
- ninja -C _build
- catchsegv meson test -C _build --print-errorlogs --no-stdsplit
- .ci/fail_skipped_tests.py _build/meson-logs/testlog.junit.xml
- catchsegv meson test -C "$MESON_BUILDDIR" --print-errorlogs --no-stdsplit
- .ci/fail_skipped_tests.py "$MESON_BUILDDIR"/meson-logs/testlog.junit.xml
artifacts:
when: always
expire_in: 1 week
paths:
- "${CI_PROJECT_DIR}/_build/meson-logs/"
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
- "${CI_PROJECT_DIR}/$MESON_BUILDDIR/meson-logs/"
test_fedora:
extends:
- .fedora-defaults
- .test
needs:
- build_fedora
test_debian:
stage: test
image: registry.freedesktop.org/upower/upower/debian/trixie:latest
dependencies:
- build_debian
before_script:
- git -c http.sslVerify=false clone https://github.com/zatrazz/glibc-tools.git
- cd glibc-tools
- ./configure
- make install
- cd ..
- cd libgudev
- apt update
- apt install -y umockdev libumockdev-dev libumockdev0 libsystemd-dev systemd
- ninja -C _debian_build install
- cd ..
script:
- meson _debian_build -Dintrospection=enabled -Dman=true -Dgtk-doc=true -Didevice=enabled --wipe
- ninja -C _debian_build
- catchsegv meson test -C _debian_build --print-errorlogs --no-stdsplit
- .ci/fail_skipped_tests.py _debian_build/meson-logs/testlog.junit.xml
artifacts:
when: always
expire_in: 1 week
paths:
- "${CI_PROJECT_DIR}/_debian_build/meson-logs/"
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
extends:
- .debian-defaults
- .test
needs:
- build_debian
check_abi:
extends:
- .fedora-defaults
stage: test
before_script:
- cd libgudev
- dnf install -y glibc-langpack-fr umockdev-devel
- meson _build -Dprefix=/usr
- ninja -C _build install
- cd ..
- *install_libgudev_from_git
script:
- check-abi --suppr .ci/upower.suppr --parameters="-Dman=false -Dgtk-doc=false -Didevice=enabled" ${LAST_ABI_BREAK} $(git rev-parse HEAD)
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
needs:
- build_fedora
# Create docs artifact for the website.
# Note that the last successful artifact build is always kept, so 1 day as
# expiry is completely fine.
docs:
extends:
- .fedora-defaults
stage: deploy
dependencies:
- build
needs:
- build_fedora
script:
- meson _build -Dintrospection=enabled -Dman=true -Dgtk-doc=true -Didevice=enabled
- ninja -C _build/ UPower-doc
- .ci/meson-build.sh --skip-test
artifacts:
name: "docs"
when: always
expire_in: 1 day
paths:
- "_build/doc/html"
- "$MESON_BUILDDIR/doc/html"
only:
- master
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
# CONTAINERS creation stage
container_fedora_build:
extends: .fdo.container-build@fedora
only:
variables:
- $CI_PIPELINE_SOURCE == "schedule" && $CRON_TASK == "BUILD_CI_IMAGES"
variables:
GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
FDO_FORCE_REBUILD: 1
# a list of packages to install
FDO_DISTRIBUTION_PACKAGES:
$DEPENDENCIES
FDO_DISTRIBUTION_EXEC: |
curl https://gitlab.freedesktop.org/hadess/check-abi/-/raw/main/contrib/check-abi-fedora.sh | bash
# CONTAINERS creation stage
container_debian_build:
extends: .fdo.container-build@debian
only:
variables:
- $CI_PIPELINE_SOURCE == "schedule" && $CRON_TASK == "BUILD_CI_IMAGES"
variables:
FDO_DISTRIBUTION_TAG: latest
FDO_DISTRIBUTION_VERSION: trixie
GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
FDO_FORCE_REBUILD: 1
# a list of packages to install
FDO_DISTRIBUTION_PACKAGES:
autoconf
automake
autopoint
autotools-dev
binutils
binutils-common
binutils-x86-64-linux-gnu
bsdextrautils
build-essential
bzip2
cpp
cpp-14
cpp-14-x86-64-linux-gnu
cpp-x86-64-linux-gnu
curl
debhelper
git
g++
g++-14
g++-14-x86-64-linux-gnu
g++-x86-64-linux-gnu
gcc
gcc-14
gcc-14-x86-64-linux-gnu
gcc-x86-64-linux-gnu
m4
make
systemd-dev
python3-dbus
python3-packaging
python3-dbusmock
gir1.2-upowerglib-1.0
libpolkit-gobject-1-dev
FDO_DISTRIBUTION_EXEC: >-
echo "deb-src http://deb.debian.org/debian/ trixie main contrib non-free" >> /etc/apt/sources.list &&
apt update &&
apt build-dep -y upower &&
curl https://gitlab.freedesktop.org/hadess/check-abi/-/raw/main/contrib/check-abi-fedora.sh | bash
MESON_ARGS: '-Dintrospection=enabled -Dman=true -Dgtk-doc=true -Didevice=enabled'
MESON_EXTRA_ARGS: 'Upower-doc'