Skip to content

Commit 8fa8899

Browse files
committed
github: Import and use bootc-ubuntu-setup action
Copy the bootc-ubuntu-setup action from bootc-dev/bootc and integrate it into both the main CI and C10S workflows. This action provides: - Disk space cleanup on GHA runners - Updated podman/just from Ubuntu plucky - Unprivileged /dev/kvm access via udev rules - Optional libvirt stack installation - Rust cache configuration The main workflow now uses this action with libvirt: 'true' to install the full virtualization stack, then removes the pre-installed bcvk binary to ensure we test the locally built version. The C10S workflow uses it for basic setup (podman, KVM access). This consolidates setup logic and ensures consistent environment configuration across workflows. Assisted-by: Claude Code (Sonnet 4.5) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 27b1cd7 commit 8fa8899

File tree

3 files changed

+112
-22
lines changed

3 files changed

+112
-22
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: 'Bootc Ubuntu Setup'
2+
description: 'Default host setup'
3+
inputs:
4+
libvirt:
5+
description: 'Install libvirt and virtualization stack'
6+
required: false
7+
default: 'false'
8+
runs:
9+
using: 'composite'
10+
steps:
11+
# The default runners have TONS of crud on them...
12+
- name: Free up disk space on runner
13+
shell: bash
14+
run: |
15+
set -xeuo pipefail
16+
sudo df -h
17+
unwanted_pkgs=('^aspnetcore-.*' '^dotnet-.*' '^llvm-.*' 'php.*' '^mongodb-.*' '^mysql-.*'
18+
azure-cli google-chrome-stable firefox mono-devel)
19+
unwanted_dirs=(/usr/share/dotnet /opt/ghc /usr/local/lib/android /opt/hostedtoolcache/CodeQL)
20+
# Start background removal operations as systemd units; if this causes
21+
# races in the future around disk space we can look at waiting for cleanup
22+
# before starting further jobs, but right now we spent a lot of time waiting
23+
# on the network and scripts and such below, giving these plenty of time to run.
24+
n=0
25+
runcleanup() {
26+
sudo systemd-run -r -u action-cleanup-${n} -- "$@"
27+
n=$(($n + 1))
28+
}
29+
runcleanup docker image prune --all --force
30+
for x in ${unwanted_dirs[@]}; do
31+
runcleanup rm -rf "$x"
32+
done
33+
# Apt removals in foreground, as we can't parallelize these
34+
for x in ${unwanted_pkgs[@]}; do
35+
/bin/time -f '%E %C' sudo apt-get remove -y $x
36+
done
37+
# We really want support for heredocs
38+
- name: Update podman and install just
39+
shell: bash
40+
run: |
41+
set -eux
42+
# Require the runner is ubuntu-24.04
43+
IDV=$(. /usr/lib/os-release && echo ${ID}-${VERSION_ID})
44+
test "${IDV}" = "ubuntu-24.04"
45+
# plucky is the next release
46+
echo 'deb http://azure.archive.ubuntu.com/ubuntu plucky universe main' | sudo tee /etc/apt/sources.list.d/plucky.list
47+
/bin/time -f '%E %C' sudo apt update
48+
# skopeo is currently older in plucky for some reason hence --allow-downgrades
49+
/bin/time -f '%E %C' sudo apt install -y --allow-downgrades crun/plucky podman/plucky skopeo/plucky just
50+
# This is the default on e.g. Fedora derivatives, but not Debian
51+
- name: Enable unprivileged /dev/kvm access
52+
shell: bash
53+
run: |
54+
set -xeuo pipefail
55+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
56+
sudo udevadm control --reload-rules
57+
sudo udevadm trigger --name-match=kvm
58+
ls -l /dev/kvm
59+
# Used by a few workflows, but generally useful
60+
- name: Set architecture variable
61+
id: set_arch
62+
shell: bash
63+
run: echo "ARCH=$(arch)" >> $GITHUB_ENV
64+
# We often use Rust, so set up opinionated default caching
65+
- name: Setup Rust cache
66+
uses: Swatinem/rust-cache@v2
67+
with:
68+
cache-all-crates: true
69+
# Only generate caches on push to git main
70+
save-if: ${{ github.ref == 'refs/heads/main' }}
71+
# Suppress actually using the cache for builds running from
72+
# git main so that we avoid incremental compilation bugs
73+
lookup-only: ${{ github.ref == 'refs/heads/main' }}
74+
# Install libvirt stack if requested
75+
- name: Install libvirt and virtualization stack
76+
if: ${{ inputs.libvirt == 'true' }}
77+
shell: bash
78+
run: |
79+
set -xeuo pipefail
80+
export BCVK_VERSION=0.5.3
81+
/bin/time -f '%E %C' sudo apt install -y libkrb5-dev pkg-config libvirt-dev genisoimage qemu-utils qemu-kvm virtiofsd libvirt-daemon-system
82+
# Something in the stack is overriding this, but we want session right now for bcvk
83+
echo LIBVIRT_DEFAULT_URI=qemu:///session >> $GITHUB_ENV
84+
td=$(mktemp -d)
85+
cd $td
86+
# Install bcvk
87+
target=bcvk-$(arch)-unknown-linux-gnu
88+
/bin/time -f '%E %C' curl -LO https://github.com/bootc-dev/bcvk/releases/download/v${BCVK_VERSION}/${target}.tar.gz
89+
tar xzf ${target}.tar.gz
90+
sudo install -T ${target} /usr/bin/bcvk
91+
cd -
92+
rm -rf "$td"
93+
94+
# Also bump the default fd limit as a workaround for https://github.com/bootc-dev/bcvk/issues/65
95+
sudo sed -i -e 's,^\* hard nofile 65536,* hard nofile 524288,' /etc/security/limits.conf
96+
- name: Cleanup status
97+
shell: bash
98+
run: |
99+
set -xeuo pipefail
100+
systemctl list-units 'action-cleanup*'
101+
df -h

