Skip to content

Commit

Permalink
feat(KFLUXDP-160): Add a rule for tekton push events (#1515)
Browse files Browse the repository at this point in the history
feat(KFLUXDP-160): Add a rule for tekton push events and skip pull request author checks
  • Loading branch information
flacatus authored Feb 20, 2025
1 parent e030e20 commit 9beeeef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
16 changes: 11 additions & 5 deletions magefiles/magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ func (ci CI) init() error {
pr.Number = openshiftJobSpec.Refs.Pulls[0].Number
}

prUrl := fmt.Sprintf("https://api.github.com/repos/%s/%s/pulls/%d", pr.Organization, pr.RepoName, pr.Number)
pr.RemoteName, pr.BranchName, err = getRemoteAndBranchNameFromPRLink(prUrl)
if err != nil {
return err
if konfluxCiSpec.KonfluxGitRefs.EventType != "push" {
prUrl := fmt.Sprintf("https://api.github.com/repos/%s/%s/pulls/%d", pr.Organization, pr.RepoName, pr.Number)
pr.RemoteName, pr.BranchName, err = getRemoteAndBranchNameFromPRLink(prUrl)
if err != nil {
return err
}
}

rctx = rulesengine.NewRuleCtx()
Expand All @@ -132,6 +134,11 @@ func (ci CI) init() error {
rctx.PrRemoteName = pr.RemoteName
rctx.PrBranchName = pr.BranchName
rctx.PrCommitSha = pr.CommitSHA

if konfluxCI == "true" {
rctx.TektonEventType = konfluxCiSpec.KonfluxGitRefs.EventType
}

return nil
}

Expand Down Expand Up @@ -1276,7 +1283,6 @@ func (Local) PreviewTestSelection() error {
}

func (Local) RunRuleDemo() error {

rctx := rulesengine.NewRuleCtx()
files, err := utils.GetChangedFiles("e2e-tests")
if err != nil {
Expand Down
5 changes: 4 additions & 1 deletion magefiles/rulesengine/repos/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,13 @@ func GetPairedCommitSha(repoForPairing string, rctx *rulesengine.RuleCtx) string
}

func IsPeriodicJob(rctx *rulesengine.RuleCtx) (bool, error) {

return rctx.JobType == "periodic", nil
}

func IsTektonPushEventType(rctx *rulesengine.RuleCtx) (bool, error) {
return rctx.TektonEventType == "push", nil
}

func IsRehearseJob(rctx *rulesengine.RuleCtx) (bool, error) {

return strings.Contains(rctx.JobName, "rehearse"), nil
Expand Down
2 changes: 2 additions & 0 deletions magefiles/rulesengine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ type RuleCtx struct {
PrRemoteName string
PrCommitSha string
PrBranchName string
TektonEventType string
RequiresMultiPlatformTests bool
RequiresSprayProxyRegistering bool
}
Expand Down Expand Up @@ -475,6 +476,7 @@ func NewRuleCtx() *RuleCtx {
"",
"",
"",
"",
false,
false}

Expand Down

0 comments on commit 9beeeef

Please sign in to comment.