Skip to content
Draft
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
3 changes: 0 additions & 3 deletions cmd/check-gh-automation/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,6 @@ func gatherModifiedRepos(releaseRepoPath string, logger *logrus.Entry) []string
for _, c := range configs {
path := strings.TrimPrefix(c, config.CiopConfigInRepoPath+"/")
split := strings.Split(path, "/")
if split[1] == ".config.prowgen" {
continue
}
if split[1] == "OWNERS" {
continue
}
Expand Down
38 changes: 5 additions & 33 deletions cmd/ci-operator-prowgen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ 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) error {
generated := map[string]*prowconfig.JobConfig{}
genJobsFunc := generateJobs(o.resolver, prowConfig, generated)
genJobsFunc := generateJobs(o.resolver, generated)
if err := o.OperateOnCIOperatorConfigDir(filepath.Join(o.fromDir, subDir), genJobsFunc); err != nil {
return fmt.Errorf("failed to generate jobs: %w", err)
}
Expand All @@ -120,37 +120,10 @@ 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, 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}}
var ok bool
var err error
var orgConfig, repoConfig *config.Prowgen

if orgConfig, ok = cache[info.Org]; !ok {
if cache[info.Org], err = config.LoadProwgenConfig(info.OrgPath); err != nil {
return err
}
orgConfig = cache[info.Org]
}

if repoConfig, ok = cache[orgRepo]; !ok {
if cache[orgRepo], err = config.LoadProwgenConfig(info.RepoPath); err != nil {
return err
}
repoConfig = cache[orgRepo]
}

switch {
case orgConfig != nil:
pInfo.Config = *orgConfig
if repoConfig != nil {
pInfo.Config.MergeDefaults(repoConfig)
}
case repoConfig != nil:
pInfo.Config = *repoConfig
}
pInfo := &prowgen.ProwgenInfo{Metadata: info.Metadata}
if resolver != nil {
resolved, err := registry.ResolveConfig(resolver, *configSpec)
if err != nil {
Expand Down Expand Up @@ -227,10 +200,9 @@ func main() {
args = append(args, "")
}
logger := logrus.WithFields(logrus.Fields{"target": opt.toDir, "source": opt.fromDir})
config := map[string]*config.Prowgen{}
for _, subDir := range args {
logger = logger.WithFields(logrus.Fields{"subdir": subDir})
if err := opt.generateJobsToDir(subDir, config); err != nil {
if err := opt.generateJobsToDir(subDir); err != nil {
logger.WithError(err).Fatal("Failed to generate jobs")
}
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/ci-operator-prowgen/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"strings"
"testing"

"github.com/openshift/ci-tools/pkg/config"
"github.com/openshift/ci-tools/pkg/testhelper"
)

Expand Down Expand Up @@ -293,7 +292,7 @@ tests:
}

o := options{fromDir: fullConfigPath, toDir: baseProwConfigDir}
if err := o.generateJobsToDir("", map[string]*config.Prowgen{}); err != nil {
if err := o.generateJobsToDir(""); err != nil {
t.Fatalf("Unexpected error generating jobs from config: %v", err)
}

Expand Down
62 changes: 62 additions & 0 deletions pkg/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,46 @@ func IsPromotionJob(jobLabels map[string]string) bool {
return ok
}

// DefaultSlackReportTemplate is the default Go template used for Slack messages
// when no custom template is provided.
const DefaultSlackReportTemplate = `{{if eq .Status.State "success"}} :large_green_circle: Job *{{.Spec.Job}}* ended with *{{.Status.State}}*. <{{.Status.URL}}|View logs> {{else}} :red_circle: Job *{{.Spec.Job}}* ended with *{{.Status.State}}*. <{{.Status.URL}}|View logs> {{end}}`

// DefaultSlackReporterJobStatesToReport is the default set of job states that
// trigger a Slack report when no custom states are provided.
var DefaultSlackReporterJobStatesToReport = []prowv1.ProwJobState{
prowv1.FailureState,
prowv1.ErrorState,
}

// SlackReporter configures Slack reporting for a specific test.
type SlackReporter struct {
// Channel is the Slack channel to report to (e.g., "#my-channel").
Channel string `json:"channel"`
// JobStatesToReport determines which job states trigger a Slack report.
// If not set, defaults to ["failure", "error"].
JobStatesToReport []prowv1.ProwJobState `json:"job_states_to_report,omitempty"`
// ReportTemplate is an optional Go template for the Slack message.
// If not set, a default template is used.
ReportTemplate string `json:"report_template,omitempty"`
}

// ProwgenExtras holds fields that control Prow job generation behavior.
// These fields were previously configured via the .config.prowgen file.
type ProwgenExtras 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"`
// DisableRehearsals prevents all tests in this config from being rehearsed.
DisableRehearsals *bool `json:"disable_rehearsals,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"`
}

// ReleaseBuildConfiguration describes how release
// artifacts are built from a repository of source
// code. The configuration is made up of two parts:
Expand All @@ -40,6 +80,10 @@ type ReleaseBuildConfiguration struct {

InputConfiguration `json:",inline"`

// Prowgen holds fields that control Prow job generation behavior.
// These fields were previously configured via the .config.prowgen file.
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.
Expand Down Expand Up @@ -858,6 +902,21 @@ type TestStepConfiguration struct {
// RestrictNetworkAccess restricts network access to RedHat intranet.
RestrictNetworkAccess *bool `json:"restrict_network_access,omitempty"`

// SlackReporter configures Slack reporting for this specific test.
// When set, the generated Prow job will have Slack reporter configuration
// that reports to the specified channel on the specified job states.
SlackReporter *SlackReporter `json:"slack_reporter,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"`

// MaxConcurrency sets the maximum number of concurrent runs of this job.
// For postsubmit and periodic jobs, this defaults to 1 if not set.
// A zero value explicitly means no concurrency limit.
MaxConcurrency *int `json:"max_concurrency,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
Expand Down Expand Up @@ -2619,6 +2678,9 @@ type OperatorStepConfiguration struct {
// Substitutions describes the pullspecs in the operator manifests that must be subsituted
// with the pull specs of the images in the CI registry
Substitutions []PullSpecSubstitution `json:"substitutions,omitempty"`

// SkipPresubmits prevents generation of operator bundle presubmit jobs.
SkipPresubmits *bool `json:"skip_presubmits,omitempty"`
}

// IndexUpdate specifies the update mode for an operator being added to an index
Expand Down
102 changes: 91 additions & 11 deletions pkg/api/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading