fix(cargo-anvil): stop anvil-msrv-test from executing benchmarks - #150
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
The repo still ships stale “immutable release” comment text and outdated MSRV/all-targets documentation in other committed/generated files, so regeneration and doc consistency fixes are needed before merge.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adjusts cargo-anvil’s generated MSRV testing recipe so it no longer executes benchmark targets (switching from cargo test --all-targets to cargo test --tests), and rewords “immutable release” action-pin comments to accurately describe GitHub’s immutable-releases mechanism rather than implying tags are inherently unmovable.
Changes:
- Update the
anvil-msrv-testrecipe template (and emitted snapshots) to usecargo test --testsfor both feature configurations, avoiding bench execution. - Strengthen the
impact.rscontract test to assert MSRV invocations don’t include--all-targets/--benches. - Reword tag-pin comments for immutable-release actions across GitHub templates and design docs; update user-facing docs (rustdoc/README/design docs) accordingly.
File summaries
| File | Description |
|---|---|
| crates/cargo-anvil/templates/justfiles/anvil/checks/msrv-test.just | Switch MSRV test selection to --tests and document rationale in-template. |
| crates/cargo-anvil/tests/impact.rs | Update expected MSRV argv and add regression assertions against bench selection. |
| crates/cargo-anvil/tests/snapshots/snapshots__local_only.snap | Re-record emitted local-only snapshot reflecting --tests MSRV invocation and comments. |
| crates/cargo-anvil/tests/snapshots/snapshots__github_backend.snap | Re-record GitHub-backend snapshot with updated MSRV recipe and action-pin comment wording. |
| crates/cargo-anvil/tests/snapshots/snapshots__ado_backend.snap | Re-record ADO-backend snapshot with updated MSRV recipe and comments. |
| crates/cargo-anvil/templates/github/setup-action.yml | Reword immutable-release pin comment for cargo-binstall in the setup action template. |
| crates/cargo-anvil/templates/github/pr-impl-workflow.yml | Reword immutable-release pin comments in PR workflow template (sticky-comment + Codecov). |
| crates/cargo-anvil/templates/github/scheduled-impl-workflow.yml | Reword immutable-release pin comment for Codecov in scheduled workflow template. |
| crates/cargo-anvil/docs/design/checks.md | Update MSRV check design contract to describe cargo test --tests and why. |
| crates/cargo-anvil/docs/design/github.md | Clarify the tag pinning rationale/comment wording and immutable-release mechanism. |
| crates/cargo-anvil/src/lib.rs | Update rustdoc table text to reflect new MSRV-test target scope. |
| crates/cargo-anvil/README.md | Update generated README table text to match rustdoc/behavior description. |
Review details
- Files reviewed: 16/17 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (97.6%) is below the target coverage (100.0%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #150 +/- ##
=======================================
- Coverage 97.6% 97.6% -0.1%
=======================================
Files 298 298
Lines 67202 67202
=======================================
- Hits 65618 65617 -1
- Misses 1584 1585 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟢 Approval recommended
The changes are internally consistent across templates/generated outputs/tests/docs and add a regression guard for the corrected MSRV invocation behavior.
Review details
- Files reviewed: 16/17 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
🟢 Approval recommended
The changes are narrowly scoped, keep behavior aligned with the stated MSRV policy, and add a regression-preventing contract assertion while updating generated artifacts consistently.
Review details
- Files reviewed: 22/23 changed files
- Comments generated: 0 new
- Review effort level: Lite
There was a problem hiding this comment.
🟢 Approval recommended
The changes directly address the stated CI failure mode, update the contract tests/docs/snapshots consistently, and appear low-risk while improving correctness and documentation clarity.
Review details
- Files reviewed: 22/23 changed files
- Comments generated: 0 new
- Review effort level: Lite
`anvil-msrv-test` ran `cargo test --all-targets`. That flag expands to
`--lib --bins --tests --benches --examples`, so the recipe built AND
EXECUTED every bench target as part of the minimum-version check.
A bench declared `harness = false` delegates its run to a separate driver
binary -- criterion's, or a profiler runner such as `gungraun-runner`
driving Valgrind. `anvil-msrv-test-setup` installs only `cargo-delta` and
the MSRV toolchain, so that driver is never present and the group fails on
a prerequisite it does not declare:
--> Error in ae_basic_operations_cg: Failed to run benchmarks:
No such file or directory (os error 2).
Is gungraun-runner installed and gungraun-runner in your $PATH?
error: recipe `anvil-msrv-test` failed with exit code 1
That failure carries no minimum-version signal. An MSRV check exists to
prove the affected packages still compile and their tests still pass under
the declared minimum compiler; running benchmark harnesses is not part of
that, and it breaks the check for any adopter with a `harness = false`
bench. Observed on microsoft/oxidizer#718 (linux and linux-arm legs).
Use `--tests` instead. Chosen over the literally-equivalent
`--lib --bins --tests` because `--lib` errors with "no library targets
found" on a bin-only affected package under impact scoping -- the same
reason `anvil-miri` already selects `--tests`, documented in `miri.just`.
`--tests` selects exactly the targets carrying `test = true`: lib unit
tests, bin unit tests and integration tests.
A compile-only `--all-targets --no-run` pass was considered and rejected.
Benches and examples are dev-only targets that no consumer compiles, so
they do not constrain the crate's real MSRV, and the repository already
covers "do they still build" without running them: `anvil-bench` is
`cargo bench --no-run` and `anvil-examples` is `cargo build --examples`.
Adding the pass would double MSRV build time on the PR critical path for
a signal already owned elsewhere. This change makes `msrv-test` consistent
with that existing repository-wide policy.
No doctest coverage is lost: `--all-targets` suppresses doctests as well,
and `anvil-doc-test` owns them.
`msrv-test.just` was the only template with `cargo test --all-targets`.
`clippy.just` and `udeps.just` also pass `--all-targets`, but to `cargo
clippy` and `cargo udeps`, which compile without executing; both are left
as they are. `anvil-llvm-cov` and the other nextest paths are untouched.
The `impact.rs` contract test pinned the old argv; it now pins the new one
and additionally asserts that neither `--all-targets` nor `--benches` ever
reaches the MSRV invocations, so a regression fails loudly rather than
silently re-enabling bench execution.
Design doc, README and the mirrored lib.rs table updated to match; the
three emitted-tree snapshots re-recorded and reviewed.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The generated workflows carried this comment at every tag-pinned action:
uses: codecov/codecov-action@v7.0.0 # immutable release, the tag cannot be moved
The claim is true for these specific pins -- GitHub's immutable-releases
feature does lock the tag to a commit, and the REST API reports
`"immutable": true` for each of them. But the sentence asserts a property
of the TAG, and read on its own it looks like a general claim that Git
tags are stable, which is false and is exactly the belief SHA-pinning
exists to defend against.
Read that way it is also self-undermining: if tags could not be moved,
the SHA pins on `actions/checkout` and `actions/download-artifact` in the
same file would be pointless. On microsoft/oxidizer#718 this produced four
separate automated-reviewer findings that a human had to rebut one at a
time.
Reword to name the mechanism the pin depends on instead:
# pinned by tag: this release is an immutable release (GitHub locks the tag to a commit)
Same length class, one line, and it no longer generalises: it says why
THIS pin is safe rather than what tags are. Applied to all five sites --
`cargo-bins/cargo-binstall` in setup-action.yml, `codecov/codecov-action`
in both pr- and scheduled-impl-workflow.yml, and both
`marocchino/sticky-pull-request-comment` uses in pr-impl-workflow.yml.
`docs/design/github.md` reproduces both the comment and a sample step, so
both copies are updated to keep the doc and the templates from drifting,
plus a sentence recording why the comment names a mechanism rather than
asserting tag stability. The "Action pinning" section already explained
that immutability is per-release and must be re-confirmed on a version
bump; added one sentence stating that `actions/checkout` and
`actions/download-artifact` stay SHA-pinned because immutable releases are
opt-in per publisher and theirs have not enabled it -- not because those
actions are less trusted.
Behaviour is unchanged: comments only, same action versions.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
ox-tools consumes its own cargo-anvil templates, so the two preceding
template changes leave the checked-in generated files stale and
`regenerate-check` fails with:
Repository anvil state is out of date.
Run 'cargo run -p cargo-anvil -- anvil' and commit the diff.
Regenerated with `cargo run -p cargo-anvil -- anvil`. The diff is exactly
the emitted counterpart of the two template edits, nothing else:
- justfiles/anvil/checks/msrv-test.just
`cargo test --all-targets` -> `--tests`, plus the rationale comment.
This repository's own MSRV check therefore stops building and running
bench targets too.
- .github/actions/anvil-setup/action.yml
cargo-binstall pin comment.
- .github/workflows/anvil-pr-impl.yml
codecov and both sticky-pull-request-comment pin comments.
- .github/workflows/anvil-scheduled-impl.yml
codecov pin comment.
`.anvil.lock` records the new catalog checksum and the four file
checksums. No other emitted file changed (84 unchanged).
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Three follow-ups from review.
1. The rationale comment in `msrv-test.just` was 22 lines. That text is
emitted verbatim into every adopter's `justfiles/`, where nobody is
looking for a design essay. Cut to 5 lines, each carrying a fact a
reader of the generated recipe needs; the full reasoning already lives
in `docs/design/checks.md`, which is where it belongs.
2. Dropped two paragraphs added to `docs/design/github.md` in the previous
commit. Both restated what the surrounding text already said.
3. The pin-comment reword had only covered the anvil templates. The
repository's own hand-maintained CI carried the same overstated wording
on actions the templates never emit, so `# immutable release, the tag
cannot be moved` still shipped from here. Updated all six:
- .github/workflows/main.yml (sticky-pull-request-comment x2, codecov)
- .github/workflows/codeql.yml (codeql-action init and analyze)
- .github/actions/setup/action.yml (taiki-e/install-action)
Every tag-pinned action in the repository now carries the new comment;
SHA-pinned actions keep their `# vX.Y.Z` version comment.
Also finished the `--all-targets` documentation sweep the first commit
missed. These still described the MSRV check as running all targets, which
would have reintroduced the bench-execution pitfall for anyone following
the docs:
- docs/design/ado.md, the `pr_msrv` stage
- docs/design/local.md, `anvil-msrv-test` (it explicitly listed
"examples, and benches as test targets")
- docs/design/local.md and docs/design/README.md, the no-tooling
fallback snippet, which told a cargo-only user to run
`cargo test --workspace --all-targets` -- the exact command that
executes bench harnesses. Now `--tests`, which also restores the
claim that the snippet matches the recipe bodies.
Templates, generated output and `.anvil.lock` regenerated; snapshots
re-recorded. No `cargo test --all-targets` remains anywhere in the repo.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`_anvil-readme` was failing on every leg with "The documentation in your source code has changed" for cargo-anvil. The README body was already in sync with the rustdoc in `src/lib.rs` -- the stale part was the `[__cargo_doc2readme_dependencies_info]` fingerprint, which encodes a hash of the doc comments doc2readme generated the link table from. The rustdoc edits in the earlier commits changed that hash without changing any rendered text, so a by-eye comparison of the two sides looked clean while `cargo doc2readme --check` still rejected it. Regenerated with `just package=cargo-anvil readme`; the only resulting change is the fingerprint line. `cargo run -p cargo-anvil -- anvil` reports all 88 generated items unchanged, so no other artifact drifted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rebasing onto main conflicted on `catalog_checksum` alone -- both sides rewrote that one line and git cannot merge a hash. main has since added a catalog item (the plan is now 92 items, up from 91), so neither side's value was correct on the new base. Resolved by regenerating rather than picking a side: `cargo run -p cargo-anvil -- anvil` recomputes the checksum from the merged catalog. It reports the other 89 generated items unchanged, so the emitted workflows, actions and justfiles this branch touches survived the rebase intact and only the lock needed updating. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
f7e75d9 to
946afed
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The MSRV recipe’s new cargo test --tests usage appears to exclude unit tests (running only “test targets”), which weakens MSRV coverage and conflicts with the intended behavior described in the PR and docs.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 22/23 changed files
- Comments generated: 1
- Review effort level: Lite
🤖 Clawpilot here! Posted automatically by Clawpilot (an AI agent), not by a human. Please verify before acting.
Two upstream fixes found while adopting cargo-anvil 0.6.0 in microsoft/oxidizer#718. Anvil defects get fixed here rather than worked around downstream, so nothing in oxidizer changes.
1.
anvil-msrv-testexecuted benchmark harnessesThe generated recipe ran
cargo test --all-targets, which expands to--lib --bins --tests --benches --examples— socargo testbuilt and executed every bench target.A bench declared
harness = falsedelegates its run to a separate driver binary (criterion's, or a profiler runner such asgungraun-runnerdriving Valgrind).anvil-msrv-test-setupinstalls onlycargo-deltaand the MSRV toolchain, so that driver is never present:An MSRV check exists to prove the affected packages still compile and their tests still pass under the declared minimum compiler. Executing benchmark harnesses is not part of that signal, it silently requires profiler prerequisites the group never declares, and it breaks the check for any adopter with a
harness = falsebench.Fix: use
--tests, which selects exactly the targets carryingtest = true— lib unit tests, bin unit tests and integration tests.--testsis preferred over the equivalent--lib --bins --testsbecause--liberrors with "no library targets found" on a bin-only affected package under impact scoping — the same reasonanvil-mirialready selects--tests, documented inmiri.just.A compile-only
--all-targets --no-runpass was considered and rejected: benches and examples are dev-only targets no consumer compiles, so they do not constrain the crate's real MSRV, and the repository already covers "do they still build" without running them —anvil-benchiscargo bench --no-run,anvil-examplesiscargo build --examples. This change makesmsrv-testconsistent with that existing policy rather than the sole exception to it.No doctest coverage is lost:
--all-targetssuppresses doctests too, andanvil-doc-testowns them.msrv-test.justwas the only template withcargo test --all-targets.clippy.justandudeps.justalso pass--all-targets, but tocargo clippyandcargo udeps, which compile without executing — both left unchanged.anvil-llvm-covand the nextest paths are untouched.The
impact.rscontract test now additionally asserts that neither--all-targetsnor--benchesreaches the MSRV invocations, so this cannot silently regress.2. Action pin comments overstated what they know
Generated workflows carried:
The claim is true for these specific pins — GitHub's immutable-releases feature does lock the tag to a commit, and the REST API reports
"immutable": truefor each. But as written it asserts a property of the tag, which reads as a general and false claim that Git tags are stable. Read that way it is also self-undermining: if tags could not be moved, the SHA pins onactions/checkoutandactions/download-artifactin the same file would be pointless. On microsoft/oxidizer#718 this produced four separate automated-reviewer findings a human had to rebut one at a time.Reworded to name the mechanism the pin depends on:
Applied at all five sites.
docs/design/github.mdreproduces both the comment and a sample step, so both copies are updated to prevent drift. That section already explained that immutability is per-release and must be re-confirmed on a version bump; added one sentence recording thatactions/checkoutandactions/download-artifactstay SHA-pinned because immutable releases are opt-in per publisher and theirs have not enabled it — not because those actions are less trusted.Behaviour unchanged for this half: comments only, same action versions.
Validation
Toolchain 1.97 (repo
rust-toolchain.toml), scoped tocargo-anvil:cargo fmt --check,cargo clippy --all-targets --all-features -D warnings, andcargo test --all-features(486 passed) all green. The three emitted-tree snapshots were re-recorded withcargo instaand reviewed; they contain only the intended changes.No version bump or CHANGELOG entry: this repo generates the CHANGELOG at release time from conventional-commit messages via separate
chore(cargo-anvil): bump to Xcommits.