Skip to content

Commit 35c7dd4

Browse files
author
Per Goncalves da Silva
committed
fixes
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 3cbb56a commit 35c7dd4

File tree

2 files changed

+75
-36
lines changed

2 files changed

+75
-36
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,21 @@ jobs:
2121
- uses: actions/setup-go@v5
2222
with:
2323
go-version-file: "go.mod"
24-
# build binaries and image for e2e test (includes experimental features)
25-
- name: Build controller image
26-
run: make e2e-build
27-
- name: Check for e2e fixture changes
28-
run: |
29-
JOB_ENV="UPDATE_FIXTURES=$(scripts/e2e_test_fixtures.sh --check)"
30-
echo "${JOB_ENV}" >> $GITHUB_ENV
31-
echo "${JOB_ENV}" >> $GITHUB_OUTPUT
32-
- name: Build e2e fixtures if necessary
33-
if: env.UPDATE_FIXTURES == 'true'
34-
run: scripts/e2e_test_fixtures.sh
35-
- name: Save images
24+
# add the fixtures changed flag (UPDATE_FIXTURES) to the job output to others can use it
25+
- name: Rebuild fixtures if necessary
3626
run: |
27+
UPDATE_FIXTURES="$(scripts/e2e_test_fixtures.sh --check)"
3728
if [ "${UPDATE_FIXTURES}" == "true" ]; then
29+
# rebuild fixtures and export the images to .tar.gz files with --save
3830
scripts/e2e_test_fixtures.sh --save
3931
fi
32+
33+
# build binaries and image for e2e test (includes experimental features)
34+
- name: Build OLM Image
35+
run: |
36+
make e2e-build
4037
docker save quay.io/operator-framework/olm:local | gzip > olm-image.tar.gz
41-
- name: Upload Docker images
38+
- name: Upload Artifacts
4239
uses: actions/upload-artifact@v4
4340
with:
4441
name: docker-images
@@ -147,4 +144,27 @@ jobs:
147144
if: ${{ needs.e2e.result == 'failure' }}
148145
run: |
149146
echo 'Failure: at least one e2e matrix job has failed'
150-
exit 1
147+
exit 1
148+
149+
publish-fixture-images:
150+
if: ${{ needs.build.outputs.UPDATE_FIXTURES == 'true' && success() }}
151+
needs: e2e-tests
152+
runs-on: ubuntu-latest
153+
steps:
154+
# checkout code and setup go
155+
- uses: actions/checkout@v4
156+
- uses: actions/setup-go@v5
157+
with:
158+
go-version-file: "go.mod"
159+
- name: Download build artifacts
160+
uses: actions/download-artifact@v4
161+
with:
162+
name: docker-images
163+
path: images/
164+
- name: Load Docker images
165+
run: |
166+
for image in images/*.tar.gz; do
167+
docker load -i $image
168+
done
169+
- name: Push fixture images
170+
run: scripts/e2e_test_fixtures.sh --push --skip-build

scripts/e2e_test_fixtures.sh

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/usr/bin/env bash
22

3-
set -x
4-
53
# Load bingo tools for kind
64
source .bingo/variables.env
75

@@ -14,8 +12,9 @@ SAVE=false
1412
CONTAINER_RUNTIME=docker
1513
REGISTRY=quay.io/olmtest
1614
TARGET_BRANCH=master
17-
JUST_CHECK=false
15+
CHECK=false
1816
LOAD_KIND=false
17+
BUILD=true
1918

2019
while [ $# -gt 0 ]; do
2120
case "$1" in
@@ -29,7 +28,7 @@ while [ $# -gt 0 ]; do
2928
;;
3029
# check if images need to be updated - won't build or push images
3130
--check)
32-
JUST_CHECK="true"
31+
CHECK="true"
3332
;;
3433
# container runtime to use, e.g. podman (default docker)
3534
--container-runtime=*)
@@ -49,11 +48,25 @@ while [ $# -gt 0 ]; do
4948
--save)
5049
SAVE="true"
5150
;;
51+
--skip-build)
52+
BUILD="false"
53+
;;
5254
*)
5355
printf "*************************\n"
5456
printf "* Error: Invalid argument.\n"
5557
# shellcheck disable=SC2059
56-
printf "* Usage: %s [--opm-version=version] [--push=true|false] [--container-runtime=runtime] [--registry=registry] [--target-branch=branch]\n" "$0"
58+
printf "* Usage: %s [--opm-version=version] [--check] [--push] [--container-runtime=runtime] [--registry=registry] [--target-branch=branch] [--kind-load] [--save] [--skip-build] \n" "$0"
59+
printf "\n"
60+
printf "\t--opm-version: opm version to build the fixtures against, e.g. 1.39.0\n"
61+
printf "\t--check: check if images need to be updated - won't build or push images\n"
62+
printf "\t--push: push images to registry after build\n"
63+
printf "\t--container-runtime: container runtime to use, e.g. podman (default docker)\n"
64+
printf "\t--registry: registry to push images (default: quay.io/olmtest)\n"
65+
printf "\t--target-branch: target branch to compare against when checking for changes (default: master)\n"
66+
printf "\t--kind-load: load fixture images into kind cluster (default: false)\n"
67+
printf "\t--save: save images to tar.gz files (default: false)\n"
68+
printf "\t--skip-build: skip building images - useful if you just want to kind-load/save/push (default: false)\n"
69+
5770
printf "*************************\n"
5871
exit 1
5972
esac
@@ -80,6 +93,8 @@ function check_changes() {
8093
fi
8194
}
8295

96+
set -x
97+
8398
# Fixtures
8499
BUNDLE_V1_IMAGE="${REGISTRY}/busybox-bundle:1.0.0-${OPM_VERSION}"
85100
BUNDLE_V1_DEP_IMAGE="${REGISTRY}/busybox-dependency-bundle:1.0.0-${OPM_VERSION}"
@@ -92,7 +107,7 @@ INDEX_V2="${REGISTRY}/busybox-dependencies-index:2.0.0-with-ListBundles-method-$
92107
TEST_CATALOG_IMAGE="${REGISTRY}/test-catalog:${OPM_VERSION}"
93108

94109
# Prints true if changes are detected, false otherwise
95-
if [ "$JUST_CHECK" = true ]; then
110+
if [ "CHECK" = true ]; then
96111
check_changes
97112
exit 0
98113
fi
@@ -109,7 +124,26 @@ if [ "$LOAD_KIND" = true ]; then
109124
exit 0
110125
fi
111126

112-
# Assumes images are already built
127+
if [ "$BUILD" = "true" ]; then
128+
# Busybox Operator
129+
# Build bundles
130+
${CONTAINER_RUNTIME} build -t "${BUNDLE_V1_IMAGE}" ./test/images/busybox-index/busybox/1.0.0
131+
${CONTAINER_RUNTIME} build -t "${BUNDLE_V1_DEP_IMAGE}" ./test/images/busybox-index/busybox-dependency/1.0.0
132+
${CONTAINER_RUNTIME} build -t "${BUNDLE_V2_IMAGE}" ./test/images/busybox-index/busybox/2.0.0
133+
${CONTAINER_RUNTIME} build -t "${BUNDLE_V2_DEP_IMAGE}" ./test/images/busybox-index/busybox-dependency/2.0.0
134+
135+
136+
# Build catalogs
137+
${CONTAINER_RUNTIME} build -t "${INDEX_V1}" --build-arg="OPM_VERSION=v${OPM_VERSION}" --build-arg="CONFIGS_DIR=indexv1" ./test/images/busybox-index
138+
${CONTAINER_RUNTIME} build -t "${INDEX_V2}" --build-arg="OPM_VERSION=v${OPM_VERSION}" --build-arg="CONFIGS_DIR=indexv2" ./test/images/busybox-index
139+
140+
# The following catalog used for e2e tests related to serving an extracted registry
141+
# See catalog_e2e_test.go
142+
# let's just reuse one of the other catalogs for this - the tests don't care about the content
143+
# only that a catalog's content can be extracted and served by a different container
144+
${CONTAINER_RUNTIME} tag "${INDEX_V2}" "${TEST_CATALOG_IMAGE}"
145+
fi
146+
113147
if [ "${SAVE}" = true ]; then
114148
${CONTAINER_RUNTIME} save "${BUNDLE_V1_IMAGE}" | gzip > bundlev1.tar.gz
115149
${CONTAINER_RUNTIME} save "${BUNDLE_V1_DEP_IMAGE}" | gzip > bundlev1dep.tar.gz
@@ -121,23 +155,8 @@ if [ "${SAVE}" = true ]; then
121155
${CONTAINER_RUNTIME} save "${INDEX_V2}" | gzip > indexv2.tar.gz
122156

123157
${CONTAINER_RUNTIME} save "${TEST_CATALOG_IMAGE}" | gzip > testcatalog.tar.gz
124-
exit 0
125158
fi
126159

127-
# Busybox Operator Index Image
128-
${CONTAINER_RUNTIME} build -t "${BUNDLE_V1_IMAGE}" ./test/images/busybox-index/busybox/1.0.0
129-
${CONTAINER_RUNTIME} build -t "${BUNDLE_V1_DEP_IMAGE}" ./test/images/busybox-index/busybox-dependency/1.0.0
130-
${CONTAINER_RUNTIME} build -t "${BUNDLE_V2_IMAGE}" ./test/images/busybox-index/busybox/2.0.0
131-
${CONTAINER_RUNTIME} build -t "${BUNDLE_V2_DEP_IMAGE}" ./test/images/busybox-index/busybox-dependency/2.0.0
132-
133-
# Build catalog from templates
134-
${CONTAINER_RUNTIME} build -t "${INDEX_V1}" --build-arg="OPM_VERSION=v${OPM_VERSION}" --build-arg="CONFIGS_DIR=indexv1" ./test/images/busybox-index
135-
${CONTAINER_RUNTIME} build -t "${INDEX_V2}" --build-arg="OPM_VERSION=v${OPM_VERSION}" --build-arg="CONFIGS_DIR=indexv2" ./test/images/busybox-index
136-
137-
# Test catalog used for e2e tests related to serving an extracted registry
138-
# Let's reuse one of the other indices for this
139-
${CONTAINER_RUNTIME} tag "${INDEX_V2}" "${TEST_CATALOG_IMAGE}"
140-
141160
if [ "$PUSH" = true ]; then
142161
# push bundles
143162
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"

0 commit comments

Comments
 (0)