maintainer-approval: count only each reviewer's latest review state - #6297
maintainer-approval: count only each reviewer's latest review state#6297TangoEnSkai wants to merge 1 commit into
Conversation
The workflow scanned the full review history for any APPROVED record, so an approval that a reviewer later replaced with CHANGES_REQUESTED, or that was dismissed, kept satisfying the check. Collapse the history to each reviewer's most recent review before evaluating maintainer approval, maintainer-authored PR approval, and per-path owner approval. COMMENTED reviews are skipped: they carry no approval state and leave the reviewer's previous standing intact, the same way GitHub resolves its own reviewers list. Closes databricks#5322
Waiting for approvalBased on git history, these people are best suited to review:
Eligible reviewers: Suggestions based on git history. See OWNERS for ownership rules. |
|
@simonfaltum when you have a moment — this touches the approval gate itself, so I kept the change as small as I could and led with tests that pin down the current behaviour. Three of the five added cases fail against The workflow runs are Happy to split the |
|
An authorized user can trigger integration tests manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
Changes
maintainer-approvaltreated approval as "has this reviewer ever left anAPPROVEDreview" rather than "is this reviewer's current review stateAPPROVED". An approval that the same reviewer later replaced withCHANGES_REQUESTED, or that was dismissed, kept satisfying the check.This collapses the review history to each reviewer's most recent review
before the three places that evaluate it — maintainer approval,
maintainer-authored PR approval, and the per-path
approverLoginslist.All three read the same
reviewsbinding, so the fix is one helper plusone reassignment.
COMMENTEDreviews are skipped rather than counted as the latest state.They carry no approval state, so a reviewer who approves and then leaves a
plain comment keeps their approval — the same way GitHub resolves its own
reviewers list. Treating them as the latest review would silently revoke
approvals instead.
Fixes #5322.
Why
The gate is supposed to reflect current approval state. Today a reviewer
who approves, spots a problem, and switches to
CHANGES_REQUESTEDcannotactually withdraw the approval — the workflow still finds the historical
APPROVEDrecord and reports success. Dismissing the review does not helpeither, for the same reason.
The behaviour dates back to the original workflow in #4912 and was carried
over when per-path approval was added in #4918. #4918 added a test that
CHANGES_REQUESTEDdoes not count as approval, but it covers only a PRwith a single
CHANGES_REQUESTEDreview, which passes either way. Theapprove-then-request-changes sequence was never covered.
Tests
node --test .github/scripts/owners.test.js .github/workflows/maintainer-approval.test.jsFive cases added to
maintainer-approval.test.js. Three fail against thecurrent code and pass with this change:
Two guard the opposite direction and pass both before and after, so the
fix does not over-correct:
COMMENTEDreview -> still approvedNo changelog fragment: this changes repository CI tooling, not CLI
behaviour.