.github/workflows/main-c10s.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
steps:
1515
- uses: actions/checkout@v4
1616

17+
- name: Setup Ubuntu environment with KVM
18+
uses: ./.github/actions/bootc-ubuntu-setup
19+
1720
- name: Build C10S test container
1821
run: podman build -f tests/fixtures/Containerfile -t localhost/bcvk:c10s .
1922

.github/workflows/main.yml

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,20 @@ jobs:
1818
runs-on: ubuntu-24.04
1919

2020
steps:
21-
- name: Install dependencies
22-
run: |
23-
sudo apt update
24-
sudo apt install -y just pkg-config go-md2man libvirt-daemon libvirt-clients qemu-kvm qemu-system qemu-utils virtiofsd
25-
26-
- name: Install podman for heredoc support
27-
run: |
28-
set -eux
29-
echo 'deb [trusted=yes] https://ftp.debian.org/debian/ testing main' | sudo tee /etc/apt/sources.list.d/testing.list
30-
sudo apt update
31-
sudo apt install -y crun/testing podman/testing just
21+
- uses: actions/checkout@v4
3222

33-
- name: Enable KVM group perms
34-
run: |
35-
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
36-
sudo udevadm control --reload-rules
37-
sudo udevadm trigger --name-match=kvm
38-
ls -l /dev/kvm
23+
- name: Setup Ubuntu environment
24+
uses: ./.github/actions/bootc-ubuntu-setup
25+
with:
26+
libvirt: 'true'
3927

40-
- uses: actions/checkout@v4
28+
- name: Remove pre-installed bcvk
29+
run: sudo rm -f /usr/bin/bcvk
4130

4231
- name: Setup Rust
4332
uses: dtolnay/rust-toolchain@stable
44-
45-
- uses: taiki-e/install-action@nextest
4633

47-
- name: Cache build artifacts
48-
uses: Swatinem/rust-cache@v2
34+
- uses: taiki-e/install-action@nextest
4935

5036
- name: Build
5137
run: just validate && just build

0 commit comments

Comments
 (0)