Skip to content

Commit 02a68bf

Browse files
authored
[v1.0.x] *: use CI-built scorecard images during e2e tests (#3915)
1 parent 11ad4ee commit 02a68bf

File tree

10 files changed

+62
-3
lines changed

10 files changed

+62
-3
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,16 +276,16 @@ test-subcommand-olm-install:
276276

277277
test-e2e: test-e2e-go test-e2e-ansible test-e2e-ansible-molecule test-e2e-helm ## Run the e2e tests
278278

279-
test-e2e-go:
279+
test-e2e-go: image-build-scorecard-test
280280
./hack/tests/e2e-go.sh
281281

282-
test-e2e-ansible: image-build-ansible
282+
test-e2e-ansible: image-build-ansible image-build-scorecard-test
283283
./hack/tests/e2e-ansible.sh
284284

285285
test-e2e-ansible-molecule: image-build-ansible
286286
./hack/tests/e2e-ansible-molecule.sh
287287

288-
test-e2e-helm: image-build-helm
288+
test-e2e-helm: image-build-helm image-build-scorecard-test
289289
./hack/tests/e2e-helm.sh
290290

291291
# Integration tests.

hack/image/build-ansible-image.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ cp $ROOTDIR/build/ansible-operator-dev-linux-gnu .
1515
docker build -f $ROOTDIR/hack/image/ansible/Dockerfile -t $1 .
1616

1717
# If using a kind cluster, load the image into all nodes.
18+
setup_envs $tmp_sdk_root
1819
load_image_if_kind "$1"
1920
popd

hack/image/build-helm-image.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ cp $ROOTDIR/build/helm-operator-dev-linux-gnu .
1515
docker build -f $ROOTDIR/hack/image/helm/Dockerfile -t $1 .
1616

1717
# If using a kind cluster, load the image into all nodes.
18+
setup_envs $tmp_sdk_root
1819
load_image_if_kind "$1"
1920
popd

hack/image/build-scorecard-test-image.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ GOOS=linux CGO_ENABLED=0 \
1717
pushd images/scorecard-test
1818
docker build -t "$1" .
1919
# If using a kind cluster, load the image into all nodes.
20+
setup_envs $tmp_sdk_root
2021
load_image_if_kind "$1"
2122
popd

hack/image/build-scorecard-test-kuttl-image.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@ GOOS=linux CGO_ENABLED=0 \
1717
pushd images/scorecard-test-kuttl
1818
docker build -t "$1" .
1919
# If using a kind cluster, load the image into all nodes.
20+
setup_envs $tmp_sdk_root
2021
load_image_if_kind "$1"
2122
popd

hack/tests/e2e-ansible.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ header_text "Adding a second Kind to test watching multiple GVKs"
184184
operator-sdk create api --kind=Foo --group ansible --version=v1alpha1
185185
sed -i".bak" -e 's/# FIXME.*/role: \/dev\/null/g' watches.yaml;rm -f watches.yaml.bak
186186

187+
sed -i".bak" -E -e 's/(FROM quay.io\/operator-framework\/scorecard-test)(:.*)?/\1:dev/g' config/scorecard/patches/basic.config.yaml; rm -f config/scorecard/patches/basic.config.yaml.bak
188+
sed -i".bak" -E -e 's/(FROM quay.io\/operator-framework\/scorecard-test)(:.*)?/\1:dev/g' config/scorecard/patches/olm.config.yaml; rm -f config/scorecard/patches/olm.config.yaml.bak
187189
sed -i".bak" -E -e 's/(FROM quay.io\/operator-framework\/ansible-operator)(:.*)?/\1:dev/g' Dockerfile; rm -f Dockerfile.bak
188190
IMG=$DEST_IMAGE make docker-build
189191
# If using a kind cluster, load the image into all nodes.

hack/tests/e2e-go.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ tests=$test_dir/e2e
1313
export TRACE=1
1414
export GO111MODULE=on
1515

16+
###########################################################################
17+
### DO NOT UNCOMMENT THESE LINES UNLESS YOU KNOW WHAT YOU'RE DOING !!!! ###
18+
### ###
19+
### They cause the integration image not to be loaded into kind in ###
20+
### TravisCI. ###
21+
### ###
22+
###########################################################################
23+
###
24+
### #prepare_staging_dir $tmp_sdk_root
25+
### #fetch_envtest_tools $tmp_sdk_root
26+
###
27+
###########################################################################
1628
setup_envs $tmp_sdk_root
1729

1830
docker pull gcr.io/kubebuilder/kube-rbac-proxy:v0.5.0

test/e2e-helm/e2e_helm_suite_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,18 @@ var _ = BeforeSuite(func(done Done) {
9797
"--domain", tc.Domain)
9898
Expect(err).Should(Succeed())
9999

100+
By("using dev image for scorecard-test")
101+
testutils.ReplaceRegexInFile(
102+
filepath.Join(tc.Dir, "config", "scorecard", "patches", "basic.config.yaml"),
103+
"quay.io/operator-framework/scorecard-test:.*",
104+
"quay.io/operator-framework/scorecard-test:dev",
105+
)
106+
testutils.ReplaceRegexInFile(
107+
filepath.Join(tc.Dir, "config", "scorecard", "patches", "olm.config.yaml"),
108+
"quay.io/operator-framework/scorecard-test:.*",
109+
"quay.io/operator-framework/scorecard-test:dev",
110+
)
111+
100112
By("creating an API definition")
101113
err = tc.CreateAPI(
102114
"--group", tc.Group,

test/e2e/e2e_suite_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,18 @@ var _ = Describe("operator-sdk", func() {
8383
"--fetch-deps=false")
8484
Expect(err).Should(Succeed())
8585

86+
By("using dev image for scorecard-test")
87+
testutils.ReplaceRegexInFile(
88+
filepath.Join(tc.Dir, "config", "scorecard", "patches", "basic.config.yaml"),
89+
"quay.io/operator-framework/scorecard-test:.*",
90+
"quay.io/operator-framework/scorecard-test:dev",
91+
)
92+
testutils.ReplaceRegexInFile(
93+
filepath.Join(tc.Dir, "config", "scorecard", "patches", "olm.config.yaml"),
94+
"quay.io/operator-framework/scorecard-test:.*",
95+
"quay.io/operator-framework/scorecard-test:dev",
96+
)
97+
8698
By("creating an API definition")
8799
err = tc.CreateAPI(
88100
"--group", tc.Group,

test/internal/utils.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"os"
2121
"os/exec"
2222
"path/filepath"
23+
"regexp"
2324
"strings"
2425

2526
. "github.com/onsi/ginkgo" //nolint:golint
@@ -101,6 +102,22 @@ func ReplaceInFile(path, old, new string) {
101102
b, err := ioutil.ReadFile(path)
102103
ExpectWithOffset(1, err).NotTo(HaveOccurred())
103104
s := strings.Replace(string(b), old, new, -1)
105+
ExpectWithOffset(1, s).NotTo(Equal(string(b)), "No replacement occurred")
106+
err = ioutil.WriteFile(path, []byte(s), info.Mode())
107+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
108+
}
109+
110+
// ReplaceRegexInFile finds all strings that match `match` and replaces them
111+
// with `replace` in the file at path.
112+
func ReplaceRegexInFile(path, match, replace string) {
113+
matcher, err := regexp.Compile(match)
114+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
115+
info, err := os.Stat(path)
116+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
117+
b, err := ioutil.ReadFile(path)
118+
ExpectWithOffset(1, err).NotTo(HaveOccurred())
119+
s := matcher.ReplaceAllString(string(b), replace)
120+
ExpectWithOffset(1, s).NotTo(Equal(string(b)), "No replacement occurred")
104121
err = ioutil.WriteFile(path, []byte(s), info.Mode())
105122
ExpectWithOffset(1, err).NotTo(HaveOccurred())
106123
}

0 commit comments

Comments
 (0)