diff --git a/cmd/config-brancher/main.go b/cmd/config-brancher/main.go index 7c4e4bcb55a..3076d78f596 100644 --- a/cmd/config-brancher/main.go +++ b/cmd/config-brancher/main.go @@ -154,11 +154,25 @@ func generateBranchedConfigs(currentRelease, bumpRelease string, futureReleases return output } -// removePeriodics removes periodic tests from the configuration +// removePeriodics removes periodic tests from the configuration. +// Tests that are both periodic and presubmit (have Presubmit: true) are preserved +// but have their periodic-related fields (Cron, Interval, MinimumInterval, ReleaseController) +// and Presubmit field removed. func removePeriodics(tests *[]api.TestStepConfiguration) { for i := len(*tests) - 1; i >= 0; i-- { - if !(*tests)[i].Portable && (*tests)[i].IsPeriodic() { - *tests = append((*tests)[:i], (*tests)[i+1:]...) + test := &(*tests)[i] + if !test.Portable && test.IsPeriodic() { + // If the test is also a presubmit, keep it but remove periodic fields + if test.Presubmit { + test.Cron = nil + test.Interval = nil + test.MinimumInterval = nil + test.ReleaseController = false + test.Presubmit = false + } else { + // Otherwise, remove the test entirely + *tests = append((*tests)[:i], (*tests)[i+1:]...) + } } } } diff --git a/cmd/config-brancher/main_test.go b/cmd/config-brancher/main_test.go index 41af33d1ef7..1891a96cc25 100644 --- a/cmd/config-brancher/main_test.go +++ b/cmd/config-brancher/main_test.go @@ -375,6 +375,49 @@ func TestGenerateBranchedConfigs(t *testing.T) { }, }, }, + { + name: "config with tests that are both periodic and presubmit gets branched with presubmit preserved but periodic fields removed when skip-periodics is set", + currentRelease: "current-release", + futureReleases: []string{"future-release"}, + skipPeriodics: true, + input: config.DataWithInfo{ + Configuration: api.ReleaseBuildConfiguration{ + Tests: []api.TestStepConfiguration{ + {As: "periodic-only", Cron: &cron}, + {As: "periodic-and-presubmit", Cron: &cron, Presubmit: true}, + {As: "periodic-presubmit-interval", Interval: &interval, Presubmit: true}, + }, + PromotionConfiguration: &api.PromotionConfiguration{ + Targets: []api.PromotionTarget{{ + Name: "current-release", + Namespace: "ocp", + }}, + }, + }, + Info: config.Info{ + Metadata: api.Metadata{Org: "org", Repo: "repo", Branch: "master"}, + }, + }, + output: []config.DataWithInfo{ + { + Configuration: api.ReleaseBuildConfiguration{ + Tests: []api.TestStepConfiguration{ + {As: "periodic-and-presubmit"}, + {As: "periodic-presubmit-interval"}, + }, + PromotionConfiguration: &api.PromotionConfiguration{ + Targets: []api.PromotionTarget{{ + Name: "future-release", + Namespace: "ocp", + }}, + }, + }, + Info: config.Info{ + Metadata: api.Metadata{Org: "org", Repo: "repo", Branch: "release-future-release"}, + }, + }, + }, + }, { name: "previously branched config that promotes to the current release from master bumps to the future release and de-mirrors correctly", currentRelease: "current-release",