CI: start a full systemd environment before running the testsuite
authorBenjamin Tissoires <benjamin.tissoires@gmail.com>
Thu, 5 Aug 2021 13:17:27 +0000 (15:17 +0200)
committerBenjamin Tissoires <benjamin.tissoires@gmail.com>
Fri, 2 Sep 2022 06:39:44 +0000 (08:39 +0200)
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
.gitlab-ci.yml
.gitlab-ci/ci.template
.gitlab-ci/start-in-systemd.sh [new file with mode: 0755]

index 3427201..42c48ef 100644 (file)
@@ -406,7 +406,7 @@ freebsd:13.0@container-clean:
     B2C_KERNEL: https://gitlab.freedesktop.org/api/v4/projects/libevdev%2Fhid-tools/packages/generic/kernel-x86_64/v5.19/bzImage
     B2C_VERSION: v0.9.8
     B2C_IMAGE: $FDO_DISTRIBUTION_IMAGE
-    B2C_COMMAND: .gitlab-ci/meson-build.sh
+    B2C_COMMAND: .gitlab-ci/start-in-systemd.sh
   script:
     # pull b2c
     - curl -L -o /app/boot2container https://gitlab.freedesktop.org/mupuf/boot2container/-/raw/v0.9.8/vm2c.py
index 1542b66..30885a6 100644 (file)
@@ -282,7 +282,7 @@ check-commit:
     B2C_KERNEL: {{ b2c.kernel }}
     B2C_VERSION: {{ b2c.version }}
     B2C_IMAGE: $FDO_DISTRIBUTION_IMAGE
-    B2C_COMMAND: .gitlab-ci/meson-build.sh
+    B2C_COMMAND: .gitlab-ci/start-in-systemd.sh
   script:
     # pull b2c
     - curl -L -o /app/boot2container https://gitlab.freedesktop.org/mupuf/boot2container/-/raw/{{b2c.version}}/vm2c.py
diff --git a/.gitlab-ci/start-in-systemd.sh b/.gitlab-ci/start-in-systemd.sh
new file mode 100755 (executable)
index 0000000..b505b20
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/env bash
+
+set -x
+
+systemd_target=basic.target
+post_command="/usr/bin/systemctl exit \$EXIT_STATUS"
+
+while [[ $# -gt 0 ]]; do
+       case $1 in
+               --debug-mode)
+                       shift
+                       systemd_target=multi-user.target
+                       post_command="echo you can now log in as root (no password) and then turn off by running \'/usr/bin/systemctl exit \$EXIT_STATUS\'"
+                       ;;
+               *)
+                       echo "Unknow commandline argument $1"
+                       exit 1
+                       ;;
+       esac
+done
+
+WORKDIR=${FDO_DISTRIBUTION_WORKINGDIR:-$PWD}
+B2C_WORKDIR=${FDO_B2C_WORKDIR:-/app}
+
+# remove root password for debugging
+sed -i 's/root:!locked::/root:::/' /etc/shadow
+
+# create a libinput test suite service
+cat <<EOF > /etc/systemd/system/libinput-testsuite.service
+
+[Unit]
+Description=Libinput test suite
+After=$systemd_target
+
+[Service]
+Type=simple
+StandardOutput=journal+console
+EnvironmentFile=$B2C_WORKDIR/.b2c_env
+WorkingDirectory=$WORKDIR
+ExecStart=$WORKDIR/.gitlab-ci/meson-build.sh
+
+# exit the container on termination
+ExecStopPost=$post_command
+
+[Install]
+WantedBy=default.target
+EOF
+
+cat /etc/systemd/system/libinput-testsuite.service
+
+# enable the service
+systemctl enable libinput-testsuite.service
+
+# disable some services we don't need in the CI
+systemctl mask network-online.target
+systemctl mask network-pre.target
+systemctl mask timers.target
+systemctl mask dnf-makecache.timer
+systemctl mask systemd-logind.service
+systemctl mask rpmdb-migrate.service
+systemctl mask systemd-network-generator.service
+systemctl mask cryptsetup-pre.target
+systemctl mask cryptsetup.target
+
+#change default target
+systemctl set-default $systemd_target
+
+# start the system
+exec /usr/sbin/init