diff --git a/magefiles/rulesengine/repos/e2e_repo.go b/magefiles/rulesengine/repos/e2e_repo.go index 020dff602..45eda7c35 100644 --- a/magefiles/rulesengine/repos/e2e_repo.go +++ b/magefiles/rulesengine/repos/e2e_repo.go @@ -51,8 +51,8 @@ var TestFilesOnlyRule = rulesengine.Rule{Name: "E2E PR Test File Diff Execution" rulesengine.ConditionFunc(CheckTektonFilesChanged), }, rulesengine.Any{ - &BuildTestFileChangeOnlyRule, - &BuildTemplateScenarioFileChangeRule, + &BuildORBuildTemplatesTestFileChangeOnlyRule, + &BuildTemplateDependentFileChangeRule, &BuildNonTestFileChangeRule, &KonfluxDemoConfigsFileOnlyChangeRule, &KonfluxDemoTestFileChangedRule, @@ -77,11 +77,11 @@ func CheckTektonFilesChanged(rctx *rulesengine.RuleCtx) (bool, error) { } -var BuildTestFileChangeOnlyRule = rulesengine.Rule{Name: "E2E PR Build Test File Change Only Rule", - Description: "Map build tests files when build test file are only changed in the e2e-repo PR", +var BuildORBuildTemplatesTestFileChangeOnlyRule = rulesengine.Rule{Name: "E2E PR Build Or Build Templates Test File Change Only Rule", + Description: "Map build tests files when build.go or build_templates.go test files are only changed in the e2e-repo PR", Condition: rulesengine.ConditionFunc(func(rctx *rulesengine.RuleCtx) (bool, error) { - return len(rctx.DiffFiles.FilterByDirString("tests/build/build_templates_scenario.go")) == 0 && + return len(rctx.DiffFiles.FilterByDirString("tests/build/build_templates_scenarios.go")) == 0 && len(rctx.DiffFiles.FilterByDirString("tests/build/const.go")) == 0 && len(rctx.DiffFiles.FilterByDirString("tests/build/source_build.go")) == 0, nil }), @@ -96,46 +96,32 @@ var BuildTestFileChangeOnlyRule = rulesengine.Rule{Name: "E2E PR Build Test File })}} -var BuildTemplateScenarioFileChangeRule = rulesengine.Rule{Name: "E2E PR Build Template Scenario File Changed Rule", - Description: "Map build tests files when build template scenario file is changed in the e2e-repo PR", +var BuildTemplateDependentFileChangeRule = rulesengine.Rule{Name: "E2E PR Build Templates Dependent File Changed Rule", + Description: "Map build templates test file when build_templates_scenario.go or source_build.go file is changed in the e2e-repo PR", Condition: rulesengine.ConditionFunc(func(rctx *rulesengine.RuleCtx) (bool, error) { - return len(rctx.DiffFiles.FilterByDirString("tests/build/build_templates_scenario.go")) != 0, nil + return len(rctx.DiffFiles.FilterByDirString("tests/build/build_templates_scenarios.go")) != 0 || len(rctx.DiffFiles.FilterByDirString("tests/build/source_build.go")) != 0, nil }), Actions: []rulesengine.Action{rulesengine.ActionFunc(func(rctx *rulesengine.RuleCtx) error { - foundInDiff := false - for _, file := range rctx.DiffFiles.FilterByDirString("tests/build/build_templates.go") { - - rctx.FocusFiles = dedupeAppendFiles(rctx.FocusFiles, file.Name) - foundInDiff = true - - } - - if !foundInDiff { - - rctx.FocusFiles = dedupeAppendFiles(rctx.FocusFiles, "tests/build/build_templates.go") - - } + rctx.FocusFiles = dedupeAppendFiles(rctx.FocusFiles, "tests/build/build_templates.go") return nil })}} var BuildNonTestFileChangeRule = rulesengine.Rule{Name: "E2E PR Build Test Helper Files Change Rule", - Description: "Map build tests files when const.go or source_build.go file is changed in the e2e-repo PR", + Description: "Map build tests files when const.go file is changed in the e2e-repo PR", Condition: rulesengine.ConditionFunc(func(rctx *rulesengine.RuleCtx) (bool, error) { - return len(rctx.DiffFiles.FilterByDirGlob("tests/build/const.go")) != 0 || len(rctx.DiffFiles.FilterByDirGlob("tests/build/source_build.go")) != 0, nil + return len(rctx.DiffFiles.FilterByDirGlob("tests/build/const.go")) != 0, nil }), Actions: []rulesengine.Action{rulesengine.ActionFunc(func(rctx *rulesengine.RuleCtx) error { for _, file := range rctx.DiffFiles.FilterByDirGlob("tests/build/*.go") { if strings.Contains(file.Name, "source_build.go") || strings.Contains(file.Name, "const.go") || strings.Contains(file.Name, "scenarios.go") { - continue - } rctx.FocusFiles = dedupeAppendFiles(rctx.FocusFiles, file.Name) diff --git a/pkg/utils/build/source_image.go b/pkg/utils/build/source_image.go index 31e775568..dd9993e92 100644 --- a/pkg/utils/build/source_image.go +++ b/pkg/utils/build/source_image.go @@ -347,26 +347,19 @@ func readDockerfile(pathContext, dockerfile, repoURL, repoRevision string) ([]by // ReadDockerfileUsedForBuild reads the Dockerfile and return its content. func ReadDockerfileUsedForBuild(c client.Client, tektonController *tekton.TektonController, pr *pipeline.PipelineRun) ([]byte, error) { - var paramDockerfileValue, paramPathContextValue string - var paramUrlValue, paramRevisionValue string + var paramDockerfileValue, paramPathContextValue, paramUrlValue, paramRevisionValue string var err error - getParam := tektonController.GetTaskRunParam - if paramDockerfileValue, err = getParam(c, pr, "build-container", "DOCKERFILE"); err != nil { - return nil, err - } - - if paramPathContextValue, err = getParam(c, pr, "build-container", "CONTEXT"); err != nil { - return nil, err - } - - // get git-clone param url and revision - if paramUrlValue, err = getParam(c, pr, "clone-repository", "url"); err != nil { - return nil, err - } - - if paramRevisionValue, err = getParam(c, pr, "clone-repository", "revision"); err != nil { - return nil, err + for _, param := range pr.Spec.Params { + if param.Name == "dockerfile" { + paramDockerfileValue = param.Value.StringVal + } else if param.Name == "path-context" { + paramPathContextValue = param.Value.StringVal + } else if param.Name == "git-url" { + paramUrlValue = param.Value.StringVal + } else if param.Name == "revision" { + paramRevisionValue = param.Value.StringVal + } } dockerfileContent, err := readDockerfile(paramPathContextValue, paramDockerfileValue, paramUrlValue, paramRevisionValue) diff --git a/tests/build/build_templates_scenarios.go b/tests/build/build_templates_scenarios.go index 5afa00a69..97d40a4bf 100644 --- a/tests/build/build_templates_scenarios.go +++ b/tests/build/build_templates_scenarios.go @@ -35,15 +35,23 @@ func (s ComponentScenarioSpec) DeepCopy() ComponentScenarioSpec { var componentScenarios = []ComponentScenarioSpec{ { - GitURL: "https://github.com/konflux-qe-bd/devfile-sample-python-basic", - Revision: "47fc22092005aabebce233a9b6eab994a8152bbd", - ContextDir: ".", - DockerFilePath: constants.DockerFilePath, - // "docker-build-multi-platform-oci-ta" needs to be enabled, when the issue https://issues.redhat.com/browse/KFLUXBUGS-1646 is fixed + GitURL: "https://github.com/konflux-qe-bd/devfile-sample-python-basic", + Revision: "47fc22092005aabebce233a9b6eab994a8152bbd", + ContextDir: ".", + DockerFilePath: constants.DockerFilePath, PipelineBundleNames: []string{"docker-build", "docker-build-oci-ta"}, EnableHermetic: false, PrefetchInput: "", }, + { + GitURL: "https://github.com/konflux-qe-bd/multiarch-sample-repo", + Revision: "bc0452861279eb59da685ba86918938c6c9d8310", + ContextDir: ".", + DockerFilePath: "Dockerfile", + PipelineBundleNames: []string{"docker-build-multi-platform-oci-ta"}, + EnableHermetic: false, + PrefetchInput: "", + }, { GitURL: "https://github.com/konflux-qe-bd/retrodep", Revision: "d8e3195d1ab9dbee1f621e3b0625a589114ac80f",