-
Notifications
You must be signed in to change notification settings - Fork 137
324 lines (317 loc) · 14.6 KB
/
Copy pathuki.yaml
File metadata and controls
324 lines (317 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
name: Build UKI images
on:
pull_request:
push:
branches:
- master
permissions:
contents: write
security-events: write
id-token: write
actions: read
concurrency:
group: ci-uki-${{ github.head_ref || github.ref }}-${{ github.repository }}
cancel-in-progress: true
jobs:
build:
name: ${{ matrix.image_name }}
uses: kairos-io/kairos-factory-action/.github/workflows/reusable-factory.yaml@8952c3a5f4f6255cc63af88cb3637a9684970c8d # v1.1.3
secrets:
registry_username: ${{ secrets.QUAY_USERNAME }}
registry_password: ${{ secrets.QUAY_PASSWORD }}
with:
auroraboot_version: "v0.23.0"
dockerfile_path: "images/Dockerfile"
base_image: ${{ matrix.base_image }}
kubernetes_distro: ${{ matrix.kubernetes_distro }}
model: "generic"
arch: "amd64"
trusted_boot: true
keys_dir: "$PWD/tests/assets/keys"
sysext_dir: "$PWD/tests/assets/sysext"
single_efi_cmdline: "testentry: nothing"
version: "auto"
iso: true
grype: false
security_scan_mode: "enforce"
registry_domain: "quay.io"
registry_namespace: "kairos"
registry_repository: "ci-temp-images"
custom_tag_format: "$FLAVOR-$FLAVOR_RELEASE-$VARIANT-$ARCH-$MODEL-$COMMIT_SHA-uki"
custom_artifact_format: "kairos-$FLAVOR-$FLAVOR_RELEASE-$VARIANT-$ARCH-$MODEL-uki"
custom_job_name_format: ${{ matrix.custom_job_name_format }}
image_labels: "quay.expires-after=6h"
summary_artifacts: true
strategy:
matrix:
include:
- image_name: "hadron-trusted"
base_image: "ghcr.io/kairos-io/hadron-trusted:v0.4.0"
kubernetes_distro: ""
custom_job_name_format: "core-amd64-generic-uki"
- image_name: "hadron-trusted"
base_image: "ghcr.io/kairos-io/hadron-trusted:v0.4.0"
kubernetes_distro: "k3s"
custom_job_name_format: "standard-amd64-generic-k3s-uki"
test_generic:
name: test_generic (${{ matrix.image_label }}, ${{ matrix.arch }}, ${{ matrix.model }}, ${{ matrix.variant }})
needs: build
runs-on: kvm
strategy:
fail-fast: false
matrix:
image_label: ["hadron-trusted"]
base_image:
- "ghcr.io/kairos-io/hadron-trusted:v0.4.0"
arch: ["amd64"]
model: ["generic"]
variant: ["standard"]
steps:
- name: Split base image
id: split
run: |
# Split base image for tag generation
BASE_IMAGE=$(echo "${{ matrix.base_image }}" | cut -d ':' -f 1)
BASE_TAG=$(echo "${{ matrix.base_image }}" | cut -d ':' -f 2 || echo 'latest')
# Handle special cases for base images with slashes
# Handle base images with slashes (registry paths)
# Examples:
# - ubuntu:24.04 -> FLAVOR=ubuntu, FLAVOR_RELEASE=24.04
# - opensuse/leap:15.6 -> FLAVOR=opensuse, FLAVOR_RELEASE=leap-15.6
# - ghcr.io/kairos-io/hadron:main -> FLAVOR=hadron, FLAVOR_RELEASE=main
if [[ "$BASE_IMAGE" == *"/"* ]]; then
DISTRO=$(echo "$BASE_IMAGE" | cut -d '/' -f 1)
SUB_DISTRO=$(echo "$BASE_IMAGE" | cut -d '/' -f 2)
FLAVOR="$DISTRO"
FLAVOR_RELEASE="$SUB_DISTRO-$BASE_TAG"
# Count number of slashes to determine if it's a registry path
SLASH_COUNT=$(echo "$BASE_IMAGE" | tr -cd '/' | wc -c)
if [[ $SLASH_COUNT -eq 1 ]]; then
# Simple case: distro/subdistro (preserve existing behavior)
DISTRO=$(echo "$BASE_IMAGE" | cut -d '/' -f 1)
SUB_DISTRO=$(echo "$BASE_IMAGE" | cut -d '/' -f 2)
FLAVOR="$DISTRO"
FLAVOR_RELEASE="$SUB_DISTRO-$BASE_TAG"
else
# Registry path with multiple slashes: extract last component as FLAVOR
# e.g., ghcr.io/kairos-io/hadron -> FLAVOR=hadron
FLAVOR=$(echo "$BASE_IMAGE" | awk -F'/' '{print $NF}')
FLAVOR_RELEASE="$BASE_TAG"
fi
else
# No slashes: simple image name
FLAVOR="$BASE_IMAGE"
FLAVOR_RELEASE="$BASE_TAG"
fi
echo "Base Image: $BASE_IMAGE"
echo "Determined Flavor: $FLAVOR"
echo "Determined Flavor Release: $FLAVOR_RELEASE"
echo "flavor=$FLAVOR" >> $GITHUB_OUTPUT
echo "flavor_release=$FLAVOR_RELEASE" >> $GITHUB_OUTPUT
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: '0'
- name: Set Version
run: echo "VERSION=$(git describe --tags --dirty )" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
timeout-minutes: 5
with:
go-version-file: tests/go.mod
cache-dependency-path: tests/go.sum
cache: ${{ runner.environment == 'self-hosted' && 'false' || 'true' }}
- name: Enable KVM group perms and install deps
run: |
sudo apt-get update
sudo apt-get install -y libvirt-clients libvirt-daemon-system libvirt-daemon virtinst bridge-utils qemu-system-x86 qemu-utils acl udev mkisofs swtpm ovmf
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
# echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
# sudo udevadm control --reload-rules
# sudo udevadm trigger --name-match=kvm
# sudo usermod -a -G kvm,libvirt $USER
#
# TODO: Switch back to the above solution when we switch to the github runners
# https://askubuntu.com/a/1081326
sudo setfacl -m u:runner:rwx /dev/kvm
- name: Login to Quay Registry
uses: docker/login-action@c99871dec2022cc055c062a10cc1a1310835ceb4 # v4
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: kairos-${{ steps.split.outputs.flavor }}-${{ steps.split.outputs.flavor_release }}-${{ matrix.variant }}-${{ matrix.arch }}-${{ matrix.model }}-uki.iso.zip
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4
with:
driver-opts: network=host
- name: Build uki upgrade image 🔧
run: |
echo "Building upgrade image for generic test"
docker buildx build --load -t upgrade-image - <<EOF
FROM quay.io/kairos/ci-temp-images:${{ steps.split.outputs.flavor }}-${{ steps.split.outputs.flavor_release }}-${{ matrix.variant }}-${{ matrix.arch }}-${{ matrix.model }}-${{ github.sha }}-uki
RUN echo "Current release info: \$(cat /etc/kairos-release)"
RUN sed -i 's/^KAIROS_VERSION=.*/KAIROS_VERSION="mynewversion"/' /etc/kairos-release
RUN echo "New release info: \$(cat /etc/kairos-release)"
EOF
mkdir -p $PWD/build
docker run --rm --network=host -v /var/run/docker.sock:/var/run/docker.sock \
-v $PWD/build:/result \
-v $PWD/tests/assets/keys:/keys \
quay.io/kairos/auroraboot:v0.25.2 --debug build-uki \
--output-dir /result --output-type container \
--public-keys /keys \
--tpm-pcr-private-key /keys/tpm2-pcr-private.pem \
--sb-key /keys/db.key --sb-cert /keys/db.pem \
docker:upgrade-image
image=$(docker load -i build/*.tar | grep "Loaded image" | awk -F: '{ st = index($0,":");print substr($0,st+1)}' | sed 's/+/-/g' | xargs)
echo "Image: $image"
rand=$(head /dev/urandom | tr -dc a-z0-9 | head -c 7)
temp_image=quay.io/kairos/ci-temp-images:$(echo $image | sed "s/:latest/-${rand}/")
# Use docker build with DOCKER_BUILDKIT=1 instead of buildx for this simple label addition
# since buildx doesn't have access to locally loaded images from docker load
DOCKER_BUILDKIT=1 docker build --label quay.expires-after="6h" --tag $temp_image - <<EOF
FROM $image
EOF
docker push $temp_image
echo $temp_image > build/upgrade_image_name
- name: Find OVMF firmware
uses: ./.github/actions/find-ovmf-firmware
with:
prefer_secboot: true
id: find_ovmf
- name: Run tests 🔧
env:
MEMORY: 6000
CPUS: 4
FIRMWARE: ${{ steps.find_ovmf.outputs.firmware }}
UKI_TEST: true
run: |
mv $PWD/kairos-*-uki.iso $PWD/build/
export ISO=$(ls $PWD/build/kairos-*-uki.iso)
export UPGRADE_IMAGE=$(cat "${PWD}/build/upgrade_image_name")
export EXPECTED_NEW_VERSION="mynewversion"
export EXPECTED_SINGLE_ENTRY="testentry"
cp tests/go.* .
go run github.com/onsi/ginkgo/v2/ginkgo -v --label-filter "generic" --fail-fast -r ./tests/
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: failure()
with:
name: ${{ steps.split.outputs.flavor }}-${{ steps.split.outputs.flavor_release }}-${{ matrix.variant }}-generic-uki.logs.zip
path: tests/**/logs/*
if-no-files-found: warn
test_boot_assessment:
name: test_boot_assessment (${{ matrix.image_label }}, ${{ matrix.arch }}, ${{ matrix.model }}, ${{ matrix.variant }})
needs: build
runs-on: kvm
strategy:
fail-fast: false
matrix:
image_label: ["hadron-trusted"]
base_image:
- "ghcr.io/kairos-io/hadron-trusted:v0.4.0"
arch: ["amd64"]
model: ["generic"]
variant: ["core"]
steps:
- name: Split base image
id: split
run: |
# Split base image for tag generation
BASE_IMAGE=$(echo "${{ matrix.base_image }}" | cut -d ':' -f 1)
BASE_TAG=$(echo "${{ matrix.base_image }}" | cut -d ':' -f 2 || echo 'latest')
# Handle special cases for base images with slashes
# Handle base images with slashes (registry paths)
# Examples:
# - ubuntu:24.04 -> FLAVOR=ubuntu, FLAVOR_RELEASE=24.04
# - opensuse/leap:15.6 -> FLAVOR=opensuse, FLAVOR_RELEASE=leap-15.6
# - ghcr.io/kairos-io/hadron:main -> FLAVOR=hadron, FLAVOR_RELEASE=main
if [[ "$BASE_IMAGE" == *"/"* ]]; then
DISTRO=$(echo "$BASE_IMAGE" | cut -d '/' -f 1)
SUB_DISTRO=$(echo "$BASE_IMAGE" | cut -d '/' -f 2)
FLAVOR="$DISTRO"
FLAVOR_RELEASE="$SUB_DISTRO-$BASE_TAG"
# Count number of slashes to determine if it's a registry path
SLASH_COUNT=$(echo "$BASE_IMAGE" | tr -cd '/' | wc -c)
if [[ $SLASH_COUNT -eq 1 ]]; then
# Simple case: distro/subdistro (preserve existing behavior)
DISTRO=$(echo "$BASE_IMAGE" | cut -d '/' -f 1)
SUB_DISTRO=$(echo "$BASE_IMAGE" | cut -d '/' -f 2)
FLAVOR="$DISTRO"
FLAVOR_RELEASE="$SUB_DISTRO-$BASE_TAG"
else
# Registry path with multiple slashes: extract last component as FLAVOR
# e.g., ghcr.io/kairos-io/hadron -> FLAVOR=hadron
FLAVOR=$(echo "$BASE_IMAGE" | awk -F'/' '{print $NF}')
FLAVOR_RELEASE="$BASE_TAG"
fi
else
# No slashes: simple image name
FLAVOR="$BASE_IMAGE"
FLAVOR_RELEASE="$BASE_TAG"
fi
echo "Base Image: $BASE_IMAGE"
echo "Determined Flavor: $FLAVOR"
echo "Determined Flavor Release: $FLAVOR_RELEASE"
echo "flavor=$FLAVOR" >> $GITHUB_OUTPUT
echo "flavor_release=$FLAVOR_RELEASE" >> $GITHUB_OUTPUT
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
fetch-depth: '0'
- name: Set Version
run: echo "VERSION=$(git describe --tags --dirty )" >> $GITHUB_ENV
- name: Install Go
uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
timeout-minutes: 5
with:
go-version-file: tests/go.mod
cache-dependency-path: tests/go.sum
cache: ${{ runner.environment == 'self-hosted' && 'false' || 'true' }}
- name: Enable KVM group perms and install deps
run: |
sudo apt-get update
sudo apt-get install -y libvirt-clients libvirt-daemon-system libvirt-daemon virtinst bridge-utils qemu-system-x86 qemu-utils acl udev mkisofs swtpm ovmf
# https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
# echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
# sudo udevadm control --reload-rules
# sudo udevadm trigger --name-match=kvm
# sudo usermod -a -G kvm,libvirt $USER
#
# TODO: Switch back to the above solution when we switch to the github runners
# https://askubuntu.com/a/1081326
sudo setfacl -m u:runner:rwx /dev/kvm
- name: Login to Quay Registry
uses: docker/login-action@c99871dec2022cc055c062a10cc1a1310835ceb4 # v4
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Download artifacts
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: kairos-${{ steps.split.outputs.flavor }}-${{ steps.split.outputs.flavor_release }}-${{ matrix.variant }}-${{ matrix.arch }}-${{ matrix.model }}-uki.iso.zip
- name: Find OVMF firmware
uses: ./.github/actions/find-ovmf-firmware
with:
prefer_secboot: true
id: find_ovmf_boot
- name: Run tests 🔧
env:
MEMORY: 6000
CPUS: 4
FIRMWARE: ${{ steps.find_ovmf_boot.outputs.firmware }}
UKI_TEST: true
run: |
mkdir -p $PWD/build
mv $PWD/kairos-*-uki.iso $PWD/build/
export ISO=$(ls $PWD/build/kairos-*-uki.iso)
cp tests/go.* .
go run github.com/onsi/ginkgo/v2/ginkgo -v --label-filter "boot-assessment" --fail-fast -r ./tests/
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: failure()
with:
name: ${{ steps.split.outputs.flavor }}-${{ steps.split.outputs.flavor_release }}-${{ inputs.variant }}-generic-uki.logs.zip
path: tests/**/logs/*
if-no-files-found: warn