CI: Add mkosi boot tests

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.
This commit is contained in:
Daan De Meyer 2020-11-30 20:57:52 +00:00
parent 8f2c4c5e93
commit 448d3462b0
2 changed files with 69 additions and 0 deletions

42
.github/workflows/mkosi.yml vendored Normal file
View File

@ -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

27
.github/workflows/test_mkosi_boot.py vendored Executable file
View File

@ -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)