ci: keep Cargo.lock in sync through releases and build --locked (#242) - #243
ci: keep Cargo.lock in sync through releases and build --locked (#242)#243beardthelion wants to merge 5 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe release workflow synchronizes ChangesCargo lock consistency
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ReleasePlease
participant SyncReleaseLock
participant Cargo
participant Git
participant PRChecks
ReleasePlease->>SyncReleaseLock: provide release PR branch
SyncReleaseLock->>Cargo: run cargo update --workspace
Cargo-->>SyncReleaseLock: update Cargo.lock
SyncReleaseLock->>Git: commit and push changed Cargo.lock
SyncReleaseLock->>PRChecks: dispatch checks on release branch
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/release.yml:
- Around line 67-70: Update the “Checkout release branch” step to authenticate
with a GitHub App or PAT credential instead of the default GITHUB_TOKEN,
ensuring the later lockfile git push triggers the PR and release-check
workflows. Preserve the existing release-branch ref and checkout action
configuration, and use the repository’s established secret or credential symbol.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 949615b0-4515-4819-b295-6614b973ca86
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
.github/workflows/pr-checks.yml.github/workflows/release.yml
|
hello bro @beardthelion please rebase to main and kindly address some coderabbit feedback |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/release.yml:
- Around line 151-154: Update the workflow-dispatch error handling in the
release-please validation flow to fail when the target release branch lacks a
workflow_dispatch trigger instead of exiting successfully. Configure the
release-please and lockfile-push authentication to use a GitHub App or PAT,
ensuring branch updates emit an immediate synchronize check run and the current
Cargo.lock commit receives --locked validation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 1c7ae8c7-f787-4e6a-a94f-4ffd78fc0e73
📒 Files selected for processing (2)
.github/workflows/pr-checks.yml.github/workflows/release.yml
jatmn
left a comment
There was a problem hiding this comment.
I found issues that need to be addressed before this is ready.
Findings
-
[P2] Rebase and regenerate the lockfile from the current release state
.release-please-manifest.json:2
This is stale-base drift rather than an intentional rollback: the branch forked before the already-mergedv0.7.0release and is nowCONFLICTING/DIRTYwithmain. A three-way merge retains main's0.7.0manifests but applies this branch'sCargo.lockworkspace records for0.6.0; a fullcargo metadata --lockedon that merge result exits 101. Rebase onto currentmainand regenerateCargo.lockfor the current manifests before this can be merged. -
[P1] Fail when the release branch cannot dispatch PR checks
.github/workflows/release.yml:151
A release PR created before this change does not contain the newworkflow_dispatchtrigger. After this job synchronizes and pushes its lockfile, dispatching against that branch returns this exact 422; exiting 0 marks the job successful while the release head has no--lockedvalidation. A later release-please rewrite is not guaranteed for an unchanged open release PR, so this is precisely the checkless branch the workflow is intended to prevent. Let the 422 fail (or otherwise ensure the branch is updated and checked). This also leaves the current CodeRabbit request to fail this error unaddressed. -
[P1] Restrict fallback discovery to the repository-owned release PR
.github/workflows/release.yml:93
When release-please does not return a freshproutput, the fallback chooses the first open PR whose branch name merely starts withrelease-please--. Any fork can open a lookalike branch;actions/checkoutthen cannot resolve that fork-only ref in this repository (or can target an unrelated same-named ref), causing the write-token sync/dispatch job to fail and leaving the real release PR stale and unchecked. Filter by same head repository/owner and the expected release-please PR metadata, and select it deterministically.
…till get validated
The branch forked before v0.7.0 merged, so the rebase left main's 0.7.0 manifests against workspace lock records still at 0.6.0. That state fails the gate this PR adds: `cargo metadata --locked` exits 101 with "cannot update the lock file because --locked was passed". Regenerated with `cargo update --workspace`, the same command the new sync-release-lock job runs. Only the 5 workspace crates move 0.6.0 -> 0.7.0; all 252 external dependencies are unchanged, so this is a version resync and not a dependency bump. `cargo metadata --locked` now exits 0.
…-PR discovery Two review findings on the sync-release-lock job. Fail on every dispatch failure. The step tolerated the 422 a release branch cut before pr-checks gained its workflow_dispatch trigger returns, on the theory that release-please would rewrite the branch and heal it. A rewrite only happens when a later releasable commit lands, so an open release PR nobody touches is never rewritten, and the tolerated path left the lock-sync commit this job had just pushed on the release head with no --locked validation. That is the exact state the job exists to prevent. No release PR is open today, and after this lands every release branch is cut from a main that already carries the trigger, so the tolerance protects nothing. Scope the fallback discovery. `gh pr list` includes fork PRs and a fork's headRefName is bare, so matching on the `release-please--` prefix alone let any fork nominate the branch this job checks out, commits to, and dispatches on: actions/checkout then cannot resolve that fork-only ref here, failing the job and leaving the real release PR unsynced and unchecked. Discovery now requires the head repo to be this repository and the author to be the release-please app, and selects the highest PR number instead of relying on gh's undocumented default ordering. Verified the new filter against the hostile inputs, using the jq program as extracted from the parsed YAML: a fork lookalike, a fork PR claiming the app author, and a same-repo human branch named `release-please--*` are all rejected; the real release PR is still selected when listed after a fork and when a second component release PR is present; an empty listing yields empty. The previous expression selected the fork's branch on all three hostile cases.
b835d2f to
5091f2d
Compare
|
All three findings were real. Rebased onto current main and pushed; the branch is now 0 behind. [P2] Rebase and regenerate the lockfile ("a full Reproduced exactly. On the rebased tree, main's Regenerated with The only rebase conflict was [P1] Fail when the release branch cannot dispatch PR checks Agreed, and the tolerance is gone rather than narrowed. Your reasoning is the part I had wrong: I assumed release-please would rewrite the branch and heal it, but a rewrite only happens when a later releasable commit lands, so an open release PR nobody touches is never healed, and the tolerated path left the lock-sync commit the job had just pushed sitting on the release head with no Two things make removing it clean rather than risky. There is no open release-please PR right now, so nothing is stranded by the stricter behavior (round one observed #240 in exactly that state; it has since merged). And once this lands, every release branch is cut from a main that already carries the trigger, so the 422 has no remaining source. The step is now a bare [P1] Restrict fallback discovery to the repository-owned release PR Confirmed, including that it is exploitable and not just untidy. Driving the old expression against hostile listings, it selects the attacker's branch in every case: Discovery now requires the head repo to be this repository and the author to be the release-please app, and selects I tested the new filter using the jq program extracted from the parsed YAML, so it is the text CI will actually run, across 11 cases. Rejected: a fork lookalike, a fork PR claiming On the PAT half of CodeRabbit's request, which I am declining as a design call rather than a verified claim: Two limits worth stating. shellcheck is not installed on my box, so actionlint's shellcheck-backed checks on the edited |
jatmn
left a comment
There was a problem hiding this comment.
Thanks for addressing the earlier review. I do not see any actionable issues on the current head.
Prior review
All three items from my CHANGES_REQUESTED review are fixed here:
Cargo.lockis regenerated for the0.7.0manifests (cargo metadata --lockedexits 0 on head).- Dispatch failures are no longer tolerated; the 422 tolerance is gone.
- Fallback release-PR discovery is scoped to same-repo
app/github-actionsbranches with deterministicmax_by(.number)selection.
What I verified
Cargo.lockworkspace records match the five release-please crates at0.7.0, including the restoredgl→base64edge.--lockedis on the five PR cargo gates this PR claims: clippy, test, release build, MSRV, and Windows.sync-release-lock+workflow_dispatchdispatch wiring is structurally sound;ubuntu-latestships Rust, so the sync job can runcargo update --workspacewithout a missing-toolchain failure.- PR Checks, CodeQL, and CodeRabbit are green on
5091f2dba0f6957d6d9eb456e5f4270a0cc045e9.
Optional follow-ups (non-blocking)
These are consistency polish, not merge blockers for #242:
- [P3] Pin
dtolnay/rust-toolchaininsync-release-lockbeforecargo update --workspaceso the bot uses the same toolchain aspr-checks, rather than whatever Rust the runner image happens to ship. - [P3] Extend
--lockedtorelease-binaries,Dockerfile, anddocker-buildin a follow-up if you want belt-and-suspenders at the shipping boundary; this PR's fix is the release-PR lock sync plus dispatched--lockedvalidation, which is sufficient for the stated goal. - [P3] Update the stale comment in
scripts/check-gitlawb-core-deps.shthat says build/test resolve without--locked; that gate intentionally avoids--locked, and the new blocking cargo jobs already catch lock staleness.
Closes #242.
Every release-please PR bumps the workspace crate versions in the Cargo.tomls but never touches Cargo.lock, so each release merge ships a tag whose lockfile disagrees with its manifests. Verified on current main: all five workspace crates sit at 0.5.1 in the lock against 0.6.0 manifests, and cargo metadata --locked exits 101. Because CI never built --locked, the drift stayed green while release binaries were built from a resolver-fresh dependency set instead of the committed lock, and local builds kept dirtying the lock for contributors.
Three parts:
Two caveats, stated as such because a workflow change is only proven by its runs:
Summary by CodeRabbit
Cargo.lockwith manifest version bumps and committing it only when it changes.