Skip to content

Commit bacf7c6

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 bacf7c6

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

.github/workflows/ansible-tox.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
name: Ansible tox
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: Install test dependencies
42+
run: |
43+
set -euxo pipefail
44+
python3 -m pip install --upgrade pip
45+
sudo apt update
46+
sudo apt install -y git ansible-core genisoimage qemu-system-x86
47+
pip3 install "git+https://github.com/linux-system-roles/[email protected]"
48+
49+
- name: Checkout repo
50+
uses: actions/checkout@v4
51+
52+
- name: Configure tox-lsr
53+
run: |
54+
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
55+
56+
- name: Run tox integration tests
57+
run: tox -e ${{ env.TOX_ENV }} -- --image-name ${{ matrix.image }} --make-batch --log-level=debug --
58+
59+
- name: Test result summary
60+
if: always()
61+
run: |
62+
set -euo pipefail
63+
while read code start end f; do
64+
if [ "$code" = "0" ]; then
65+
echo -n "PASS: "
66+
else
67+
echo -n "FAIL: "
68+
fi
69+
echo "$(basename $f)"
70+
done < batch.report
71+
72+
- name: Show test logs on failure
73+
if: failure()
74+
run: |
75+
set -euo pipefail
76+
for f in tests/*.log; do
77+
echo "::group::$(basename $f)"
78+
cat "$f"
79+
echo "::endgroup::"
80+
done

0 commit comments

Comments
 (0)