From 917055443ccde2fa4620e977d8abc895ca973b9b Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Tue, 24 Sep 2024 16:16:57 +0200 Subject: [PATCH 1/2] feat: enable dockerfile check for hermetic builds STONEBLD-2795 Hermetic builds should now push the original dockerfile, not the modified one. Enable the check. Signed-off-by: Adam Cmiel --- tests/build/build_templates.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/build/build_templates.go b/tests/build/build_templates.go index 4fe7c1dac..514ee3faa 100644 --- a/tests/build/build_templates.go +++ b/tests/build/build_templates.go @@ -362,8 +362,7 @@ var _ = framework.BuildSuiteDescribe("Build templates E2E test", Label("build", }) It("should push Dockerfile to registry", Label(buildTemplatesTestLabel), func() { - // Once https://issues.redhat.com/browse/STONEBLD-2795 is resolved, apply this check for hermetic scenario as well - if !scenario.EnableHermetic && !IsFBCBuildPipeline(pipelineBundleName) { + if !IsFBCBuildPipeline(pipelineBundleName) { ensureOriginalDockerfileIsPushed(kubeadminClient, pr) } }) From d73dae2253f461a9e5a9689818ffeb66742053bf Mon Sep 17 00:00:00 2001 From: Adam Cmiel Date: Wed, 25 Sep 2024 14:01:29 +0200 Subject: [PATCH 2/2] fix: improve dockerfile check error messages When the dockerfile image doesn't exist, print the expected image Compare the content of the Dockerfile as a string, not as an array of bytes. Otherwise the error message is not readable to humans. Signed-off-by: Adam Cmiel --- tests/build/build_templates.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/build/build_templates.go b/tests/build/build_templates.go index 514ee3faa..d7d074864 100644 --- a/tests/build/build_templates.go +++ b/tests/build/build_templates.go @@ -844,7 +844,7 @@ func ensureOriginalDockerfileIsPushed(hub *framework.ControllerHub, pr *tektonpi }.String() exists, err := build.DoesTagExistsInQuay(dockerfileImage) Expect(err).Should(Succeed()) - Expect(exists).Should(BeTrue()) + Expect(exists).Should(BeTrue(), fmt.Sprintf("image doesn't exist: %s", dockerfileImage)) // Ensure the original Dockerfile used for build was pushed c := hub.CommonController.KubeRest() @@ -859,7 +859,7 @@ func ensureOriginalDockerfileIsPushed(hub *framework.ControllerHub, pr *tektonpi if entry.Type().IsRegular() && entry.Name() == "Dockerfile" { content, err := os.ReadFile(filepath.Join(storePath, entry.Name())) Expect(err).Should(Succeed()) - Expect(content).Should(Equal(originDockerfileContent)) + Expect(string(content)).Should(Equal(string(originDockerfileContent))) return } }