Skip to content

Commit c226fcd

Browse files
author
Per Goncalves da Silva
committed
update fixture script and e2e gha
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 2550b48 commit c226fcd

File tree

2 files changed

+90
-37
lines changed

2 files changed

+90
-37
lines changed

.github/workflows/e2e-tests.yml

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,25 @@ jobs:
2424
# build binaries and image for e2e test (includes experimental features)
2525
- name: Build controller image
2626
run: make e2e-build
27-
- name: Save image
28-
run: docker save quay.io/operator-framework/olm:local -o olm-image.tar
29-
- name: Upload Docker image as artifact
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
36+
run: |
37+
if [ "${UPDATE_FIXTURES}" == "true" ]; then
38+
scripts/e2e_test_fixtures.sh --save
39+
fi
40+
docker save quay.io/operator-framework/olm:local | gzip > olm-image.tar.gz
41+
- name: Upload Docker images
3042
uses: actions/upload-artifact@v4
3143
with:
32-
name: olm-image.tar
33-
path: olm-image.tar
44+
name: docker-images
45+
path: "*.tar.gz"
3446

3547
# Run e2e tests in parallel jobs
3648
# Take olm image from the previous stage
@@ -54,13 +66,17 @@ jobs:
5466
with:
5567
go-version-file: "go.mod"
5668

