Skip to content

Commit b93df6f

Browse files
author
Hector Vido
committed
Respecting always_run from config file
1 parent 2a29d23 commit b93df6f

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

cmd/ci-operator-prowgen/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ func (o *options) generateJobsToDir(subDir string, prowConfig map[string]*config
123123
func generateJobs(resolver registry.Resolver, cache map[string]*config.Prowgen, output map[string]*prowconfig.JobConfig) func(configSpec *cioperatorapi.ReleaseBuildConfiguration, info *config.Info) error {
124124
return func(configSpec *cioperatorapi.ReleaseBuildConfiguration, info *config.Info) error {
125125
orgRepo := fmt.Sprintf("%s/%s", info.Org, info.Repo)
126+
if orgRepo == "rh-ecosystem-edge/recert" && info.Filename == "/home/hector/go/src/github.com/openshift/release/ci-operator/config/rh-ecosystem-edge/recert/rh-ecosystem-edge-recert-release-4.18.yaml" {
127+
print(orgRepo)
128+
}
126129
pInfo := &prowgen.ProwgenInfo{Metadata: info.Metadata, Config: config.Prowgen{Private: false, Expose: false}}
127130
var ok bool
128131
var err error
@@ -195,8 +198,8 @@ func writeToDir(dir string, c map[string]*prowconfig.JobConfig) error {
195198
errCh := make(chan error)
196199
map_ := func() error {
197200
for x := range ch {
198-
i := strings.Index(x.k, "/")
199-
org, repo := x.k[:i], x.k[i+1:]
201+
i := strings.Split(x.k, "/")
202+
org, repo := i[0], i[1]
200203
if err := jc.WriteToDir(dir, org, repo, x.v, prowgen.Generator, nil); err != nil {
201204
errCh <- err
202205
}

pkg/jobconfig/files.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func WriteToDir(jobDir, org, repo string, jobConfig *prowconfig.JobConfig, gener
365365
return nil
366366
}
367367

368-
// Given two JobConfig, merge jobs from the `source` one to to `destination`
368+
// Given two JobConfig, merge jobs from the `source` one to `destination`
369369
// one. Jobs are matched by name. All jobs from `source` will be present in
370370
// `destination` - if there were jobs with the same name in `destination`, they
371371
// will be updated. All jobs in `destination` that are not overwritten this
@@ -471,7 +471,6 @@ func mergeJobConfig(destination, source *prowconfig.JobConfig, allJobs sets.Set[
471471
func mergePresubmits(old, new *prowconfig.Presubmit) prowconfig.Presubmit {
472472
merged := *new
473473

474-
merged.AlwaysRun = old.AlwaysRun
475474
merged.RunIfChanged = old.RunIfChanged
476475
merged.SkipIfOnlyChanged = old.SkipIfOnlyChanged
477476
merged.MaxConcurrency = old.MaxConcurrency

pkg/prowgen/prowgen.go

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ func GenerateJobs(configSpec *cioperatorapi.ReleaseBuildConfiguration, info *Pro
8888
}
8989
} else if element.Postsubmit {
9090
postsubmit := generatePostsubmitForTest(g, info, func(options *generatePostsubmitOptions) {
91+
if element.AlwaysRun != nil {
92+
options.alwaysRun = element.AlwaysRun
93+
}
9194
options.runIfChanged = element.RunIfChanged
9295
options.skipIfOnlyChanged = element.SkipIfOnlyChanged
9396
})
@@ -180,13 +183,16 @@ func GenerateJobs(configSpec *cioperatorapi.ReleaseBuildConfiguration, info *Pro
180183

181184
func handlePresubmit(g *prowJobBaseBuilder, element api.TestStepConfiguration, info *ProwgenInfo, disableRehearsal bool, requests api.ResourceList, presubmits map[string][]prowconfig.Presubmit, orgrepo string) {
182185
presubmit := generatePresubmitForTest(g, element.As, info, func(options *generatePresubmitOptions) {
183-
options.pipelineRunIfChanged = element.PipelineRunIfChanged
184-
options.Capabilities = element.Capabilities
185-
options.runIfChanged = element.RunIfChanged
186-
options.skipIfOnlyChanged = element.SkipIfOnlyChanged
187-
options.defaultDisable = element.AlwaysRun != nil && !*element.AlwaysRun
188-
options.optional = element.Optional
189-
options.disableRehearsal = disableRehearsal
186+
if element.AlwaysRun != nil {
187+
options.alwaysRun = element.AlwaysRun
188+
options.defaultDisable = !*element.AlwaysRun
189+
}
190+
options.Capabilities = element.Capabilities
191+
options.disableRehearsal = disableRehearsal
192+
options.optional = element.Optional
193+
options.pipelineRunIfChanged = element.PipelineRunIfChanged
194+
options.runIfChanged = element.RunIfChanged
195+
options.skipIfOnlyChanged = element.SkipIfOnlyChanged
190196
})
191197
v, requestingKVM := requests[cioperatorapi.KVMDeviceLabel]
192198
if requestingKVM {
@@ -205,6 +211,7 @@ func testContainsLease(test *cioperatorapi.TestStepConfiguration) bool {
205211
}
206212

207213
type generatePresubmitOptions struct {
214+
alwaysRun *bool
208215
pipelineRunIfChanged string
209216
Capabilities []string
210217
runIfChanged string
@@ -238,7 +245,6 @@ func generatePresubmitForTest(jobBaseBuilder *prowJobBaseBuilder, name string, i
238245
}
239246
pj := &prowconfig.Presubmit{
240247
JobBase: base,
241-
AlwaysRun: opts.runIfChanged == "" && opts.skipIfOnlyChanged == "" && !opts.defaultDisable && opts.pipelineRunIfChanged == "",
242248
Brancher: prowconfig.Brancher{Branches: sets.List(sets.New[string](jc.ExactlyBranch(info.Branch), jc.FeatureBranch(info.Branch)))},
243249
Reporter: prowconfig.Reporter{
244250
Context: fmt.Sprintf("ci/prow/%s", shortName),
@@ -251,11 +257,17 @@ func generatePresubmitForTest(jobBaseBuilder *prowJobBaseBuilder, name string, i
251257
},
252258
Optional: opts.optional,
253259
}
260+
if opts.alwaysRun != nil {
261+
pj.AlwaysRun = *opts.alwaysRun
262+
} else {
263+
pj.AlwaysRun = opts.runIfChanged == "" && opts.skipIfOnlyChanged == "" && !opts.defaultDisable && opts.pipelineRunIfChanged == ""
264+
}
254265
injectCapabilities(pj.Labels, opts.Capabilities)
255266
return pj
256267
}
257268

258269
type generatePostsubmitOptions struct {
270+
alwaysRun *bool
259271
runIfChanged string
260272
Capabilities []string
261273
skipIfOnlyChanged string

0 commit comments

Comments
 (0)