-
Notifications
You must be signed in to change notification settings - Fork 107
225 lines (198 loc) · 6.71 KB
/
test_e2e.yml
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
name: e2e tests
on:
pull_request: {}
push:
branches: [main]
jobs:
cloud:
name: Cloud ${{ matrix.k3s }}
permissions:
id-token: write
runs-on: ubuntu-latest
strategy:
matrix:
k3s: [ v1.25, v1.26, v1.27, v1.28 ]
fail-fast: false
env:
K3S_CHANNEL: ${{ matrix.k3s }}
SCOPE: gha-${{ github.run_id }}-${{ github.run_attempt }}-${{ matrix.k3s }}
# Domain must be available in the account running the tests. This domain is available in the account
# running the public integration tests.
CERT_DOMAIN: hc-integrations-test.de
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.21"
- uses: actions/checkout@master
- uses: hetznercloud/tps-action@main
with:
token: ${{ secrets.HCLOUD_TOKEN }}
- uses: 3bit/setup-hcloud@v2
- uses: yokawasa/action-setup-kube-tools@v0.9.3
with:
setup-tools: |
helm
kubectl
skaffold
helm: v3.11.2
kubectl: v1.28.1
skaffold: v2.3.0
- name: Install k3sup
run: |
curl -sLS https://get.k3sup.dev | sh
- name: Setup test environment
run: |
source <(hack/dev-up.sh)
# make exported env variables available to following jobs
echo "KUBECONFIG=$KUBECONFIG" >> "$GITHUB_ENV"
echo "SKAFFOLD_DEFAULT_REPO=$SKAFFOLD_DEFAULT_REPO" >> "$GITHUB_ENV"
echo "CONTROL_IP=$CONTROL_IP" >> "$GITHUB_ENV"
- name: Build and Deploy HCCM
run: |
skaffold build --tag="e2e-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}"
tag=$(skaffold build --tag="e2e-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}" --quiet --output="{{ (index .Builds 0).Tag }}")
skaffold deploy --images=hetznercloud/hcloud-cloud-controller-manager=$tag
- name: Run tests
run: |
go test ./tests/e2e -tags e2e -v -timeout 60m
- name: Download logs & events
if: always()
continue-on-error: true
run: |
mkdir debug-logs
kubectl logs \
--namespace kube-system \
--selector app.kubernetes.io/name=hcloud-cloud-controller-manager \
--all-containers \
--prefix=true \
--tail=-1 \
> debug-logs/hccm.log
kubectl get events \
--all-namespaces \
--sort-by=.firstTimestamp \
--output yaml \
> debug-logs/events.yaml
- name: Show HCCM Logs on Failure
if: failure()
continue-on-error: true
run: |
echo "::group::hccm.log"
cat debug-logs/hccm.log
echo "::endgroup::"
- name: Cleanup test environment
if: always()
continue-on-error: true
run: |
hack/dev-down.sh
- name: Persist debug artifacts
if: always()
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: debug-logs-${{ env.SCOPE }}
path: debug-logs/
robot:
name: Robot
permissions:
id-token: write
# Make sure that only one Job is using the server at a time
concurrency: robot-test-server
environment: e2e-robot
env:
K3S_CHANNEL: v1.28
SCOPE: gha-${{ github.run_id }}-${{ github.run_attempt }}-robot
# Disable routes in dev-env, not supported for Robot.
ROUTES_ENABLED: "false"
ROBOT_ENABLED: "true"
SERVER_NUMBER: ${{ vars.SERVER_NUMBER }}
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: "1.21"
- uses: actions/checkout@master
- uses: hetznercloud/tps-action@main
with:
token: ${{ secrets.HCLOUD_TOKEN }}
- uses: 3bit/setup-hcloud@v2
- uses: yokawasa/action-setup-kube-tools@v0.9.3
with:
setup-tools: |
helm
kubectl
skaffold
helm: v3.11.2
kubectl: v1.28.1
skaffold: v2.3.0
- name: Install k3sup
run: |
curl -sLS https://get.k3sup.dev | sh
- name: Setup test environment
env:
ROBOT_USER: ${{ secrets.ROBOT_USER }}
ROBOT_PASSWORD: ${{ secrets.ROBOT_PASSWORD }}
run: |
source <(hack/dev-up.sh)
# make exported env variables available to following jobs
echo "KUBECONFIG=$KUBECONFIG" >> "$GITHUB_ENV"
echo "SKAFFOLD_DEFAULT_REPO=$SKAFFOLD_DEFAULT_REPO" >> "$GITHUB_ENV"
echo "CONTROL_IP=$CONTROL_IP" >> "$GITHUB_ENV"
- name: Build and Deploy HCCM
run: |
skaffold build --tag="e2e-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}"
tag=$(skaffold build --tag="e2e-${GITHUB_RUN_ID}-${GITHUB_RUN_NUMBER}" --quiet --output="{{ (index .Builds 0).Tag }}")
skaffold deploy \
--profile=robot \
--images=hetznercloud/hcloud-cloud-controller-manager=$tag
- name: Setup Robot Server
env:
ROBOT_USER: ${{ secrets.ROBOT_USER }}
ROBOT_PASSWORD: ${{ secrets.ROBOT_PASSWORD }}
working-directory: hack/robot-e2e
run: |
ansible-galaxy install -r requirements.yml
echo "::group::ansible-playbook e2e-setup-robot-server.yml"
ansible-playbook e2e-setup-robot-server.yml -e scope=$SCOPE -e server_number=$SERVER_NUMBER -vvv
echo "::endgroup::"
- name: Run tests
env:
ROBOT_USER: ${{ secrets.ROBOT_USER }}
ROBOT_PASSWORD: ${{ secrets.ROBOT_PASSWORD }}
run: |
go test ./tests/e2e -tags e2e,robot -v -timeout 60m
- name: Download logs & events
if: always()
continue-on-error: true
run: |
mkdir debug-logs
kubectl logs \
--namespace kube-system \
--selector app.kubernetes.io/name=hcloud-cloud-controller-manager \
--all-containers \
--prefix=true \
--tail=-1 \
> debug-logs/hccm.log
kubectl get events \
--all-namespaces \
--sort-by=.firstTimestamp \
--output yaml \
> debug-logs/events.yaml
- name: Show HCCM Logs on Failure
if: failure()
continue-on-error: true
run: |
echo "::group::hccm.log"
cat debug-logs/hccm.log
echo "::endgroup::"
- name: Cleanup test environment
if: always()
continue-on-error: true
run: |
hack/dev-down.sh
- name: Persist debug artifacts
if: always()
continue-on-error: true
uses: actions/upload-artifact@v3
with:
name: debug-logs-${{ env.SCOPE }}
path: debug-logs/