From 54d985014a9cbe975005a597bcad3fcae58f0f59 Mon Sep 17 00:00:00 2001 From: Prucek Date: Mon, 20 Apr 2026 14:42:46 +0200 Subject: [PATCH 1/2] feat(pkg/api): add ProwgenExtras field --- pkg/api/types.go | 15 ++++++++++ pkg/api/zz_generated.deepcopy.go | 30 +++++++++++++++++++ .../zz_generated.ci_operator_reference.go | 12 ++++++++ 3 files changed, 57 insertions(+) diff --git a/pkg/api/types.go b/pkg/api/types.go index bd6db72227..126f7c2e64 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -24,6 +24,13 @@ func IsPromotionJob(jobLabels map[string]string) bool { return ok } +// ProwgenExtras holds fields that control Prow job generation behavior. +// These fields were previously configured via the .config.prowgen file +type ProwgenExtras struct { + // DisableRehearsals prevents all tests in config from being rehearsed. + DisableRehearsals *bool `json:"disable_rehearsals,omitempty"` +} + // ReleaseBuildConfiguration describes how release // artifacts are built from a repository of source // code. The configuration is made up of two parts: @@ -39,6 +46,9 @@ type ReleaseBuildConfiguration struct { InputConfiguration `json:",inline"` + // Prowgen holds fields that control Prow job generation behavior. + Prowgen *ProwgenExtras `json:"prowgen,omitempty"` + // BinaryBuildCommands will create a "bin" image based on "src" that // contains the output of this command. This allows reuse of binary artifacts // across other steps. If empty, no "bin" image will be created. @@ -859,6 +869,11 @@ type TestStepConfiguration struct { // RestrictNetworkAccess restricts network access to RedHat intranet. RestrictNetworkAccess *bool `json:"restrict_network_access,omitempty"` + // DisableRehearsal prevents this specific test from being picked up for rehearsals. + // Note: this cannot re-enable rehearsals if they are globally disabled via + // prowgen.disable_rehearsals or .config.prowgen's disable_all setting. + DisableRehearsal *bool `json:"disable_rehearsal,omitempty"` + // ShardCount describes the number of jobs that should be generated as shards for this test // Each generated job will be a duplication, but contain a suffix and the necessary SHARD_ARGS will be passed to the steps // Only applicable to presubmits and periodics diff --git a/pkg/api/zz_generated.deepcopy.go b/pkg/api/zz_generated.deepcopy.go index f0380ba357..a4e5347542 100644 --- a/pkg/api/zz_generated.deepcopy.go +++ b/pkg/api/zz_generated.deepcopy.go @@ -1438,6 +1438,26 @@ func (in *PromotionTarget) DeepCopy() *PromotionTarget { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ProwgenExtras) DeepCopyInto(out *ProwgenExtras) { + *out = *in + if in.DisableRehearsals != nil { + in, out := &in.DisableRehearsals, &out.DisableRehearsals + *out = new(bool) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProwgenExtras. +func (in *ProwgenExtras) DeepCopy() *ProwgenExtras { + if in == nil { + return nil + } + out := new(ProwgenExtras) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PullSpecSubstitution) DeepCopyInto(out *PullSpecSubstitution) { *out = *in @@ -1709,6 +1729,11 @@ func (in *ReleaseBuildConfiguration) DeepCopyInto(out *ReleaseBuildConfiguration *out = *in out.Metadata = in.Metadata in.InputConfiguration.DeepCopyInto(&out.InputConfiguration) + if in.Prowgen != nil { + in, out := &in.Prowgen, &out.Prowgen + *out = new(ProwgenExtras) + (*in).DeepCopyInto(*out) + } if in.BinaryBuildCommandsList != nil { in, out := &in.BinaryBuildCommandsList, &out.BinaryBuildCommandsList *out = make([]RefCommands, len(*in)) @@ -2261,6 +2286,11 @@ func (in *TestStepConfiguration) DeepCopyInto(out *TestStepConfiguration) { *out = new(bool) **out = **in } + if in.DisableRehearsal != nil { + in, out := &in.DisableRehearsal, &out.DisableRehearsal + *out = new(bool) + **out = **in + } if in.ShardCount != nil { in, out := &in.ShardCount, &out.ShardCount *out = new(int) diff --git a/pkg/webreg/zz_generated.ci_operator_reference.go b/pkg/webreg/zz_generated.ci_operator_reference.go index f13d3ec585..fd0e85590d 100644 --- a/pkg/webreg/zz_generated.ci_operator_reference.go +++ b/pkg/webreg/zz_generated.ci_operator_reference.go @@ -334,6 +334,10 @@ const ciOperatorReferenceYaml = "# The list of base images describe\n" + " # this will cause both a floating tag and commit-specific tags\n" + " # to be promoted.\n" + " tag_by_commit: true\n" + + "# Prowgen holds fields that control Prow job generation behavior.\n" + + "prowgen:\n" + + " # DisableRehearsals prevents all tests in config from being rehearsed.\n" + + " disable_rehearsals: false\n" + "# RawSteps are literal Steps that should be\n" + "# included in the final pipeline.\n" + "raw_steps:\n" + @@ -621,6 +625,10 @@ const ciOperatorReferenceYaml = "# The list of base images describe\n" + " # of pull request workflows. Setting this field will\n" + " # create a periodic job instead of a presubmit\n" + " cron: \"\"\n" + + " # DisableRehearsal prevents this specific test from being picked up for rehearsals.\n" + + " # Note: this cannot re-enable rehearsals if they are globally disabled via\n" + + " # prowgen.disable_rehearsals or .config.prowgen's disable_all setting.\n" + + " disable_rehearsal: false\n" + " # Interval is how frequently the test should be run based\n" + " # on the last time the test ran. Setting this field will\n" + " # create a periodic job instead of a presubmit\n" + @@ -1541,6 +1549,10 @@ const ciOperatorReferenceYaml = "# The list of base images describe\n" + " # of pull request workflows. Setting this field will\n" + " # create a periodic job instead of a presubmit\n" + " cron: \"\"\n" + + " # DisableRehearsal prevents this specific test from being picked up for rehearsals.\n" + + " # Note: this cannot re-enable rehearsals if they are globally disabled via\n" + + " # prowgen.disable_rehearsals or .config.prowgen's disable_all setting.\n" + + " disable_rehearsal: false\n" + " # Interval is how frequently the test should be run based\n" + " # on the last time the test ran. Setting this field will\n" + " # create a periodic job instead of a presubmit\n" + From 52aa218e4145e0923247b9cb08a7dbd28238367c Mon Sep 17 00:00:00 2001 From: Prucek Date: Mon, 20 Apr 2026 14:46:30 +0200 Subject: [PATCH 2/2] refactor(pkg/config): move Prowgen struct to pkg/api --- cmd/ci-operator-prowgen/main.go | 26 +++- cmd/ci-operator-prowgen/main_test.go | 4 +- pkg/api/types.go | 107 ++++++++++++++- pkg/config/load.go | 118 +--------------- pkg/config/load_test.go | 68 +++++----- pkg/image-graph-generator/operator.go | 2 +- pkg/prowgen/jobbase_test.go | 66 ++++----- pkg/prowgen/prowgen.go | 8 +- pkg/prowgen/prowgen_test.go | 94 +++++++++---- ...ed_all_rehearsals_ci_operator_config_.yaml | 66 +++++++++ ...disabled_all_rehearsals_prowgen_file_.yaml | 62 +++++++++ ...sals_at_job_level_ci_operator_config_.yaml | 127 ++++++++++++++++++ ...rehearsals_at_job_level_prowgen_file_.yaml | 125 +++++++++++++++++ 13 files changed, 648 insertions(+), 225 deletions(-) create mode 100644 pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_all_rehearsals_ci_operator_config_.yaml create mode 100644 pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_all_rehearsals_prowgen_file_.yaml create mode 100644 pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_rehearsals_at_job_level_ci_operator_config_.yaml create mode 100644 pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_rehearsals_at_job_level_prowgen_file_.yaml diff --git a/cmd/ci-operator-prowgen/main.go b/cmd/ci-operator-prowgen/main.go index eea7e38fe9..c6c7f0e9f1 100644 --- a/cmd/ci-operator-prowgen/main.go +++ b/cmd/ci-operator-prowgen/main.go @@ -102,7 +102,7 @@ func (o *options) process() error { // generateJobsToDir generates prow job configuration into the dir provided by // consuming ci-operator configuration. -func (o *options) generateJobsToDir(subDir string, prowConfig map[string]*config.Prowgen) error { +func (o *options) generateJobsToDir(subDir string, prowConfig map[string]*cioperatorapi.Prowgen) error { generated := map[string]*prowconfig.JobConfig{} genJobsFunc := generateJobs(o.resolver, prowConfig, generated) if err := o.OperateOnCIOperatorConfigDir(filepath.Join(o.fromDir, subDir), genJobsFunc); err != nil { @@ -120,13 +120,21 @@ func (o *options) generateJobsToDir(subDir string, prowConfig map[string]*config return writeToDir(o.toDir, generated) } -func generateJobs(resolver registry.Resolver, cache map[string]*config.Prowgen, output map[string]*prowconfig.JobConfig) func(configSpec *cioperatorapi.ReleaseBuildConfiguration, info *config.Info) error { +func generateJobs(resolver registry.Resolver, cache map[string]*cioperatorapi.Prowgen, output map[string]*prowconfig.JobConfig) func(configSpec *cioperatorapi.ReleaseBuildConfiguration, info *config.Info) error { return func(configSpec *cioperatorapi.ReleaseBuildConfiguration, info *config.Info) error { orgRepo := fmt.Sprintf("%s/%s", info.Org, info.Repo) - pInfo := &prowgen.ProwgenInfo{Metadata: info.Metadata, Config: config.Prowgen{Private: false, Expose: false}} + pInfo := &prowgen.ProwgenInfo{ + Metadata: info.Metadata, + Config: cioperatorapi.ProwgenExtras{ + Prowgen: cioperatorapi.Prowgen{ + Private: false, + Expose: false, + }, + }, + } var ok bool var err error - var orgConfig, repoConfig *config.Prowgen + var orgConfig, repoConfig *cioperatorapi.Prowgen if orgConfig, ok = cache[info.Org]; !ok { if cache[info.Org], err = config.LoadProwgenConfig(info.OrgPath); err != nil { @@ -144,13 +152,17 @@ func generateJobs(resolver registry.Resolver, cache map[string]*config.Prowgen, switch { case orgConfig != nil: - pInfo.Config = *orgConfig + pInfo.Config.Prowgen = *orgConfig if repoConfig != nil { pInfo.Config.MergeDefaults(repoConfig) } case repoConfig != nil: - pInfo.Config = *repoConfig + pInfo.Config.Prowgen = *repoConfig + } + if configSpec.Prowgen == nil { + configSpec.Prowgen = &cioperatorapi.ProwgenExtras{} } + configSpec.Prowgen.Prowgen = pInfo.Config.Prowgen if resolver != nil { resolved, err := registry.ResolveConfig(resolver, *configSpec) if err != nil { @@ -227,7 +239,7 @@ func main() { args = append(args, "") } logger := logrus.WithFields(logrus.Fields{"target": opt.toDir, "source": opt.fromDir}) - config := map[string]*config.Prowgen{} + config := map[string]*cioperatorapi.Prowgen{} for _, subDir := range args { logger = logger.WithFields(logrus.Fields{"subdir": subDir}) if err := opt.generateJobsToDir(subDir, config); err != nil { diff --git a/cmd/ci-operator-prowgen/main_test.go b/cmd/ci-operator-prowgen/main_test.go index 4934c280ff..ee8dc0e6f2 100644 --- a/cmd/ci-operator-prowgen/main_test.go +++ b/cmd/ci-operator-prowgen/main_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/openshift/ci-tools/pkg/config" + "github.com/openshift/ci-tools/pkg/api" "github.com/openshift/ci-tools/pkg/testhelper" ) @@ -293,7 +293,7 @@ tests: } o := options{fromDir: fullConfigPath, toDir: baseProwConfigDir} - if err := o.generateJobsToDir("", map[string]*config.Prowgen{}); err != nil { + if err := o.generateJobsToDir("", map[string]*api.Prowgen{}); err != nil { t.Fatalf("Unexpected error generating jobs from config: %v", err) } diff --git a/pkg/api/types.go b/pkg/api/types.go index 126f7c2e64..cf722677cf 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -2,6 +2,8 @@ package api import ( "fmt" + "regexp" + "slices" "strings" "k8s.io/apimachinery/pkg/util/sets" @@ -25,12 +27,115 @@ func IsPromotionJob(jobLabels map[string]string) bool { } // ProwgenExtras holds fields that control Prow job generation behavior. -// These fields were previously configured via the .config.prowgen file +// TODO: After migration, remove the Prowgen embedding. type ProwgenExtras struct { + Prowgen `json:"-"` + // DisableRehearsals prevents all tests in config from being rehearsed. DisableRehearsals *bool `json:"disable_rehearsals,omitempty"` } +func (p *ProwgenExtras) AreRehearsalsDisabled() bool { + if p.DisableRehearsals != nil { + return *p.DisableRehearsals + } + return p.Rehearsals.DisableAll +} + +func (p *ProwgenExtras) IsRehearsalDisabledForTest(config *ReleaseBuildConfiguration, testName string) bool { + if p.AreRehearsalsDisabled() { + return true + } + + for _, test := range config.Tests { + if test.As == testName { + if test.DisableRehearsal != nil { + return *test.DisableRehearsal + } + } + } + + return slices.Contains(p.Rehearsals.DisabledRehearsals, testName) +} + +// Prowgen holds the configuration from a .config.prowgen file. +type Prowgen struct { + Private bool `json:"private,omitempty"` + Expose bool `json:"expose,omitempty"` + Rehearsals Rehearsals `json:"rehearsals,omitempty"` + SlackReporterConfigs []SlackReporterConfig `json:"slack_reporter,omitempty"` + SkipOperatorPresubmits []SkipOperatorPresubmit `json:"skip_operator_presubmits,omitempty"` + EnableSecretsStoreCSIDriver bool `json:"enable_secrets_store_csi_driver,omitempty"` +} + +type Rehearsals struct { + DisableAll bool `json:"disable_all,omitempty"` + DisabledRehearsals []string `json:"disabled_rehearsals,omitempty"` +} + +type SlackReporterConfig struct { + Channel string `json:"channel,omitempty"` + JobStatesToReport []prowv1.ProwJobState `json:"job_states_to_report,omitempty"` + ReportTemplate string `json:"report_template,omitempty"` + JobNames []string `json:"job_names,omitempty"` + JobNamePatterns []string `json:"job_name_patterns,omitempty"` + ExcludedVariants []string `json:"excluded_variants,omitempty"` + ExcludedJobPatterns []string `json:"excluded_job_patterns,omitempty"` +} + +type SkipOperatorPresubmit struct { + Branch string `json:"branch,omitempty"` + Variant string `json:"variant,omitempty"` +} + +func (p *Prowgen) MergeDefaults(defaults *Prowgen) { + if defaults.Private { + p.Private = true + } + if defaults.Expose { + p.Expose = true + } + if defaults.EnableSecretsStoreCSIDriver { + p.EnableSecretsStoreCSIDriver = true + } + if defaults.Rehearsals.DisableAll { + p.Rehearsals.DisableAll = true + } + p.Rehearsals.DisabledRehearsals = append(p.Rehearsals.DisabledRehearsals, defaults.Rehearsals.DisabledRehearsals...) +} + +func (p *Prowgen) GetSlackReporterConfigForJobName(fullJobName, testName, variant string) *SlackReporterConfig { +nextSlackReporterConfig: + for _, s := range p.SlackReporterConfigs { + if slices.Contains(s.ExcludedVariants, variant) { + continue + } + for _, excludePattern := range s.ExcludedJobPatterns { + if matched, err := regexp.MatchString(excludePattern, fullJobName); err == nil && matched { + continue nextSlackReporterConfig + } + } + if slices.Contains(s.JobNames, testName) { + return &s + } + for _, pattern := range s.JobNamePatterns { + if matched, err := regexp.MatchString(pattern, testName); err == nil && matched { + return &s + } + } + } + return nil +} + +func (p *Prowgen) SkipPresubmits(branch string, variant string) bool { + for _, skip := range p.SkipOperatorPresubmits { + if skip.Branch == branch && skip.Variant == variant { + return true + } + } + return false +} + // ReleaseBuildConfiguration describes how release // artifacts are built from a repository of source // code. The configuration is made up of two parts: diff --git a/pkg/config/load.go b/pkg/config/load.go index d2107e3bef..6d727a9a49 100644 --- a/pkg/config/load.go +++ b/pkg/config/load.go @@ -7,7 +7,6 @@ import ( "path" "path/filepath" "regexp" - "slices" "strings" "github.com/ghodss/yaml" @@ -15,7 +14,6 @@ import ( utilerrors "k8s.io/apimachinery/pkg/util/errors" "k8s.io/apimachinery/pkg/util/sets" - prowv1 "sigs.k8s.io/prow/pkg/apis/prowjobs/v1" cioperatorapi "github.com/openshift/ci-tools/pkg/api" "github.com/openshift/ci-tools/pkg/util" @@ -26,100 +24,8 @@ import ( // ProwgenFile is the name of prowgen's configuration file. var ProwgenFile = ".config.prowgen" -// Prowgen holds the information of the prowgen's configuration file. -type Prowgen struct { - // Private indicates that generated jobs should be marked as hidden - // from display in deck and that they should mount appropriate git credentials - // to clone the repository under test. - Private bool `json:"private,omitempty"` - // Expose declares that jobs should not be hidden from view in deck if they - // are private. - // This field has no effect if private is not set. - Expose bool `json:"expose,omitempty"` - // Rehearsals declares any disabled rehearsals for jobs - Rehearsals Rehearsals `json:"rehearsals,omitempty"` - // SlackReporterConfigs defines all desired slack reporter info for included jobs - SlackReporterConfigs []SlackReporterConfig `json:"slack_reporter,omitempty"` - // SkipOperatorPresubmits allow users to skip the presubmit generation for that specific variant - SkipOperatorPresubmits []SkipOperatorPresubmits `json:"skip_operator_presubmits,omitempty"` - // EnableSecretsStoreCSIDriver indicates that jobs should use the new CSI Secrets Store - // mechanism to handle multi-stage credentials secrets. - EnableSecretsStoreCSIDriver bool `json:"enable_secrets_store_csi_driver,omitempty"` -} - -// SlackReporterConfig groups test names to a channel to report; mimicking Prow's version, with some unnecessary fields removed -type SlackReporterConfig struct { - Channel string `json:"channel,omitempty"` - JobStatesToReport []prowv1.ProwJobState `json:"job_states_to_report,omitempty"` - ReportTemplate string `json:"report_template,omitempty"` - // JobNames matches against test names (e.g., "unit", "e2e") not full Prow job names. - // This is intentional for backward compatibility - existing configs use test names here. - JobNames []string `json:"job_names,omitempty"` - // JobNamePatterns are regex patterns that match against test names (e.g., ".*-e2e$"). - // Like JobNames, these match test names, not full Prow job names. - JobNamePatterns []string `json:"job_name_patterns,omitempty"` - // ExcludedVariants is a list of variants to skip (e.g., ["hypershift", "okd"]) - ExcludedVariants []string `json:"excluded_variants,omitempty"` - // ExcludedJobPatterns are regex patterns that match against FULL Prow job names - // (e.g., "^pull-.*-skip$" or "^periodic-"). This lets you exclude specific job types - // or use prefixes that only exist in the full job name, not the test name. - ExcludedJobPatterns []string `json:"excluded_job_patterns,omitempty"` -} - -type SkipOperatorPresubmits struct { - Branch string `json:"branch,omitempty"` - Variant string `json:"variant,omitempty"` -} - -// GetSlackReporterConfigForJobName checks against full job names, allowing excluded_job_patterns -// to work with prefixes like "pull-", "periodic-", etc. -func (p *Prowgen) GetSlackReporterConfigForJobName(fullJobName, testName, variant string) *SlackReporterConfig { -nextSlackReporterConfig: - for _, s := range p.SlackReporterConfigs { - if slices.Contains(s.ExcludedVariants, variant) { - continue - } - - // Check if job is excluded by pattern (using full job name) - for _, excludePattern := range s.ExcludedJobPatterns { - if matched, err := regexp.MatchString(excludePattern, fullJobName); err == nil && matched { - continue nextSlackReporterConfig - } - } - - // Check exact job name matches first (against test name for backward compatibility) - if slices.Contains(s.JobNames, testName) { - return &s - } - - // Check regex pattern matches (against test name for backward compatibility) - for _, pattern := range s.JobNamePatterns { - if matched, err := regexp.MatchString(pattern, testName); err == nil && matched { - return &s - } - } - } - return nil -} - -func (p *Prowgen) MergeDefaults(defaults *Prowgen) { - if defaults.Private { - p.Private = true - } - if defaults.Expose { - p.Expose = true - } - if defaults.EnableSecretsStoreCSIDriver { - p.EnableSecretsStoreCSIDriver = true - } - if defaults.Rehearsals.DisableAll { - p.Rehearsals.DisableAll = true - } - p.Rehearsals.DisabledRehearsals = append(p.Rehearsals.DisabledRehearsals, defaults.Rehearsals.DisabledRehearsals...) -} - -func LoadProwgenConfig(folder string) (*Prowgen, error) { - var pConfig *Prowgen +func LoadProwgenConfig(folder string) (*cioperatorapi.Prowgen, error) { + var pConfig *cioperatorapi.Prowgen path := filepath.Join(folder, ProwgenFile) b, err := os.ReadFile(path) if err != nil && !os.IsNotExist(err) { @@ -141,7 +47,7 @@ func LoadProwgenConfig(folder string) (*Prowgen, error) { return pConfig, nil } -func validateProwgenConfig(pConfig *Prowgen) error { +func validateProwgenConfig(pConfig *cioperatorapi.Prowgen) error { var errs []error if len(pConfig.SlackReporterConfigs) > 1 { // There is no reason to validate if we only have one slack_reporter_config jobsSeen := sets.NewString() @@ -189,15 +95,6 @@ func validateProwgenConfig(pConfig *Prowgen) error { return utilerrors.NewAggregate(errs) } -type Rehearsals struct { - // DisableAll indicates that all jobs will not have their "can-be-rehearsed" label set - // and therefore will not be picked up for rehearsals. - DisableAll bool `json:"disable_all,omitempty"` - // DisabledRehearsals contains a list of jobs that will not have their "can-be-rehearsed" label set - // and therefore will not be picked up for rehearsals. - DisabledRehearsals []string `json:"disabled_rehearsals,omitempty"` -} - func readCiOperatorConfig(configFilePath string, info Info) (*cioperatorapi.ReleaseBuildConfiguration, error) { data, err := gzip.ReadFileMaybeGZIP(configFilePath) if err != nil { @@ -496,12 +393,3 @@ func LoadByOrgRepo(path string) (ByOrgRepo, error) { } return config, nil } - -func (p *Prowgen) SkipPresubmits(branch string, variant string) bool { - for _, skip := range p.SkipOperatorPresubmits { - if skip.Branch == branch && skip.Variant == variant { - return true - } - } - return false -} diff --git a/pkg/config/load_test.go b/pkg/config/load_test.go index 8a44976a38..790c3d6a25 100644 --- a/pkg/config/load_test.go +++ b/pkg/config/load_test.go @@ -99,13 +99,13 @@ func TestExtractRepoElementsFromPath(t *testing.T) { func TestValidateProwgenConfig(t *testing.T) { testCases := []struct { name string - pConfig *Prowgen + pConfig *api.Prowgen expected error }{ { name: "valid", - pConfig: &Prowgen{ - SlackReporterConfigs: []SlackReporterConfig{ + pConfig: &api.Prowgen{ + SlackReporterConfigs: []api.SlackReporterConfig{ { Channel: "#slack-channel", JobStatesToReport: []prowv1.ProwJobState{"error"}, @@ -123,8 +123,8 @@ func TestValidateProwgenConfig(t *testing.T) { }, { name: "invalid, same job in multiple slack reporter configs", - pConfig: &Prowgen{ - SlackReporterConfigs: []SlackReporterConfig{ + pConfig: &api.Prowgen{ + SlackReporterConfigs: []api.SlackReporterConfig{ { Channel: "#slack-channel", JobStatesToReport: []prowv1.ProwJobState{"error"}, @@ -143,8 +143,8 @@ func TestValidateProwgenConfig(t *testing.T) { }, { name: "invalid regex patterns cause validation errors", - pConfig: &Prowgen{ - SlackReporterConfigs: []SlackReporterConfig{ + pConfig: &api.Prowgen{ + SlackReporterConfigs: []api.SlackReporterConfig{ { Channel: "#slack-channel", JobNamePatterns: []string{"[invalid"}, @@ -159,8 +159,8 @@ func TestValidateProwgenConfig(t *testing.T) { }, { name: "duplicate regex patterns cause validation errors", - pConfig: &Prowgen{ - SlackReporterConfigs: []SlackReporterConfig{ + pConfig: &api.Prowgen{ + SlackReporterConfigs: []api.SlackReporterConfig{ { Channel: "#slack-channel", JobNamePatterns: []string{"^unit.*"}, @@ -175,8 +175,8 @@ func TestValidateProwgenConfig(t *testing.T) { }, { name: "valid regex patterns pass validation", - pConfig: &Prowgen{ - SlackReporterConfigs: []SlackReporterConfig{ + pConfig: &api.Prowgen{ + SlackReporterConfigs: []api.SlackReporterConfig{ { Channel: "#slack-channel", JobNamePatterns: []string{"^unit.*", "^e2e.*"}, @@ -190,8 +190,8 @@ func TestValidateProwgenConfig(t *testing.T) { }, { name: "invalid excluded job patterns cause validation errors", - pConfig: &Prowgen{ - SlackReporterConfigs: []SlackReporterConfig{ + pConfig: &api.Prowgen{ + SlackReporterConfigs: []api.SlackReporterConfig{ { Channel: "#slack-channel", ExcludedJobPatterns: []string{"[invalid"}, @@ -206,8 +206,8 @@ func TestValidateProwgenConfig(t *testing.T) { }, { name: "valid excluded job patterns pass validation", - pConfig: &Prowgen{ - SlackReporterConfigs: []SlackReporterConfig{ + pConfig: &api.Prowgen{ + SlackReporterConfigs: []api.SlackReporterConfig{ { Channel: "#slack-channel", JobNamePatterns: []string{".*"}, @@ -235,15 +235,15 @@ func TestValidateProwgenConfig(t *testing.T) { func TestValidateProwgenSkipOperatorPresubmits(t *testing.T) { testCases := []struct { name string - pConfig *Prowgen + pConfig *api.Prowgen branch string variant string expected bool }{ { name: "skipping operator presubmits, exactly match", - pConfig: &Prowgen{ - SkipOperatorPresubmits: []SkipOperatorPresubmits{ + pConfig: &api.Prowgen{ + SkipOperatorPresubmits: []api.SkipOperatorPresubmit{ { Branch: "main", Variant: "4.18", @@ -260,8 +260,8 @@ func TestValidateProwgenSkipOperatorPresubmits(t *testing.T) { }, { name: "generating operator presubmits, mismatch branches", - pConfig: &Prowgen{ - SkipOperatorPresubmits: []SkipOperatorPresubmits{ + pConfig: &api.Prowgen{ + SkipOperatorPresubmits: []api.SkipOperatorPresubmit{ { Branch: "dev", Variant: "4.18", @@ -274,7 +274,7 @@ func TestValidateProwgenSkipOperatorPresubmits(t *testing.T) { }, { name: "skipping operator presubmits, empty values", - pConfig: &Prowgen{}, + pConfig: &api.Prowgen{}, branch: "main", variant: "4.19", expected: false, @@ -295,15 +295,15 @@ func TestValidateProwgenSkipOperatorPresubmits(t *testing.T) { func TestProwgen_MergeDefaults_SlackReporterConfigs(t *testing.T) { testCases := []struct { name string - base Prowgen - defaults Prowgen - expected []SlackReporterConfig + base api.Prowgen + defaults api.Prowgen + expected []api.SlackReporterConfig }{ { name: "slack reporter configs are never merged from defaults", - base: Prowgen{}, - defaults: Prowgen{ - SlackReporterConfigs: []SlackReporterConfig{ + base: api.Prowgen{}, + defaults: api.Prowgen{ + SlackReporterConfigs: []api.SlackReporterConfig{ { Channel: "#test-channel", JobStatesToReport: []prowv1.ProwJobState{"failure"}, @@ -316,8 +316,8 @@ func TestProwgen_MergeDefaults_SlackReporterConfigs(t *testing.T) { }, { name: "existing slack reporter configs are preserved unchanged", - base: Prowgen{ - SlackReporterConfigs: []SlackReporterConfig{ + base: api.Prowgen{ + SlackReporterConfigs: []api.SlackReporterConfig{ { Channel: "#existing-channel", JobStatesToReport: []prowv1.ProwJobState{"error"}, @@ -325,8 +325,8 @@ func TestProwgen_MergeDefaults_SlackReporterConfigs(t *testing.T) { }, }, }, - defaults: Prowgen{ - SlackReporterConfigs: []SlackReporterConfig{ + defaults: api.Prowgen{ + SlackReporterConfigs: []api.SlackReporterConfig{ { Channel: "#default-channel", JobStatesToReport: []prowv1.ProwJobState{"failure"}, @@ -335,7 +335,7 @@ func TestProwgen_MergeDefaults_SlackReporterConfigs(t *testing.T) { }, }, }, - expected: []SlackReporterConfig{ + expected: []api.SlackReporterConfig{ { Channel: "#existing-channel", JobStatesToReport: []prowv1.ProwJobState{"error"}, @@ -345,8 +345,8 @@ func TestProwgen_MergeDefaults_SlackReporterConfigs(t *testing.T) { }, { name: "empty base with empty defaults stays empty", - base: Prowgen{}, - defaults: Prowgen{}, + base: api.Prowgen{}, + defaults: api.Prowgen{}, expected: nil, }, } diff --git a/pkg/image-graph-generator/operator.go b/pkg/image-graph-generator/operator.go index def333d7a9..6bd6ce1fad 100644 --- a/pkg/image-graph-generator/operator.go +++ b/pkg/image-graph-generator/operator.go @@ -79,7 +79,7 @@ func (o *Operator) callback(c *api.ReleaseBuildConfiguration, i *config.Info) er return nil } - configProwgen := &config.Prowgen{} + configProwgen := &api.Prowgen{} orgProwgenConfig, err := config.LoadProwgenConfig(i.OrgPath) if err != nil { return err diff --git a/pkg/prowgen/jobbase_test.go b/pkg/prowgen/jobbase_test.go index b016b27875..c48b9952c5 100644 --- a/pkg/prowgen/jobbase_test.go +++ b/pkg/prowgen/jobbase_test.go @@ -4,12 +4,10 @@ import ( "testing" "time" - "k8s.io/utils/pointer" + "k8s.io/utils/ptr" prowv1 "sigs.k8s.io/prow/pkg/apis/prowjobs/v1" - v1 "sigs.k8s.io/prow/pkg/apis/prowjobs/v1" ciop "github.com/openshift/ci-tools/pkg/api" - "github.com/openshift/ci-tools/pkg/config" "github.com/openshift/ci-tools/pkg/testhelper" ) @@ -153,7 +151,7 @@ func TestProwJobBaseBuilder(t *testing.T) { name: "private job without cloning, including podspec", info: &ProwgenInfo{ Metadata: ciop.Metadata{Org: "vorg", Repo: "vrepo", Branch: "vbranch"}, - Config: config.Prowgen{Private: true}, + Config: ciop.ProwgenExtras{Prowgen: ciop.Prowgen{Private: true}}, }, prefix: "default", podSpecBuilder: NewCiOperatorPodSpecGenerator(), @@ -162,7 +160,7 @@ func TestProwJobBaseBuilder(t *testing.T) { name: "private job with cloning, including podspec", info: &ProwgenInfo{ Metadata: ciop.Metadata{Org: "vorg", Repo: "vrepo", Branch: "vbranch"}, - Config: config.Prowgen{Private: true}, + Config: ciop.ProwgenExtras{Prowgen: ciop.Prowgen{Private: true}}, }, prefix: "default", inputs: ciop.InputConfiguration{ @@ -224,7 +222,7 @@ func TestGenerateJobBase(t *testing.T) { name: "test", info: &ProwgenInfo{ Metadata: ciop.Metadata{Org: "org", Repo: "repo", Branch: "branch"}, - Config: config.Prowgen{Private: true}, + Config: ciop.ProwgenExtras{Prowgen: ciop.Prowgen{Private: true}}, }, }, { @@ -232,7 +230,7 @@ func TestGenerateJobBase(t *testing.T) { name: "test", info: &ProwgenInfo{ Metadata: ciop.Metadata{Org: "org", Repo: "repo", Branch: "branch"}, - Config: config.Prowgen{Private: true, Expose: true}, + Config: ciop.ProwgenExtras{Prowgen: ciop.Prowgen{Private: true, Expose: true}}, }, }, { @@ -240,7 +238,7 @@ func TestGenerateJobBase(t *testing.T) { name: "test", info: &ProwgenInfo{ Metadata: ciop.Metadata{Org: "org", Repo: "repo", Branch: "branch"}, - Config: config.Prowgen{Private: false, Expose: true}, + Config: ciop.ProwgenExtras{Prowgen: ciop.Prowgen{Private: false, Expose: true}}, }, }, } @@ -278,7 +276,7 @@ func TestNewProwJobBaseBuilderForTest(t *testing.T) { As: "simple", Commands: "make", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "src"}, - Timeout: &v1.Duration{Duration: time.Second}, + Timeout: &prowv1.Duration{Duration: time.Second}, }, info: defaultInfo, }, @@ -295,7 +293,7 @@ func TestNewProwJobBaseBuilderForTest(t *testing.T) { As: "simple", Commands: "make", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "src"}, - Timeout: &v1.Duration{Duration: time.Second}, + Timeout: &prowv1.Duration{Duration: time.Second}, }, info: defaultInfo, }, @@ -324,7 +322,7 @@ func TestNewProwJobBaseBuilderForTest(t *testing.T) { test: ciop.TestStepConfiguration{ As: "simple", MultiStageTestConfiguration: &ciop.MultiStageTestConfiguration{ - Workflow: pointer.StringPtr("workflow"), + Workflow: ptr.To("workflow"), }, }, info: defaultInfo, @@ -334,12 +332,12 @@ func TestNewProwJobBaseBuilderForTest(t *testing.T) { test: ciop.TestStepConfiguration{ As: "simple", MultiStageTestConfiguration: &ciop.MultiStageTestConfiguration{ - Workflow: pointer.StringPtr("workflow"), + Workflow: ptr.To("workflow"), }, }, info: &ProwgenInfo{ Metadata: ciop.Metadata{Org: "o", Repo: "r", Branch: "b"}, - Config: config.Prowgen{EnableSecretsStoreCSIDriver: true}, + Config: ciop.ProwgenExtras{Prowgen: ciop.Prowgen{EnableSecretsStoreCSIDriver: true}}, }, }, { @@ -351,7 +349,7 @@ func TestNewProwJobBaseBuilderForTest(t *testing.T) { }, info: &ProwgenInfo{ Metadata: ciop.Metadata{Org: "o", Repo: "r", Branch: "b"}, - Config: config.Prowgen{EnableSecretsStoreCSIDriver: true}, + Config: ciop.ProwgenExtras{Prowgen: ciop.Prowgen{EnableSecretsStoreCSIDriver: true}}, }, }, { @@ -360,7 +358,7 @@ func TestNewProwJobBaseBuilderForTest(t *testing.T) { As: "simple", ClusterClaim: &ciop.ClusterClaim{Product: "ocp"}, MultiStageTestConfiguration: &ciop.MultiStageTestConfiguration{ - Workflow: pointer.StringPtr("workflow"), + Workflow: ptr.To("workflow"), }, }, info: defaultInfo, @@ -371,7 +369,7 @@ func TestNewProwJobBaseBuilderForTest(t *testing.T) { As: "simple", MultiStageTestConfiguration: &ciop.MultiStageTestConfiguration{ ClusterProfile: ciop.ClusterProfileAlibabaCloud, - Workflow: pointer.StringPtr("workflow"), + Workflow: ptr.To("workflow"), }, }, info: defaultInfo, @@ -393,7 +391,7 @@ func TestNewProwJobBaseBuilderForTest(t *testing.T) { test: ciop.TestStepConfiguration{ As: "simple", MultiStageTestConfiguration: &ciop.MultiStageTestConfiguration{ - Workflow: pointer.StringPtr("workflow"), + Workflow: ptr.To("workflow"), }, }, info: defaultInfo, @@ -427,13 +425,15 @@ func TestNewProwJobBaseBuilderForTest(t *testing.T) { }, info: &ProwgenInfo{ Metadata: ciop.Metadata{Org: "o", Repo: "r", Branch: "b"}, - Config: config.Prowgen{ - SlackReporterConfigs: []config.SlackReporterConfig{ - { - Channel: "some-channel", - JobStatesToReport: []prowv1.ProwJobState{"error"}, - ReportTemplate: "some template", - JobNames: []string{"unit", "e2e"}, + Config: ciop.ProwgenExtras{ + Prowgen: ciop.Prowgen{ + SlackReporterConfigs: []ciop.SlackReporterConfig{ + { + Channel: "some-channel", + JobStatesToReport: []prowv1.ProwJobState{"error"}, + ReportTemplate: "some template", + JobNames: []string{"unit", "e2e"}, + }, }, }, }, @@ -448,14 +448,16 @@ func TestNewProwJobBaseBuilderForTest(t *testing.T) { }, info: &ProwgenInfo{ Metadata: ciop.Metadata{Org: "o", Repo: "r", Branch: "b"}, - Config: config.Prowgen{ - SlackReporterConfigs: []config.SlackReporterConfig{ - { - Channel: "some-channel", - JobStatesToReport: []prowv1.ProwJobState{"error"}, - ReportTemplate: "some template", - JobNames: []string{"unit-skip", "e2e"}, - ExcludedJobPatterns: []string{".*-skip$"}, + Config: ciop.ProwgenExtras{ + Prowgen: ciop.Prowgen{ + SlackReporterConfigs: []ciop.SlackReporterConfig{ + { + Channel: "some-channel", + JobStatesToReport: []prowv1.ProwJobState{"error"}, + ReportTemplate: "some template", + JobNames: []string{"unit-skip", "e2e"}, + ExcludedJobPatterns: []string{".*-skip$"}, + }, }, }, }, diff --git a/pkg/prowgen/prowgen.go b/pkg/prowgen/prowgen.go index 8b427dbc55..cd61feaaff 100644 --- a/pkg/prowgen/prowgen.go +++ b/pkg/prowgen/prowgen.go @@ -9,7 +9,6 @@ import ( prowconfig "sigs.k8s.io/prow/pkg/config" cioperatorapi "github.com/openshift/ci-tools/pkg/api" - "github.com/openshift/ci-tools/pkg/config" jc "github.com/openshift/ci-tools/pkg/jobconfig" ) @@ -21,7 +20,7 @@ const ( type ProwgenInfo struct { cioperatorapi.Metadata - Config config.Prowgen + Config cioperatorapi.ProwgenExtras } // GenerateJobs @@ -42,9 +41,6 @@ func GenerateJobs(configSpec *cioperatorapi.ReleaseBuildConfiguration, info *Pro presubmits := map[string][]prowconfig.Presubmit{} postsubmits := map[string][]prowconfig.Postsubmit{} var periodics []prowconfig.Periodic - rehearsals := info.Config.Rehearsals - disabledRehearsals := sets.New[string](rehearsals.DisabledRehearsals...) - for _, element := range configSpec.Tests { shardCount := 1 if element.ShardCount != nil { @@ -65,7 +61,7 @@ func GenerateJobs(configSpec *cioperatorapi.ReleaseBuildConfiguration, info *Pro g.WithLabel(fmt.Sprintf("capability/%s", element.NodeArchitecture), string(element.NodeArchitecture)) } - disableRehearsal := rehearsals.DisableAll || disabledRehearsals.Has(element.As) + disableRehearsal := info.Config.IsRehearsalDisabledForTest(configSpec, element.As) if element.IsPeriodic() { cron := "" diff --git a/pkg/prowgen/prowgen_test.go b/pkg/prowgen/prowgen_test.go index f51356467b..f95a07fa59 100644 --- a/pkg/prowgen/prowgen_test.go +++ b/pkg/prowgen/prowgen_test.go @@ -6,13 +6,11 @@ import ( "testing" corev1 "k8s.io/api/core/v1" - utilpointer "k8s.io/utils/pointer" + "k8s.io/utils/ptr" prowv1 "sigs.k8s.io/prow/pkg/apis/prowjobs/v1" prowconfig "sigs.k8s.io/prow/pkg/config" - "github.com/openshift/ci-tools/pkg/api" ciop "github.com/openshift/ci-tools/pkg/api" - "github.com/openshift/ci-tools/pkg/config" "github.com/openshift/ci-tools/pkg/testhelper" ) @@ -456,7 +454,7 @@ func TestGenerateJobs(t *testing.T) { config: &ciop.ReleaseBuildConfiguration{ Tests: []ciop.TestStepConfiguration{}, Images: ciop.ImageConfiguration{Items: []ciop.ProjectDirectoryImageBuildStepConfiguration{{}}}, - PromotionConfiguration: &ciop.PromotionConfiguration{Targets: []api.PromotionTarget{{Namespace: "ci"}}}, + PromotionConfiguration: &ciop.PromotionConfiguration{Targets: []ciop.PromotionTarget{{Namespace: "ci"}}}, }, repoInfo: &ProwgenInfo{Metadata: ciop.Metadata{ Org: "organization", @@ -473,7 +471,7 @@ func TestGenerateJobs(t *testing.T) { {To: "out-2", From: "base"}, }}, PromotionConfiguration: &ciop.PromotionConfiguration{ - Targets: []api.PromotionTarget{{ + Targets: []ciop.PromotionTarget{{ Namespace: "ci", AdditionalImages: map[string]string{ "out": "out-1", @@ -617,7 +615,7 @@ func TestGenerateJobs(t *testing.T) { id: "cluster label for periodic", config: &ciop.ReleaseBuildConfiguration{ Tests: []ciop.TestStepConfiguration{ - {As: "unit", Cron: utilpointer.String(cron), Cluster: "build01", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + {As: "unit", Cron: ptr.To(cron), Cluster: "build01", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, }, }, repoInfo: &ProwgenInfo{Metadata: ciop.Metadata{ @@ -630,7 +628,7 @@ func TestGenerateJobs(t *testing.T) { id: "periodic with presubmit", config: &ciop.ReleaseBuildConfiguration{ Tests: []ciop.TestStepConfiguration{ - {As: "unit", Cron: utilpointer.String(cron), Presubmit: true, Cluster: "build01", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + {As: "unit", Cron: ptr.To(cron), Presubmit: true, Cluster: "build01", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, }, }, repoInfo: &ProwgenInfo{Metadata: ciop.Metadata{ @@ -653,38 +651,79 @@ func TestGenerateJobs(t *testing.T) { }}, }, { - id: "disabled rehearsals at job level", + id: "disabled rehearsals at job level (prowgen file)", config: &ciop.ReleaseBuildConfiguration{ Tests: []ciop.TestStepConfiguration{ {As: "unit", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, {As: "lint", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, - {As: "periodic-unit", Cron: utilpointer.String(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, - {As: "periodic-lint", Cron: utilpointer.String(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + {As: "periodic-unit", Cron: ptr.To(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + {As: "periodic-lint", Cron: ptr.To(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, }, }, repoInfo: &ProwgenInfo{ - Config: config.Prowgen{Rehearsals: config.Rehearsals{DisabledRehearsals: []string{"unit", "periodic-unit"}}}, Metadata: ciop.Metadata{ Org: "organization", Repo: "repository", Branch: "branch", - }}, + }, + Config: ciop.ProwgenExtras{ + Prowgen: ciop.Prowgen{ + Rehearsals: ciop.Rehearsals{DisabledRehearsals: []string{"unit", "periodic-unit"}}, + }, + }, + }, }, { - id: "disabled rehearsals at repo level", + id: "disabled all rehearsals (prowgen file)", config: &ciop.ReleaseBuildConfiguration{ Tests: []ciop.TestStepConfiguration{ {As: "unit", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, - {As: "periodic-unit", Cron: utilpointer.String(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + {As: "periodic-unit", Cron: ptr.To(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, }, }, repoInfo: &ProwgenInfo{ - Config: config.Prowgen{Rehearsals: config.Rehearsals{DisableAll: true}}, Metadata: ciop.Metadata{ Org: "organization", Repo: "repository", Branch: "branch", - }}, + }, + Config: ciop.ProwgenExtras{ + Prowgen: ciop.Prowgen{ + Rehearsals: ciop.Rehearsals{DisableAll: true}, + }, + }, + }, + }, + { + id: "disabled rehearsals at job level (ci-operator config)", + config: &ciop.ReleaseBuildConfiguration{ + Tests: []ciop.TestStepConfiguration{ + {As: "unit", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}, DisableRehearsal: ptr.To(true)}, + {As: "lint", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + {As: "periodic-unit", Cron: ptr.To(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + {As: "periodic-lint", Cron: ptr.To(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + }, + }, + repoInfo: &ProwgenInfo{Metadata: ciop.Metadata{ + Org: "organization", + Repo: "repository", + Branch: "branch", + }}, + }, + { + id: "disabled all rehearsals (ci-operator config)", + config: &ciop.ReleaseBuildConfiguration{ + Tests: []ciop.TestStepConfiguration{ + {As: "unit", ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + {As: "periodic-unit", Cron: ptr.To(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + }, + Prowgen: &ciop.ProwgenExtras{Prowgen: ciop.Prowgen{Rehearsals: ciop.Rehearsals{DisableAll: true}}}, + }, + repoInfo: &ProwgenInfo{Metadata: ciop.Metadata{ + Org: "organization", + Repo: "repository", + Branch: "branch", + }}, }, { id: "multiarch postsubmit images", @@ -741,15 +780,16 @@ func TestGenerateJobs(t *testing.T) { Repo: "repository", Branch: "branch", }, - Config: config.Prowgen{ - SlackReporterConfigs: []config.SlackReporterConfig{ - { - Channel: "some-channel", - JobStatesToReport: []prowv1.ProwJobState{"error"}, - ReportTemplate: "some template", - JobNames: []string{"images", "e2e"}, - }, - }, + Config: ciop.ProwgenExtras{ + Prowgen: ciop.Prowgen{ + SlackReporterConfigs: []ciop.SlackReporterConfig{ + { + Channel: "some-channel", + JobStatesToReport: []prowv1.ProwJobState{"error"}, + ReportTemplate: "some template", + JobNames: []string{"images", "e2e"}, + }, + }}, }, }, }, @@ -757,7 +797,7 @@ func TestGenerateJobs(t *testing.T) { id: "periodic with capabilities", config: &ciop.ReleaseBuildConfiguration{ Tests: []ciop.TestStepConfiguration{ - {As: "unit", Capabilities: []string{"intranet"}, Cron: utilpointer.String(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, + {As: "unit", Capabilities: []string{"intranet"}, Cron: ptr.To(cron), ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, }, }, repoInfo: &ProwgenInfo{Metadata: ciop.Metadata{ @@ -770,7 +810,7 @@ func TestGenerateJobs(t *testing.T) { id: "periodic/presubmit with capabilities", config: &ciop.ReleaseBuildConfiguration{ Tests: []ciop.TestStepConfiguration{ - {As: "unit", Capabilities: []string{"intranet", "arm64", "rce", "sshd-bastion"}, Cron: utilpointer.String(cron), Presubmit: true, ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, // rce - release-controller-eligible, sshd-bastion - for multiarch P/Z libvirt jobs + {As: "unit", Capabilities: []string{"intranet", "arm64", "rce", "sshd-bastion"}, Cron: ptr.To(cron), Presubmit: true, ContainerTestConfiguration: &ciop.ContainerTestConfiguration{From: "bin"}}, // rce - release-controller-eligible, sshd-bastion - for multiarch P/Z libvirt jobs }, }, repoInfo: &ProwgenInfo{Metadata: ciop.Metadata{ diff --git a/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_all_rehearsals_ci_operator_config_.yaml b/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_all_rehearsals_ci_operator_config_.yaml new file mode 100644 index 0000000000..33c0911e74 --- /dev/null +++ b/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_all_rehearsals_ci_operator_config_.yaml @@ -0,0 +1,66 @@ +periodics: +- agent: kubernetes + cron: 0 0 * * * + decorate: true + decoration_config: + skip_cloning: true + extra_refs: + - base_ref: branch + org: organization + repo: repository + labels: + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: periodic-ci-organization-repository-branch-periodic-unit + spec: + containers: + - args: + - --gcs-upload-secret=/secrets/gcs/service-account.json + - --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson + - --report-credentials-file=/etc/report/credentials + - --target=periodic-unit + command: + - ci-operator + env: + - name: HTTP_SERVER_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + image: quay-proxy.ci.openshift.org/openshift/ci:ci_ci-operator_latest + imagePullPolicy: Always + name: "" + ports: + - containerPort: 8080 + name: http + resources: + requests: + cpu: 10m + volumeMounts: + - mountPath: /secrets/gcs + name: gcs-credentials + readOnly: true + - mountPath: /secrets/manifest-tool + name: manifest-tool-local-pusher + readOnly: true + - mountPath: /etc/pull-secret + name: pull-secret + readOnly: true + - mountPath: /etc/report + name: result-aggregator + readOnly: true + serviceAccountName: ci-operator + volumes: + - name: manifest-tool-local-pusher + secret: + secretName: manifest-tool-local-pusher + - name: pull-secret + secret: + secretName: registry-pull-credentials + - name: result-aggregator + secret: + secretName: result-aggregator +presubmits: + organization/repository: + - always_run: false + labels: + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: pull-ci-organization-repository-branch-unit diff --git a/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_all_rehearsals_prowgen_file_.yaml b/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_all_rehearsals_prowgen_file_.yaml new file mode 100644 index 0000000000..51006b6d14 --- /dev/null +++ b/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_all_rehearsals_prowgen_file_.yaml @@ -0,0 +1,62 @@ +periodics: +- agent: kubernetes + cron: 0 0 * * * + decorate: true + decoration_config: + skip_cloning: true + extra_refs: + - base_ref: branch + org: organization + repo: repository + name: periodic-ci-organization-repository-branch-periodic-unit + spec: + containers: + - args: + - --gcs-upload-secret=/secrets/gcs/service-account.json + - --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson + - --report-credentials-file=/etc/report/credentials + - --target=periodic-unit + command: + - ci-operator + env: + - name: HTTP_SERVER_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + image: quay-proxy.ci.openshift.org/openshift/ci:ci_ci-operator_latest + imagePullPolicy: Always + name: "" + ports: + - containerPort: 8080 + name: http + resources: + requests: + cpu: 10m + volumeMounts: + - mountPath: /secrets/gcs + name: gcs-credentials + readOnly: true + - mountPath: /secrets/manifest-tool + name: manifest-tool-local-pusher + readOnly: true + - mountPath: /etc/pull-secret + name: pull-secret + readOnly: true + - mountPath: /etc/report + name: result-aggregator + readOnly: true + serviceAccountName: ci-operator + volumes: + - name: manifest-tool-local-pusher + secret: + secretName: manifest-tool-local-pusher + - name: pull-secret + secret: + secretName: registry-pull-credentials + - name: result-aggregator + secret: + secretName: result-aggregator +presubmits: + organization/repository: + - always_run: false + name: pull-ci-organization-repository-branch-unit diff --git a/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_rehearsals_at_job_level_ci_operator_config_.yaml b/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_rehearsals_at_job_level_ci_operator_config_.yaml new file mode 100644 index 0000000000..6576b40437 --- /dev/null +++ b/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_rehearsals_at_job_level_ci_operator_config_.yaml @@ -0,0 +1,127 @@ +periodics: +- agent: kubernetes + cron: 0 0 * * * + decorate: true + decoration_config: + skip_cloning: true + extra_refs: + - base_ref: branch + org: organization + repo: repository + labels: + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: periodic-ci-organization-repository-branch-periodic-unit + spec: + containers: + - args: + - --gcs-upload-secret=/secrets/gcs/service-account.json + - --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson + - --report-credentials-file=/etc/report/credentials + - --target=periodic-unit + command: + - ci-operator + env: + - name: HTTP_SERVER_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + image: quay-proxy.ci.openshift.org/openshift/ci:ci_ci-operator_latest + imagePullPolicy: Always + name: "" + ports: + - containerPort: 8080 + name: http + resources: + requests: + cpu: 10m + volumeMounts: + - mountPath: /secrets/gcs + name: gcs-credentials + readOnly: true + - mountPath: /secrets/manifest-tool + name: manifest-tool-local-pusher + readOnly: true + - mountPath: /etc/pull-secret + name: pull-secret + readOnly: true + - mountPath: /etc/report + name: result-aggregator + readOnly: true + serviceAccountName: ci-operator + volumes: + - name: manifest-tool-local-pusher + secret: + secretName: manifest-tool-local-pusher + - name: pull-secret + secret: + secretName: registry-pull-credentials + - name: result-aggregator + secret: + secretName: result-aggregator +- agent: kubernetes + cron: 0 0 * * * + decorate: true + decoration_config: + skip_cloning: true + extra_refs: + - base_ref: branch + org: organization + repo: repository + labels: + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: periodic-ci-organization-repository-branch-periodic-lint + spec: + containers: + - args: + - --gcs-upload-secret=/secrets/gcs/service-account.json + - --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson + - --report-credentials-file=/etc/report/credentials + - --target=periodic-lint + command: + - ci-operator + env: + - name: HTTP_SERVER_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + image: quay-proxy.ci.openshift.org/openshift/ci:ci_ci-operator_latest + imagePullPolicy: Always + name: "" + ports: + - containerPort: 8080 + name: http + resources: + requests: + cpu: 10m + volumeMounts: + - mountPath: /secrets/gcs + name: gcs-credentials + readOnly: true + - mountPath: /secrets/manifest-tool + name: manifest-tool-local-pusher + readOnly: true + - mountPath: /etc/pull-secret + name: pull-secret + readOnly: true + - mountPath: /etc/report + name: result-aggregator + readOnly: true + serviceAccountName: ci-operator + volumes: + - name: manifest-tool-local-pusher + secret: + secretName: manifest-tool-local-pusher + - name: pull-secret + secret: + secretName: registry-pull-credentials + - name: result-aggregator + secret: + secretName: result-aggregator +presubmits: + organization/repository: + - always_run: false + name: pull-ci-organization-repository-branch-unit + - always_run: false + labels: + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: pull-ci-organization-repository-branch-lint diff --git a/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_rehearsals_at_job_level_prowgen_file_.yaml b/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_rehearsals_at_job_level_prowgen_file_.yaml new file mode 100644 index 0000000000..2ba80b5ab2 --- /dev/null +++ b/pkg/prowgen/testdata/zz_fixture_TestGenerateJobs_disabled_rehearsals_at_job_level_prowgen_file_.yaml @@ -0,0 +1,125 @@ +periodics: +- agent: kubernetes + cron: 0 0 * * * + decorate: true + decoration_config: + skip_cloning: true + extra_refs: + - base_ref: branch + org: organization + repo: repository + name: periodic-ci-organization-repository-branch-periodic-unit + spec: + containers: + - args: + - --gcs-upload-secret=/secrets/gcs/service-account.json + - --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson + - --report-credentials-file=/etc/report/credentials + - --target=periodic-unit + command: + - ci-operator + env: + - name: HTTP_SERVER_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + image: quay-proxy.ci.openshift.org/openshift/ci:ci_ci-operator_latest + imagePullPolicy: Always + name: "" + ports: + - containerPort: 8080 + name: http + resources: + requests: + cpu: 10m + volumeMounts: + - mountPath: /secrets/gcs + name: gcs-credentials + readOnly: true + - mountPath: /secrets/manifest-tool + name: manifest-tool-local-pusher + readOnly: true + - mountPath: /etc/pull-secret + name: pull-secret + readOnly: true + - mountPath: /etc/report + name: result-aggregator + readOnly: true + serviceAccountName: ci-operator + volumes: + - name: manifest-tool-local-pusher + secret: + secretName: manifest-tool-local-pusher + - name: pull-secret + secret: + secretName: registry-pull-credentials + - name: result-aggregator + secret: + secretName: result-aggregator +- agent: kubernetes + cron: 0 0 * * * + decorate: true + decoration_config: + skip_cloning: true + extra_refs: + - base_ref: branch + org: organization + repo: repository + labels: + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: periodic-ci-organization-repository-branch-periodic-lint + spec: + containers: + - args: + - --gcs-upload-secret=/secrets/gcs/service-account.json + - --image-import-pull-secret=/etc/pull-secret/.dockerconfigjson + - --report-credentials-file=/etc/report/credentials + - --target=periodic-lint + command: + - ci-operator + env: + - name: HTTP_SERVER_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + image: quay-proxy.ci.openshift.org/openshift/ci:ci_ci-operator_latest + imagePullPolicy: Always + name: "" + ports: + - containerPort: 8080 + name: http + resources: + requests: + cpu: 10m + volumeMounts: + - mountPath: /secrets/gcs + name: gcs-credentials + readOnly: true + - mountPath: /secrets/manifest-tool + name: manifest-tool-local-pusher + readOnly: true + - mountPath: /etc/pull-secret + name: pull-secret + readOnly: true + - mountPath: /etc/report + name: result-aggregator + readOnly: true + serviceAccountName: ci-operator + volumes: + - name: manifest-tool-local-pusher + secret: + secretName: manifest-tool-local-pusher + - name: pull-secret + secret: + secretName: registry-pull-credentials + - name: result-aggregator + secret: + secretName: result-aggregator +presubmits: + organization/repository: + - always_run: false + name: pull-ci-organization-repository-branch-unit + - always_run: false + labels: + pj-rehearse.openshift.io/can-be-rehearsed: "true" + name: pull-ci-organization-repository-branch-lint