14
14
description : " Force rebuild"
15
15
required : false
16
16
default : false
17
+ run_tests :
18
+ type : boolean
19
+ description : " Run unit & e2e tests"
20
+ required : false
21
+ default : true
17
22
18
23
defaults :
19
24
run :
35
40
id-token : write
36
41
outputs :
37
42
docs_only : ${{ github.event.pull_request && steps.docs.outputs.docs_only == 'true' }}
38
- k8s_latest : " 1.32.0 "
43
+ k8s_latest : ${{ steps.vars.outputs.k8s_latest }}
39
44
go_path : ${{ steps.vars.outputs.go_path }}
40
45
go_code_md5 : ${{ steps.vars.outputs.go_code_md5 }}
41
46
binary_cache_hit : ${{ steps.binary-cache.outputs.cache-hit }}
@@ -215,25 +220,25 @@ jobs:
215
220
uses : actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
216
221
with :
217
222
go-version-file : go.mod
218
- if : ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
223
+ if : ${{ needs.checks.outputs.binary_cache_hit != 'true' && (inputs.run_tests && inputs.run_tests || true) }}
219
224
220
225
- name : Run Tests
221
226
run : make cover
222
- if : ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
227
+ if : ${{ needs.checks.outputs.binary_cache_hit != 'true' && (inputs.run_tests && inputs.run_tests || true) }}
223
228
224
229
- name : Upload coverage to Codecov
225
230
uses : codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
226
231
with :
227
232
files : ./coverage.txt
228
233
token : ${{ secrets.CODECOV_TOKEN }} # required
229
- if : ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
234
+ if : ${{ needs.checks.outputs.binary_cache_hit != 'true' && (inputs.run_tests && inputs.run_tests || true) }}
230
235
231
236
- name : Run static check
232
237
uses : dominikh/staticcheck-action@024238d2898c874f26d723e7d0ff4308c35589a2 # v1.4.0
233
238
with :
234
239
version : " v0.6.0"
235
240
install-go : false
236
- if : ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
241
+ if : ${{ needs.checks.outputs.binary_cache_hit != 'true' && (inputs.run_tests && inputs.run_tests || true) }}
237
242
238
243
binaries :
239
244
name : Build Binaries
@@ -253,7 +258,7 @@ jobs:
253
258
uses : actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
254
259
with :
255
260
go-version-file : go.mod
256
- if : ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
261
+ if : ${{ (inputs.force && inputs.force || false) || needs.checks.outputs.binary_cache_hit != 'true' }}
257
262
258
263
- name : Build binaries
259
264
uses : goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
@@ -272,14 +277,14 @@ jobs:
272
277
AWS_NAP_WAF_DOS_PRODUCT_CODE : ${{ secrets.AWS_NAP_WAF_DOS_PRODUCT_CODE }}
273
278
AWS_NAP_WAF_DOS_PUB_KEY : ${{ secrets.AWS_NAP_WAF_DOS_PUB_KEY }}
274
279
GORELEASER_CURRENT_TAG : " v${{ needs.checks.outputs.ic_version }}"
275
- if : ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
280
+ if : ${{ (inputs.force && inputs.force || false) || needs.checks.outputs.binary_cache_hit != 'true' }}
276
281
277
282
- name : Store Artifacts in Cache
278
283
uses : actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
279
284
with :
280
285
path : ${{ github.workspace }}/dist
281
286
key : nginx-ingress-${{ needs.checks.outputs.go_code_md5 }}
282
- if : ${{ needs.checks.outputs.binary_cache_hit != 'true' }}
287
+ if : ${{ (inputs.force && inputs.force || false) || needs.checks.outputs.binary_cache_hit != 'true' }}
283
288
284
289
build-docker :
285
290
name : Build Docker OSS
@@ -372,8 +377,68 @@ jobs:
372
377
secrets : inherit
373
378
if : ${{ inputs.force || (needs.checks.outputs.forked_workflow == 'true' && needs.checks.outputs.docs_only == 'false') || (needs.checks.outputs.forked_workflow == 'false' && needs.checks.outputs.stable_image_exists != 'true' && needs.checks.outputs.docs_only == 'false') }}
374
379
380
+ package-tests :
381
+ if : ${{ needs.checks.outputs.docs_only != 'true' && (inputs.run_tests && inputs.run_tests || true) }}
382
+ name : Package Tests
383
+ runs-on : ubuntu-22.04
384
+ needs : [checks, binaries, build-docker, build-docker-plus, build-docker-nap]
385
+ permissions :
386
+ contents : read
387
+ pull-requests : write # for package report
388
+ id-token : write
389
+ steps :
390
+ - name : Checkout Repository
391
+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
392
+
393
+ - name : Setup QEMU
394
+ uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
395
+ with :
396
+ platforms : arm64
397
+ if : ${{ needs.checks.outputs.forked_workflow == 'false' || needs.checks.outputs.docs_only == 'false' }}
398
+
399
+ - name : Authenticate to Google Cloud
400
+ id : auth
401
+ uses : google-github-actions/auth@ba79af03959ebeac9769e648f473a284504d9193 # v2.1.10
402
+ with :
403
+ token_format : access_token
404
+ workload_identity_provider : ${{ secrets.GCR_WORKLOAD_IDENTITY }}
405
+ service_account : ${{ secrets.GCR_SERVICE_ACCOUNT }}
406
+ if : ${{ needs.checks.outputs.forked_workflow == 'false' || needs.checks.outputs.docs_only == 'false' }}
407
+
408
+ - name : Login to GCR
409
+ uses : docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
410
+ with :
411
+ registry : gcr.io
412
+ username : oauth2accesstoken
413
+ password : ${{ steps.auth.outputs.access_token }}
414
+ if : ${{ needs.checks.outputs.forked_workflow == 'false' || needs.checks.outputs.docs_only == 'false' }}
415
+
416
+ - name : Install Python dependencies
417
+ run : |
418
+ make -f tests/Makefile setup-venv
419
+ if : ${{ needs.checks.outputs.forked_workflow == 'false' || needs.checks.outputs.docs_only == 'false' }}
420
+
421
+ - name : Run tests
422
+ id : packages
423
+ run : |
424
+ source tests/venv/bin/activate
425
+ python tests/scripts/check_container_packages.py --tag ${{ needs.checks.outputs.build_tag }} --log package_output.txt
426
+ if : ${{ needs.checks.outputs.forked_workflow == 'false' || needs.checks.outputs.docs_only == 'false' }}
427
+
428
+ - name : Add comment
429
+ run : |
430
+ # make sure the comment is formatted correctly, as a code block
431
+ echo '### Package Report' > output.txt
432
+ echo '```' >> output.txt
433
+ cat package_output.txt >> output.txt
434
+ echo '```' >> output.txt
435
+ gh pr comment --edit-last --create-if-none ${{ github.event.pull_request.number }} -F output.txt
436
+ env :
437
+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
438
+ if : ${{ ( needs.checks.outputs.forked_workflow == 'false' || needs.checks.outputs.docs_only == 'false' ) && github.event.pull_request }}
439
+
375
440
helm-tests :
376
- if : ${{ needs.checks.outputs.docs_only != 'true' }}
441
+ if : ${{ needs.checks.outputs.docs_only != 'true' && (inputs.run_tests && inputs.run_tests || true) }}
377
442
name : Helm Tests ${{ matrix.base-os }}
378
443
runs-on : ubuntu-22.04
379
444
needs : [checks, binaries, build-docker, build-docker-plus]
@@ -512,7 +577,7 @@ jobs:
512
577
if : ${{ steps.stable_exists.outputs.exists != 'true' && needs.checks.outputs.docs_only == 'false' }}
513
578
514
579
setup-matrix :
515
- if : ${{ inputs.force || needs.checks.outputs.docs_only != 'true' }}
580
+ if : ${{ inputs.force || (inputs.run_tests && inputs.run_tests || true) || needs.checks.outputs.docs_only != 'true' }}
516
581
name : Setup Matrix for Smoke Tests
517
582
runs-on : ubuntu-22.04
518
583
needs : [binaries, checks]
@@ -574,7 +639,7 @@ jobs:
574
639
if : ${{ steps.check-image.outcome == 'failure' && needs.checks.outputs.docs_only == 'false' }}
575
640
576
641
smoke-tests-oss :
577
- if : ${{ inputs.force || needs.checks.outputs.docs_only != 'true' }}
642
+ if : ${{ inputs.force || (inputs.run_tests && inputs.run_tests || true) || needs.checks.outputs.docs_only != 'true' }}
578
643
name : ${{ matrix.images.label }} ${{ matrix.images.image }} ${{ matrix.k8s }} smoke tests
579
644
needs :
580
645
- checks
@@ -601,7 +666,7 @@ jobs:
601
666
k8s-version : ${{ matrix.k8s }}
602
667
603
668
smoke-tests-plus :
604
- if : ${{ inputs.force || needs.checks.outputs.docs_only != 'true' }}
669
+ if : ${{ inputs.force || (inputs.run_tests && inputs.run_tests || true) || needs.checks.outputs.docs_only != 'true' }}
605
670
name : ${{ matrix.images.label }} ${{ matrix.images.image }} ${{ matrix.k8s }} smoke tests
606
671
needs :
607
672
- checks
@@ -628,7 +693,7 @@ jobs:
628
693
k8s-version : ${{ matrix.k8s }}
629
694
630
695
smoke-tests-nap :
631
- if : ${{ inputs.force || needs.checks.outputs.docs_only != 'true' }}
696
+ if : ${{ inputs.force || (inputs.run_tests && inputs.run_tests || true) || needs.checks.outputs.docs_only != 'true' }}
632
697
name : ${{ matrix.images.label }} ${{ matrix.images.image }} ${{ matrix.k8s }} smoke tests
633
698
needs :
634
699
- checks
@@ -672,10 +737,12 @@ jobs:
672
737
if : ${{ !cancelled() }}
673
738
runs-on : ubuntu-22.04
674
739
name : Final CI Results
675
- needs : [tag-stable, build-docker, build-docker-plus, build-docker-nap, smoke-tests-oss, smoke-tests-plus, smoke-tests-nap]
740
+ needs : [tag-stable, build-docker, build-docker-plus, build-docker-nap, smoke-tests-oss, smoke-tests-plus, smoke-tests-nap, package-tests, helm-tests ]
676
741
steps :
677
742
- run : |
678
743
tagResult="${{ needs.tag-stable.result }}"
744
+ packageResult="${{ needs.package-tests.result }}"
745
+ helmResult="${{ needs.helm-tests.result }}"
679
746
smokeOSSResult="${{ needs.smoke-tests-oss.result }}"
680
747
smokePlusResult="${{ needs.smoke-tests-plus.result }}"
681
748
smokeNAPResult="${{ needs.smoke-tests-nap.result }}"
@@ -703,6 +770,12 @@ jobs:
703
770
if [[ $buildNAPResult != "success" && $buildNAPResult != "skipped" ]]; then
704
771
exit 1
705
772
fi
773
+ if [[ $helmResult != "success" && $helmResult != "skipped" ]]; then
774
+ exit 1
775
+ fi
776
+ if [[ $packageResult != "success" && $packageResult != "skipped" ]]; then
777
+ exit 1
778
+ fi
706
779
707
780
trigger-image-promotion :
708
781
name : Promote images on Force Run
0 commit comments