From b57d78b4a5cdcdb9ee6858c65a0bc9c4f0ec66d2 Mon Sep 17 00:00:00 2001 From: Sebastien Graf <95282692+Seb-GRAF@users.noreply.github.com> Date: Tue, 17 Nov 2026 10:46:44 +0100 Subject: [PATCH 1/6] ci: review every pull request with cubic, and risky ones with CodeRabbit --- .coderabbit.yaml | 8 ++- .github/deep-review-paths | 16 +++++ .github/scripts/deep-review.mjs | 11 ++++ .github/scripts/deep-review.test.mjs | 24 ++++++++ .github/scripts/pull-request-checks.mjs | 4 +- .github/scripts/pull-request-checks.test.mjs | 5 ++ .github/workflows/deep-review.yml | 40 +++++++++++++ AGENTS.md | 2 +- CONTRIBUTING.md | 2 +- DECISIONS.md | 3 +- cubic.yaml | 62 ++++++++++++++++++++ 11 files changed, 170 insertions(+), 7 deletions(-) create mode 100644 .github/deep-review-paths create mode 100644 .github/scripts/deep-review.mjs create mode 100644 .github/scripts/deep-review.test.mjs create mode 100644 .github/workflows/deep-review.yml create mode 100644 cubic.yaml diff --git a/.coderabbit.yaml b/.coderabbit.yaml index 3c33e423..f45b8947 100644 --- a/.coderabbit.yaml +++ b/.coderabbit.yaml @@ -1,6 +1,8 @@ # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json -# CodeRabbit reviews every pull request. It reads AGENTS.md on its own, as one of its default code -# guidelines; the path instructions point it at what reviews of StableBar keep catching. +# CodeRabbit reviews pull requests labeled deep-review, and cubic reviews every pull request +# (cubic.yaml). .github/workflows/deep-review.yml adds the label to big or risky changes, and anyone +# can add it by hand. CodeRabbit reads AGENTS.md on its own, as one of its default code guidelines; +# the path instructions point it at what reviews of StableBar keep catching. language: en-US reviews: # Only the most important findings go inline. Each one is a thread to resolve before merging. @@ -18,6 +20,8 @@ reviews: auto_review: enabled: true drafts: false + # Adding the label starts a review. + labels: ["deep-review"] # Every base branch, so pull requests stacked on another branch are reviewed too. base_branches: [".*"] # Keep reviewing every push: by default reviews pause after five reviewed commits, silently diff --git a/.github/deep-review-paths b/.github/deep-review-paths new file mode 100644 index 00000000..e649a525 --- /dev/null +++ b/.github/deep-review-paths @@ -0,0 +1,16 @@ +Sources/StableBar/PrivateAPI.swift +Sources/StableBar/AppUpdate.swift +Sources/StableBar/UpdateRelease.swift +Sources/StableBar/ICloudSync*.swift +Sources/StableBar/Uninstall*.swift +Resources/Info.plist +Resources/StableBar.entitlements +.github/workflows/** +.github/scripts/** +.githooks/** +scripts/** +.releaserc.json +Package.swift +Package.resolved +package.json +package-lock.json diff --git a/.github/scripts/deep-review.mjs b/.github/scripts/deep-review.mjs new file mode 100644 index 00000000..2f72cec1 --- /dev/null +++ b/.github/scripts/deep-review.mjs @@ -0,0 +1,11 @@ +// Decides whether a pull request gets the deep-review label, which starts a CodeRabbit review. +// .github/workflows/deep-review.yml runs the default branch's copy of this module, so a pull request +// never runs its own. +import { readFileSync } from "node:fs"; +import { matchesGlob } from "node:path"; + +export const deepReviewPaths = readFileSync(new URL("../deep-review-paths", import.meta.url), "utf8").trim().split("\n"); + +export function needsDeepReview(files, changedLines) { + return changedLines > 400 || files.some((file) => deepReviewPaths.some((path) => matchesGlob(file, path))); +} diff --git a/.github/scripts/deep-review.test.mjs b/.github/scripts/deep-review.test.mjs new file mode 100644 index 00000000..653ec25c --- /dev/null +++ b/.github/scripts/deep-review.test.mjs @@ -0,0 +1,24 @@ +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { execFileSync } from "node:child_process"; +import { matchesGlob } from "node:path"; +import { deepReviewPaths, needsDeepReview } from "./deep-review.mjs"; + +test("needsDeepReview asks for more than 400 changed lines", () => { + assert.equal(needsDeepReview(["docs/widgets.md"], 400), false); + assert.equal(needsDeepReview(["docs/widgets.md"], 401), true); +}); + +test("needsDeepReview matches the listed paths", () => { + for (const file of ["Sources/StableBar/PrivateAPI.swift", "Sources/StableBar/ICloudSyncSettings.swift", + ".github/workflows/ci.yml", ".github/scripts/fixtures/screens.json", "scripts/build.sh", "Package.resolved"]) + assert.equal(needsDeepReview(["docs/widgets.md", file], 10), true, file); + for (const file of ["Sources/StableBar/BarStore.swift", "Sources/StableBar/Settings/PrivateAPI.swift", + "docs/scripts.md", "Tests/StableBarTests/UninstallTests.swift"]) + assert.equal(needsDeepReview([file], 10), false, file); +}); + +test("every listed path matches a file", () => { + const files = execFileSync("git", ["ls-files"], { cwd: new URL("../..", import.meta.url), encoding: "utf8" }).split("\n"); + for (const path of deepReviewPaths) assert.ok(files.some((file) => matchesGlob(file, path)), path); +}); diff --git a/.github/scripts/pull-request-checks.mjs b/.github/scripts/pull-request-checks.mjs index b5ebcbff..229f6789 100644 --- a/.github/scripts/pull-request-checks.mjs +++ b/.github/scripts/pull-request-checks.mjs @@ -5,13 +5,13 @@ const keywords = "close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved" const sectionNames = ["Problem", "Changes", "Testing"]; const attributionHint = 'End it with the model and harness that did the work, such as "Claude Opus 5.5 via Claude Code", or with "No agent".'; -// The text GitHub shows, following CommonMark: auto-generated summaries and comments are hidden, +// The text GitHub shows, following CommonMark: auto-generated blocks and comments are hidden, // code is shown as written, a comment that starts a line hides everything up to its "-->" (or the // rest of the description when it never closes), and an unclosed "/g, ""); + .replace(//gi, ""); const shown = []; let paragraph = []; let fence = null; diff --git a/.github/scripts/pull-request-checks.test.mjs b/.github/scripts/pull-request-checks.test.mjs index e0fdb527..f34efc44 100644 --- a/.github/scripts/pull-request-checks.test.mjs +++ b/.github/scripts/pull-request-checks.test.mjs @@ -11,6 +11,9 @@ const filled = ["## Problem", "The clock disappears on a notched display.", "", "## Merging", "Rebase merge.", "", attribution].join("\n"); const summary = "\n\n" + "## Summary by CodeRabbit\n* New stuff\n"; +const cubicButtons = "\n\n\n" + + 'View guided diff\n' + + "\n"; const everything = ["Problem", "Changes", "Testing", "attribution line"]; test("visibleText drops comments, auto-generated blocks and carriage returns", () => { @@ -18,6 +21,7 @@ test("visibleText drops comments, auto-generated blocks and carriage returns", ( assert.equal(visibleText("a\n")).missing, ["Testing"]); assert.deepEqual(checkDescription(filled.replace("## Testing", "## testing")).missing, []); assert.deepEqual(checkDescription(filled + summary).missing, []); + assert.deepEqual(checkDescription(filled + cubicButtons).missing, []); assert.deepEqual(checkDescription(filled.replace("Keep it left of the notch.", "Handle the literal `" }; + const summary = { user: codeRabbit, body: "" }; + const cubic = { user: { login: "cubic-dev-ai[bot]" }, body: "rate limited by coderabbit.ai" }; + const pr = { headSha: "b", updatedAt: "2026-11-17T09:00:00Z", reviews: [], comments: [limited], now: Date.parse("2026-11-17T10:00:00Z") }; + assert.equal(needsRetry(pr), true); + assert.equal(needsRetry({ ...pr, comments: [cubic] }), true); + assert.equal(needsRetry({ ...pr, comments: [summary] }), false); + assert.equal(needsRetry({ ...pr, now: Date.parse("2026-11-17T09:20:00Z") }), false); + assert.equal(needsRetry({ ...pr, reviews: [{ user: codeRabbit, commit_id: "b" }] }), false); + assert.equal(needsRetry({ ...pr, reviews: [{ user: codeRabbit, commit_id: "a" }] }), true); +}); diff --git a/.github/workflows/deep-review.yml b/.github/workflows/deep-review.yml index 8b1dde6b..9ca2a567 100644 --- a/.github/workflows/deep-review.yml +++ b/.github/workflows/deep-review.yml @@ -2,12 +2,17 @@ name: Deep review # Adds the deep-review label, which starts a CodeRabbit review, to a pull request that changes more # than 400 lines or a file listed in .github/deep-review-paths. It never removes the label. A draft -# gets it once it's ready for review, since CodeRabbit skips drafts. pull_request_target runs the -# default branch's copy of this workflow and of .github/scripts, so a pull request never runs its own -# code here. The logic and its tests are in .github/scripts/deep-review.mjs. +# gets it once it's ready for review, since CodeRabbit skips drafts. Every hour it adds the label anew +# to a labeled pull request that CodeRabbit left unreviewed because of its review limit, or never +# answered. pull_request_target runs the default branch's copy of this workflow and of +# .github/scripts, so a pull request never runs its own code here. The logic and its tests are in +# .github/scripts/deep-review.mjs. on: pull_request_target: types: [opened, reopened, synchronize, ready_for_review] + schedule: + - cron: "17 * * * *" + workflow_dispatch: permissions: contents: read @@ -20,7 +25,9 @@ concurrency: jobs: label: name: Deep review label - if: ${{ !github.event.pull_request.draft && !contains(github.event.pull_request.labels.*.name, 'deep-review') }} + if: >- + github.event_name == 'pull_request_target' && !github.event.pull_request.draft + && !contains(github.event.pull_request.labels.*.name, 'deep-review') runs-on: ubuntu-latest timeout-minutes: 5 steps: @@ -38,3 +45,29 @@ jobs: const files = await github.paginate(github.rest.pulls.listFiles, { owner, repo, pull_number: pr.number, per_page: 100 }); if (needsDeepReview(files.map((file) => file.filename), pr.additions + pr.deletions)) await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: ["deep-review"] }); + + retry: + name: Ask CodeRabbit again + if: github.event_name != 'pull_request_target' + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v7 + with: + ref: ${{ github.event.repository.default_branch }} + sparse-checkout: .github/scripts + persist-credentials: false + - uses: actions/github-script@v9 + with: + script: | + const { needsRetry } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/deep-review.mjs`); + const { owner, repo } = context.repo; + const pulls = await github.paginate(github.rest.pulls.list, { owner, repo, state: "open", per_page: 100 }); + for (const pr of pulls.filter((pr) => !pr.draft && pr.labels.some((label) => label.name === "deep-review"))) { + const reviews = await github.paginate(github.rest.pulls.listReviews, { owner, repo, pull_number: pr.number, per_page: 100 }); + const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number: pr.number, per_page: 100 }); + if (!needsRetry({ headSha: pr.head.sha, updatedAt: pr.updated_at, reviews, comments, now: Date.now() })) continue; + core.info(`Asking CodeRabbit again on #${pr.number}.`); + await github.rest.issues.removeLabel({ owner, repo, issue_number: pr.number, name: "deep-review" }); + await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: ["deep-review"] }); + } diff --git a/AGENTS.md b/AGENTS.md index 05b98548..527933cd 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -85,7 +85,7 @@ A configuration change rarely lives in one place. Before calling one done, say w - A `fix`, `feat` or `perf` pull request needs an issue. Before opening it, search with the `triage` skill. If an open issue covers the problem, link it. If none does, file one with `triage` (the request for the pull request covers filing it) and link that. If triage finds the problem already fixed or declined, tell the developer before going on. Other types, such as `ci`, `test`, `docs` or `chore`, can skip the issue. - Titles follow Conventional Commits in plain words, such as `fix: keep the clock visible on a notched display`. Every commit message is checked too, and the types of the commits that reach `main` decide the next release (see [Commits and releases](CONTRIBUTING.md#commits-and-releases)). - Fill in the [pull request template](.github/pull_request_template.md), and end the description with the model and harness that did the work. The `Description` check fails without that line, and `Linked issue` fails a `fix`, `feat` or `perf` pull request that closes no issue. -- cubic reviews every pull request, and CodeRabbit reviews those labeled `deep-review`. The label is added automatically when a pull request changes more than 400 lines or a file in [.github/deep-review-paths](.github/deep-review-paths); add it yourself when a change is risky, such as when cubic's review points out a risk. Answer each comment from either by fixing the code or replying why not, then resolve the thread: unresolved threads block merging. Don't post `@coderabbitai review` again and again: each request uses up one of the pull request author's few CodeRabbit reviews per hour. +- cubic reviews every pull request, and CodeRabbit reviews those labeled `deep-review`. The label is added automatically when a pull request changes more than 400 lines or a file in [.github/deep-review-paths](.github/deep-review-paths); add it yourself when a change is risky, such as when cubic's review points out a risk. Answer each comment from either by fixing the code or replying why not, then resolve the thread: unresolved threads block merging. Don't post `@coderabbitai review`: each request uses up one of the pull request author's few CodeRabbit reviews per hour, and the Deep review workflow already asks CodeRabbit again every hour when its limit held a review back. - Upload screenshots and recordings to the pull request; never commit them. The images in `docs/images` are the exception: they illustrate the README and the guide, and CI draws them (see [Docs images](CONTRIBUTING.md#docs-images)). - Keep to one problem per pull request. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e29e5eca..c6ee6db5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,7 +90,7 @@ There is no web view or custom drawing loop. Private macOS API, for hiding and r Reviews are requested automatically from the people listed in [CODEOWNERS](.github/CODEOWNERS), but they are not required. Ask for one when a change is risky or outside your usual area. -[cubic](https://cubic.dev) also reviews every pull request once it is out of draft. [CodeRabbit](https://coderabbit.ai) reviews pull requests labeled `deep-review`: the label is added automatically when a pull request changes more than 400 lines or a file listed in [.github/deep-review-paths](.github/deep-review-paths), and you can add it yourself when a change is risky. Fix each comment from either or reply why not, then resolve its thread: unresolved conversations block merging. Their rules come from [AGENTS.md](AGENTS.md), [cubic.yaml](cubic.yaml) and [.coderabbit.yaml](.coderabbit.yaml). CodeRabbit allows each pull request author only a few reviews per hour, so don't ask it again and again with `@coderabbitai review`. +[cubic](https://cubic.dev) also reviews every pull request once it is out of draft. [CodeRabbit](https://coderabbit.ai) reviews pull requests labeled `deep-review`: the label is added automatically when a pull request changes more than 400 lines or a file listed in [.github/deep-review-paths](.github/deep-review-paths), and you can add it yourself when a change is risky. Fix each comment from either or reply why not, then resolve its thread: unresolved conversations block merging. Their rules come from [AGENTS.md](AGENTS.md), [cubic.yaml](cubic.yaml) and [.coderabbit.yaml](.coderabbit.yaml). CodeRabbit allows each pull request author only a few reviews per hour. When its limit holds a review back, the Deep review workflow asks it again every hour, so there's no need to ask with `@coderabbitai review`. [DECISIONS.md](DECISIONS.md) lists the lasting decisions about releases, reviews and code. A pull request that sets a new rule or policy adds an entry there. diff --git a/DECISIONS.md b/DECISIONS.md index d2969b23..fc1af84e 100644 --- a/DECISIONS.md +++ b/DECISIONS.md @@ -13,7 +13,7 @@ Add an entry when a pull request sets a rule, a policy or a choice not to do som ## Reviews and checks -- **cubic reviews every pull request, CodeRabbit the risky ones** (2026-11-17, [#772]). CodeRabbit's free plan allows each author two reviews an hour, so pull requests opened together went unreviewed. cubic is free for public repositories and resolves its own threads. CodeRabbit, which had reviewed every pull request since 2026-10-31 ([#391]), now reviews those labeled `deep-review`: more than 400 changed lines, a file in `.github/deep-review-paths`, or added by hand. No paid review tools or API keys. +- **cubic reviews every pull request, CodeRabbit the risky ones** (2026-11-17, [#772], [#773]). CodeRabbit's free plan allows each author two reviews an hour, so pull requests opened together went unreviewed. cubic is free for public repositories and resolves its own threads. CodeRabbit, which had reviewed every pull request since 2026-10-31 ([#391]), now reviews those labeled `deep-review`: more than 400 changed lines, a file in `.github/deep-review-paths`, or added by hand. A workflow asks it again every hour when its limit held a review back. No paid review tools or API keys. - **No auto-merge** (2026-10-31). The rules need no approval, but a maintainer merges; nothing merges itself. - **A person approves changed screens** (2026-10-31, [#395], [#397]). CI draws before/after screens, and any maintainer, the author too, adds `visual-ok` after looking. A visible change also shows screenshots in its pull request description (2026-11-08, [#484]). - **Pull requests compare with `main`'s own screens** (2026-11-17). Each push to `main` draws its screens once, and a pull request uses those of its base, drawing from the base only the scenes it adds or edits, instead of drawing the whole base again in every run. Docs images drawn from one commit on different CI Macs, and on two runner images, matched byte for byte. A cancelled draw leaves Visual review pending, not failed. @@ -83,3 +83,4 @@ Add an entry when a pull request sets a rule, a policy or a choice not to do som [#664]: https://github.com/Seb-GRAF/StableBar/issues/664 [#676]: https://github.com/Seb-GRAF/StableBar/issues/676 [#772]: https://github.com/Seb-GRAF/StableBar/issues/772 +[#773]: https://github.com/Seb-GRAF/StableBar/pull/773 From efa7549cfd998c3660cc4c41421f5275d07d6209 Mon Sep 17 00:00:00 2001 From: Sebastien Graf <95282692+Seb-GRAF@users.noreply.github.com> Date: Tue, 17 Nov 2026 11:40:30 +0100 Subject: [PATCH 3/6] ci: retry CodeRabbit per latest commit, and label pull requests that rename listed files --- .github/scripts/deep-review.mjs | 14 +++++++------- .github/scripts/deep-review.test.mjs | 20 ++++++++++++-------- .github/workflows/deep-review.yml | 14 ++++++++------ 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/.github/scripts/deep-review.mjs b/.github/scripts/deep-review.mjs index 512ea7c0..d2ea871c 100644 --- a/.github/scripts/deep-review.mjs +++ b/.github/scripts/deep-review.mjs @@ -10,13 +10,13 @@ export function needsDeepReview(files, changedLines) { return changedLines > 400 || files.some((file) => deepReviewPaths.some((path) => matchesGlob(file, path))); } -// Whether to add the label anew, which asks CodeRabbit again: it hasn't reviewed the head commit, and -// its summary comment says it hit the review limit, or it never answered. CodeRabbit doesn't retry by -// itself. A pull request updated in the last 30 minutes may still have a review on the way. -export function needsRetry({ headSha, updatedAt, reviews, comments, now }) { - const fromCodeRabbit = (item) => item.user.login === "coderabbitai[bot]"; +// Whether to add the label anew, which asks CodeRabbit again: since the head commit, CodeRabbit either +// hasn't answered or answered that it hit its review limit. It rewrites its summary comment on each +// attempt, and doesn't retry by itself. A pull request updated in the last 30 minutes may still have +// a review on the way. +export function needsRetry({ headDate, updatedAt, comments, now }) { if (now - Date.parse(updatedAt) < 30 * 60 * 1000) return false; - if (reviews.some((review) => fromCodeRabbit(review) && review.commit_id === headSha)) return false; - const answers = comments.filter(fromCodeRabbit); + const answers = comments.filter((comment) => + comment.user.login === "coderabbitai[bot]" && Date.parse(comment.updated_at) >= Date.parse(headDate)); return answers.length === 0 || answers.some((comment) => comment.body.includes("rate limited by coderabbit.ai")); } diff --git a/.github/scripts/deep-review.test.mjs b/.github/scripts/deep-review.test.mjs index b3677c71..7f260232 100644 --- a/.github/scripts/deep-review.test.mjs +++ b/.github/scripts/deep-review.test.mjs @@ -19,20 +19,24 @@ test("needsDeepReview matches the listed paths", () => { }); test("every listed path matches a file", () => { - const files = execFileSync("git", ["ls-files"], { cwd: new URL("../..", import.meta.url), encoding: "utf8" }).split("\n"); + const files = execFileSync("git", ["ls-files"], + { cwd: new URL("../..", import.meta.url), encoding: "utf8", timeout: 60_000 }).split("\n"); for (const path of deepReviewPaths) assert.ok(files.some((file) => matchesGlob(file, path)), path); }); -test("needsRetry asks CodeRabbit again after its review limit or when it never answered", () => { +test("needsRetry asks CodeRabbit again when, since the head commit, it hit its limit or didn't answer", () => { const codeRabbit = { login: "coderabbitai[bot]" }; - const limited = { user: codeRabbit, body: "" }; - const summary = { user: codeRabbit, body: "" }; - const cubic = { user: { login: "cubic-dev-ai[bot]" }, body: "rate limited by coderabbit.ai" }; - const pr = { headSha: "b", updatedAt: "2026-11-17T09:00:00Z", reviews: [], comments: [limited], now: Date.parse("2026-11-17T10:00:00Z") }; + const limited = { user: codeRabbit, updated_at: "2026-11-17T08:40:00Z", + body: "" }; + const summary = { user: codeRabbit, updated_at: "2026-11-17T08:40:00Z", + body: "" }; + const cubic = { user: { login: "cubic-dev-ai[bot]" }, updated_at: "2026-11-17T08:40:00Z", body: "rate limited by coderabbit.ai" }; + const pr = { headDate: "2026-11-17T08:30:00Z", updatedAt: "2026-11-17T09:00:00Z", comments: [limited], + now: Date.parse("2026-11-17T10:00:00Z") }; assert.equal(needsRetry(pr), true); + assert.equal(needsRetry({ ...pr, comments: [] }), true); assert.equal(needsRetry({ ...pr, comments: [cubic] }), true); assert.equal(needsRetry({ ...pr, comments: [summary] }), false); + assert.equal(needsRetry({ ...pr, comments: [summary], headDate: "2026-11-17T08:50:00Z" }), true); assert.equal(needsRetry({ ...pr, now: Date.parse("2026-11-17T09:20:00Z") }), false); - assert.equal(needsRetry({ ...pr, reviews: [{ user: codeRabbit, commit_id: "b" }] }), false); - assert.equal(needsRetry({ ...pr, reviews: [{ user: codeRabbit, commit_id: "a" }] }), true); }); diff --git a/.github/workflows/deep-review.yml b/.github/workflows/deep-review.yml index 9ca2a567..bacbbc4a 100644 --- a/.github/workflows/deep-review.yml +++ b/.github/workflows/deep-review.yml @@ -3,8 +3,8 @@ name: Deep review # Adds the deep-review label, which starts a CodeRabbit review, to a pull request that changes more # than 400 lines or a file listed in .github/deep-review-paths. It never removes the label. A draft # gets it once it's ready for review, since CodeRabbit skips drafts. Every hour it adds the label anew -# to a labeled pull request that CodeRabbit left unreviewed because of its review limit, or never -# answered. pull_request_target runs the default branch's copy of this workflow and of +# to a labeled pull request whose latest commit CodeRabbit left unreviewed because of its review +# limit, or never answered. pull_request_target runs the default branch's copy of this workflow and of # .github/scripts, so a pull request never runs its own code here. The logic and its tests are in # .github/scripts/deep-review.mjs. on: @@ -20,7 +20,8 @@ permissions: concurrency: group: deep-review-${{ github.event.pull_request.number }} - cancel-in-progress: true + # A retry run that stopped between removing and adding the label would leave the label off. + cancel-in-progress: ${{ github.event_name == 'pull_request_target' }} jobs: label: @@ -43,7 +44,8 @@ jobs: const { owner, repo } = context.repo; const pr = context.payload.pull_request; const files = await github.paginate(github.rest.pulls.listFiles, { owner, repo, pull_number: pr.number, per_page: 100 }); - if (needsDeepReview(files.map((file) => file.filename), pr.additions + pr.deletions)) + const paths = files.flatMap((file) => file.previous_filename ? [file.filename, file.previous_filename] : [file.filename]); + if (needsDeepReview(paths, pr.additions + pr.deletions)) await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: ["deep-review"] }); retry: @@ -64,9 +66,9 @@ jobs: const { owner, repo } = context.repo; const pulls = await github.paginate(github.rest.pulls.list, { owner, repo, state: "open", per_page: 100 }); for (const pr of pulls.filter((pr) => !pr.draft && pr.labels.some((label) => label.name === "deep-review"))) { - const reviews = await github.paginate(github.rest.pulls.listReviews, { owner, repo, pull_number: pr.number, per_page: 100 }); + const { data: head } = await github.rest.git.getCommit({ owner, repo, commit_sha: pr.head.sha }); const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number: pr.number, per_page: 100 }); - if (!needsRetry({ headSha: pr.head.sha, updatedAt: pr.updated_at, reviews, comments, now: Date.now() })) continue; + if (!needsRetry({ headDate: head.committer.date, updatedAt: pr.updated_at, comments, now: Date.now() })) continue; core.info(`Asking CodeRabbit again on #${pr.number}.`); await github.rest.issues.removeLabel({ owner, repo, issue_number: pr.number, name: "deep-review" }); await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: ["deep-review"] }); From 1b3cd1d6e9f197b6c6b152952ed873aeef3eca0d Mon Sep 17 00:00:00 2001 From: Sebastien Graf <95282692+Seb-GRAF@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:12:15 +0100 Subject: [PATCH 4/6] ci: keep cubic from fixing pull requests on its own --- cubic.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cubic.yaml b/cubic.yaml index 3e895154..891cd6ae 100644 --- a/cubic.yaml +++ b/cubic.yaml @@ -60,3 +60,7 @@ pr_descriptions: # The Description check reads the description's last line, so cubic leaves it alone. generate: false cubic_review_link: false +issues: + # Authors fix review comments themselves; with auto-fix off, cubic pushes no commits on its own and + # adds no auto-fix button to descriptions. + auto_fix: "off" From 5b7f4d49d025a097c4d36877b78d5e44b8a2d21c Mon Sep 17 00:00:00 2001 From: Sebastien Graf <95282692+Seb-GRAF@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:15:53 +0100 Subject: [PATCH 5/6] ci: retry CodeRabbit on its limit notice, oldest first, and list the review setup --- .github/deep-review-paths | 7 +++++++ .github/scripts/deep-review.mjs | 16 +++++++--------- .github/scripts/deep-review.test.mjs | 23 ++++++++++------------- .github/workflows/deep-review.yml | 27 +++++++++++++++------------ AGENTS.md | 2 +- CONTRIBUTING.md | 2 +- 6 files changed, 41 insertions(+), 36 deletions(-) diff --git a/.github/deep-review-paths b/.github/deep-review-paths index e649a525..ed6c0a4c 100644 --- a/.github/deep-review-paths +++ b/.github/deep-review-paths @@ -3,10 +3,17 @@ Sources/StableBar/AppUpdate.swift Sources/StableBar/UpdateRelease.swift Sources/StableBar/ICloudSync*.swift Sources/StableBar/Uninstall*.swift +Sources/StableBar/ConfigurationLoader.swift +Sources/StableBar/PackageSecrets.swift Resources/Info.plist Resources/StableBar.entitlements .github/workflows/** .github/scripts/** +.github/deep-review-paths +.github/CODEOWNERS +.github/dependabot.yml +.coderabbit.yaml +cubic.yaml .githooks/** scripts/** .releaserc.json diff --git a/.github/scripts/deep-review.mjs b/.github/scripts/deep-review.mjs index d2ea871c..c58b6c4a 100644 --- a/.github/scripts/deep-review.mjs +++ b/.github/scripts/deep-review.mjs @@ -10,13 +10,11 @@ export function needsDeepReview(files, changedLines) { return changedLines > 400 || files.some((file) => deepReviewPaths.some((path) => matchesGlob(file, path))); } -// Whether to add the label anew, which asks CodeRabbit again: since the head commit, CodeRabbit either -// hasn't answered or answered that it hit its review limit. It rewrites its summary comment on each -// attempt, and doesn't retry by itself. A pull request updated in the last 30 minutes may still have -// a review on the way. -export function needsRetry({ headDate, updatedAt, comments, now }) { - if (now - Date.parse(updatedAt) < 30 * 60 * 1000) return false; - const answers = comments.filter((comment) => - comment.user.login === "coderabbitai[bot]" && Date.parse(comment.updated_at) >= Date.parse(headDate)); - return answers.length === 0 || answers.some((comment) => comment.body.includes("rate limited by coderabbit.ai")); +// Whether to add the label anew, which asks CodeRabbit again: at least 30 minutes ago, its summary +// comment said it hit the review limit on the head commit. CodeRabbit doesn't retry by itself, and +// drops the notice once it reviews. +export function needsRetry({ headSha, comments, now }) { + return comments.some((comment) => comment.user.login === "coderabbitai[bot]" + && comment.body.includes("rate limited by coderabbit.ai") && comment.body.includes(headSha) + && now - Date.parse(comment.updated_at) >= 30 * 60 * 1000); } diff --git a/.github/scripts/deep-review.test.mjs b/.github/scripts/deep-review.test.mjs index 7f260232..fc1558cd 100644 --- a/.github/scripts/deep-review.test.mjs +++ b/.github/scripts/deep-review.test.mjs @@ -24,19 +24,16 @@ test("every listed path matches a file", () => { for (const path of deepReviewPaths) assert.ok(files.some((file) => matchesGlob(file, path)), path); }); -test("needsRetry asks CodeRabbit again when, since the head commit, it hit its limit or didn't answer", () => { - const codeRabbit = { login: "coderabbitai[bot]" }; - const limited = { user: codeRabbit, updated_at: "2026-11-17T08:40:00Z", - body: "" }; - const summary = { user: codeRabbit, updated_at: "2026-11-17T08:40:00Z", - body: "" }; - const cubic = { user: { login: "cubic-dev-ai[bot]" }, updated_at: "2026-11-17T08:40:00Z", body: "rate limited by coderabbit.ai" }; - const pr = { headDate: "2026-11-17T08:30:00Z", updatedAt: "2026-11-17T09:00:00Z", comments: [limited], - now: Date.parse("2026-11-17T10:00:00Z") }; +test("needsRetry asks CodeRabbit again 30 minutes after its review limit held back the head commit", () => { + const limited = (user, head) => ({ user: { login: user }, updated_at: "2026-11-17T09:00:00Z", + body: `\nbetween a1 and ${head}.` }); + const summary = { user: { login: "coderabbitai[bot]" }, updated_at: "2026-11-17T09:00:00Z", + body: "\nbetween a1 and b2." }; + const pr = { headSha: "b2", comments: [limited("coderabbitai[bot]", "b2")], now: Date.parse("2026-11-17T09:30:00Z") }; assert.equal(needsRetry(pr), true); - assert.equal(needsRetry({ ...pr, comments: [] }), true); - assert.equal(needsRetry({ ...pr, comments: [cubic] }), true); + assert.equal(needsRetry({ ...pr, now: Date.parse("2026-11-17T09:29:00Z") }), false); + assert.equal(needsRetry({ ...pr, headSha: "c3" }), false); assert.equal(needsRetry({ ...pr, comments: [summary] }), false); - assert.equal(needsRetry({ ...pr, comments: [summary], headDate: "2026-11-17T08:50:00Z" }), true); - assert.equal(needsRetry({ ...pr, now: Date.parse("2026-11-17T09:20:00Z") }), false); + assert.equal(needsRetry({ ...pr, comments: [limited("cubic-dev-ai[bot]", "b2")] }), false); + assert.equal(needsRetry({ ...pr, comments: [] }), false); }); diff --git a/.github/workflows/deep-review.yml b/.github/workflows/deep-review.yml index bacbbc4a..48e05ff2 100644 --- a/.github/workflows/deep-review.yml +++ b/.github/workflows/deep-review.yml @@ -1,12 +1,9 @@ name: Deep review -# Adds the deep-review label, which starts a CodeRabbit review, to a pull request that changes more -# than 400 lines or a file listed in .github/deep-review-paths. It never removes the label. A draft -# gets it once it's ready for review, since CodeRabbit skips drafts. Every hour it adds the label anew -# to a labeled pull request whose latest commit CodeRabbit left unreviewed because of its review -# limit, or never answered. pull_request_target runs the default branch's copy of this workflow and of -# .github/scripts, so a pull request never runs its own code here. The logic and its tests are in -# .github/scripts/deep-review.mjs. +# Adds the deep-review label, which starts a CodeRabbit review, and every hour asks CodeRabbit again +# where its review limit held a review back. pull_request_target runs the default branch's copy of +# this workflow and of .github/scripts, so a pull request never runs its own code here. The logic and +# its tests are in .github/scripts/deep-review.mjs. on: pull_request_target: types: [opened, reopened, synchronize, ready_for_review] @@ -64,12 +61,18 @@ jobs: script: | const { needsRetry } = await import(`${process.env.GITHUB_WORKSPACE}/.github/scripts/deep-review.mjs`); const { owner, repo } = context.repo; - const pulls = await github.paginate(github.rest.pulls.list, { owner, repo, state: "open", per_page: 100 }); + const pulls = await github.paginate(github.rest.pulls.list, { owner, repo, state: "open", sort: "created", direction: "asc", per_page: 100 }); + // CodeRabbit allows each pull request author two reviews an hour; the oldest go first. + const asked = new Map(); for (const pr of pulls.filter((pr) => !pr.draft && pr.labels.some((label) => label.name === "deep-review"))) { - const { data: head } = await github.rest.git.getCommit({ owner, repo, commit_sha: pr.head.sha }); + if (asked.get(pr.user.login) === 2) continue; const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number: pr.number, per_page: 100 }); - if (!needsRetry({ headDate: head.committer.date, updatedAt: pr.updated_at, comments, now: Date.now() })) continue; + if (!needsRetry({ headSha: pr.head.sha, comments, now: Date.now() })) continue; + asked.set(pr.user.login, (asked.get(pr.user.login) ?? 0) + 1); core.info(`Asking CodeRabbit again on #${pr.number}.`); - await github.rest.issues.removeLabel({ owner, repo, issue_number: pr.number, name: "deep-review" }); - await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: ["deep-review"] }); + try { + await github.rest.issues.removeLabel({ owner, repo, issue_number: pr.number, name: "deep-review" }); + } finally { + await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: ["deep-review"] }); + } } diff --git a/AGENTS.md b/AGENTS.md index 527933cd..3fdbc1c9 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -85,7 +85,7 @@ A configuration change rarely lives in one place. Before calling one done, say w - A `fix`, `feat` or `perf` pull request needs an issue. Before opening it, search with the `triage` skill. If an open issue covers the problem, link it. If none does, file one with `triage` (the request for the pull request covers filing it) and link that. If triage finds the problem already fixed or declined, tell the developer before going on. Other types, such as `ci`, `test`, `docs` or `chore`, can skip the issue. - Titles follow Conventional Commits in plain words, such as `fix: keep the clock visible on a notched display`. Every commit message is checked too, and the types of the commits that reach `main` decide the next release (see [Commits and releases](CONTRIBUTING.md#commits-and-releases)). - Fill in the [pull request template](.github/pull_request_template.md), and end the description with the model and harness that did the work. The `Description` check fails without that line, and `Linked issue` fails a `fix`, `feat` or `perf` pull request that closes no issue. -- cubic reviews every pull request, and CodeRabbit reviews those labeled `deep-review`. The label is added automatically when a pull request changes more than 400 lines or a file in [.github/deep-review-paths](.github/deep-review-paths); add it yourself when a change is risky, such as when cubic's review points out a risk. Answer each comment from either by fixing the code or replying why not, then resolve the thread: unresolved threads block merging. Don't post `@coderabbitai review`: each request uses up one of the pull request author's few CodeRabbit reviews per hour, and the Deep review workflow already asks CodeRabbit again every hour when its limit held a review back. +- cubic reviews every pull request, and CodeRabbit reviews those labeled `deep-review`. The label is added automatically when a pull request changes more than 400 lines or a file in [.github/deep-review-paths](.github/deep-review-paths); add it yourself, or ask a maintainer to, when a change is risky, such as when cubic's review points out a risk. Answer each comment from either by fixing the code or replying why not, then resolve the thread: unresolved threads block merging. Don't post `@coderabbitai review`: each request uses up one of the pull request author's few CodeRabbit reviews per hour, and the Deep review workflow already asks CodeRabbit again every hour when its limit held a review back. - Upload screenshots and recordings to the pull request; never commit them. The images in `docs/images` are the exception: they illustrate the README and the guide, and CI draws them (see [Docs images](CONTRIBUTING.md#docs-images)). - Keep to one problem per pull request. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c6ee6db5..1caab4d2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -90,7 +90,7 @@ There is no web view or custom drawing loop. Private macOS API, for hiding and r Reviews are requested automatically from the people listed in [CODEOWNERS](.github/CODEOWNERS), but they are not required. Ask for one when a change is risky or outside your usual area. -[cubic](https://cubic.dev) also reviews every pull request once it is out of draft. [CodeRabbit](https://coderabbit.ai) reviews pull requests labeled `deep-review`: the label is added automatically when a pull request changes more than 400 lines or a file listed in [.github/deep-review-paths](.github/deep-review-paths), and you can add it yourself when a change is risky. Fix each comment from either or reply why not, then resolve its thread: unresolved conversations block merging. Their rules come from [AGENTS.md](AGENTS.md), [cubic.yaml](cubic.yaml) and [.coderabbit.yaml](.coderabbit.yaml). CodeRabbit allows each pull request author only a few reviews per hour. When its limit holds a review back, the Deep review workflow asks it again every hour, so there's no need to ask with `@coderabbitai review`. +[cubic](https://cubic.dev) also reviews every pull request once it is out of draft. [CodeRabbit](https://coderabbit.ai) reviews pull requests labeled `deep-review`: the label is added automatically when a pull request changes more than 400 lines or a file listed in [.github/deep-review-paths](.github/deep-review-paths), and you can add it yourself, or ask a maintainer to, when a change is risky. Fix each comment from either or reply why not, then resolve its thread: unresolved conversations block merging. Their rules come from [AGENTS.md](AGENTS.md), [cubic.yaml](cubic.yaml) and [.coderabbit.yaml](.coderabbit.yaml). CodeRabbit allows each pull request author only a few reviews per hour. When its limit holds a review back, the Deep review workflow asks it again every hour, so there's no need to ask with `@coderabbitai review`. [DECISIONS.md](DECISIONS.md) lists the lasting decisions about releases, reviews and code. A pull request that sets a new rule or policy adds an entry there. From 9ad1ec5ec78a11112c4673d155f062b481e2abd2 Mon Sep 17 00:00:00 2001 From: Sebastien Graf <95282692+Seb-GRAF@users.noreply.github.com> Date: Tue, 17 Nov 2026 13:20:13 +0100 Subject: [PATCH 6/6] ci: label pull requests that change how package sources are fetched --- .github/deep-review-paths | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/deep-review-paths b/.github/deep-review-paths index ed6c0a4c..cf2d38fc 100644 --- a/.github/deep-review-paths +++ b/.github/deep-review-paths @@ -5,6 +5,7 @@ Sources/StableBar/ICloudSync*.swift Sources/StableBar/Uninstall*.swift Sources/StableBar/ConfigurationLoader.swift Sources/StableBar/PackageSecrets.swift +Sources/StableBar/PackageSourceFetching.swift Resources/Info.plist Resources/StableBar.entitlements .github/workflows/**