forked from confidential-containers/cloud-api-adaptor
-
Notifications
You must be signed in to change notification settings - Fork 0
198 lines (176 loc) · 6.55 KB
/
e2e_libvirt.yaml
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
# (C) Copyright Confidential Containers Contributors 2023.
# SPDX-License-Identifier: Apache-2.0
#
# Run libvirt e2e tests.
name: (Callable) libvirt e2e tests
on:
workflow_call:
inputs:
runner:
default: 'ubuntu-24.04'
description: The runner to execute the workflow on. Defaults to 'ubuntu-24.04'.
required: false
type: string
podvm_image:
required: true
type: string
caa_image:
required: true
type: string
install_directory_artifact:
description: The archive name of the install directory
default: ''
required: false
type: string
git_ref:
default: 'main'
description: Git ref to checkout the cloud-api-adaptor repository. Defaults to main.
required: false
type: string
secure_comms:
default: 'none'
description: SecureComms configuration. Defaults to none.
required: false
type: string
oras:
description: Whether the podvm_image is oras published
default: false
required: false
type: boolean
container_runtime:
default: 'containerd'
description: Name of the container runtime. Either containerd or crio.
required: false
type: string
env:
CLOUD_PROVIDER: libvirt
DEBIAN_FRONTEND: noninteractive
defaults:
run:
working-directory: src/cloud-api-adaptor
jobs:
test:
runs-on: ${{ inputs.runner }}
# TODO: remove this when the crio job gets stable
continue-on-error: ${{ inputs.container_runtime == 'crio' && true || false }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.git_ref }}
- name: Rebase the code
if: github.event_name == 'pull_request_target'
working-directory: ./
run: |
./hack/ci-helper.sh rebase-atop-of-the-latest-target-branch
- name: Read properties from versions.yaml
run: |
sudo snap install yq
go_version="$(yq '.tools.golang' versions.yaml)"
[ -n "$go_version" ]
echo "GO_VERSION=${go_version}" >> "$GITHUB_ENV"
echo "ORAS_VERSION=$(yq -e '.tools.oras' versions.yaml)" >> "$GITHUB_ENV"
- name: Setup Golang version ${{ env.GO_VERSION }}
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: "**/go.sum"
- name: Setup docker
if: ${{ runner.environment == 'self-hosted' }}
run: |
sudo apt-get update -y
sudo apt-get install -y docker.io
sudo usermod -aG docker "$USER"
- uses: oras-project/setup-oras@v1
with:
version: ${{ env.ORAS_VERSION }}
- name: Extract qcow2 from ${{ inputs.podvm_image }}
if: ${{ !inputs.oras }}
run: |
qcow2=$(echo ${{ inputs.podvm_image }} | sed -e "s#.*/\(.*\):.*#\1.qcow2#")
./hack/download-image.sh ${{ inputs.podvm_image }} . -o "${qcow2}" --clean-up
echo "PODVM_QCOW2=$(pwd)/${qcow2}" >> "$GITHUB_ENV"
# Clean up docker images to make space
docker system prune -a -f
working-directory: src/cloud-api-adaptor/podvm
- name: Use oras to get qcow2 from ${{ inputs.podvm_image }}
if: ${{ inputs.oras }}
run: |
oras pull ${{ inputs.podvm_image }}
tar xvJpf podvm.tar.xz
qcow2=$(find ./*.qcow2)
echo "PODVM_QCOW2=$(pwd)/${qcow2}" >> "$GITHUB_ENV"
working-directory: src/cloud-api-adaptor/podvm
- name: Config Libvirt
run: |
export TEST_E2E_SECURE_COMMS="${{ inputs.secure_comms }}"
./libvirt/config_libvirt.sh
echo "container_runtime=\"${{ inputs.container_runtime }}\"" >> libvirt.properties
# For debugging
cat libvirt.properties
# Add the kcli install directory to PATH for later steps
echo "${HOME}/.local/bin" >> "$GITHUB_PATH"
- name: Install gh cli
run: |
sudo apt update -y
sudo apt install -y gh
- name: Double check that OVMF is installed
run: |
sudo apt update -y
sudo apt install -y ovmf
- name: Install kustomize
run: |
command -v kustomize >/dev/null || \
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | \
sudo bash -s /usr/local/bin
# For the legacy packer approach we don't want to use the default firmware, so comment it out
- name: Set blank firmware for packer libvirt tests
if: ${{ !inputs.oras }}
run: |
cd "install/overlays/libvirt"
sed -i 's/\(- LIBVIRT_EFI_FIRMWARE=.*\)/#\1/g' kustomization.yaml
# Print for debugging
echo "::group::Kustomization.yaml"
cat kustomization.yaml
echo "::endgroup::"
- name: Update kustomization configuration
run: |
cd "install/overlays/libvirt"
kustomize edit set image "cloud-api-adaptor=${{ inputs.caa_image }}"
# Print for debugging
echo "::group::libvirt kustomization"
cat kustomization.yaml
echo "::endgroup::"
- name: Checkout KBS Repository
run: |
test/utils/checkout_kbs.sh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: run tests
id: runTests
env:
AUTHENTICATED_REGISTRY_IMAGE: ${{ vars.AUTHENTICATED_REGISTRY_IMAGE }}
REGISTRY_CREDENTIAL_ENCODED: ${{ secrets.REGISTRY_CREDENTIAL_ENCODED }}
run: |
export CLOUD_PROVIDER=libvirt
export CONTAINER_RUNTIME="${{ inputs.container_runtime }}"
export DEPLOY_KBS=true
export TEST_PROVISION="yes"
export TEST_TEARDOWN="no"
export TEST_PROVISION_FILE="$PWD/libvirt.properties"
export TEST_PODVM_IMAGE="${{ env.PODVM_QCOW2 }}"
export TEST_E2E_TIMEOUT="75m"
export TEST_E2E_SECURE_COMMS="${{ inputs.secure_comms }}"
make test-e2e
- name: Debug tests failure
if: failure() && steps.runTests.outcome == 'failure'
working-directory: ./
run: |
export KUBECONFIG="${HOME}/.kcli/clusters/peer-pods/auth/kubeconfig"
./hack/ci-e2e-debug-fail.sh
# Avoid running with `set -e` as command fails should be allowed
shell: bash {0}
- name: Clean-up cluster
if: ${{ always() && runner.environment == 'self-hosted' }}
run: ./libvirt/kcli_cluster.sh delete