Repository navigation
fix(ci): build api-gate detector from base tip when merge base predates it - #3193
Conversation
…es it The API Review Gate builds cmd/api-gate from the PR's merge-base checkout so a PR cannot neuter the detector by editing its own code. When the merge base predates the commit that introduced the gate, cmd/api-gate is absent from both the merge base and the equally old head, so the head fallback also fails to build and the required check errors out before evaluating any API content. This blocks every open PR whose merge base is older than the gate, and neither a re-run nor an approving review clears it. Add the base branch tip as an intermediate build source: prefer the merge-base checkout, fall back to the base tip when the merge base lacks the tool, and bootstrap from head only while the tool exists nowhere on the base branch yet. The base tip is a protected branch, not PR-authored, so it preserves the "analyze head as data, not code" property. The API surface is still diffed against the merge base; only where the detector binary is compiled changes. This unblocks the backlog without forcing every affected PR to rebase. The selection stays inline in the workflow rather than in a helper script: a helper would be read from the untrusted PR head, which both reintroduces the failure for heads that predate the helper and lets a PR steer the selection away from the trusted build. Assisted-By: Claude <[email protected]> Signed-off-by: Aleksei Sviridkin <[email protected]>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe "Build api-gate" step in the CI workflow was updated to add an intermediate fallback: when ChangesAPI Review Gate build fallback
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant Workflow as CI Workflow
participant MergeBase as Merge-base Worktree
participant BaseTip as Base-tip Worktree
participant Head as PR Head Workspace
Workflow->>MergeBase: Check for cmd/api-gate
alt exists in merge-base
MergeBase-->>Workflow: Build api-gate here
else absent in merge-base
Workflow->>BaseTip: Create detached worktree, check for cmd/api-gate
alt exists on origin/BASE_REF
BaseTip-->>Workflow: Build api-gate here
else absent on origin/BASE_REF
Workflow->>Head: Bootstrap build from head
Head-->>Workflow: Build api-gate here
end
end
Suggested labels: ci, github-actions Suggested reviewers: cozystack maintainers familiar with CI workflows ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Note Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported. |
What this PR does
The
API Review Gaterequired check builds thecmd/api-gatedetector from the PR's merge-base checkout so a PR cannot neuter the detector by editing its own code. When a PR's merge base predates the commit that introduced the gate (fa871249c),cmd/api-gateis absent from both the merge base and the equally old head, so the head fallback also fails to build and the check errors out before evaluating any API content. This red-blocks every open PR whose merge base is older than the gate, and neither a re-run nor an approving review clears it.This adds the base branch tip (
origin/<base>) as an intermediate build source: prefer the merge-base checkout, fall back to the base tip when the merge base lacks the tool, and bootstrap from the head only while the tool exists nowhere on the base branch yet. The base tip is a protected, non-PR-authored branch, so it preserves the "analyze the head as data, not code" property. The API surface is still diffed against the merge base; only where the detector binary is compiled changes. This unblocks the pre-gate backlog without forcing every affected PR to rebase.The selection is kept inline in the workflow rather than in a helper script: a helper would be read from the untrusted PR head, which both reintroduces the failure for heads that predate the helper and lets a PR steer the selection away from the trusted build.
Closes #3192
Screenshots
N/A — CI-only change, no user-facing UI.
Release note
Summary by CodeRabbit