forked from cilium/cilium
-
Notifications
You must be signed in to change notification settings - Fork 0
485 lines (439 loc) · 17.8 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
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: '{}'
# Run every 6 hours
schedule:
- cron: '0 1/6 * * *'
# By specifying the access of one of the scopes, all of those that are not
# specified are set to 'none'.
permissions:
# 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 == 'schedule' && github.sha) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.PR-number)
}}
cancel-in-progress: true
env:
check_url: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
jobs:
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@38f3f27c7d52fb381273e95542f07f0fba301307 # v2.0.0
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.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@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
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@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
# renovate: datasource=golang-version depName=go
go-version: 1.21.5
- name: Build Ginkgo
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
go install github.com/onsi/ginkgo/[email protected]
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.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 to be available
timeout-minutes: 30
shell: bash
run: |
for image in cilium-ci operator-generic-ci hubble-relay-ci ; do
until docker manifest inspect quay.io/${{ env.QUAY_ORGANIZATION_DEV }}/$image:${{ needs.setup-vars.outputs.SHA }} &> /dev/null; do sleep 45s; done
done
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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.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})" \
--argfile focus main-focus.json \
'.include |= map(select(.["k8s-version"] as $k | $prs[] | select($k == .))) + $focus.include |
. + {"k8s-version": $prs} |
.focus = $focus.focus | .exclude = $focus.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:
group: ginkgo-runners
timeout-minutes: 35
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: Checkout context ref (trusted)
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ inputs.context-ref || github.sha }}
persist-credentials: false
- 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ inputs.SHA || github.sha }}
persist-credentials: false
- name: Install cilium-cli
shell: bash
run: |
cid=$(docker create quay.io/cilium/cilium-cli-ci:latest ls)
docker cp $cid:/usr/local/bin/cilium ./cilium-cli
docker rm $cid
- 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@8410a93e544b7e180a2365e5fdab0724a39bc02a # v0.0.13
with:
test-name: datapath-conformance
install-dependencies: true
image-version: ${{ matrix.kernel }}
host-mount: ./
cpu: 4
mem: 12G
cmd: |
git config --global --add safe.directory /host
mv /host/helm /usr/bin
mv /host/cilium-cli /usr/bin
- name: Provision kind
timeout-minutes: 5
uses: cilium/little-vm-helper@8410a93e544b7e180a2365e5fdab0724a39bc02a # v0.0.13
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
# Some tests using demo-customcalls.yaml are mounting this directoy
mkdir -p /home/vagrant/go/src/github.com/cilium
ln -s /host /home/vagrant/go/src/github.com/cilium/cilium
git config --add safe.directory /cilium
# Load Ginkgo build from GitHub
- name: Load ${{ matrix.name }} Ginkgo build from GitHub
uses: actions/cache/restore@704facf57e6136b1bc63b828d79edcd491f0ee84 # v3.3.2
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@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
# renovate: datasource=golang-version depName=go
go-version: 1.21.5
- name: Build Ginkgo
if: ${{ steps.cache.outputs.cache-hit != 'true' }}
shell: bash
run: |
go install github.com/onsi/ginkgo/[email protected]
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@8410a93e544b7e180a2365e5fdab0724a39bc02a # v0.0.13
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 }}" == 4.19-* ]]; then
export KERNEL=419
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"
./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
- name: Fetch artifacts
if: ${{ !success() && steps.provision-vh-vms.outcome == 'success' }}
uses: cilium/little-vm-helper@8410a93e544b7e180a2365e5fdab0724a39bc02a # v0.0.13
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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: cilium-sysdumps
path: |
cilium-sysdump-*.zip
bugtool-*.tar.gz
test_results-*.tar.gz
retention-days: 5
- 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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
with:
name: cilium-junits
path: cilium-junits/*.xml
retention-days: 5
- name: Publish Test Results As GitHub Summary
if: ${{ always() }}
uses: aanm/junit2md@332ebf0fddd34e91b03a832cfafaa826306558f9 # v0.0.3
with:
junit-directory: "cilium-junits"
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@38f3f27c7d52fb381273e95542f07f0fba301307 # v2.0.0
with:
sha: ${{ inputs.SHA || github.sha }}
status: ${{ steps.commit-status.outputs.status }}