CI: in b2c, compile on the host, then test in qemu
authorBenjamin Tissoires <benjamin.tissoires@gmail.com>
Thu, 11 Aug 2022 05:19:14 +0000 (07:19 +0200)
committerBenjamin Tissoires <benjamin.tissoires@gmail.com>
Fri, 2 Sep 2022 06:41:28 +0000 (08:41 +0200)
Looks like we are having clock skew issues on qemu, so given that
we just need qemu in the image, we can compile on the host (reliable)
and then only start the tests in qemu.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
.gitlab-ci.yml
.gitlab-ci/ci.template
.gitlab-ci/config.yml
.gitlab-ci/meson-build.sh
.gitlab-ci/meson-prep.sh [new file with mode: 0644]
.gitlab-ci/meson-test.sh [new file with mode: 0755]
.gitlab-ci/start-in-systemd.sh

index 42c48ef..13cd24f 100644 (file)
@@ -76,7 +76,7 @@ variables:
   # See the documentation here:                                                 #
   # https://wayland.freedesktop.org/libinput/doc/latest/building_libinput.html  #
   ###############################################################################
-  FEDORA_PACKAGES:  'git-core gcc gcc-c++ pkgconf-pkg-config meson check-devel libudev-devel libevdev-devel doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx_rtd_theme python3-pytest-xdist libwacom-devel cairo-devel gtk4-devel glib2-devel mtdev-devel diffutils wayland-protocols-devel valgrind systemd-udev'
+  FEDORA_PACKAGES:  'git-core gcc gcc-c++ pkgconf-pkg-config meson check-devel libudev-devel libevdev-devel doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx_rtd_theme python3-pytest-xdist libwacom-devel cairo-devel gtk4-devel glib2-devel mtdev-devel diffutils wayland-protocols-devel valgrind systemd-udev qemu-img qemu-system-x86-core qemu-system-aarch64-core jq python3-click python3-rich'
   DEBIAN_PACKAGES:  'git gcc g++ pkg-config meson check libudev-dev libevdev-dev doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx-rtd-theme python3-pytest-xdist libwacom-dev libcairo2-dev libgtk-3-dev libglib2.0-dev libmtdev-dev curl'
   UBUNTU_PACKAGES:  'git gcc g++ pkg-config meson check libudev-dev libevdev-dev doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx-rtd-theme python3-pytest-xdist libwacom-dev libcairo2-dev libgtk-3-dev libglib2.0-dev libmtdev-dev'
   ARCH_PACKAGES:    'git gcc pkgconfig meson check libsystemd libevdev doxygen graphviz python-sphinx python-recommonmark python-sphinx_rtd_theme python-pytest-xdist libwacom gtk4 mtdev diffutils wayland-protocols'
@@ -88,12 +88,12 @@ variables:
   # changing these will force rebuilding the associated image
   # Note: these tags have no meaning and are not tied to a particular
   # libinput version
-  FEDORA_TAG:  '2022-08-08.0'
-  DEBIAN_TAG:  '2022-08-08.0'
-  UBUNTU_TAG:  '2022-08-08.0'
-  ARCH_TAG:    '2022-08-08.0'
-  ALPINE_TAG:  '2022-08-08.0'
-  FREEBSD_TAG: '2022-08-08.0'
+  FEDORA_TAG:  '2022-09-02.0'
+  DEBIAN_TAG:  '2022-09-02.0'
+  UBUNTU_TAG:  '2022-09-02.0'
+  ARCH_TAG:    '2022-09-02.0'
+  ALPINE_TAG:  '2022-09-02.0'
+  FREEBSD_TAG: '2022-09-02.0'
 
   FDO_UPSTREAM_REPO: libinput/libinput
 
@@ -397,7 +397,6 @@ freebsd:13.0@container-clean:
 .build-in-b2c@template:
   extends:
     - .policy
-    - .fdo.b2c-image@fedora
     - .default_artifacts
   tags:
     - kvm
@@ -408,9 +407,14 @@ freebsd:13.0@container-clean:
     B2C_IMAGE: $FDO_DISTRIBUTION_IMAGE
     B2C_COMMAND: .gitlab-ci/start-in-systemd.sh
   script:
+    # first build in the host container
+    - .gitlab-ci/meson-build.sh --skip-test
+
     # pull b2c
     - curl -L -o /app/boot2container https://gitlab.freedesktop.org/mupuf/boot2container/-/raw/v0.9.8/vm2c.py
     - chmod +x /app/boot2container
+
+    # runs the test suite only
     - /app/boot2container
 
 #
@@ -490,6 +494,7 @@ freebsd:13.0@container-clean:
 
 .fedora:36@test-suite-vm:
   extends:
+    - .fdo.distribution-image@fedora
     - .test-suite-vm
   variables:
     FDO_DISTRIBUTION_VERSION: 36
index 30885a6..dd7de66 100644 (file)
@@ -273,7 +273,6 @@ check-commit:
 .build-in-b2c@template:
   extends:
     - .policy
-    - .fdo.b2c-image@fedora
     - .default_artifacts
   tags:
     - kvm
@@ -284,9 +283,14 @@ check-commit:
     B2C_IMAGE: $FDO_DISTRIBUTION_IMAGE
     B2C_COMMAND: .gitlab-ci/start-in-systemd.sh
   script:
+    # first build in the host container
+    - .gitlab-ci/meson-build.sh --skip-test
+
     # pull b2c
     - curl -L -o /app/boot2container https://gitlab.freedesktop.org/mupuf/boot2container/-/raw/{{b2c.version}}/vm2c.py
     - chmod +x /app/boot2container
+
+    # runs the test suite only
     - /app/boot2container
 
 #
@@ -369,6 +373,7 @@ check-commit:
 {% set version = "{}".format(distro.versions|last()) %}
 .{{distro.name}}:{{version}}@test-suite-vm:
   extends:
+    - .fdo.distribution-image@{{distro.name}}
     - .test-suite-vm
   variables:
     FDO_DISTRIBUTION_VERSION: {{version}}
index 776ec4e..4615684 100644 (file)
@@ -3,7 +3,7 @@
 #
 
 # We're happy to rebuild all containers when one changes.
-.default_tag: &default_tag '2022-08-08.0'
+.default_tag: &default_tag '2022-09-02.0'
 
 distributions:
   - name: fedora
@@ -36,7 +36,14 @@ distributions:
       - diffutils
       - wayland-protocols-devel
       - valgrind        # for the valgrind run, optional
-      - systemd-udev    # for the qemu run, optional
+      # below packages are for the qemu runs, so optional
+      - systemd-udev    # for the qemu run
+      - qemu-img
+      - qemu-system-x86-core
+      - qemu-system-aarch64-core
+      - jq
+      - python3-click
+      - python3-rich
   - name: debian
     tag: *default_tag
     versions:
index 4d5330d..11fe03e 100755 (executable)
@@ -76,4 +76,3 @@ fi
 if [[ -n "$MESON_RUN_TEST" ]]; then
        meson test -C "$MESON_BUILDDIR" $MESON_TEST_ARGS --print-errorlogs
 fi
-
diff --git a/.gitlab-ci/meson-prep.sh b/.gitlab-ci/meson-prep.sh
new file mode 100644 (file)
index 0000000..e2630fe
--- /dev/null
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+set -x
+if [[ -f .meson_environment ]]; then
+       . .meson_environment
+fi
+
+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_JOB_ID=$(date +%s)
+       CI_JOB_NAME='libinput-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
+       NINJA_ARGS="-j$FDO_CI_CONCURRENT $NINJA_ARGS"
+       MESON_TESTTHREADS="$FDO_CI_CONCURRENT"
+fi
+
+echo "*************************************************"
+echo "builddir: $MESON_BUILDDIR"
+echo "meson args: $MESON_ARGS"
+echo "ninja args: $NINJA_ARGS"
+echo "meson test args: $MESON_TEST_ARGS"
+echo "*************************************************"
+
+set -e
diff --git a/.gitlab-ci/meson-test.sh b/.gitlab-ci/meson-test.sh
new file mode 100755 (executable)
index 0000000..ef72dfb
--- /dev/null
@@ -0,0 +1,12 @@
+#!/usr/bin/env bash
+
+DIR="${BASH_SOURCE%/*}"
+if [[ ! -d "$DIR" ]]; then DIR="$PWD"; fi
+. $DIR/meson-prep.sh
+
+if [[ -z "$MESON_TEST_ARGS" ]]; then
+    echo "\$MESON_TEST_ARGS undefined."
+    exit 1
+fi
+
+meson test -C "$MESON_BUILDDIR" $MESON_TEST_ARGS --print-errorlogs
index b505b20..99650d2 100755 (executable)
@@ -37,7 +37,7 @@ Type=simple
 StandardOutput=journal+console
 EnvironmentFile=$B2C_WORKDIR/.b2c_env
 WorkingDirectory=$WORKDIR
-ExecStart=$WORKDIR/.gitlab-ci/meson-build.sh
+ExecStart=$WORKDIR/.gitlab-ci/meson-build.sh --skip-setup --skip-build
 
 # exit the container on termination
 ExecStopPost=$post_command