Skip to content

Commit 96f6838

Browse files
committed
CI: migrate Vagrant + Cirrus to Lima + GHA
- Unlike proprietary Vagrant, Lima remains to be an open source project - GHA now natively supports nested virt on Linux runners Signed-off-by: Akihiro Suda <[email protected]> (cherry picked from commit 135552e) Signed-off-by: Akihiro Suda <[email protected]>
1 parent 4dbf9ac commit 96f6838

File tree

4 files changed

+99
-121
lines changed

4 files changed

+99
-121
lines changed

.cirrus.yml

+2-68
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,10 @@
11
---
2-
# We use Cirrus for RHEL clones (native) and Fedora (in Vagrant), because
3-
# neither is available on GHA natively, so the only option is VM.
4-
# In GHA, nested virtualization is only supported on macOS instances, which
5-
# are slow and flaky.
2+
# We use Cirrus for RHEL clones because Cirrus can directly run them
3+
# without depending on nested virtualization.
64

75
# NOTE Cirrus execution environments lack a terminal, needed for
86
# some integration tests. So we use `ssh -tt` command to fake a terminal.
97

10-
task:
11-
timeout_in: 30m
12-
13-
env:
14-
DEBIAN_FRONTEND: noninteractive
15-
HOME: /root
16-
# yamllint disable rule:key-duplicates
17-
matrix:
18-
DISTRO: fedora
19-
20-
name: vagrant DISTRO:$DISTRO
21-
22-
compute_engine_instance:
23-
image_project: cirrus-images
24-
image: family/docker-kvm
25-
platform: linux
26-
nested_virtualization: true
27-
# CPU limit: `16 / NTASK`: see https://cirrus-ci.org/faq/#are-there-any-limits
28-
cpu: 4
29-
# Memory limit: `4GB * NCPU`
30-
memory: 16G
31-
32-
host_info_script: |
33-
uname -a
34-
# -----
35-
cat /etc/os-release
36-
# -----
37-
df -T
38-
# -----
39-
cat /proc/cpuinfo
40-
install_libvirt_vagrant_script: |
41-
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
42-
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
43-
sudo sed -i 's/^# deb-src/deb-src/' /etc/apt/sources.list
44-
apt-get update
45-
apt-get install -y libvirt-daemon libvirt-daemon-system vagrant
46-
systemctl enable --now libvirtd
47-
apt-get build-dep -y vagrant ruby-libvirt
48-
apt-get install -y --no-install-recommends libxslt-dev libxml2-dev libvirt-dev ruby-bundler ruby-dev zlib1g-dev
49-
vagrant plugin install vagrant-libvirt
50-
vagrant_cache:
51-
fingerprint_script: cat Vagrantfile.$DISTRO
52-
folder: /root/.vagrant.d/boxes
53-
vagrant_up_script: |
54-
ln -sf Vagrantfile.$DISTRO Vagrantfile
55-
# Retry if it fails (download.fedoraproject.org returns 404 sometimes)
56-
vagrant up --no-tty || vagrant up --no-tty
57-
mkdir -p -m 0700 /root/.ssh
58-
vagrant ssh-config >> /root/.ssh/config
59-
guest_info_script: |
60-
ssh default 'sh -exc "uname -a && systemctl --version && df -T && cat /etc/os-release && go version && sestatus && rpm -q container-selinux"'
61-
check_config_script: |
62-
ssh default /vagrant/script/check-config.sh
63-
unit_tests_script: |
64-
ssh default 'sudo -i make -C /vagrant localunittest'
65-
integration_systemd_script: |
66-
ssh -tt default "sudo -i make -C /vagrant localintegration RUNC_USE_SYSTEMD=yes"
67-
integration_fs_script: |
68-
ssh -tt default "sudo -i make -C /vagrant localintegration"
69-
integration_systemd_rootless_script: |
70-
ssh -tt default "sudo -i make -C /vagrant localrootlessintegration RUNC_USE_SYSTEMD=yes"
71-
integration_fs_rootless_script: |
72-
ssh -tt default "sudo -i make -C /vagrant localrootlessintegration"
73-
748
task:
759
timeout_in: 30m
7610

.github/workflows/test.yml

+62
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,72 @@ jobs:
217217
- name: unit test
218218
run: sudo -E PATH="$PATH" -- make GOARCH=386 localunittest
219219

