Skip to content

Commit 4f34ce0

Browse files
committed
ci: run the checks of the Makefile on GitHub Actions
Nothing runs the checks of the Makefile on a change before it lands. Add a workflow that runs them on ubuntu-24.04 for every pull request and every push to main: - lint-and-test: make setup, then make -k -o qemu, which runs every check but the QEMU boots. - qemu: the packages of tests/qemu/ubuntu-packages, the udev rule that GitHub documents to open /dev/kvm to the runner user, then make qemu. The kernel RPMs and DriverSample.efi are cached under a key of the files that pin them and saved only when the job passes, as run.sh reuses DriverSample.efi unchecked. The logs of failed boots are uploaded. The actions are pinned to commit SHAs, and the token can only read the repository. Signed-off-by: Dmitrii Okunev <xaionaro@meta.com>
1 parent a568f54 commit 4f34ce0

2 files changed

Lines changed: 81 additions & 0 deletions

File tree

‎.github/workflows/checks.yml‎

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# The checks of the Makefile; the QEMU boots, which need KVM and apt packages, in
2+
# a job of their own.
3+
name: ci
4+
5+
on:
6+
push:
7+
branches: [main]
8+
pull_request:
9+
10+
permissions:
11+
contents: read
12+
13+
# PRs: a new push cancels the previous run. main: one group per run, as a shared
14+
# group drops pending runs.
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.run_id || github.ref }}
17+
cancel-in-progress: true
18+
19+
jobs:
20+
lint-and-test:
21+
runs-on: ubuntu-24.04
22+
timeout-minutes: 60
23+
steps:
24+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
25+
with:
26+
persist-credentials: false
27+
28+
- run: make setup
29+
30+
# After setup: the key covers installed toolchains.
31+
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 # v2.9.2
32+
33+
# Every check but the boots.
34+
- run: make -k -o qemu
35+
36+
qemu:
37+
runs-on: ubuntu-24.04
38+
timeout-minutes: 120
39+
steps:
40+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
41+
with:
42+
persist-credentials: false
43+
44+
- run: |
45+
sudo apt-get update
46+
xargs --arg-file=tests/qemu/ubuntu-packages sudo apt-get install --yes
47+
48+
# Opens /dev/kvm to the runner user, per
49+
# https://github.blog/changelog/2024-04-02-github-actions-hardware-accelerated-android-virtualization-now-available/
50+
- run: |
51+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' |
52+
sudo tee /etc/udev/rules.d/99-kvm4all.rules
53+
sudo udevadm control --reload-rules
54+
sudo udevadm trigger --name-match=kvm
55+
56+
# No rust-cache: its cleanup takes run.sh's initramfs/tests for a cargo
57+
# profile and logs errors; the builds take about a minute without it.
58+
- run: make setup
59+
60+
# Kernel RPMs and DriverSample.efi. Saved only on success, as run.sh reuses
61+
# DriverSample.efi unchecked.
62+
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
63+
with:
64+
path: |
65+
target/qemu-test/kernel-rpms
66+
target/qemu-test/driver-sample
67+
key: qemu-inputs-${{ hashFiles('tests/qemu/kernel.sha256', 'tests/qemu/build-driver-sample.sh') }}
68+
69+
- run: make qemu
70+
71+
- if: failure()
72+
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
73+
with:
74+
name: qemu-test-logs
75+
path: |
76+
target/qemu-test/*/*/*.log
77+
target/qemu-test/*/executables
78+
if-no-files-found: ignore
79+
retention-days: 14

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ make help # lists the checks
159159

160160
`make qemu`, the QEMU tests, also needs an x86_64 host with `/dev/kvm` and the packages that [`tests/qemu/README.md`](tests/qemu/README.md) lists.
161161

162+
GitHub Actions runs the checks on every pull request and every push to main, as [`.github/workflows/checks.yml`](.github/workflows/checks.yml) describes.
163+
162164
## QEMU tests
163165

164166
End-to-end tests boot QEMU guests and run `uefisettings` against emulated firmware; [`tests/qemu/README.md`](tests/qemu/README.md) explains how to run them.

0 commit comments

Comments
 (0)