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
7 changes: 4 additions & 3 deletions .failproofai/policies/review-policies.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ customPolicies.add({
isResolved
comments(first: 1) {
nodes {
author { login }
author { login __typename }
}
}
}
Expand All @@ -93,8 +93,9 @@ customPolicies.add({

const unresolvedBotThreads = threads.filter((t) => {
if (t.isResolved) return false;
const author = t.comments?.nodes?.[0]?.author?.login ?? "";
return author.includes("[bot]");
const node = t.comments?.nodes?.[0];
if (!node?.author) return false;
return node.author.__typename === "Bot" || node.author.login.includes("[bot]");
});

if (unresolvedBotThreads.length > 0) {
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Unreleased

### Fixes
- Treat cancelled CI runs as non-failing in `require-ci-green-before-stop` policy (#128)

Comment thread
coderabbitai[bot] marked this conversation as resolved.
## 0.0.6-beta.1 — 2026-04-20

### Features
Expand Down
5 changes: 2 additions & 3 deletions __tests__/hooks/builtin-policies.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2709,14 +2709,13 @@ describe("hooks/builtin-policies", () => {
expect(result.reason).toContain("still running");
});

it("denies when CI has a cancelled conclusion (not success/skipped)", async () => {
it("allows when CI has a cancelled conclusion (superseded runs are not failures)", async () => {
mockCiScenario("feat/branch", JSON.stringify([
{ status: "completed", conclusion: "cancelled", name: "deploy" },
]));
const ctx = makeCtx({ eventType: "Stop", session: { cwd: "/repo" } });
const result = await policy.fn(ctx);
expect(result.decision).toBe("deny");
expect(result.reason).toContain("failing");
expect(result.decision).toBe("allow");
});

it("failing checks take priority over pending checks", async () => {
Expand Down
2 changes: 1 addition & 1 deletion docs/built-in-policies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ pull requests. If `gh` is not installed or not authenticated, the policy fails o
### `require-ci-green-before-stop`

**Event:** Stop
**Default:** Denies stopping when CI checks are failing or still running on the current branch. Checks both GitHub Actions workflow runs and third-party bot checks (e.g. CodeRabbit, SonarCloud, Codecov). Treats `skipped` conclusions as success. Returns an informational message when all checks pass.
**Default:** Denies stopping when CI checks are failing or still running on the current branch. Checks both GitHub Actions workflow runs and third-party bot checks (e.g. CodeRabbit, SonarCloud, Codecov). Treats `skipped` and `cancelled` conclusions as success. Returns an informational message when all checks pass.

No parameters.

Expand Down
6 changes: 5 additions & 1 deletion src/hooks/builtin-policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,11 @@ function requireCiGreenBeforeStop(ctx: PolicyContext): PolicyResult {
if (allChecks.length === 0) return allow(`No CI runs found for branch "${branch}".`);

const failing = allChecks.filter(
(r) => r.status === "completed" && r.conclusion !== "success" && r.conclusion !== "skipped",
(r) =>
r.status === "completed" &&
r.conclusion !== "success" &&
r.conclusion !== "skipped" &&
r.conclusion !== "cancelled",
);
if (failing.length > 0) {
const names = failing.map((r) => `"${r.name}"`).join(", ");
Expand Down
Loading