Skip to content

Commit cfe05d5

Browse files
ci: build e2e image once and reuse across jobs (#3575)
Signed-off-by: Jintao Zhang <zhangjintao9020@gmail.com> Co-authored-by: Patryk Małek <pmalek@users.noreply.github.com>
1 parent bca4b8d commit cfe05d5

File tree

3 files changed

+52
-7
lines changed

3 files changed

+52
-7
lines changed

.github/workflows/__e2e_chainsaw_tests.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ jobs:
3232
egress-policy: audit
3333
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
3434

35-
- name: build docker image
36-
run: make docker.build
35+
- name: download e2e image artifact
36+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
37+
with:
38+
name: kong-operator-e2e-image-${{ github.run_id }}
39+
40+
- name: load docker image
41+
run: docker load -i kong-operator_e2e.tar
3742

3843
- uses: jdx/mise-action@c1ecc8f748cd28cdeabf76dab3cccde4ce692fe4 # v4.0.0
3944
with:

.github/workflows/__e2e_tests.yaml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ jobs:
2929
go-version-file: go.mod
3030
cache: false
3131

32-
- name: build docker image
33-
env:
34-
IMG: kong-operator
35-
TAG: e2e-${{ github.sha }}
36-
run: make docker.build
32+
- name: download e2e image artifact
33+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
34+
with:
35+
name: kong-operator-e2e-image-${{ github.run_id }}
36+
37+
- name: load docker image
38+
run: docker load -i kong-operator_e2e.tar
3739

3840
- uses: jdx/mise-action@c1ecc8f748cd28cdeabf76dab3cccde4ce692fe4 # v4.0.0
3941
with:

.github/workflows/tests.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,41 @@ env:
4242
MISE_VERBOSE: 1
4343

4444
jobs:
45+
build-e2e-image:
46+
runs-on: ubuntu-latest
47+
needs: [check-docs-only]
48+
if: ${{ needs.check-docs-only.outputs.docs_only != 'true' }}
49+
env:
50+
IMG: kong-operator
51+
TAG: e2e-${{ github.sha }}
52+
steps:
53+
- name: Harden Runner
54+
uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0
55+
with:
56+
egress-policy: audit
57+
- name: checkout repository
58+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
59+
60+
- name: setup golang
61+
uses: actions/setup-go@4b73464bb391d4059bd26b0524d20df3927bd417 # v6.3.0
62+
with:
63+
go-version-file: go.mod
64+
cache: false
65+
66+
- name: build docker image
67+
run: make docker.build
68+
69+
- name: save docker image as artifact
70+
run: docker save ${{ env.IMG }}:${{ env.TAG }} -o kong-operator_e2e.tar
71+
72+
- name: upload docker image artifact
73+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
74+
with:
75+
name: kong-operator-e2e-image-${{ github.run_id }}
76+
path: kong-operator_e2e.tar
77+
retention-days: 1
78+
if-no-files-found: error
79+
4580
check-docs-only:
4681
runs-on: ubuntu-latest
4782
outputs:
@@ -352,6 +387,7 @@ jobs:
352387
e2e-tests:
353388
needs:
354389
- check-docs-only
390+
- build-e2e-image
355391
- matrix_k8s_node_versions
356392
if: ${{ needs.check-docs-only.outputs.docs_only != 'true' }}
357393
uses: ./.github/workflows/__e2e_tests.yaml
@@ -360,6 +396,7 @@ jobs:
360396
e2e-tests-chainsaw:
361397
needs:
362398
- check-docs-only
399+
- build-e2e-image
363400
- matrix_k8s_node_versions
364401
if: ${{ needs.check-docs-only.outputs.docs_only != 'true' }}
365402
uses: ./.github/workflows/__e2e_chainsaw_tests.yaml
@@ -420,6 +457,7 @@ jobs:
420457
- samples
421458
- install-with-kustomize
422459
- build
460+
- build-e2e-image
423461
- CRDs
424462
- unit-tests
425463
- envtest-tests

0 commit comments

Comments
 (0)