forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 0
522 lines (473 loc) · 19 KB
/
conformance-ginkgo.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
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
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
name: Conformance Ginkgo (ci-ginkgo)
# Any change in triggers needs to be reflected in the concurrency group.
on:
workflow_dispatch:
inputs:
PR-number:
description: "Pull request number."
required: true
context-ref:
description: "Context in which the workflow runs. If PR is from a fork, will be the PR target branch (general case). If PR is NOT from a fork, will be the PR branch itself (this allows committers to test changes to workflows directly from PRs)."
required: true
SHA:
description: "SHA under test (head of the PR branch)."
required: true
extra-args:
description: "[JSON object] Arbitrary arguments passed from the trigger comment via regex capture group. Parse with 'fromJson(inputs.extra-args).argName' in workflow."
required: false
default: '{}'
push:
branches:
- 'renovate/main-**'
# Run every 8 hours
schedule:
- cron: '0 1/8 * * *'
# By specifying the access of one of the scopes, all of those that are not
# specified are set to 'none'.
permissions:
# To read actions state with catchpoint/workflow-telemetry-action
actions: read
# To be able to access the repository with actions/checkout
contents: read
# To allow retrieving information from the PR API
pull-requests: read
# To be able to set commit status
statuses: write
concurrency:
# Structure:
# - Workflow name
# - Event type
# - A unique identifier depending on event type:
# - schedule: SHA
# - workflow_dispatch: PR number
#
# This structure ensures a unique concurrency group name is generated for each
# type of testing, such that re-runs will cancel the previous run.
group: |
${{ github.workflow }}
${{ github.event_name }}
${{
(github.event_name == 'push' && github.sha) ||
(github.event_name == 'schedule' && github.sha) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.PR-number)
}}
cancel-in-progress: true
jobs:
echo-inputs:
if: ${{ github.event_name == 'workflow_dispatch' }}
name: Echo Workflow Dispatch Inputs
runs-on: ubuntu-24.04
steps:
- name: Echo Workflow Dispatch Inputs
run: |
echo '${{ tojson(inputs) }}'
setup-vars:
name: Setup Vars
runs-on: ubuntu-latest
outputs:
SHA: ${{ steps.vars.outputs.SHA }}
context-ref: ${{ steps.vars.outputs.context-ref }}
owner: ${{ steps.vars.outputs.owner }}
steps:
- name: Set up job variables
id: vars
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
SHA="${{ inputs.SHA }}"
CONTEXT_REF="${{ inputs.context-ref }}"
OWNER="${{ inputs.PR-number }}"
else
SHA="${{ github.sha }}"
CONTEXT_REF="${{ github.sha }}"
OWNER="${{ github.ref_name }}"
OWNER="${OWNER//[.\/]/-}"
fi
echo SHA=${SHA} >> $GITHUB_OUTPUT
echo context-ref=${CONTEXT_REF} >> $GITHUB_OUTPUT
echo owner=${OWNER} >> $GITHUB_OUTPUT
commit-status-start:
name: Commit Status Start
runs-on: ubuntu-latest
steps:
- name: Set initial commit status
uses: myrotvorets/set-commit-status-action@3730c0a348a2ace3c110851bed53331bc6406e9f # v2.0.1
with:
sha: ${{ inputs.SHA || github.sha }}
# Pre-build the ginkgo binary so that we don't have to build it for all
# runners.
build-ginkgo-binary:
runs-on: ubuntu-latest
name: Build Ginkgo E2E
timeout-minutes: 30
steps:
# If any of these steps are modified, please update the copy of these
# steps further down under the 'setup-and-test' jobs.
# Warning: since this is a privileged workflow, subsequent workflow job
# steps must take care not to execute untrusted code.
- name: Checkout pull request branch (NOT TRUSTED)
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
ref: ${{ inputs.SHA || github.sha }}
persist-credentials: false
# Load Ginkgo build from GitHub
- name: Load ginkgo E2E from GH cache
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
id: cache
with:
path: /tmp/.ginkgo-build/
key: ${{ runner.os }}-ginkgo-e2e-${{ hashFiles('**/*.go') }}
- name: Install Go
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
# renovate: datasource=golang-version depName=go
go-version: 1.23.2
- name: Build Ginkgo
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
go install github.com/onsi/ginkgo/ginkgo@v1.16.5
mkdir -p /tmp/.ginkgo-build
- name: Build Test
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd test
/home/runner/go/bin/ginkgo build
strip test.test
tar -cz test.test -f test.tgz
- name: Store Ginkgo Test in GitHub cache path
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
mkdir -p /tmp/.ginkgo-build/
if [ -f test/test.tgz ]; then
cp test/test.tgz /tmp/.ginkgo-build/
echo "file copied"
fi
wait-for-images:
needs: setup-vars
runs-on: ubuntu-latest
name: Wait for images
timeout-minutes: 30
steps:
- name: Checkout context ref (trusted)
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
ref: ${{ inputs.context-ref || github.sha }}
persist-credentials: false
- name: Set Environment Variables
uses: ./.github/actions/set-env-variables
- name: Wait for images
uses: ./.github/actions/wait-for-images
with:
SHA: ${{ inputs.SHA }}
generate-matrix:
name: Generate Job Matrix from YAMLs
needs: setup-vars
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout context ref (trusted)
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
ref: ${{ inputs.context-ref || github.sha }}
persist-credentials: false
- name: Convert YAML to JSON
run: |
work_dir=".github/actions/ginkgo"
destination_directory="/tmp/generated/ginkgo"
mkdir -p "${destination_directory}"
for file in "${work_dir}"/main*.yaml; do
if [[ -f "$file" ]]; then
filename=$(basename "$file")
new_filename="${filename%.yaml}.json"
yq -o=json "${file}" | jq . > "${destination_directory}/${new_filename}"
fi
done
- name: Generate Matrix
id: set-matrix
run: |
if ${{ github.event_name == 'schedule' }}; then
k8s_versions_to_run='main-scheduled.json'
else
k8s_versions_to_run='main-prs.json'
fi
# Generate a Matrix from all k8s versions defined in '${k8s_versions_to_run}'
# combined with 'main-focus.yaml'.
# Use 'main-k8s-versions.yaml' to
# retrieve which kernel versions should be used for which k8s version.
dir="/tmp/generated/ginkgo"
cd ${dir}
jq --argjson prs "$(jq '.["k8s-version"]' ${k8s_versions_to_run})" \
--slurpfile focus main-focus.json \
'.include |= map(select(.["k8s-version"] as $k | $prs[] | select($k == .))) + $focus[0].include |
. + {"k8s-version": $prs} |
.focus = $focus[0].focus | .exclude = $focus[0].exclude' \
main-k8s-versions.json> /tmp/merged.json
echo "Generated matrix:"
cat /tmp/merged.json
echo "matrix=$(jq -c . < /tmp/merged.json)" >> $GITHUB_OUTPUT
setup-and-test:
needs: [setup-vars, build-ginkgo-binary, generate-matrix, wait-for-images]
runs-on: ${{ vars.GH_RUNNER_EXTRA_POWER_UBUNTU_LATEST || 'ubuntu-latest' }}
timeout-minutes: 45
name: "E2E Test (${{ matrix.k8s-version }}, ${{matrix.focus}})"
env:
job_name: "E2E Test (${{ matrix.k8s-version }}, ${{matrix.focus}})"
strategy:
fail-fast: false
max-parallel: 60
matrix: ${{ fromJSON(needs.generate-matrix.outputs.matrix) }}
steps:
- name: Collect Workflow Telemetry
uses: catchpoint/workflow-telemetry-action@94c3c3d9567a0205de6da68a76c428ce4e769af1 # v2.0.0
with:
comment_on_pr: false
- name: Checkout context ref (trusted)
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
ref: ${{ inputs.context-ref || github.sha }}
persist-credentials: false
- name: Cleanup Disk space in runner
if: runner.name == 'ubuntu-latest'
uses: ./.github/actions/disk-cleanup
- name: Set Environment Variables
uses: ./.github/actions/set-env-variables
# Warning: since this is a privileged workflow, subsequent workflow job
# steps must take care not to execute untrusted code.
- name: Checkout pull request branch (NOT TRUSTED)
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
ref: ${{ inputs.SHA || github.sha }}
persist-credentials: false
- name: Install cilium-cli
uses: cilium/cilium-cli@6977c4a640ad45da3a95eb12054497f2bdd22c48 # v0.16.19
with:
skip-build: ${{ env.CILIUM_CLI_SKIP_BUILD }}
ci-version: ${{ env.CILIUM_CLI_VERSION }}
binary-dir: '.'
- name: Install helm
shell: bash
run: |
# renovate: datasource=github-releases depName=helm/helm
HELM_VERSION=v3.13.1
wget "https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz"
tar -xf "helm-${HELM_VERSION}-linux-amd64.tar.gz"
mv ./linux-amd64/helm ./helm
- name: Provision LVH VMs
id: provision-vh-vms
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
with:
test-name: datapath-conformance
install-dependencies: true
image-version: ${{ matrix.kernel }}
images-folder-parent: "/tmp"
host-mount: ./
cpu: 4
mem: 12G
# renovate: datasource=github-tags depName=cilium/little-vm-helper
lvh-version: "v0.0.19"
cmd: |
git config --global --add safe.directory /host
mv /host/helm /usr/bin
mv /host/cilium /usr/bin/cilium-cli
- name: Provision kind
timeout-minutes: 5
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
with:
provision: 'false'
cmd: |
cd /host/
if [[ "${{ matrix.kernel }}" == bpf-next-* ]]; then
./contrib/scripts/kind.sh "" 2 "" "${{ matrix.kube-image }}" "none" "${{ matrix.ip-family }}"
kubectl label node kind-worker2 cilium.io/ci-node=kind-worker2
# Avoid re-labeling this node by setting "node-role.kubernetes.io/controlplane"
kubectl label node kind-worker2 node-role.kubernetes.io/controlplane=
else
./contrib/scripts/kind.sh "" 1 "" "${{ matrix.kube-image }}" "iptables" "${{ matrix.ip-family }}"
fi
git config --add safe.directory /cilium
# Load Ginkgo build from GitHub
- name: Load ${{ matrix.name }} Ginkgo build from GitHub
uses: actions/cache/restore@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
id: cache
with:
path: /tmp/.ginkgo-build/
key: ${{ runner.os }}-ginkgo-e2e-${{ hashFiles('**/*.go') }}
# Re-build the tests if it was a cache miss.
- name: Install Go
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
# renovate: datasource=golang-version depName=go
go-version: 1.23.2
- name: Build Ginkgo
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
go install github.com/onsi/ginkgo/ginkgo@v1.16.5
mkdir -p /tmp/.ginkgo-build
- name: Build Test
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
cd test
/home/runner/go/bin/ginkgo build
strip test.test
tar -cz test.test -f test.tgz
- name: Store Ginkgo Test in GitHub cache path
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
mkdir -p /tmp/.ginkgo-build/
if [ -f test/test.tgz ]; then
cp test/test.tgz /tmp/.ginkgo-build/
echo "file copied"
fi
- name: Copy Ginkgo binary
shell: bash
run: |
cd test/
tar -xf /tmp/.ginkgo-build/test.tgz
- name: Run tests
id: run-tests
timeout-minutes: 40
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
with:
provision: 'false'
cmd: |
cd /host/test/
kubectl get ns -A -o wide
kubectl get pods -A -o wide
export K8S_NODES=2
export NETNEXT=0
if [[ "${{ matrix.kernel }}" == bpf-next-* ]]; then
export KERNEL=net-next
export NETNEXT=1
export KUBEPROXY=0
export K8S_NODES=3
export NO_CILIUM_ON_NODES=kind-worker2
elif [[ "${{ matrix.kernel }}" == 5.4-* ]]; then
export KERNEL=54
fi
export K8S_VERSION=${{ matrix.k8s-version }}
export CNI_INTEGRATION=kind
export INTEGRATION_TESTS=true
# GitHub actions do not support IPv6 connectivity to outside
# world.
export CILIUM_NO_IPV6_OUTSIDE=true
echo "/root/go/bin/ginkgo \
--focus=\"${{ matrix.cliFocus }}\" \
--skip=\"${{ matrix.cliSkip }}\" \
--seed=1679952881 \
-v -- \
-cilium.provision=false \
-cilium.image=quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/cilium-ci \
-cilium.tag=${{ needs.setup-vars.outputs.SHA }} \
-cilium.operator-image=quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/operator \
-cilium.operator-tag=${{ needs.setup-vars.outputs.SHA }} \
-cilium.hubble-relay-image=quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/hubble-relay-ci \
-cilium.hubble-relay-tag=${{ needs.setup-vars.outputs.SHA }} \
-cilium.kubeconfig=/root/.kube/config \
-cilium.provision-k8s=false \
-cilium.operator-suffix=-ci ${{ env.CILIUM_GINKGO_EXTRA_ARGS }}"
./test.test \
--ginkgo.focus="${{ matrix.cliFocus }}" \
--ginkgo.skip="${{ matrix.cliSkip }}" \
--ginkgo.seed=1679952881 \
--ginkgo.v -- \
-cilium.provision=false \
-cilium.image=quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/cilium-ci \
-cilium.tag=${{ needs.setup-vars.outputs.SHA }} \
-cilium.operator-image=quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/operator \
-cilium.operator-tag=${{ needs.setup-vars.outputs.SHA }} \
-cilium.hubble-relay-image=quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/hubble-relay-ci \
-cilium.hubble-relay-tag=${{ needs.setup-vars.outputs.SHA }} \
-cilium.kubeconfig=/root/.kube/config \
-cilium.provision-k8s=false \
-cilium.operator-suffix=-ci ${{ env.CILIUM_GINKGO_EXTRA_ARGS }}
- name: Fetch artifacts
if: ${{ !success() && steps.provision-vh-vms.outcome == 'success' }}
uses: cilium/little-vm-helper@97c89f004bd0ab4caeacfe92ebc956e13e362e6b # v0.0.19
with:
provision: 'false'
cmd: |
cd /host
kubectl get pods --all-namespaces -o wide
tar -zcf "test_results-${{ env.job_name }}.tar.gz" /host/test/test_results
- name: Upload artifacts
if: ${{ !success() }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: cilium-sysdumps-${{ matrix.k8s-version }}-${{matrix.focus}}
path: |
cilium-sysdump-*.zip
bugtool-*.tar.gz
test_results-*.tar.gz
- name: Fetch JUnits
if: ${{ always() && steps.run-tests.outcome != 'skipped' }}
shell: bash
run: |
mkdir -p cilium-junits
cd test/
junit_filename="${{ env.job_name }}.xml"
for filename in *.xml; do cp "${filename}" "../cilium-junits/${junit_filename}"; done;
- name: Upload JUnits [junit]
if: ${{ always() }}
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
with:
name: cilium-junits-${{ matrix.k8s-version }}-${{matrix.focus}}
path: cilium-junits/*.xml
- name: Publish Test Results As GitHub Summary
if: ${{ always() }}
uses: aanm/junit2md@332ebf0fddd34e91b03a832cfafaa826306558f9 # v0.0.3
with:
junit-directory: "cilium-junits"
merge-upload:
if: ${{ always() }}
name: Merge and Upload Artifacts
runs-on: ubuntu-latest
needs: setup-and-test
steps:
- name: Checkout context ref (trusted)
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4.2.1
with:
ref: ${{ inputs.context-ref || github.sha }}
persist-credentials: false
- name: Merge Sysdumps
uses: ./.github/actions/merge-artifacts
with:
name: cilium-sysdumps
pattern: cilium-sysdumps-*
token: ${{ secrets.GITHUB_TOKEN }}
- name: Merge JUnits
uses: ./.github/actions/merge-artifacts
with:
name: cilium-junits
pattern: cilium-junits-*
token: ${{ secrets.GITHUB_TOKEN }}
commit-status-final:
if: ${{ always() }}
name: Commit Status Final
needs: setup-and-test
runs-on: ubuntu-latest
steps:
- name: Determine final commit status
id: commit-status
shell: bash
run: |
# When one of the prerequisites of setup-and-test fails, then that
# job gets skipped. Let's convert the status so that we correctly
# report that as a proper failure.
if [ "${{ needs.setup-and-test.result }}" != "skipped" ]; then
echo "status=${{ needs.setup-and-test.result }}" >> $GITHUB_OUTPUT
else
echo "status=failure" >> $GITHUB_OUTPUT
fi
- name: Set final commit status
uses: myrotvorets/set-commit-status-action@3730c0a348a2ace3c110851bed53331bc6406e9f # v2.0.1
with:
sha: ${{ inputs.SHA || github.sha }}
status: ${{ steps.commit-status.outputs.status }}