57-
# load the olm image
58-
- name: Load OLM Docker image
69+
# load images into kind
70+
- name: Download build artifacts
5971
uses: actions/download-artifact@v4
6072
with:
61-
name: olm-image.tar
62-
path: .
63-
- run: docker load < olm-image.tar
73+
name: docker-images
74+
path: images/
75+
- name: Load Docker images
76+
run: |
77+
for image in images/*.tar.gz; do
78+
docker load -i $image
79+
done
6480
6581
# set e2e environment variables
6682
# Set ginkgo output and parallelism
@@ -88,6 +104,9 @@ jobs:
88104
KIND_CREATE_OPTS="--kubeconfig=${E2E_KUBECONFIG_ROOT}/kubeconfig-${i}" \
89105
HELM_INSTALL_OPTS="--kubeconfig ${E2E_KUBECONFIG_ROOT}/kubeconfig-${i}" \
90106
make kind-create deploy;
107+
if [ "${{ needs.build.outputs.UPDATE_FIXTURES }}" == "true" ]; then
108+
scripts/e2e_test_fixtures.sh --kind-load
109+
fi
91110
done
92111
93112
# run non-flakes if matrix-id is not 'flakes'

scripts/e2e_test_fixtures.sh

Lines changed: 61 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
#!/usr/bin/env bash
22

3+
set -x
4+
5+
# Load bingo tools for kind
6+
source .bingo/variables.env
7+
38
# Default values
9+
KIND=${KIND:-kind}
10+
KIND_CLUSTER_NAME=${KIND_CLUSTER_NAME:-kind-olmv0}
411
OPM_VERSION=$(go list -m github.com/operator-framework/operator-registry | cut -d" " -f2 | sed 's/^v//')
512
PUSH=false
13+
SAVE=false
614
CONTAINER_RUNTIME=docker
715
REGISTRY=quay.io/olmtest
816
TARGET_BRANCH=master
917
JUST_CHECK=false
18+
LOAD_KIND=false
1019

1120
while [ $# -gt 0 ]; do
1221
case "$1" in
@@ -34,7 +43,12 @@ while [ $# -gt 0 ]; do
3443
--target-branch=*)
3544
TARGET_BRANCH="${1#*=}"
3645
;;
37-
46+
--kind-load)
47+
LOAD_KIND="true"
48+
;;
49+
--save)
50+
SAVE="true"
51+
;;
3852
*)
3953
printf "*************************\n"
4054
printf "* Error: Invalid argument.\n"
@@ -50,6 +64,7 @@ function check_changes() {
5064
OPM_CHANGED=false
5165
FIXTURES_CHANGED=false
5266

67+
git fetch origin "${TARGET_BRANCH}" --depth=2
5368
if git diff "origin/${TARGET_BRANCH}" -- go.mod | grep -E '^\+[[:space:]]+github.com/operator-framework/operator-registry' > /dev/null; then
5469
OPM_CHANGED=true
5570
fi
@@ -65,15 +80,6 @@ function check_changes() {
6580
fi
6681
}
6782

68-
function push_fixtures() {
69-
${CONTAINER_RUNTIME} push "${TEST_CATALOG_IMAGE}"
70-
}
71-
72-
if [ "$JUST_CHECK" = true ]; then
73-
check_changes
74-
exit 0
75-
fi
76-
7783
# Fixtures
7884
BUNDLE_V1_IMAGE="${REGISTRY}/busybox-bundle:1.0.0-${OPM_VERSION}"
7985
BUNDLE_V1_DEP_IMAGE="${REGISTRY}/busybox-dependency-bundle:1.0.0-${OPM_VERSION}"
@@ -85,36 +91,64 @@ INDEX_V2="${REGISTRY}/busybox-dependencies-index:2.0.0-with-ListBundles-method-$
8591

8692
TEST_CATALOG_IMAGE="${REGISTRY}/test-catalog:${OPM_VERSION}"
8793

94+
# Prints true if changes are detected, false otherwise
95+
if [ "$JUST_CHECK" = true ]; then
96+
check_changes
97+
exit 0
98+
fi
99+
100+
# Assumes images are already built, kind cluster is running, and kubeconfig is set
101+
if [ "$LOAD_KIND" = true ]; then
102+
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${BUNDLE_V1_IMAGE}"
103+
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${BUNDLE_V1_DEP_IMAGE}"
104+
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${BUNDLE_V2_IMAGE}"
105+
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${BUNDLE_V2_DEP_IMAGE}"
106+
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${INDEX_V1}"
107+
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${INDEX_V2}"
108+
${KIND} load docker-image --name="${KIND_CLUSTER_NAME}" "${TEST_CATALOG_IMAGE}"
109+
exit 0
110+
fi
111+
112+
# Assumes images are already built
113+
if [ "${SAVE}" = true ]; then
114+
${CONTAINER_RUNTIME} save "${BUNDLE_V1_IMAGE}" | gzip > bundlev1.tar.gz
115+
${CONTAINER_RUNTIME} save "${BUNDLE_V1_DEP_IMAGE}" | gzip > bundlev1dep.tar.gz
116+
117+
${CONTAINER_RUNTIME} save "${BUNDLE_V2_IMAGE}" | gzip > bundlev2.tar.gz
118+
${CONTAINER_RUNTIME} save "${BUNDLE_V2_DEP_IMAGE}" | gzip > bundlev2dep.tar.gz
119+
120+
${CONTAINER_RUNTIME} save "${INDEX_V1}" | gzip > indexv1.tar.gz
121+
${CONTAINER_RUNTIME} save "${INDEX_V2}" | gzip > indexv2.tar.gz
122+
123+
${CONTAINER_RUNTIME} save "${TEST_CATALOG_IMAGE}" | gzip > testcatalog.tar.gz
124+
exit 0
125+
fi
126+
88127
# Busybox Operator Index Image
89128
${CONTAINER_RUNTIME} build -t "${BUNDLE_V1_IMAGE}" ./test/images/busybox-index/busybox/1.0.0
90129
${CONTAINER_RUNTIME} build -t "${BUNDLE_V1_DEP_IMAGE}" ./test/images/busybox-index/busybox-dependency/1.0.0
91130
${CONTAINER_RUNTIME} build -t "${BUNDLE_V2_IMAGE}" ./test/images/busybox-index/busybox/2.0.0
92131
${CONTAINER_RUNTIME} build -t "${BUNDLE_V2_DEP_IMAGE}" ./test/images/busybox-index/busybox-dependency/2.0.0
93132

94133
# Build catalog from templates
95-
mkdir -p ./test/images/busybox-index/indexv1
96-
mkdir -p ./test/images/busybox-index/indexv2
97-
sed -e "s|#BUNDLE_V1_IMAGE#|\"${BUNDLE_V1_IMAGE}\"|g" -e "s|#BUNDLE_V1_DEP_IMAGE#|\"${BUNDLE_V1_DEP_IMAGE}\"|g" ./test/images/busybox-index/busybox-index-v1.template.json > ./test/images/busybox-index/indexv1/catalog.json
98-
sed -e "s|#BUNDLE_V1_IMAGE#|\"${BUNDLE_V1_IMAGE}\"|g" -e "s|#BUNDLE_V1_DEP_IMAGE#|\"${BUNDLE_V1_DEP_IMAGE}\"|g" -e "s|#BUNDLE_V2_IMAGE#|\"${BUNDLE_V2_IMAGE}\"|g" -e "s|#BUNDLE_V2_DEP_IMAGE#|\"${BUNDLE_V2_DEP_IMAGE}\"|g" ./test/images/busybox-index/busybox-index-v2.template.json > ./test/images/busybox-index/indexv2/catalog.json
99-
100-
# Clean up
101-
rm -rf ./test/images/busybox-index/indexv1
102-
rm -rf ./test/images/busybox-index/indexv2
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
103136

104137
# Test catalog used for e2e tests related to serving an extracted registry
105138
# Let's reuse one of the other indices for this
106-
${CONTAINER_RUNTIME} tag -t "${TEST_CATALOG_IMAGE}" "${INDEX_V2}"
139+
${CONTAINER_RUNTIME} tag "${INDEX_V2}" "${TEST_CATALOG_IMAGE}"
107140

108141
if [ "$PUSH" = true ]; then
109142
# push bundles
110-
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
111-
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
112-
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
113-
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
143+
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
144+
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
145+
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
146+
${CONTAINER_RUNTIME} push "${BUNDLE_V1_IMAGE}"
114147

115-
# push indexes
116-
${CONTAINER_RUNTIME} push "${INDEX_V1}"
117-
${CONTAINER_RUNTIME} push "${INDEX_V2}"
148+
# push indexes
149+
${CONTAINER_RUNTIME} push "${INDEX_V1}"
150+
${CONTAINER_RUNTIME} push "${INDEX_V2}"
118151

119-
# push test catalog
152+
# push test catalog
153+
${CONTAINER_RUNTIME} push "${TEST_CATALOG_IMAGE}"
120154
fi

0 commit comments

Comments
 (0)