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
46 changes: 46 additions & 0 deletions .github/detect-unreviewed-merge/tests/approval.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,27 @@ for (const approvalMode of ['any-approval', 'latest-per-reviewer']) {
}
});

test(`${approvalMode}: comfy-cursor-approver APPROVED counts (User, no [bot] suffix)`, async () => {
assert.equal(await run({approvalMode, reviews: [review('comfy-cursor-approver')]}), 0);
});

test(`${approvalMode}: that approval is dropped only when the exact login is ignored`, async () => {
const reviews = [review('comfy-cursor-approver')];
assert.equal(await run({approvalMode, reviews, ignore: 'comfy-cursor-approver'}), 1);
assert.equal(await run({approvalMode, reviews, ignore: 'Comfy-Cursor-Approver'}), 1);
});

test(`${approvalMode}: a [bot] suffix is not implied in either direction`, async () => {
const app = [review('comfy-cursor-approver[bot]', 'APPROVED', undefined, 'Bot')];
assert.equal(await run({approvalMode, reviews: app, ignore: 'comfy-cursor-approver'}), 0);
assert.equal(await run({approvalMode, reviews: [review('comfy-cursor-approver')], ignore: 'comfy-cursor-approver[bot]'}), 0);
});

test(`${approvalMode}: comfy-cursor-approver still counts when a different login is ignored`, async () => {
const reviews = [review('other-bot[bot]', 'APPROVED', undefined, 'Bot'), review('comfy-cursor-approver')];
assert.equal(await run({approvalMode, reviews, ignore: 'other-bot[bot]'}), 0);
});

test(`${approvalMode}: warns when the only counted approval is a Bot's`, async () => {
const warnings = [];
const reviews = [review('typo-app[bot]', 'APPROVED', undefined, 'Bot')];
Expand All @@ -100,3 +121,28 @@ test('latest-per-reviewer: a dismissed human approval still does not count', asy
const reviews = [review('human', 'APPROVED', '2026-10-01T00:00:00Z'), review('human', 'DISMISSED', '2026-10-01T01:00:00Z')];
assert.equal(await run({reviews}), 1);
});

test('latest-per-reviewer: a later DISMISSED from comfy-cursor-approver does not count', async () => {
const reviews = [
review('comfy-cursor-approver', 'APPROVED', '2026-10-01T00:00:00Z'),
review('comfy-cursor-approver', 'DISMISSED', '2026-10-01T01:00:00Z'),
];
assert.equal(await run({reviews}), 1);
});

test('latest-per-reviewer: a later COMMENTED review does not knock out comfy-cursor-approver', async () => {
const reviews = [
review('comfy-cursor-approver', 'APPROVED', '2026-10-01T00:00:00Z'),
review('comfy-cursor-approver', 'COMMENTED', '2026-10-01T02:00:00Z'),
];
assert.equal(await run({reviews}), 0);
});

test('any-approval: a DISMISSED comfy-cursor-approver review does not count', async () => {
// GitHub replaces APPROVED with DISMISSED on that review object. any-approval
// does not reconstruct a historical approval the API no longer reports.
assert.equal(await run({
approvalMode: 'any-approval',
reviews: [review('comfy-cursor-approver', 'DISMISSED')],
}), 1);
});
30 changes: 16 additions & 14 deletions .github/workflows/detect-unreviewed-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ name: Detect Unreviewed Merge (reusable)
# uses: Comfy-Org/github-workflows/.github/workflows/detect-unreviewed-merge.yml@<full-commit-sha> # v1 — substitute a real 40-char SHA
# with:
# approval-mode: latest-per-reviewer # or 'any-approval' for private repos
# # Logins whose APPROVED reviews do not count — e.g. the identity a
# # cursor-review `approve_max_severity` caller approves as.
# # Optional opt-out. An APPROVED review counts, including one from an
# # automated approver. List a login only when that approval must not
# # satisfy the check. The match is exact (`name` != `name[bot]`).
# ignore-approvers: ''
# secrets:
# UNREVIEWED_MERGES_TOKEN: ${{ secrets.UNREVIEWED_MERGES_TOKEN }}
Expand All @@ -45,12 +46,11 @@ on:
default: latest-per-reviewer
ignore-approvers:
description: >-
Logins (whitespace- or comma-separated, case-insensitive, `[bot]`
suffix included) whose reviews are ignored by the approval check in
BOTH modes. Pass any automated approver — e.g. the identity a
cursor-review caller with `approve_max_severity` approves as — so a
PR whose only approval is the bot's is still reported as unreviewed.
Default '' ignores no one.
Logins (whitespace- or comma-separated, case-insensitive; the
`[bot]` suffix is part of the login and is not stripped) whose
reviews are ignored in BOTH modes. An APPROVED review counts,
including one from an automated approver, unless that exact login
is listed. Default '' ignores no one.
type: string
required: false
default: ''
Expand Down Expand Up @@ -142,9 +142,11 @@ jobs:
pull_number: pr.number,
});

