Skip to content

Commit 2a3da7a

Browse files
authored
[chore] Build container images once for e2e tests (#3900)
# Conflicts: # .github/workflows/e2e.yaml
1 parent f15e959 commit 2a3da7a

File tree

2 files changed

+62
-3
lines changed

2 files changed

+62
-3
lines changed

.github/workflows/e2e.yaml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,45 @@ concurrency:
1313
permissions:
1414
contents: read
1515

16+
env:
17+
IMAGE_ARCHIVE_FILENAME: images.tar
18+
VERSION: e2e
19+
1620
jobs:
21+
build-test-images:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Check out code into the Go module directory
25+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
26+
- name: Set up Go
27+
uses: actions/setup-go@0aaccfd150d50ccaeb58ebd88d36e91967a5f35b # v5.4.0
28+
id: setup-go
29+
with:
30+
go-version: "~1.24.2"
31+
32+
- name: Cache tools
33+
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3
34+
with:
35+
path: bin
36+
key: tools-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('Makefile') }}-${{ steps.setup-go.outputs.go-version }}
37+
38+
- name: Install tools
39+
run: make install-tools
40+
41+
- name: Build test image archive
42+
run: make container-image-archive IMAGE_ARCHIVE=${IMAGE_ARCHIVE_FILENAME} VERSION=${VERSION}
43+
44+
- name: Upload test image archive
45+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
46+
with:
47+
name: Test image archive
48+
path: ${{ env.IMAGE_ARCHIVE_FILENAME }}
49+
if-no-files-found: 'error'
50+
retention-days: 1
51+
1752
e2e-tests:
1853
runs-on: ubuntu-latest
54+
needs: [build-test-images]
1955
strategy:
2056
fail-fast: false
2157
matrix:
@@ -75,12 +111,17 @@ jobs:
75111
- name: Install tools
76112
run: make install-tools
77113

114+
- name: Download test image archive
115+
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
116+
with:
117+
name: Test image archive
118+
78119
- name: Prepare e2e tests
79120
env:
80121
KUBE_VERSION: ${{ matrix.kube-version }}
81122
run: |
82123
set -e
83-
make ${{ matrix.setup != '' && matrix.setup || 'prepare-e2e' }} KUBE_VERSION=$KUBE_VERSION VERSION=e2e
124+
make ${{ matrix.setup != '' && matrix.setup || 'prepare-e2e' }} KUBE_VERSION=$KUBE_VERSION VERSION=$VERSION IMAGE_ARCHIVE=$IMAGE_ARCHIVE_FILENAME
84125
- name: Run e2e tests
85126
env:
86127
KUBE_VERSION: ${{ matrix.kube-version }}

Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ e2e-upgrade: undeploy chainsaw
370370
$(CHAINSAW) test --test-dir ./tests/e2e-upgrade
371371

372372
.PHONY: prepare-e2e
373-
prepare-e2e: chainsaw set-image-controller add-image-targetallocator add-image-opampbridge container container-target-allocator container-operator-opamp-bridge container-bridge-test-server start-kind cert-manager install-metrics-server install-targetallocator-prometheus-crds load-image-all deploy
373+
prepare-e2e: chainsaw set-image-controller add-image-targetallocator add-image-opampbridge start-kind cert-manager install-metrics-server install-targetallocator-prometheus-crds load-image-all deploy
374374

375375
.PHONY: scorecard-tests
376376
scorecard-tests: operator-sdk
@@ -438,7 +438,13 @@ install-targetallocator-prometheus-crds:
438438
./hack/install-targetallocator-prometheus-crds.sh
439439

440440
.PHONY: load-image-all
441-
load-image-all: load-image-operator load-image-target-allocator load-image-operator-opamp-bridge load-image-bridge-test-server
441+
load-image-all:
442+
ifeq ($(IMAGE_ARCHIVE),)
443+
@make container container-target-allocator container-operator-opamp-bridge container-bridge-test-server load-image-operator load-image-target-allocator load-image-operator-opamp-bridge load-image-bridge-test-server
444+
else
445+
$(KIND) load --name $(KIND_CLUSTER_NAME) image-archive $(IMAGE_ARCHIVE)
446+
endif
447+
442448

443449
.PHONY: load-image-operator
444450
load-image-operator: container kind
@@ -718,3 +724,15 @@ catalog-build: opm bundle-build bundle-push ## Build a catalog image.
718724
.PHONY: catalog-push
719725
catalog-push: ## Push a catalog image.
720726
docker push $(CATALOG_IMG)
727+
728+
container-image-archive: IMAGE_LIST_FILE = images-$(VERSION).txt
729+
container-image-archive: container container-target-allocator container-operator-opamp-bridge container-bridge-test-server
730+
ifeq ($(IMAGE_ARCHIVE),)
731+
$(error "Use make container-image-archive IMAGE_ARCHIVE=<filename>")
732+
endif
733+
@rm -f $(IMAGE_LIST_FILE)
734+
@echo "$(IMG)" >>$(IMAGE_LIST_FILE)
735+
@echo "$(TARGETALLOCATOR_IMG)" >>$(IMAGE_LIST_FILE)
736+
@echo "$(OPERATOROPAMPBRIDGE_IMG)" >>$(IMAGE_LIST_FILE)
737+
@echo "$(BRIDGETESTSERVER_IMG)" >>$(IMAGE_LIST_FILE)
738+
xargs -x -n 50 docker save -o "$(IMAGE_ARCHIVE)" <$(IMAGE_LIST_FILE)

0 commit comments

Comments
 (0)