Skip to content

Commit e484c4b

Browse files
committed
Restructure GHA workflows
Signed-off-by: apostasie <spam_blackhole@farcloser.world>
1 parent 4dd9ad9 commit e484c4b

16 files changed

Lines changed: 787 additions & 570 deletions
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: job-test-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: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
# Currently, Lima job test only for EL, though in the future it could be used to also test FreeBSD or other linux-es
2+
name: job-test-in-lima
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+
target:
14+
required: true
15+
type: string
16+
guest:
17+
required: true
18+
type: string
19+
20+
jobs:
21+
test:
22+
name: "${{ inputs.guest }} ${{ inputs.target }}"
23+
timeout-minutes: ${{ inputs.timeout }}
24+
runs-on: "${{ inputs.runner }}"
25+
env:
26+
TARGET: ${{ inputs.target }}
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://${{ inputs.guest }}
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" = "rootless" ] && TARGET=test-integration-rootless || TARGET=test-integration
89+
docker buildx create --name with-gha --use
90+
docker buildx build \
91+
--output=type=docker \
92+
--cache-from type=gha,scope=test-integration-dependencies-amd64 \
93+
-t test-integration --target "${TARGET}" \
94+
.
95+
96+
- name: "Run integration tests"
97+
# Presumably, something is broken with the way docker exposes /dev to the container, as it appears to only
98+
# randomly work. Mounting /dev does workaround the issue.
99+
# This might be due to the old kernel shipped with Alma (4.18), or something else between centos/docker.
100+
run: |
101+
set -eux
102+
if [ "$TARGET" = "rootless" ]; then
103+
echo "rootless"
104+
docker run -t -v /dev:/dev --rm --privileged test-integration /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=false
105+
else
106+
echo "rootful"
107+
docker run -t -v /dev:/dev --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=false
108+
fi
109+
- name: "Run: integration tests (flaky)"
110+
run: |
111+
set -eux
112+
if [ "$TARGET" = "rootless" ]; then
113+
echo "rootless"
114+
docker run -t -v /dev:/dev --rm --privileged test-integration /test-integration-rootless.sh ./hack/test-integration.sh -test.only-flaky=true
115+
else
116+
echo "rootful"
117+
docker run -t -v /dev:/dev --rm --privileged test-integration ./hack/test-integration.sh -test.only-flaky=true
118+
fi
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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: job-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+
# Will appear as freebsd / 14 in GitHub UI
18+
name: "14"
19+
timeout-minutes: ${{ inputs.timeout }}
20+
runs-on: "${{ inputs.runner }}"
21+
steps:
22+
- name: "Init: checkout"
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
with:
25+
fetch-depth: 1
26+
27+
- name: "Init: setup cache"
28+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
29+
with:
30+
path: /root/.vagrant.d
31+
key: vagrant
32+
33+
- name: "Init: set up vagrant"
34+
run: |
35+
# from https://github.com/containerd/containerd/blob/v2.0.2/.github/workflows/ci.yml#L583-L596
36+
# which is based on https://github.com/opencontainers/runc/blob/v1.1.8/.cirrus.yml#L41-L49
37+
curl -fsSL --proto '=https' --tlsv1.2 https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
38+
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
39+
sudo sed -i 's/^Types: deb$/Types: deb deb-src/' /etc/apt/sources.list.d/ubuntu.sources
40+
sudo apt-get update -qq
41+
sudo apt-get install -qq libvirt-daemon libvirt-daemon-system vagrant ovmf
42+
# https://github.com/vagrant-libvirt/vagrant-libvirt/issues/1725#issuecomment-1454058646
43+
sudo cp /usr/share/OVMF/OVMF_VARS_4M.fd /var/lib/libvirt/qemu/nvram/
44+
sudo systemctl enable --now libvirtd
45+
sudo apt-get build-dep -qq ruby-libvirt
46+
sudo apt-get install -qq --no-install-recommends libxslt-dev libxml2-dev libvirt-dev ruby-bundler ruby-dev zlib1g-dev
47+
# Disable strict dependency enforcement to bypass gem version conflicts during the installation of the vagrant-libvirt plugin.
48+
sudo env VAGRANT_DISABLE_STRICT_DEPENDENCY_ENFORCEMENT=1 vagrant plugin install vagrant-libvirt
49+
50+
- name: "Init: boot VM"
51+
run: |
52+
ln -sf Vagrantfile.freebsd Vagrantfile
53+
sudo vagrant up --no-tty
54+
55+
- name: "Run: test-unit"
56+
run: sudo vagrant up --provision-with=test-unit
57+
58+
- name: "Run: test-integration"
59+
run: sudo vagrant up --provision-with=test-integration

0 commit comments

Comments
 (0)