// An automated approver (ignore-approvers) is not a reviewer: drop
// its reviews before EITHER mode looks, so its APPROVED can neither
// count itself nor shadow anything in latest-per-reviewer.
// ignore-approvers is an opt-out, matched on the exact login
// (`name` does not match `name[bot]`). Drop those reviews before
// EITHER mode looks, so a listed APPROVED can neither count nor
// shadow another reviewer. Every other APPROVED counts, including
// a machine-user approver (type User, no `[bot]` suffix).
const ignored = new Set(
(process.env.IGNORE_APPROVERS || '')
.split(/[\s,]+/)
Expand Down Expand Up @@ -189,10 +191,10 @@ jobs:
const hasApproval = counted.length > 0;

if (hasApproval) {
// ignore-approvers fails open on a typo or a rotated identity, so
// say when the only approvals that counted are from Bot accounts.
// ignore-approvers fails open on a typo or a rotated identity.
// A Bot-typed approval still counts; say so when it was the only one.
if (counted.every(r => r.user?.type === 'Bot')) {
core.warning(`PR #${pr.number}'s approval came only from bot account(s) (${[...new Set(counted.map(r => r.user?.login))].join(', ')}) — if this repo auto-approves, list that identity in ignore-approvers.`);
core.warning(`PR #${pr.number}'s approval came only from bot account(s) (${[...new Set(counted.map(r => r.user?.login))].join(', ')}). That APPROVED review counts; list the login in ignore-approvers only when it must not.`);
}
core.info('PR has an approving review — no action needed.');
return;
Expand Down
7 changes: 4 additions & 3 deletions docs/callers/cursor-review.md
Original file line number Diff line number Diff line change
Expand Up @@ -1086,9 +1086,10 @@ GitHub runs the caller workflow from the PR's head, so a commit can remove
`pull_request_target` the caller comes from the BASE branch, so a PR cannot
drop its own dismissal — another reason to use the shape in the trust model below.

**Pair it with `detect-unreviewed-merge`'s `ignore-approvers`.** Pass the
approver identity there, or the bot's approval satisfies that SOC 2 audit and a
PR merged with no human review files nothing. See
**An approver's `APPROVED` review satisfies `detect-unreviewed-merge`.** That
includes the account this lane approves as. List that login in
`ignore-approvers` only when the approval must not count; a caller that
already lists it keeps dropping the review until the login is removed. See
[`detect-unreviewed-merge.md`](detect-unreviewed-merge.md#automated-approvers-ignore-approvers).

### Trust model
Expand Down
37 changes: 27 additions & 10 deletions docs/callers/detect-unreviewed-merge.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ jobs:
uses: Comfy-Org/github-workflows/.github/workflows/detect-unreviewed-merge.yml@<full-commit-sha>
with:
approval-mode: latest-per-reviewer # 'any-approval' for private repos
# Only if this repo auto-approves (cursor-review `approve_max_severity`):
# the identity that approves, so its approval is not counted as a review.
# ignore-approvers: my-review-app[bot]
# Optional. An APPROVED review counts, including from an automated
# approver. List a login only when that approval must not count.
# The match is exact: `name` does not match `name[bot]`.
# ignore-approvers: some-bot[bot]
secrets:
UNREVIEWED_MERGES_TOKEN: ${{ secrets.UNREVIEWED_MERGES_TOKEN }}
```
Expand All @@ -69,7 +70,7 @@ Read-only on your repo. The issue write happens on the tracking repo via the PAT
| Input | Default | Notes |
|---|---|---|
| `approval-mode` | `latest-per-reviewer` | Which historical approvals count. Pick deliberately — see below. |
| `ignore-approvers` | `''` | Logins (whitespace- or comma-separated, case-insensitive, `[bot]` suffix included) whose reviews the check ignores in both modes. **Required in practice for any repo that auto-approves** — see below. |
| `ignore-approvers` | `''` | Opt-out. Logins (whitespace- or comma-separated, case-insensitive; the `[bot]` suffix is part of the login and is not stripped) whose reviews the check ignores in both modes. Empty counts every `APPROVED` review, including an automated approver's. |

### Choosing `approval-mode`

Expand All @@ -84,12 +85,28 @@ in the other. Check the repo's branch-protection settings, then pick.

### Automated approvers: `ignore-approvers`

An approval by a bot is not a human review. If the repo enables cursor-review's
`approve_max_severity`, the bot's `APPROVED` would otherwise satisfy this check
in either mode — a PR could be labelled, auto-approved and merged with nobody
looking, and no tracking issue filed. Pass the identity that approves: the
`APPROVER_TOKEN` account's login, else your `bot_app_id` App's `<slug>[bot]`,
else `github-actions[bot]`. A human approval alongside the bot's still counts.
An `APPROVED` review satisfies the check in either mode, including one from an
automated approver. That is a machine user (the `APPROVER_TOKEN` account; login
has no `[bot]` suffix and `user.type` is `User`) or a GitHub App (`<slug>[bot]`,
`user.type` `Bot`). `user.type` is not a filter, and a `[bot]` suffix is not
inferred: listing `name` does not ignore `name[bot]`, or the reverse.

`ignore-approvers` is the opt-out for a login that must not satisfy the check.
The match is that exact login, case-insensitive. A listed review is dropped
before either mode runs, so it cannot count and cannot shadow another
reviewer's latest decision. Leave the input empty for an approver whose
approval should count. A human approval alongside a listed login still counts.
Comment thread
luke-mino-altherr marked this conversation as resolved.
Resolved
When `ignore-approvers` is nonempty, an `APPROVED` review without a usable
`user.login` is not eligible and does not satisfy the check.

A review GitHub has dismissed is state `DISMISSED` and does not count in either
mode — dismissal replaces `APPROVED` on that review, so `any-approval` does not
keep a hidden earlier approval. `latest-per-reviewer` also drops an approval
that the same login later superseded with a non-comment review. A later
`COMMENTED` review does not.

Callers that already pass an approver's login here keep dropping that approval
until they remove the login. A pin bump does not edit the input.

## Gotchas

Expand Down
Loading