Skip to content

ci: keep Cargo.lock in sync through releases and build --locked (#242)#243

Open
beardthelion wants to merge 3 commits into
mainfrom
ci/242-lock-sync-release
Open

ci: keep Cargo.lock in sync through releases and build --locked (#242)#243
beardthelion wants to merge 3 commits into
mainfrom
ci/242-lock-sync-release

Conversation

@beardthelion

@beardthelion beardthelion commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

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:

  1. Sync Cargo.lock to the 0.6.0 manifests (cargo update --workspace). The diff is the five crate version fields plus a base64 dep edge for gl that the lock had also dropped. cargo metadata --locked passes after, fails exit 101 before.
  2. Build --locked in PR CI (clippy, test, release build, MSRV check, Windows test), so any future manifest/lock drift fails loudly at PR time instead of surfacing as mystery-dirty trees.
  3. A sync-release-lock job in release.yml: while a release PR is open, check out its branch (release-please's pr output, headBranchName), run cargo update --workspace, and push the lock bump onto the release branch. The release PR then carries its own lock sync, so the tagged tree is internally consistent and its --locked CI passes.

Two caveats, stated as such because a workflow change is only proven by its runs:

  • The sync job pushes with GITHUB_TOKEN. Release-please's own branch pushes do trigger pr-checks in this repo (chore(main): release 0.7.0 #240's head has a pull_request run), and the sync push uses the same mechanism, but the first release cycle after this merges is the real proof. If the sync commit fails to re-trigger checks on the release PR, the job needs an app or PAT token instead.
  • Merge order vs chore(main): release 0.7.0 #240: this branch syncs the lock to 0.6.0. If the 0.7.0 release merges first, I will rebase and re-run the sync so the committed lock matches 0.7.0 before this lands; merging this first is simpler (the sync job then fixes chore(main): release 0.7.0 #240's branch automatically on its next refresh, once release-please force-pushes it against the new main).

Summary by CodeRabbit

  • Chores
    • Improved build and test reliability by enforcing Cargo lockfile consistency across CI checks.
    • Added automated synchronization of the dependency lockfile during release preparation, committing it only when it changes.
    • Enhanced release and PR-check workflows to improve check-run attachment on release branches and added support for release pull request branch handling.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The release workflow synchronizes Cargo.lock on release PR branches and dispatches pull-request checks. Cargo CI commands now require the existing lockfile across formatting, tests, builds, MSRV, and Windows validation.

Changes

Cargo lock consistency

Layer / File(s) Summary
Release PR lock synchronization
.github/workflows/release.yml
Release automation exposes the release PR branch, runs cargo update --workspace, conditionally commits and pushes Cargo.lock, and dispatches pr-checks.
Locked Cargo CI gates
.github/workflows/pr-checks.yml
Formatting, testing, release builds, MSRV checks, and Windows tests invoke Cargo with --locked; the workflow also supports manual dispatch.

Estimated code review effort: 2 (Simple) | ~10 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
Loading

Possibly related PRs

  • Gitlawb/node#57 — Modified the Cargo commands and CI jobs now receiving --locked.
  • Gitlawb/node#129 — Added explicit crate versions for Release Please, which are synchronized into Cargo.lock.
  • Gitlawb/node#237 — Added the Windows test lane whose Cargo invocation now receives --locked.

Suggested labels: workflow-change

Suggested reviewers: kevincodex1

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the CI and release lockfile sync changes tied to #242.
Description check ✅ Passed The description covers the summary, motivation, changes, and verification, though it does not use the full template structure.
Linked Issues check ✅ Passed The workflow updates satisfy #242 by syncing Cargo.lock in release automation and enforcing --locked builds in CI.
Out of Scope Changes check ✅ Passed The changes stay focused on release-lock synchronization and locked CI builds with no clear unrelated churn.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/242-lock-sync-release

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Checkov (3.3.8)
.github/workflows/pr-checks.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'

.github/workflows/release.yml

Traceback (most recent call last):
File "/usr/local/bin/checkov", line 2, in
from checkov.main import Checkov
ModuleNotFoundError: No module named 'checkov'


Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between b484a24 and 42f1d8f.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • .github/workflows/pr-checks.yml
  • .github/workflows/release.yml

Comment thread .github/workflows/release.yml Outdated
@kevincodex1

Copy link
Copy Markdown
Contributor

hello bro @beardthelion please rebase to main and kindly address some coderabbit feedback

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 42f1d8f and b835d2f.

📒 Files selected for processing (2)
  • .github/workflows/pr-checks.yml
  • .github/workflows/release.yml

Comment on lines +151 to +154
if echo "$out" | grep -qi "does not have a workflow_dispatch trigger"; then
echo "release branch predates the dispatch trigger; checks attach after release-please next rebases it"
echo "$out"
exit 0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Do not allow a synchronized release branch to remain unchecked.

This accepted 422 leaves the current Cargo.lock commit without the required --locked validation. A dispatch uses the workflow at the requested ref, so a branch predating workflow_dispatch cannot self-validate until a later rewrite. Fail this path and use a GitHub App/PAT for release-please and lockfile pushes so the PR receives a synchronize check run immediately. (docs.github.com)

🤖 Prompt for 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.

In @.github/workflows/release.yml around lines 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.

@jatmn jatmn left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-merged v0.7.0 release and is now CONFLICTING/DIRTY with main. A three-way merge retains main's 0.7.0 manifests but applies this branch's Cargo.lock workspace records for 0.6.0; a full cargo metadata --locked on that merge result exits 101. Rebase onto current main and regenerate Cargo.lock for 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 new workflow_dispatch trigger. 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 --locked validation. 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 fresh pr output, the fallback chooses the first open PR whose branch name merely starts with release-please--. Any fork can open a lookalike branch; actions/checkout then 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:ci CI, release, or packaging pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Release automation ships a stale Cargo.lock: lock-sync the release PR and build --locked in CI

3 participants