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
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 @@
- **`/hive approve` no longer promises a merge for a workflow-file head that also removes tests.** Its reply keyed the "a trusted merger's Approve review lets the lane merge" caption on the workflow-path fence alone; since the contributor lane checks removed tests before the owner-approval release ([#15027](https://github.com/hivecommons/hive/pull/15027)), such a head stops at `contributor-lane:tests-removed`, so the reply now gives the manual-merge wording instead ([#15034](https://github.com/hivecommons/hive/issues/15034)).
5 changes: 4 additions & 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,10 @@ 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 {
// The owner-approval release lifts only the workflow-path fence; a head
// that also removes tests stops at tests-removed, so it gets the manual
// caption below rather than a promise the lane will merge it.
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
25 changes: 18 additions & 7 deletions src/pkg/github/automerge/pr_approve_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ import (
func TestPRApproveReply(t *testing.T) {
for _, tc := range []struct {
name, author, actor, verdict, file, body, want string
labels []string
bot, disabled, readError, trustedAuthor bool
// removedTest adds a deleted test file to the diff.
removedTest string
labels []string
bot, disabled, readError, trustedAuthor bool
releaseFence bool
}{
{name: "says no needs-human blocks", author: testHiveAppBotLogin, actor: "owner", want: "No `needs-human` label blocks this PR."},
{name: "says needs-human still blocks", author: testHiveAppBotLogin, actor: "owner", labels: []string{"needs-human"}, want: "`needs-human` still blocks this PR"},
Expand All @@ -32,6 +35,8 @@ func TestPRApproveReply(t *testing.T) {
{name: "bot", author: "contributor", actor: "owner", bot: true, want: "a bot cannot release"},
{name: "rejected contributor", author: "contributor", actor: "owner", verdict: "reject", want: "cannot override this contributor-lane verdict"},
{name: "manual workflow", author: "contributor", actor: "owner", file: ".github/workflows/ci.yml", want: "requires a person to merge manually"},
{name: "owner approval releases workflow fence", author: "contributor", actor: "owner", file: ".github/workflows/ci.yml", releaseFence: true, want: "merges only on a hive owner's explicit approval"},
{name: "workflow fence with removed test stays manual", author: "contributor", actor: "owner", file: ".github/workflows/ci.yml", removedTest: "src/pkg/widget/widget_test.go", releaseFence: true, want: "requires a person to merge manually"},
{name: "manual path", author: testHiveAppBotLogin, actor: "owner", file: "sensitive/config.yaml", want: "requires a person to merge manually"},
{name: "carried fence on App lane", author: testHiveAppBotLogin, actor: "owner", body: CarriedFenceMarker(contributorLaneReasonTestsRemoved, 9), want: "carries a diff fence from the contributor PR it supersedes"},
{name: "disabled lane", author: "contributor", actor: "owner", disabled: true, want: "must merge it manually"},
Expand Down Expand Up @@ -64,7 +69,11 @@ func TestPRApproveReply(t *testing.T) {
if file == "" {
file = "src/main.go"
}
json.NewEncoder(w).Encode([]*gh.CommitFile{{Filename: gh.Ptr(file), Status: gh.Ptr("modified")}})
files := []*gh.CommitFile{{Filename: gh.Ptr(file), Status: gh.Ptr("modified")}}
if tc.removedTest != "" {
files = append(files, &gh.CommitFile{Filename: gh.Ptr(tc.removedTest), Status: gh.Ptr("removed")})
}
json.NewEncoder(w).Encode(files)
default:
t.Errorf("unexpected read: %s", r.URL.Path)
w.WriteHeader(http.StatusNotFound)
Expand All @@ -74,10 +83,12 @@ func TestPRApproveReply(t *testing.T) {
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" },
TrustedAuthorPolicy: func() TrustedAuthorPolicy { return TrustedAuthorPolicy{Enabled: tc.trustedAuthor} },
TrustedAuthorizer: func(string, string) TrustedAuthorDecision { return TrustedAuthorDecision{Allowed: tc.trustedAuthor} },
ContributorLanePolicy: func() ContributorLanePolicy { return ContributorLanePolicy{Enabled: true} },
MergerAuthorizer: func(login string) bool { return login == "owner" },
TrustedAuthorPolicy: func() TrustedAuthorPolicy { return TrustedAuthorPolicy{Enabled: tc.trustedAuthor} },
TrustedAuthorizer: func(string, string) TrustedAuthorDecision { return TrustedAuthorDecision{Allowed: tc.trustedAuthor} },
ContributorLanePolicy: func() ContributorLanePolicy {
return ContributorLanePolicy{Enabled: true, OwnerApprovalReleasesWorkflowFence: tc.releaseFence}
},
ContributorLaneVerdict: func(string, int, string) ContributorLaneVerdict {
return ContributorLaneVerdict{Configured: true, Verdict: verdict}
},
Expand Down
Loading