Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/images
decorate: true
decoration_config:
Expand Down Expand Up @@ -50,7 +51,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/unit
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/rhel-images
decorate: true
decoration_config:
Expand Down Expand Up @@ -52,7 +53,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/rhel-unit
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/images
decorate: true
decoration_config:
Expand Down Expand Up @@ -50,7 +51,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/unit
decorate: true
decoration_config:
Expand Down
21 changes: 15 additions & 6 deletions pkg/prowgen/prowgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ func generatePresubmitForTest(name string, info *ProwgenInfo, podSpec *corev1.Po
return &prowconfig.Presubmit{
JobBase: base,
AlwaysRun: true,
Brancher: prowconfig.Brancher{Branches: []string{info.Branch}},
Brancher: prowconfig.Brancher{Branches: sets.NewString(exactlyBranch(info.Branch), featureBranch(info.Branch)).List()},
Reporter: prowconfig.Reporter{
Context: fmt.Sprintf("ci/prow/%s", shortName),
},
Expand All @@ -458,7 +458,7 @@ func generatePostsubmitForTest(name string, info *ProwgenInfo, podSpec *corev1.P
base := generateJobBase(name, jc.PostsubmitPrefix, info, podSpec, false, pathAlias, jobRelease, skipCloning)
return &prowconfig.Postsubmit{
JobBase: base,
Brancher: prowconfig.Brancher{Branches: []string{makeBranchExplicit(info.Branch)}},
Brancher: prowconfig.Brancher{Branches: []string{exactlyBranch(info.Branch)}},
}
}

Expand Down Expand Up @@ -616,16 +616,25 @@ func generateJobBase(name, prefix string, info *ProwgenInfo, podSpec *corev1.Pod
// not.
var simpleBranchRegexp = regexp.MustCompile(`^[\w\-.]+$`)

// makeBranchExplicit updates the provided branch to prevent wildcard matches to the given branch
// if the branch value does not appear to contain an explicit regex pattern. I.e. 'master'
// is turned into '^master$'.
func makeBranchExplicit(branch string) string {
// exactlyBranch returns a regex string that matches exactly the given branch name: I.e. returns
// '^master$' for 'master'. If the given branch name already looks like a regex, return it unchanged.
func exactlyBranch(branch string) string {
if !simpleBranchRegexp.MatchString(branch) {
return branch
}
return fmt.Sprintf("^%s$", regexp.QuoteMeta(branch))
}

// featureBranch returns a regex string that matches feature branch prefixes for the given branch name:
// I.e. returns '^master-' for 'master'. If the given branch name already looks like a regex,
// return it unchanged.
func featureBranch(branch string) string {
if !simpleBranchRegexp.MatchString(branch) {
return branch
}
return fmt.Sprintf("^%s-", regexp.QuoteMeta(branch))
}

// IsGenerated returns true if the job was generated using prowgen
func IsGenerated(job prowconfig.JobBase) bool {
_, generated := job.Labels[prowJobLabelGenerated]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/images
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/also-testname
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/testname
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/testname
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
agent: kubernetes
always_run: true
branches:
- branch
- ^branch$
- ^branch-
context: ci/prow/testname
decorate: true
labels:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/unit
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/e2e
decorate: true
decoration_config:
Expand Down Expand Up @@ -84,7 +85,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/images
decorate: true
decoration_config:
Expand Down Expand Up @@ -140,7 +142,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/unit
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/test
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/ci-index
decorate: true
decoration_config:
Expand Down Expand Up @@ -50,7 +51,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/ci-index-my-bundle
decorate: true
decoration_config:
Expand Down Expand Up @@ -97,7 +99,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/e2e
decorate: true
decoration_config:
Expand Down Expand Up @@ -170,7 +173,8 @@ presubmits:
- agent: kubernetes
always_run: false
branches:
- master
- ^master$
- ^master-
context: ci/prow/images
decorate: true
decoration_config:
Expand Down Expand Up @@ -232,7 +236,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/lint
decorate: true
decoration_config:
Expand Down Expand Up @@ -279,7 +284,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/steps
decorate: true
decoration_config:
Expand Down Expand Up @@ -333,7 +339,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/unit
decorate: true
decoration_config:
Expand Down Expand Up @@ -380,7 +387,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/variant-images
decorate: true
decoration_config:
Expand Down Expand Up @@ -431,7 +439,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
context: ci/prow/variant-unit
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master-removed-promotion
- ^master-removed-promotion$
- ^master-removed-promotion-
context: ci/prow/images
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- release-3.11
- ^release-3\.11$
- ^release-3\.11-
context: ci/prow/images
decorate: true
decoration_config:
Expand Down Expand Up @@ -61,7 +62,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- release-3.11
- ^release-3\.11$
- ^release-3\.11-
context: ci/prow/lint
decorate: true
decoration_config:
Expand Down Expand Up @@ -108,7 +110,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- release-3.11
- ^release-3\.11$
- ^release-3\.11-
context: ci/prow/unit
decorate: true
decoration_config:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
cluster: api.ci
context: ci/prow/images
decorate: true
Expand Down Expand Up @@ -51,7 +52,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
cluster: api.ci
context: ci/prow/unit
decorate: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
cluster: api.ci
context: ci/prow/images
decorate: true
Expand Down Expand Up @@ -53,7 +54,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- master
- ^master$
- ^master-
cluster: ci/api-build01-ci-devcluster-openshift-com:6443
context: ci/prow/unit
decorate: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ presubmits:
- agent: kubernetes
always_run: true
branches:
- nonstandard
- ^nonstandard$
- ^nonstandard-
cluster: ci/api-build01-ci-devcluster-openshift-com:6443
context: ci/prow/unit
decorate: true
Expand Down
Loading