Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add docker-build-multi-platform-oci-ta pipeline test #1464

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 11 additions & 25 deletions magefiles/rulesengine/repos/e2e_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
}),
Expand All @@ -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)

Expand Down
29 changes: 11 additions & 18 deletions pkg/utils/build/source_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 13 additions & 5 deletions tests/build/build_templates_scenarios.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down