-
Notifications
You must be signed in to change notification settings - Fork 1.3k
406 lines (384 loc) · 13.8 KB
/
integration.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
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
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
name: Integration tests
on: pull_request
permissions:
contents: read
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
DOCKER_REGISTRY: ghcr.io/linkerd
GH_ANNOTATION: true
K3D_VERSION: v5.4.4
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10
YQ_VERSION: v4.25.1
LINKERD2_PROXY_REPO: ${{ vars.LINKERD2_PROXY_REPO || 'linkerd/linkerd2-proxy' }}
LINKERD2_PROXY_RELEASE_PREFIX: ${{ vars.LINKERD2_PROXY_RELEASE_PREFIX || 'release/' }}
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
meta:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- id: tag
run: echo "tag=$(CI_FORCE_CLEAN=1 bin/root-tag)" >> "$GITHUB_OUTPUT"
- uses: tj-actions/changed-files@c3a1bb2c992d77180ae65be6ae6c166cf40f857c
id: core
with:
files: |
.github/workflows/integration.yml
.proxy-version
go.sum
**/*.go
**/*.rs
**/Dockerfile*
charts/**
justfile
bin/fetch-proxy
bin/_test-helper.sh
files_ignore: |
.devcontainer/**
**/Chart.yaml
**/README*
outputs:
tag: ${{ steps.tag.outputs.tag }}
changed: ${{ steps.core.outputs.any_changed }}
info:
needs: meta
runs-on: ubuntu-22.04
timeout-minutes: 2
steps:
- name: Info
run: |
echo "tag=${{ needs.meta.outputs.tag }}"
echo "changed=${{ needs.meta.outputs.changed }}"
build-cli:
needs: meta
if: needs.meta.outputs.changed == 'true'
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- uses: ./.github/actions/docker-build
id: build
with:
docker-registry: ${{ env.DOCKER_REGISTRY }}
docker-target: linux-amd64
component: cli-bin
tag: ${{ needs.meta.outputs.tag }}
- name: Extract CLI binary
run: |
mkdir -p /home/runner/archives
id=$(docker create '${{ steps.build.outputs.image }}')
docker cp "$id:/out/linkerd-linux-amd64" /home/runner/archives/linkerd
v=$(/home/runner/archives/linkerd version --short --client)
[[ "$v" == '${{ needs.meta.outputs.tag }}' ]] || exit 1
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
name: image-archives-cli
path: /home/runner/archives
##
## Core: Test the core control plane
##
## TODO(ver) CNI configurations should be tested separately.
##
build-core:
needs: meta
if: needs.meta.outputs.changed == 'true'
runs-on: ubuntu-22.04
strategy:
matrix:
component:
- controller
- policy-controller
- proxy
timeout-minutes: 20
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- uses: ./.github/actions/docker-build
id: build
env:
LINKERD2_PROXY_GITHUB_TOKEN: ${{ secrets.LINKERD2_PROXY_GITHUB_TOKEN || github.token }}
with:
docker-registry: ${{ env.DOCKER_REGISTRY }}
docker-target: linux-amd64
component: ${{ matrix.component }}
tag: ${{ needs.meta.outputs.tag }}
- name: Run docker save
run: |
mkdir -p /home/runner/archives
docker save '${{ steps.build.outputs.image }}' >'/home/runner/archives/${{ matrix.component }}.tar'
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
name: image-archives-${{ matrix.component }}
path: /home/runner/archives
test-core:
needs: [meta, build-cli, build-core]
if: needs.meta.outputs.changed == 'true'
strategy:
matrix:
test:
- cni-calico-deep
- deep
- deep-native-sidecar
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: "1.22"
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
pattern: image-archives-*
path: image-archives
merge-multiple: true
- run: cp image-archives/linkerd "$HOME" && chmod 755 "$HOME/linkerd"
- run: find image-archives -ls
- run: bin/tests --images archive --cleanup-docker --name ${{ matrix.test }} "$HOME/linkerd"
env:
LINKERD_DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
TAG: ${{ needs.meta.outputs.tag }}
##
## Policy: Only run policy tests when the policy controller or proxy changes
##
test-policy:
needs: [meta, build-cli, build-core]
if: needs.meta.outputs.changed == 'true'
runs-on: ubuntu-22.04
timeout-minutes: 20
strategy:
matrix:
k8s:
- v1.22
- v1.29
steps:
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: olix0r/cargo-action-fmt/setup@9269f3aa1ff01775d95efc97037e2cbdb41d9684
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
pattern: image-archives-*
path: image-archives
merge-multiple: true
- run: find image-archives -ls
- run: cp image-archives/linkerd "$HOME" && chmod 755 "$HOME/linkerd"
- name: Setup deps
shell: bash
run: |
rm -rf "$HOME/.cargo"
bin/scurl -v https://sh.rustup.rs | sh -s -- -y --default-toolchain "$(./bin/rust-toolchain-version)"
# shellcheck disable=SC1090
source ~/.cargo/env
echo "PATH=$PATH" >> "$GITHUB_ENV"
bin/scurl -v "https://raw.githubusercontent.com/k3d-io/k3d/${K3D_VERSION}/install.sh" | bash
bin/scurl -vo /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64" && chmod +x /usr/local/bin/yq
- uses: Swatinem/rust-cache@23bce251a8cd2ffc3c1075eaa2367cf899916d84
- run: cargo install cargo-nextest
- run: just policy-test-build
- run: just k3d-k8s='${{ matrix.k8s }}' k3d-create
- run: docker load <image-archives/controller.tar
- run: docker load <image-archives/policy-controller.tar
- run: docker load <image-archives/proxy.tar
- run: docker image ls
- run: just linkerd-tag='${{ needs.meta.outputs.tag }}' linkerd-exec="$HOME/linkerd" linkerd-install
- name: Load images
run: |
# Image loading is flakey in CI, so retry!
for _ in {1..6} ; do
if just linkerd-tag='${{ needs.meta.outputs.tag }}' policy-test-deps-load ; then exit 0 ; fi
sleep 10
echo retrying...
done
exit 1
- run: just policy-test-run --jobs=1
env:
# https://nexte.st/book/retries.html
NEXTEST_RETRIES: 3
##
## Ext: Run tests that require non-core components.
##
build-ext:
needs: meta
if: needs.meta.outputs.changed == 'true'
runs-on: ubuntu-22.04
strategy:
matrix:
component:
- jaeger-webhook
- metrics-api
- tap
- web
timeout-minutes: 15
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- uses: ./.github/actions/docker-build
id: build
with:
docker-registry: ${{ env.DOCKER_REGISTRY }}
docker-target: linux-amd64
component: ${{ matrix.component }}
tag: ${{ needs.meta.outputs.tag }}
- name: Run docker save
run: |
mkdir -p /home/runner/archives
docker save '${{ steps.build.outputs.image }}' >'/home/runner/archives/${{ matrix.component }}.tar'
- uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
name: image-archives-${{ matrix.component }}
path: /home/runner/archives
# These tests exercise core functionality, but need the viz extension.
test-ext:
needs: [meta, build-cli, build-core, build-ext]
if: needs.meta.outputs.changed == 'true'
strategy:
matrix:
integration_test:
- cluster-domain
- default-policy-deny
- external
- rsa-ca
- helm-upgrade
- uninstall
- upgrade-edge
runs-on: ubuntu-22.04
timeout-minutes: 15
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: "1.22"
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
pattern: image-archives-*
path: image-archives
merge-multiple: true
- run: cp image-archives/linkerd "$HOME" && chmod 755 "$HOME/linkerd"
- run: ls -l image-archives/linkerd
- run: bin/tests --images archive --cleanup-docker --name '${{ matrix.integration_test }}' "$HOME/linkerd"
env:
LINKERD_DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
##
## Viz: Run the (flakey) `viz` suite only when the `viz` extension is updated.
##
test-viz:
needs: [meta, build-cli, build-core, build-ext]
if: needs.meta.outputs.changed == 'true'
runs-on: ubuntu-22.04
timeout-minutes: 30
steps:
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: "1.22"
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
pattern: image-archives-*
path: image-archives
merge-multiple: true
- run: cp image-archives/linkerd "$HOME" && chmod 755 "$HOME/linkerd"
- run: ls -l image-archives/linkerd
- run: bin/tests --images archive --cleanup-docker --name viz "$HOME/linkerd"
env:
LINKERD_DOCKER_REGISTRY: ${{ env.DOCKER_REGISTRY }}
##
## Multicluster: Run 'multicluster' suite only when the 'multicluster' extension is updated.
## Tests are run on min and max k8s versions
##
test-multicluster:
needs: [meta, build-cli, build-core, build-ext]
if: needs.meta.outputs.changed == 'true'
runs-on: ubuntu-22.04
timeout-minutes: 20
strategy:
matrix:
k8s:
- v1.22
- v1.29
steps:
- uses: extractions/setup-just@dd310ad5a97d8e7b41793f8ef055398d51ad4de6
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version: "1.22"
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
pattern: image-archives-*
path: image-archives
merge-multiple: true
- run: cp image-archives/linkerd "$HOME" && chmod 755 "$HOME/linkerd"
- run: ls -l image-archives/linkerd
- name: Setup deps
shell: bash
run: |
echo "PATH=$PATH" >> "$GITHUB_ENV"
bin/scurl -v "https://raw.githubusercontent.com/k3d-io/k3d/${K3D_VERSION}/install.sh" | bash
- name: Load docker images
run: |
for img in controller policy-controller proxy; do
docker load <"image-archives/${img}.tar"
done
- run: docker image ls
- run: just mc-test-build
- name: Run just mc-test-load
run: |
just linkerd-tag='${{ needs.meta.outputs.tag }}' \
k3d-k8s='${{ matrix.k8s }}' \
mc-test-load
- name: Run just mc-test-run
run: |
just linkerd-tag='${{ needs.meta.outputs.tag }}' \
k3d-k8s='${{ matrix.k8s }}' \
mc-test-run
build-ok:
needs: [build-cli, build-core, build-ext]
if: always()
runs-on: ubuntu-22.04
steps:
- name: Results
run: |
echo 'needs.build-cli.result: ${{ needs.build-cli.result }}'
echo 'needs.build-core.result: ${{ needs.build-core.result }}'
echo 'needs.build-ext.result: ${{ needs.build-ext.result }}'
- name: Verify jobs
# All jobs must succeed or be skipped.
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1
# Try to re-run the integration tests if they fail, but only up to 3 times.
integrations-retry:
needs:
[build-ok, test-core, test-policy, test-ext, test-viz, test-multicluster]
if: failure() && fromJSON(github.run_attempt) < 3 && needs.build-ok.result == 'success'
runs-on: ubuntu-22.04
permissions:
actions: write
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
GH_DEBUG: api
REF: ${{ github.head_ref }}
steps:
- run: gh workflow run rerun.yml -F 'run_id=${{ github.run_id }}' --ref "$REF"
integrations-ok:
needs:
[build-ok, test-core, test-policy, test-ext, test-viz, test-multicluster]
if: always()
runs-on: ubuntu-22.04
steps:
- name: Results
run: |
echo 'needs.build-ok.result: ${{ needs.build-ok.result }}'
echo 'needs.test-core.result: ${{ needs.test-core.result }}'
echo 'needs.test-policy.result: ${{ needs.test-policy.result }}'
echo 'needs.test-ext.result: ${{ needs.test-ext.result }}'
echo 'needs.test-viz.result: ${{ needs.test-viz.result }}'
echo 'needs.test-multicluster.result: ${{ needs.test-multicluster.result }}'
- name: Verify jobs
# All jobs must succeed or be skipped.
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: exit 1