From eebf56b650cf6b9a04ab205c270231c317b7255a Mon Sep 17 00:00:00 2001 From: Costas Kirgoussios Date: Sat, 21 Nov 2026 20:55:03 +0200 Subject: [PATCH] ci: keep Cargo.lock current on the release branch and check it release-please bumps each crate's Cargo.toml but looks for a lock file inside the package folder, so the workspace Cargo.lock at the root kept the old versions and the next cargo build rewrote a tracked file. The release-refresh job now runs cargo update --workspace, which sets the workspace crates' versions and moves no dependency, and commits Cargo.lock with the other derived files. CI and just check gain a --locked step that fails on a lock file that disagrees with the manifests; in just check it runs first, before any cargo command could rewrite the file. Co-Authored-By: Claude Fable 5.2 --- .github/workflows/ci.yml | 7 +++++++ .github/workflows/release-refresh.yml | 30 +++++++++++++++++++++++---- Justfile | 8 ++++++- docs/PLUGIN_GUIDELINES.md | 2 +- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 37a34ba..b50c6e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -120,6 +120,13 @@ jobs: - name: Cache dependencies uses: Swatinem/rust-cache@v2 + # A cargo build quietly rewrites a Cargo.lock that disagrees with the crate + # manifests, so a stale one fails nothing by itself. release-refresh.yml + # updates it on the release branch; this catches a crate version changed + # anywhere else without its lock entry. + - name: Check Cargo.lock matches the crate manifests + run: cargo metadata --locked --format-version 1 > /dev/null + # Confirms every binary named in a plugin's hooks.json / .mcp.json is a # [[bin]] target this workspace builds. Those are plain strings that no # compiler or test validates. diff --git a/.github/workflows/release-refresh.yml b/.github/workflows/release-refresh.yml index 0d384f7..456b938 100644 --- a/.github/workflows/release-refresh.yml +++ b/.github/workflows/release-refresh.yml @@ -8,7 +8,11 @@ name: Release Refresh # INSTALL.md, the Antigravity and Qwen READMEs). Without a refresh, every # release PR fails `gen-marketplaces.sh --check` and `check-install-pins.sh` # on its first CI run - red through no fault of the release content. -# Footprint documents no longer carry a version stamp, so they need no refresh. +# It also does not update the workspace Cargo.lock at the repository root (it +# looks for a lock file inside each package folder), so the lock file kept the +# old version of every crate a release bumped, and the next cargo build +# rewrote a tracked file. Footprint documents no longer carry a version stamp, +# so they need no refresh. # # This job runs both against the release branch and commits the # result back to it when it changes anything. It converges: the push @@ -63,6 +67,17 @@ jobs: continue-on-error: true run: bash scripts/check-install-pins.sh --write + # Sets the version of each workspace crate in Cargo.lock to the one its + # Cargo.toml now carries, and changes nothing else (no dependency moves). + # It needs the registry index, so it needs the network: --offline fails + # on a runner with an empty cargo home. continue-on-error for the same + # reason as the step above; CI's `--locked` step catches a lock file this + # could not update. + - name: Refresh Cargo.lock + id: lock + continue-on-error: true + run: cargo update --workspace + - name: Commit refresh env: # Passed through env, never spliced into the script text: head_ref is @@ -70,8 +85,8 @@ jobs: # standing between it and the shell. HEAD_REF: ${{ github.head_ref }} run: | - # Only the generated marketplace manifests and the install - # documents whose pins the step above rewrites. A release branch never + # Only the generated marketplace manifests, the install documents + # whose pins a step above rewrites, and Cargo.lock. A release branch never # carries hand-written changes, but an unrestricted `git add -A` # would commit them silently if it ever did - and a refresh commit # must never smuggle content into a release. @@ -82,7 +97,8 @@ jobs: .opencode-plugin/marketplace.json \ opencode/plugins/*/INSTALL.md \ antigravity/plugins/*/README.md \ - qwen/plugins/*/README.md + qwen/plugins/*/README.md \ + Cargo.lock if git diff --cached --quiet; then echo "Derived files already fresh; nothing to commit." else @@ -99,3 +115,9 @@ jobs: run: | echo "::error::The step 'Refresh install-document pins' failed: scripts/check-install-pins.sh --write found a problem that needs a hand edit. Its log lists each one." exit 1 + + - name: Fail when Cargo.lock could not be refreshed + if: steps.lock.outcome == 'failure' + run: | + echo "::error::The step 'Refresh Cargo.lock' failed: cargo update --workspace did not complete. Its log has the reason; re-run this workflow once it is resolved." + exit 1 diff --git a/Justfile b/Justfile index 3efa33d..c11f01c 100644 --- a/Justfile +++ b/Justfile @@ -391,9 +391,15 @@ site-preview: @echo 'Check: 1) 320 px and desktop widths; 2) light, dark and the theme toggle; 3) a sparse card (todov2 has three greyed tabs); 4) a Qwen card shows Not measured; 5) an OpenCode card shows the setup bar and resident 0 B; 6) every copy button, and the page with JavaScript disabled' python3 -m http.server --bind 127.0.0.1 --directory target/preview 8000 +# Check that Cargo.lock agrees with every crate's Cargo.toml. It runs first in `check`: any +# later cargo command would quietly rewrite a stale lock file and hide the problem. +# `cargo update --workspace` fixes it and changes no dependency. +lock: + cargo metadata --locked --format-version 1 > /dev/null + # Run all pre-flight checks (what CI and lefthook run; see ci.yml — `links` # is hook-only and `gen-* --check` + opencode suites run in CI but not here) -check: fmt lint test deny spellcheck links versions wiring marketplace qwen-marketplace agy-marketplace dispatch smoke footprint opencode-wiring bump-opencode-plugin-test rerun-runner-failures-test doc-paths-test doc-paths gate-wiring-test gate-wiring install-pins-test install-pins readme-coverage-test readme-coverage agy-wiring agy-validate footprint-budgets devtools-skills skills-bundles skills-release-wiring site-check +check: lock fmt lint test deny spellcheck links versions wiring marketplace qwen-marketplace agy-marketplace dispatch smoke footprint opencode-wiring bump-opencode-plugin-test rerun-runner-failures-test doc-paths-test doc-paths gate-wiring-test gate-wiring install-pins-test install-pins readme-coverage-test readme-coverage agy-wiring agy-validate footprint-budgets devtools-skills skills-bundles skills-release-wiring site-check # Build the example Claude Code plugin's binaries into its bin/ directory. # Windows developers run this locally; CI produces the other platforms. diff --git a/docs/PLUGIN_GUIDELINES.md b/docs/PLUGIN_GUIDELINES.md index 791db69..c0e90f3 100644 --- a/docs/PLUGIN_GUIDELINES.md +++ b/docs/PLUGIN_GUIDELINES.md @@ -87,7 +87,7 @@ Release tags are never pushed by hand; see `HACK.md`. | File | What to do | Generated | What fails if you skip it | |---|---|---|---| -| `Cargo.lock` | Run `cargo metadata --format-version 1 > /dev/null`; it adds the crate to `Cargo.lock`. Commit that change. | yes | Nothing: no build here passes `--locked`, so the next contributor's build rewrites it. | +| `Cargo.lock` | Run `cargo metadata --format-version 1 > /dev/null`; it adds the crate to `Cargo.lock`. Commit that change. On a release the release branch updates each crate's version in it for you. | yes | `just lock`, and the CI step "Check Cargo.lock matches the crate manifests". | | `scripts/check-package-versions.sh` | As in 3.1, and add the crate's `Cargo.toml` to the list of crates that must not inherit the workspace version. | no | Nothing: the list is hardcoded. | | `/.gitignore` | Claude Code and Antigravity: a file holding the line `/bin/`, with the leading slash, so that the binary sources inside the crate stay tracked; copy `claude-code/plugins/repo-tasks-mcp-cc/.gitignore`. The root `.gitignore` already covers the Qwen and OpenCode staging folders. | no | Nothing: a built binary shows as untracked. | | `Cargo.toml` release metadata | Copy the exemplar's `[package.metadata.release]`, which rewrites the version in the host manifest in the same commit as a crate version bump, and `[package.metadata.dist.binaries]`. | no | Nothing in this repository checks either. |