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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Hardened the automerge workflow-approval path against the read-only integration eligibility probe: the probe could reach the `/ok-to-test` post, where the mutation boundary refused the comment and the caller logged a WARN on every tick. The probe now skips the post and leaves it to the live sweep; live behaviour is unchanged.
6 changes: 6 additions & 0 deletions src/pkg/github/automerge/automerge_held_runs.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ func (c *Engine) workflowApprovalAttention(ctx context.Context, displayRepo, own
if c.workflowApprovalUntrustedKnown(owner, repo, number) {
return workflowApprovalUntrustedPrefix + contextName
}
if integrationEligibilityProbe(ctx) {
// The read-only eligibility probe cannot comment: its mutation
// boundary would refuse the post and WARN every tick. Skipping
// leaves the post to the live sweep.
return workflowApprovalRequiredPrefix + contextName
}
firstSeen, first := c.markWorkflowApprovalCommandSeen(owner, repo, number, headSHA)
state, scanned := c.workflowApprovalCommentState(ctx, displayRepo, owner, repo, number, headSHA, first)
if scanned && (state.rejected || state.prowManaged) && !c.okToTestWorkflowInstalled(ctx, displayRepo, owner, repo) {
Expand Down
27 changes: 27 additions & 0 deletions src/pkg/github/automerge/automerge_held_runs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,3 +717,30 @@ func TestWorkflowApprovalUntrustedReasonParksAtNeedsDecision(t *testing.T) {
t.Fatalf("decisionCause(%q) = %q, want Prow, the command and the workflow path named", reason, cause)
}
}

func TestWorkflowApprovalAttentionSkipsCommandInReadOnlyEligibilityProbe(t *testing.T) {
var comments []string
pr := missingRequiredPR(func(p *selfAuthoredPR) {
p.workflowRuns = []map[string]any{heldRun(1, "acme/widget")}
p.commentBodies = &comments
})
var merged []int
api := newSelfAuthoredAutoMergeAPI(t, []selfAuthoredPR{pr}, &merged)
defer api.Close()
c := newAutoMergeSweepClient(api.URL)

probeCtx := context.WithValue(context.Background(), integrationEligibilityContextKey{}, &integrationEligibilityCapture{})
want := workflowApprovalRequiredPrefix + "ci/build"
if got := c.workflowApprovalAttention(probeCtx, "widget", "acme", "widget", 23, "sha23", "ci/build", 1); got != want {
t.Fatalf("probe reason = %q, want %q", got, want)
}
if len(comments) != 0 {
t.Fatalf("probe posted comments %q, want none", comments)
}
if got := c.workflowApprovalAttention(context.Background(), "widget", "acme", "widget", 23, "sha23", "ci/build", 1); got != want {
t.Fatalf("live reason = %q, want %q", got, want)
}
if len(comments) != 1 || comments[0] != workflowApprovalCommandBody("sha23") {
t.Fatalf("live comments = %q, want one command after the probe", comments)
}
}
Loading