]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
CI: Add mkosi boot tests 17787/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 30 Nov 2020 20:57:52 +0000 (20:57 +0000)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Fri, 4 Dec 2020 22:24:12 +0000 (22:24 +0000)
Using the new mkosi Github Action, we can add some simple boot tests
for the systemd mkosi configs. This makes sure these keep working
as expected.

.github/workflows/mkosi.yml [new file with mode: 0644]
.github/workflows/test_mkosi_boot.py [new file with mode: 0755]

diff --git a/.github/workflows/mkosi.yml b/.github/workflows/mkosi.yml
new file mode 100644 (file)
index 0000000..7c55d7d
--- /dev/null
@@ -0,0 +1,42 @@
+name: mkosi
+
+# Simple boot tests that build and boot the mkosi images generated by the mkosi config files in .mkosi.
+
+on:
+  push:
+    branches:
+      - master
+  pull_request:
+    branches:
+      - master
+
+jobs:
+  ci:
+    runs-on: ubuntu-20.04
+    strategy:
+      fail-fast: false
+      matrix:
+        distro:
+          - arch
+          - debian
+          - ubuntu
+          - fedora
+
+    steps:
+    - uses: actions/checkout@v2
+    - uses: systemd/mkosi@v8
+
+    - name: Install
+      run: sudo apt-get update && sudo apt-get install --no-install-recommends
+        ovmf
+        python3-pexpect
+        qemu-system-x86-64
+
+    - name: Build ${{ matrix.distro }}
+      run: sudo python3 -m mkosi --default .mkosi/mkosi.${{ matrix.distro }} --password= --qemu-headless build
+
+    - name: Boot ${{ matrix.distro }} systemd-nspawn
+      run: sudo ./.github/workflows/test_mkosi_boot.py python3 -m mkosi --default .mkosi/mkosi.${{ matrix.distro }} --password= --qemu-headless boot
+
+    - name: Boot ${{ matrix.distro }} QEMU
+      run: sudo ./.github/workflows/test_mkosi_boot.py python3 -m mkosi --default .mkosi/mkosi.${{ matrix.distro }} --password= --qemu-headless qemu
diff --git a/.github/workflows/test_mkosi_boot.py b/.github/workflows/test_mkosi_boot.py
new file mode 100755 (executable)
index 0000000..37904eb
--- /dev/null
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+import pexpect
+import sys
+
+
+def run() -> None:
+    p = pexpect.spawnu(" ".join(sys.argv[1:]), logfile=sys.stdout, timeout=300)
+
+    p.expect("login:")
+    p.sendline("root")
+
+    p.expect("#")
+    p.sendline("systemctl poweroff")
+
+    p.expect(pexpect.EOF)
+
+
+try:
+    run()
+except pexpect.EOF:
+    print("UNEXPECTED EOF")
+    sys.exit(1)
+except pexpect.TIMEOUT:
+    print("TIMED OUT")
+    sys.exit(1)