Skip to content

Commit 0b94607

Browse files
committed
Restructure GHA workflows
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
1 parent fb3b8c1 commit 0b94607

File tree

12 files changed

+696
-469
lines changed

12 files changed

+696
-469
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This job pre-heats the cache for the test image by building all dependencies
2+
name: build-dependencies
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
timeout:
8+
required: true
9+
type: number
10+
runner:
11+
required: true
12+
type: string
13+
containerd-version:
14+
required: false
15+
default: ''
16+
type: string
17+
18+
env:
19+
GOTOOLCHAIN: local
20+
21+
jobs:
22+
# This job builds the dependency target of the test docker image for all supported architectures and cache it in GHA
23+
build-dependencies:
24+
# Note: for whatever reason, you cannot access env.RUNNER_ARCH here
25+
name: "${{ contains(inputs.runner, 'arm') && 'arm64' || 'amd64' }}${{ inputs.containerd-version && format(' | {0}', inputs.containerd-version) || ''}}"
26+
timeout-minutes: ${{ inputs.timeout }}
27+
runs-on: "${{ inputs.runner }}"
28+
defaults:
29+
run:
30+
shell: bash
31+
32+
steps:
33+
- name: "Init: checkout"
34+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
35+
with:
36+
fetch-depth: 1
37+
38+
- name: "Init: expose GitHub Runtime variables for gha"
39+
uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
40+
41+
- name: "Run: build dependencies for the integration test environment image"
42+
run: |
43+
# Cache is sharded per-architecture
44+
arch=${{ env.RUNNER_ARCH == 'ARM64' && 'arm64' || 'amd64' }}
45+
docker buildx create --name with-gha --use
46+
# Honor old containerd if requested
47+
args=()
48+
if [ "${{ inputs.containerd-version }}" != "" ]; then
49+
args=(--build-arg CONTAINERD_VERSION=${{ inputs.containerd-version }})
50+
fi
51+
docker buildx build \
52+
--cache-to type=gha,compression=zstd,mode=max,scope=test-integration-dependencies-"$arch" \
53+
--cache-from type=gha,scope=test-integration-dependencies-"$arch" \
54+
--target build-dependencies "${args[@]}" .
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Currently, Lima job test only for EL8, though in the future it could be used to also test FreeBSD
2+
# EL8 is used for testing compatibility with cgroup v1.
3+
# Do not upgrade this to EL9 (cgroup v2).
4+
name: test-in-lima
5+
6+
on:
7+
workflow_call:
8+
inputs:
9+
timeout:
10+
required: true
11+
type: number
12+
runner:
13+
required: true
14+
type: string
15+
16+
jobs:
17+
test:
18+
name: "${{ matrix.mode }} (cgroup v1)"
19+
timeout-minutes: ${{ inputs.timeout }}
20+
runs-on: "${{ inputs.runner }}"
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
mode: ["rootful", "rootless"]
25+
env:
26+
MODE: ${{ matrix.mode }}
27+
steps:
28+
- name: "Init: checkout"
29+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
30+
with:
31+
fetch-depth: 1
32+
33+
- name: "Init: lima"
34+
uses: lima-vm/lima-actions/setup@be564a1408f84557d067b099a475652288074b2e # v1.0.0
35+
id: lima-actions-setup
36+
37+
- name: "Init: Cache"
38+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
39+
with:
40+
path: ~/.cache/lima
41+
key: lima-${{ steps.lima-actions-setup.outputs.version }}
42+
43+
- name: "Init: start the guest VM"
44+
run: |
45+
set -eux
46+
# containerd=none is set because the built-in containerd support conflicts with Docker
47+
limactl start \
48+
--name=default \
49+
--cpus=4 \
50+
--memory=12 \
51+
--containerd=none \
52+
--set '.mounts=null | .portForwards=[{"guestSocket":"/var/run/docker.sock","hostSocket":"{{.Dir}}/sock/docker.sock"}]' \
53+
template://almalinux-8
54+
55+
# FIXME: the tests should be directly executed in the VM without nesting Docker inside it
56+
# https://github.com/containerd/nerdctl/issues/3858
57+
- name: "Init: install dockerd in the guest VM"
58+
run: |
59+
set -eux
60+
lima sudo mkdir -p /etc/systemd/system/docker.socket.d
61+
cat <<-EOF | lima sudo tee /etc/systemd/system/docker.socket.d/override.conf
62+
[Socket]
63+
SocketUser=$(whoami)
64+
EOF
65+
lima sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
66+
lima sudo dnf -q -y install docker-ce --nobest
67+
lima sudo systemctl enable --now docker
68+
69+
- name: "Init: configure the host to use dockerd in the guest VM"
70+
run: |
71+
set -eux
72+
sudo systemctl disable --now docker.service docker.socket
73+
export DOCKER_HOST="unix://$(limactl ls --format '{{.Dir}}/sock/docker.sock' default)"
74+
echo "DOCKER_HOST=${DOCKER_HOST}" >>$GITHUB_ENV
75+
docker info
76+
docker version
77+
78+
- name: "Init: expose GitHub Runtime variables for gha"
79+
uses: crazy-max/ghaction-github-runtime@3cb05d89e1f492524af3d41a1c98c83bc3025124 # v3.1.0
80+
81+
- name: "Init: prepare integration tests"
82+
run: |
83+
set -eux
84+
85+
sudo losetup -Dv
86+
sudo losetup -lv
87+
88+
TARGET=test-integration
89+
[ "$MODE" = "rootless" ] && TARGET=test-integration-rootless
90+
docker buildx create --name with-gha --use
91+
docker buildx build \
92+
--output=type=docker \
93+
--cache-from type=gha,scope=test-integration-dependencies-amd64 \
94+
-t test-integration --target "${TARGET}" \
95+
.
96+
97+
- name: "Run integration tests"
98+
# Presumably, something is broken with the way docker exposes /dev to the container, as it appears to only
99+
# randomly work. Mounting /dev does workaround the issue.
100+
# This might be due to the old kernel shipped with Alma (4.18), or something else between centos/docker.
101+
run: |
102+
set -eux
103+
if [ "$MODE" = "rootless" ]; then
104+
echo "rootless"
105+
docker run -t -v /dev:/dev --rm --privileged test-integration /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=false
106+
else
107+
echo "rootful"
108+
docker run -t -v /dev:/dev --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=false
109+
fi
110+
- name: "Run: integration tests (flaky)"
111+
run: |
112+
set -eux
113+
if [ "$MODE" = "rootless" ]; then
114+
echo "rootless"
115+
docker run -t -v /dev:/dev --rm --privileged test-integration /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=true
116+
else
117+
echo "rootful"
118+
docker run -t -v /dev:/dev --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=true
119+
fi
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Right now, this is testing solely FreeBSD, but could be used to test other targets.
2+
# Alternatively, this might get replaced entirely by Lima eventually.
3+
name: test-in-vagrant
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
timeout:
9+
required: true
10+
type: number
11+
runner:
12+
required: true
13+
type: string
14+
15+
jobs:
16+
test:
17+
name: "14"
18+
timeout-minutes: ${{ inputs.timeout }}
19+
runs-on: "${{ inputs.runner }}"
20+
steps:
21+
- name: "Init: checkout"
22+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
with:
24+
fetch-depth: 1
25+
26+
- name: "Init: setup cache"
27+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
28+
with:
29+
path: /root/.vagrant.d
30+
key: vagrant
31+
32+
- name: "Init: set up vagrant"
33+
run: |
34+
# from https://github.com/containerd/containerd/blob/v2.0.2/.github/workflows/ci.yml#L583-L596
35+
# which is based on https://github.com/opencontainers/runc/blob/v1.1.8/.cirrus.yml#L41-L49
36+
curl -fsSL --proto '=https' --tlsv1.2 https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
37+
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
38+
sudo sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
39+
sudo apt-get update -qq
40+
sudo apt-get install -qq libvirt-daemon libvirt-daemon-system vagrant ovmf
41+
# https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1725#issuecomment-1454058646
42+
sudo cp /usr/share/OVMF/OVMF_VARS_4M.fd /var/lib/libvirt/qemu/nvram/
43+
sudo systemctl enable --now libvirtd
44+
sudo apt-get build-dep -qq ruby-libvirt
45+
sudo apt-get install -qq --no-install-recommends libxslt-dev libxml2-dev libvirt-dev ruby-bundler ruby-dev zlib1g-dev
46+
# Disable strict dependency enforcement to bypass gem version conflicts during the installation of the vagrant-libvirt plugin.
47+
sudo env VAGRANT_DISABLE_STRICT_DEPENDENCY_ENFORCEMENT=1 vagrant plugin install vagrant-libvirt
48+
49+
- name: "Init: boot VM"
50+
run: |
51+
ln -sf Vagrantfile.freebsd Vagrantfile
52+
sudo vagrant up --no-tty
53+
54+
- name: "Run: test-unit"
55+
run: sudo vagrant up --provision-with=test-unit
56+
57+
- name: "Run: test-integration"
58+
run: sudo vagrant up --provision-with=test-integration

0 commit comments

Comments
 (0)