Skip to content
Closed
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
1 change: 1 addition & 0 deletions changelog.d/fixed-approve-reply-tests-removed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- The `/hive approve` reply no longer promises that a trusted merger's Approve review will merge a contributor PR whose head edits CI workflow files and also removes tests; the lane stops such a head at `contributor-lane:tests-removed` regardless of approval, so the reply now says a maintainer must merge it manually. Message-only change. (#15034)
2 changes: 1 addition & 1 deletion src/pkg/github/automerge/pr_approve_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (c *Engine) PRApproveReply(ctx context.Context, displayRepo string, number
if contributor {
diffReason = contributorLaneDiffReason(files)
}
if len(intent.HumanMergePathMatches(files, patterns)) == 0 && diffReason == contributorLaneReasonWorkflowPath && c.currentContributorLanePolicy().OwnerApprovalReleasesWorkflowFence {
if len(intent.HumanMergePathMatches(files, patterns)) == 0 && diffReason == contributorLaneReasonWorkflowPath && contributorLaneTestsRemovedReason(files) == "" && c.currentContributorLanePolicy().OwnerApprovalReleasesWorkflowFence {
return "`/hive approve` acknowledged, but this PR edits CI workflow / action files, which the contributor lane merges only on a hive owner's explicit approval: a trusted merger submits a GitHub **Approve** review for the current head (`" + stagelabels.ShortSHA(head) + "`) or approves it from the Hive dashboard, and the lane merges once CI and the other gates are clear. Approval on an earlier head does not carry over.", nil
}
if len(intent.HumanMergePathMatches(files, patterns)) > 0 || diffReason != "" {
Expand Down
34 changes: 34 additions & 0 deletions src/pkg/github/automerge/pr_approve_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,37 @@ func TestPRApproveReply(t *testing.T) {
})
}
}

func TestPRApproveReplyWorkflowHeadThatRemovesTestsIsManualMerge(t *testing.T) {
api := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/repos/acme/widget/pulls/7":
json.NewEncoder(w).Encode(&gh.PullRequest{Number: gh.Ptr(7), State: gh.Ptr("open"), User: &gh.User{Login: gh.Ptr("contributor")}, Head: &gh.PullRequestBranch{SHA: gh.Ptr("sha7")}})
case "/repos/acme/widget/pulls/7/files":
json.NewEncoder(w).Encode([]*gh.CommitFile{
{Filename: gh.Ptr(".github/workflows/ci.yml"), Status: gh.Ptr("modified")},
{Filename: gh.Ptr("src/main_test.go"), Status: gh.Ptr("removed")},
})
default:
t.Errorf("unexpected read: %s", r.URL.Path)
w.WriteHeader(http.StatusNotFound)
}
}))
defer api.Close()
client := hgithub.NewClient("token", "acme", []string{"widget"}, nil, api.URL)
client.SetAppBotLogin(testHiveAppBotLogin)
e := New(client, Options{
MergerAuthorizer: func(login string) bool { return login == "owner" },
ContributorLanePolicy: func() ContributorLanePolicy {
return ContributorLanePolicy{Enabled: true, OwnerApprovalReleasesWorkflowFence: true}
},
ContributorLaneVerdict: func(string, int, string) ContributorLaneVerdict {
return ContributorLaneVerdict{Configured: true, Verdict: "requires_human"}
},
RepoAutoMergeEnabled: func(string) bool { return true },
})
reply, err := e.PRApproveReply(context.Background(), "acme/widget", 7, &gh.IssueComment{Body: gh.Ptr("/hive approve"), User: &gh.User{Login: gh.Ptr("owner"), Type: gh.Ptr("User")}})
if err != nil || !strings.Contains(reply, "requires a person to merge manually") || strings.Contains(reply, "the lane merges once CI") {
t.Fatalf("reply=%q err=%v, want the generic manual-merge reply", reply, err)
}
}
Loading