220+
fedora:
221+
timeout-minutes: 30
222+
runs-on: ubuntu-24.04
223+
steps:
224+
- uses: actions/checkout@v4
225+
226+
- uses: lima-vm/lima-actions/setup@v1
227+
id: lima-actions-setup
228+
229+
- uses: actions/cache@v4
230+
with:
231+
path: ~/.cache/lima
232+
key: lima-${{ steps.lima-actions-setup.outputs.version }}
233+
234+
- name: "Start VM"
235+
# --plain is set to disable file sharing, port forwarding, built-in containerd, etc. for faster start up
236+
#
237+
# CPUs: min(4, host CPU cores)
238+
# RAM: min(4 GiB, half of host memory)
239+
# Disk: 100 GiB
240+
run: limactl start --plain --name=default template://fedora
241+
242+
- name: "Initialize VM"
243+
run: |
244+
set -eux -o pipefail
245+
limactl cp -r . default:/tmp/runc
246+
lima sudo /tmp/runc/script/setup_host_fedora.sh
247+
248+
- name: "Show guest info"
249+
run: |
250+
set -eux -o pipefail
251+
lima uname -a
252+
lima systemctl --version
253+
lima df -T
254+
lima cat /etc/os-release
255+
lima go version
256+
lima sestatus
257+
lima rpm -q container-selinux
258+
259+
- name: "Check config"
260+
run: lima /tmp/runc/script/check-config.sh
261+
262+
# NOTE the execution environment lacks a terminal, needed for
263+
# some integration tests. So we use `ssh -tt` command to fake a terminal.
264+
- uses: lima-vm/lima-actions/ssh@v1
265+
266+
- name: "Run unit tests"
267+
run: ssh -tt lima-default sudo -i make -C /tmp/runc localunittest
268+
269+
- name: "Run integration tests (systemd driver)"
270+
run: ssh -tt lima-default sudo -i make -C /tmp/runc localintegration RUNC_USE_SYSTEMD=yes
271+
272+
- name: "Run integration tests (fs driver)"
273+
run: ssh -tt lima-default sudo -i make -C /tmp/runc localintegration
274+
275+
- name: "Run integration tests (systemd driver, rootless)"
276+
run: ssh -tt lima-default sudo -i make -C /tmp/runc localrootlessintegration RUNC_USE_SYSTEMD=yes
277+
278+
- name: "Run integration tests (fs driver, rootless)"
279+
run: ssh -tt lima-default sudo -i make -C /tmp/runc localrootlessintegration
280+
220281
all-done:
221282
needs:
222283
- test
223284
- cross-i386
285+
- fedora
224286
runs-on: ubuntu-24.04
225287
steps:
226288
- run: echo "All jobs completed"

Vagrantfile.fedora

-53
This file was deleted.

script/setup_host_fedora.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
set -eux -o pipefail
3+
DNF_OPTS="-y --setopt=install_weak_deps=False --setopt=tsflags=nodocs --exclude=kernel,kernel-core"
4+
RPMS="bats git-core glibc-static golang jq libseccomp-devel make"
5+
# Work around dnf mirror failures by retrying a few times.
6+
for i in $(seq 0 2); do
7+
sleep "$i"
8+
# shellcheck disable=SC2086
9+
dnf $DNF_OPTS update && dnf $DNF_OPTS install $RPMS && break
10+
done
11+
dnf clean all
12+
13+
# To avoid "avc: denied { nosuid_transition }" from SELinux as we run tests on /tmp.
14+
mount -o remount,suid /tmp
15+
16+
# Add a user for rootless tests
17+
useradd -u2000 -m -d/home/rootless -s/bin/bash rootless
18+
19+
# Allow root and rootless itself to execute `ssh rootless@localhost` in tests/rootless.sh
20+
ssh-keygen -t ecdsa -N "" -f /root/rootless.key
21+
# shellcheck disable=SC2174
22+
mkdir -m 0700 -p /home/rootless/.ssh
23+
cp /root/rootless.key /home/rootless/.ssh/id_ecdsa
24+
cat /root/rootless.key.pub >>/home/rootless/.ssh/authorized_keys
25+
chown -R rootless.rootless /home/rootless
26+
27+
# Delegate cgroup v2 controllers to rootless user via --systemd-cgroup
28+
mkdir -p /etc/systemd/system/[email protected]
29+
cat >/etc/systemd/system/[email protected]/delegate.conf <<EOF
30+
[Service]
31+
# default: Delegate=pids memory
32+
# NOTE: delegation of cpuset requires systemd >= 244 (Fedora >= 32, Ubuntu >= 20.04).
33+
Delegate=yes
34+
EOF
35+
systemctl daemon-reload

0 commit comments

Comments
 (0)