Skip to content

Commit 79b7472

Browse files
committed
ci: Run QEMU tox integration tests in GitHub workflow
GitHub workflows recently grew the ability to set up nested QEMU kvm, but without much fanfare (see [1]). It just needs to create the `/dev/kvm` device node, but the host has it enabled and the kernel supports it. With that we can run the QEMU tox tests. They are not covered anywhere else, and currently have some bugs, so let's cover them in CI and keep them green. [1] https://github.com/orgs/community/discussions/8305
1 parent 3ffcc73 commit 79b7472

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: QEMU/KVM Integration tests
3+
on: # yamllint disable-line rule:truthy
4+
pull_request:
5+
merge_group:
6+
branches:
7+
- main
8+
types:
9+
- checks_requested
10+
push:
11+
branches:
12+
- main
13+
workflow_dispatch:
14+
env:
15+
TOX_ENV: qemu-ansible-core-2.16
16+
17+
permissions:
18+
contents: read
19+
jobs:
20+
tox:
21+
runs-on: ubuntu-latest
22+
23+
strategy:
24+
fail-fast: false
25+
matrix:
26+
image:
27+
- centos-9
28+
- centos-10
29+
# ansible/libdnf5 bug: https://issues.redhat.com/browse/RHELMISC-10110
30+
# - fedora-41
31+
- fedora-42
32+
33+
steps:
34+
- name: Set up /dev/kvm
35+
run: |
36+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm.rules
37+
sudo udevadm control --reload-rules
38+
sudo udevadm trigger --name-match=kvm --settle
39+
ls -l /dev/kvm
40+
41+
- name: Disable man-db to speed up package install
42+
run: |
43+
echo "set man-db/auto-update false" | sudo debconf-communicate
44+
sudo dpkg-reconfigure man-db
45+
46+
- name: Install test dependencies
47+
run: |
48+
set -euxo pipefail
49+
python3 -m pip install --upgrade pip
50+
sudo apt update
51+
sudo apt install -y --no-install-recommends git ansible-core genisoimage qemu-system-x86
52+
pip3 install "git+https://github.com/linux-system-roles/[email protected]"
53+
54+
- name: Checkout repo
55+
uses: actions/checkout@v4
56+
57+
- name: Configure tox-lsr
58+
run: |
59+
curl -o ~/.config/linux-system-roles.json https://raw.githubusercontent.com/linux-system-roles/linux-system-roles.github.io/master/download/linux-system-roles.json
60+
61+
- name: Run tox integration tests
62+
run: tox -e ${{ env.TOX_ENV }} -- --image-name ${{ matrix.image }} --make-batch --log-level=debug --
63+
64+
- name: Test result summary
65+
if: always()
66+
run: |
67+
set -euo pipefail
68+
while read code start end f; do
69+
if [ "$code" = "0" ]; then
70+
echo -n "PASS: "
71+
else
72+
echo -n "FAIL: "
73+
fi
74+
echo "$(basename $f)"
75+
done < batch.report
76+
77+
- name: Show test logs on failure
78+
if: failure()
79+
run: |
80+
set -euo pipefail
81+
for f in tests/*.log; do
82+
echo "::group::$(basename $f)"
83+
cat "$f"
84+
echo "::endgroup::"
85+
done

0 commit comments

Comments
 (0)