gitlab-ci: use qemu to run the full test suite
authorBenjamin Tissoires <benjamin.tissoires@gmail.com>
Tue, 6 Aug 2019 10:40:44 +0000 (12:40 +0200)
committerBenjamin Tissoires <benjamin.tissoires@gmail.com>
Fri, 4 Oct 2019 18:02:33 +0000 (20:02 +0200)
We currently allow the stage to fail, but at least,
we can make use of it.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
.gitlab-ci.yml

index 67f25de..762d626 100644 (file)
 include:
   # Arch container builder template
   - project: 'wayland/ci-templates'
-    ref: 955e61e67cf29327cf907432f668df9eec4ca6a2 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
+    ref: ff90ddcf059bfce35bd5f9b89a59d5d0c912b458 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
     file: '/templates/arch.yml'
   # Fedora container builder template
   - project: 'wayland/ci-templates'
-    ref: 955e61e67cf29327cf907432f668df9eec4ca6a2 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
+    ref: ff90ddcf059bfce35bd5f9b89a59d5d0c912b458 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
     file: '/templates/fedora.yml'
   # Ubuntu container builder template
   - project: 'wayland/ci-templates'
-    ref: 955e61e67cf29327cf907432f668df9eec4ca6a2 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
+    ref: ff90ddcf059bfce35bd5f9b89a59d5d0c912b458 # see https://docs.gitlab.com/ee/ci/yaml/#includefile
     file: '/templates/ubuntu.yml'
 
 stages:
@@ -56,6 +56,7 @@ variables:
   # https://wayland.freedesktop.org/libinput/doc/latest/building_libinput.html  #
   ###############################################################################
   FEDORA_RPMS:        'git gcc gcc-c++ pkgconf-pkg-config meson check-devel libudev-devel libevdev-devel doxygen graphviz python3-sphinx python3-recommonmark                          libwacom-devel cairo-devel   gtk3-devel   glib2-devel    mtdev-devel'
+  FEDORA_QEMU_RPMS:   'git gcc gcc-c++ pkgconf-pkg-config meson check-devel libudev-devel libevdev-devel doxygen graphviz python3-sphinx python3-recommonmark                          libwacom-devel cairo-devel   gtk3-devel   glib2-devel    mtdev-devel diffutils valgrind'
   UBUNTU_CUSTOM_DEBS: 'git gcc g++     pkg-config         meson check       libudev-dev   libevdev-dev   doxygen graphviz python3-sphinx python3-recommonmark python3-sphinx-rtd-theme libwacom-dev   libcairo2-dev libgtk-3-dev libglib2.0-dev libmtdev-dev'
   ARCH_PKGS:          'git gcc         pkgconfig          meson check       libsystemd    libevdev       doxygen graphviz  python-sphinx  python-recommonmark python-sphinx_rtd_theme  libwacom                     gtk3                        mtdev      diffutils'
   FREEBSD_BUILD_PKGS: 'meson'
@@ -70,6 +71,7 @@ variables:
   UBUNTU_TAG: '2019-08-07.0'
   ARCH_TAG: '2019-08-07.0'
   FREEBSD_TAG: '2019-08-07.0'
+  QEMU_TAG: 'qemu-vm-2019-08-06.1'
 
   UBUNTU_EXEC: "bash .gitlab-ci/ubuntu_install.sh $UBUNTU_CUSTOM_DEBS"
 
@@ -79,6 +81,7 @@ variables:
   UBUNTU_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/ubuntu/$UBUNTU_VERSION:$UBUNTU_TAG
   ARCH_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/archlinux/rolling:$ARCH_TAG
   FREEBSD_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/freebsd/11.2:$FREEBSD_TAG
+  QEMU_CONTAINER_IMAGE: $CI_REGISTRY_IMAGE/fedora/$FEDORA_VERSION:$QEMU_TAG
 
   MESON_BUILDDIR: "build dir"
   NINJA_ARGS: ''
@@ -137,6 +140,21 @@ variables:
         skopeo inspect docker://$CI_REGISTRY_IMAGE/$IMAGE > /dev/null && exit 0 || true ;
       fi
 
+fedora:30@qemu-prep:
+  extends: .fedora@qemu-build
+  stage: container_prep
+  tags:
+    - kvm
+  variables:
+    GIT_STRATEGY: none
+    FEDORA_VERSION: 30
+    FEDORA_TAG: $QEMU_TAG
+    FEDORA_RPMS: $FEDORA_QEMU_RPMS
+    DISTRIB_FLAVOR: fedora
+    DISTRIB_VERSION: $FEDORA_VERSION
+    TAG: $QEMU_TAG
+  <<: *pull_upstream_or_rebuild
+
 fedora:30@container-prep:
   extends: .fedora@container-build
   stage: container_prep
@@ -361,6 +379,64 @@ freebsd:11.2@container-clean:
 # Fedora
 #
 
+.check_tainted: &check_tainted |
+  # make sure the kernel is not tainted
+  if [[ "$(ssh localhost -p 5555 cat /proc/sys/kernel/tainted)" -gt 0 ]];
+  then
+    echo tainted kernel ;
+    exit 1 ;
+  fi
+
+fedora:30@test-suite-vm:
+  stage: build
+  image: $QEMU_CONTAINER_IMAGE
+  tags:
+    - kvm
+  variables:
+    FEDORA_VERSION: 30
+    MESON_BUILDDIR: build_dir
+  script:
+    # start our vm, no args required
+    - /app/start_vm.sh
+
+    - *check_tainted
+
+    - "scp -P 5555 -r $PWD localhost:"
+    - ssh localhost -p 5555 rm -rf $CI_PROJECT_NAME/"$MESON_BUILDDIR"
+    - ssh localhost -p 5555 "cd $CI_PROJECT_NAME ; meson \"$MESON_BUILDDIR\" $MESON_ARGS"
+    - ssh localhost -p 5555 "cd $CI_PROJECT_NAME ; meson configure \"$MESON_BUILDDIR\" "
+    - ssh localhost -p 5555 "cd $CI_PROJECT_NAME ; ninja -C \"$MESON_BUILDDIR\" $NINJA_ARGS"
+    - ssh localhost -p 5555 "cd $CI_PROJECT_NAME ; meson test -C \"$MESON_BUILDDIR\" --print-errorlogs" && touch .success || true
+
+    # no matter the results of the tests, we want to fetch the logs
+    - scp -P 5555 -r localhost:$CI_PROJECT_NAME/$MESON_BUILDDIR .
+
+    - *check_tainted
+
+    - ssh localhost -p 5555 halt || true
+    - sleep 2
+    - kill $(pgrep qemu)
+
+    - if [[ ! -e .success ]] ;
+      then
+        exit 1 ;
+      fi
+
+  after_script:
+    # no matter the results of the tests, we want to kill the VM
+    - kill $(pgrep qemu)
+
+  artifacts:
+    name: "qemu-meson-logs-$CI_JOB_NAME"
+    when: always
+    expire_in: 1 week
+    paths:
+      - $MESON_BUILDDIR/meson-logs
+      - console.out
+
+  allow_failure: true
+
+
 .fedora-build@template:
   extends: .build@template
   image: $FEDORA_CONTAINER_IMAGE