1414 description : " Force rebuild"
1515 required : false
1616 default : false
17+ run_tests :
18+ type : boolean
19+ description : " Run unit & e2e tests"
20+ required : false
21+ default : true
1722
1823defaults :
1924 run :
3540 id-token : write
3641 outputs :
3742 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 }}
3944 go_path : ${{ steps.vars.outputs.go_path }}
4045 go_code_md5 : ${{ steps.vars.outputs.go_code_md5 }}
4146 binary_cache_hit : ${{ steps.binary-cache.outputs.cache-hit }}
@@ -215,25 +220,25 @@ jobs:
215220 uses : actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
216221 with :
217222 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) }}
219224
220225 - name : Run Tests
221226 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) }}
223228
224229 - name : Upload coverage to Codecov
225230 uses : codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5.4.3
226231 with :
227232 files : ./coverage.txt
228233 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) }}
230235
231236 - name : Run static check
232237 uses : dominikh/staticcheck-action@024238d2898c874f26d723e7d0ff4308c35589a2 # v1.4.0
233238 with :
234239 version : " v0.6.0"
235240 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) }}
237242
238243 binaries :
239244 name : Build Binaries
@@ -253,7 +258,7 @@ jobs:
253258 uses : actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
254259 with :
255260 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' }}
257262
258263 - name : Build binaries
259264 uses : goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
@@ -272,14 +277,14 @@ jobs:
272277 AWS_NAP_WAF_DOS_PRODUCT_CODE : ${{ secrets.AWS_NAP_WAF_DOS_PRODUCT_CODE }}
273278 AWS_NAP_WAF_DOS_PUB_KEY : ${{ secrets.AWS_NAP_WAF_DOS_PUB_KEY }}
274279 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' }}
276281
277282 - name : Store Artifacts in Cache
278283 uses : actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
279284 with :
280285 path : ${{ github.workspace }}/dist
281286 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' }}
283288
284289 build-docker :
285290 name : Build Docker OSS
@@ -372,8 +377,68 @@ jobs:
372377 secrets : inherit
373378 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') }}
374379
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+
375440 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) }}
377442 name : Helm Tests ${{ matrix.base-os }}
378443 runs-on : ubuntu-22.04
379444 needs : [checks, binaries, build-docker, build-docker-plus]
@@ -512,7 +577,7 @@ jobs:
512577 if : ${{ steps.stable_exists.outputs.exists != 'true' && needs.checks.outputs.docs_only == 'false' }}
513578
514579 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' }}
516581 name : Setup Matrix for Smoke Tests
517582 runs-on : ubuntu-22.04
518583 needs : [binaries, checks]
@@ -574,7 +639,7 @@ jobs:
574639 if : ${{ steps.check-image.outcome == 'failure' && needs.checks.outputs.docs_only == 'false' }}
575640
576641 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' }}
578643 name : ${{ matrix.images.label }} ${{ matrix.images.image }} ${{ matrix.k8s }} smoke tests
579644 needs :
580645 - checks
@@ -601,7 +666,7 @@ jobs:
601666 k8s-version : ${{ matrix.k8s }}
602667
603668 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' }}
605670 name : ${{ matrix.images.label }} ${{ matrix.images.image }} ${{ matrix.k8s }} smoke tests
606671 needs :
607672 - checks
@@ -628,7 +693,7 @@ jobs:
628693 k8s-version : ${{ matrix.k8s }}
629694
630695 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' }}
632697 name : ${{ matrix.images.label }} ${{ matrix.images.image }} ${{ matrix.k8s }} smoke tests
633698 needs :
634699 - checks
@@ -672,10 +737,12 @@ jobs:
672737 if : ${{ !cancelled() }}
673738 runs-on : ubuntu-22.04
674739 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 ]
676741 steps :
677742 - run : |
678743 tagResult="${{ needs.tag-stable.result }}"
744+ packageResult="${{ needs.package-tests.result }}"
745+ helmResult="${{ needs.helm-tests.result }}"
679746 smokeOSSResult="${{ needs.smoke-tests-oss.result }}"
680747 smokePlusResult="${{ needs.smoke-tests-plus.result }}"
681748 smokeNAPResult="${{ needs.smoke-tests-nap.result }}"
@@ -703,6 +770,12 @@ jobs:
703770 if [[ $buildNAPResult != "success" && $buildNAPResult != "skipped" ]]; then
704771 exit 1
705772 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
706779
707780 trigger-image-promotion :
708781 name : Promote images on Force Run
0 commit comments