Skip to content

Commit

Permalink
feat: add an option to skip builds for draft PR
Browse files Browse the repository at this point in the history
Signed-off-by: ankitm123 <[email protected]>
  • Loading branch information
ankitm123 authored and msvticket committed Sep 25, 2023
1 parent cbf115a commit de0b484
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/config/job/presubmit.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ type Presubmit struct {
// (Default: `/test <job name>`)
RerunCommand string `json:"rerun_command,omitempty"`
JenkinsSpec *JenkinsSpec `json:"jenkins_spec,omitempty"`
// SkipDraftPRBuild controls if we want to build a PR in draft mode
SkipDraftPRBuild bool `default:"false" json:"skip_draft_pr_build,omitempty"`

// We'll set these when we load it.
// re *regexp.Regexp // from Trigger.
Expand Down
10 changes: 10 additions & 0 deletions pkg/plugins/trigger/pull-request.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,5 +270,15 @@ func buildAll(c Client, pr *scm.PullRequest, eventGUID string, elideSkippedConte
if err != nil {
return err
}

for _, v := range c.Config.GetPresubmits(pr.Base.Repo) {
// For multiple pre submits this wont run any of the pre-submits, which is not desirable
fmt.Println(v.Name, " ", v.SkipDraftPRBuild)
if v.SkipDraftPRBuild && pr.Draft {
c.Logger.Debug("Skipping build for draft PR")
return nil
}
}

return RunAndSkipJobs(c, pr, toTest, toSkip, eventGUID, elideSkippedContexts)
}

0 comments on commit de0b484

Please sign in to comment.