diff --git a/pkg/statusreconciler/controller.go b/pkg/statusreconciler/controller.go index 61998ce8a9..6f1c5e79a0 100644 --- a/pkg/statusreconciler/controller.go +++ b/pkg/statusreconciler/controller.go @@ -234,6 +234,9 @@ func (c *Controller) triggerNewPresubmits(addedPresubmits map[string][]config.Pr continue } for _, pr := range prs { + if pr.Draft { + continue + } if pr.Mergable != nil && !*pr.Mergable { // the PR cannot be merged as it is, so the user will need to update the PR (and trigger // testing via the PR push event) or re-test if the HEAD of the branch they are targeting diff --git a/pkg/statusreconciler/controller_test.go b/pkg/statusreconciler/controller_test.go index 1c2f5eddf7..a67bf05766 100644 --- a/pkg/statusreconciler/controller_test.go +++ b/pkg/statusreconciler/controller_test.go @@ -856,6 +856,25 @@ func TestControllerReconcile(t *testing.T) { }, Mergable: ¬Mergable, } + draftPr := github.PullRequest{ + User: github.User{ + Login: author, + }, + Number: secondPrNumber, + Base: github.PullRequestBranch{ + Repo: github.Repo{ + Owner: github.User{ + Login: org, + }, + Name: repo, + }, + Ref: baseRef, + }, + Head: github.PullRequestBranch{ + SHA: "prsha-draft", + }, + Draft: true, + } thirdPr := github.PullRequest{ User: github.User{ Login: author, @@ -1057,6 +1076,31 @@ func TestControllerReconcile(t *testing.T) { return controller, checker }, }, + { + name: "no errors and draft PR means we should see no trigger, a retire and a migrate", + generator: func() (Controller, func(*testing.T)) { + fpjt := newfakeProwJobTriggerer() + fghc := newFakeGitHubClient(orgRepoKey) + fghc.prs[orgRepoKey] = []github.PullRequest{draftPr} + fghc.refs[orgRepoKey]["heads/"+draftPr.Base.Ref] = baseSha + fsm := newFakeMigrator(orgRepoKey) + ftc := newFakeTrustedChecker(orgRepoKey) + ftc.trusted[orgRepoKey][secondPrAuthorKey] = true + controller := Controller{ + continueOnError: true, + addedPresubmitDenylist: sets.New[string](), + prowJobTriggerer: &fpjt, + githubClient: &fghc, + statusMigrator: &fsm, + trustedChecker: &ftc, + } + checker := func(t *testing.T) { + checkTriggerer(t, fpjt, map[prKey]sets.Set[string]{}) + checkMigrator(t, fsm, map[orgRepo]sets.Set[string]{orgRepoKey: sets.New[string]("required-job")}, map[orgRepo]migrationSet{orgRepoKey: {migrate: nil}}) + } + return controller, checker + }, + }, { name: "no errors and PR that doesn't match the added job means we should see no trigger, a retire and a migrate", generator: func() (Controller, func(*testing.T)) { diff --git a/site/content/en/docs/components/optional/status-reconciler.md b/site/content/en/docs/components/optional/status-reconciler.md index dbc6af930f..e171e1a4d0 100644 --- a/site/content/en/docs/components/optional/status-reconciler.md +++ b/site/content/en/docs/components/optional/status-reconciler.md @@ -10,7 +10,7 @@ in flight do not cause those PRs to get stuck. When the set of blocking presubmits changes for a repository, one of three cases occurs: -- a new blocking presubmit exists and should be triggered for every trusted pull request in flight +- a new blocking presubmit exists and should be triggered for every trusted, non-draft pull request in flight - an existing blocking presubmit is removed and should have its' status retired - an existing blocking presubmit is renamed and should have its' status migrated