fix(cargo-anvil): make stable toolchains deterministic - #109
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. ❌ Your project status has failed because the head coverage (97.7%) 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 #109 +/- ##
=====================================
Coverage 97.7% 97.7%
=====================================
Files 286 286
Lines 62438 62441 +3
=====================================
+ Hits 61009 61015 +6
+ Misses 1429 1426 -3
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:
|
Add a conditional Linux PR check when a selecting toolchain file differs from the workspace MSRV, with support for mapped internal toolchains. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Run affected-package tests under every declared root MSRV across the same GitHub and ADO platform matrices as ordinary PR tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Validate resolver diagnostics across stdout and stderr so the regression tests behave consistently across host PowerShell implementations. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collapse PowerShell line wrapping before asserting resolver errors so the tests are portable across host terminal widths. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assert stable resolver diagnostic fragments independently so PowerShell continuation markers do not make the tests host-dependent. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove the globally exported resolved toolchain and route stable commands through private Just helpers. Keep explicit nightly and MSRV selection at each command site, and preserve current-checkout toolchain selection for impact baselines. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Reject incomplete internal mappings, accept member MSRVs satisfied by the root floor, and cover public and mapped MSRV provisioning branches. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Install the Just bootstrap before invoking private resolver recipes in GitHub Actions, preserving recipe-based selection without assuming Just is preinstalled on hosted runners. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Accept PowerShell's platform-specific diagnostic wrapping while still asserting every actionable part of the mapped-toolchain error. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7996e6f-5c20-4d7a-b2f7-690af95e557e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7996e6f-5c20-4d7a-b2f7-690af95e557e
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 93 out of 94 changed files in this pull request and generated 2 comments.
Suppressed comments (2)
Previously missed (1) — in code that hasn't changed since the last review.
justfiles/anvil/tools.just:483
_check-toolrunscargo {{_anvil_stable_toolchain_args}} install --listduring validate-prereqs. When the stable selector falls back to+<MSRV>, this can cause rustup to auto-install the MSRV toolchain (or fail in a confusing way) just to list installed cargo tools, which makes validation non-read-only and hides the intended "install stable toolchain" guidance.
justfiles/anvil/tools.just:254
Test-ToolchainInstalleddoesn't recognize installed stable-version toolchains when rustup normalizes them to include a patch (e.g.1.95.0-x86_64-...). The current regex only matches^<toolchain>(-|$), so1.95will not match1.95.0-..., causing false "not installed" errors and redundant install attempts.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7996e6f-5c20-4d7a-b2f7-690af95e557e
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 93 out of 94 changed files in this pull request and generated 1 comment.
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
justfiles/anvil/tools.just:272
cargo metadatawrites JSON to stdout and warnings/errors to stderr. Capturing2>&1into$metadataTextcan corrupt the JSON even whencargo metadatasucceeds with warnings, causingConvertFrom-Jsonto throw a misleading parse error. Capture stdout only for the success path, and only merge stderr when re-running for diagnostics on failure.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7996e6f-5c20-4d7a-b2f7-690af95e557e
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7996e6f-5c20-4d7a-b2f7-690af95e557e
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 93 out of 94 changed files in this pull request and generated no new comments.
Suppressed comments (4)
Previously missed (2) — in code that hasn't changed since the last review.
justfiles/anvil/tools.just:271
cargo metadataoutput is captured with2>&1and then piped toConvertFrom-Json. Any warning text written to stderr (even when the command succeeds) will corrupt the JSON and make MSRV compatibility validation fail non-deterministically.
This issue also appears on line 489 of the same file.
crates/cargo-anvil/templates/justfiles/anvil/tools.just:271
cargo metadataoutput is captured with2>&1and then piped toConvertFrom-Json. Any warning text written to stderr (even when the command succeeds) will corrupt the JSON and make MSRV compatibility validation fail non-deterministically.
This issue also appears on line 489 of the same file.
justfiles/anvil/tools.just:491
- If
cargo install --listfails (for example becauseRUSTUP_AUTO_INSTALL=0prevents auto-provisioning of the selected toolchain), this code silently treats the tool as missing and prints an incorrect install hint. It should fail with a message that the selected stable toolchain/cargo invocation is unavailable.
crates/cargo-anvil/templates/justfiles/anvil/tools.just:491 - If
cargo install --listfails (for example becauseRUSTUP_AUTO_INSTALL=0prevents auto-provisioning of the selected toolchain), this code silently treats the tool as missing and prints an incorrect install hint. It should fail with a message that the selected stable toolchain/cargo invocation is unavailable.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 93 out of 94 changed files in this pull request and generated no new comments.
Suppressed comments (4)
Previously missed (2) — in code that hasn't changed since the last review.
justfiles/anvil/tools.just:633
- When the stable selection is provided via RUSTUP_TOOLCHAIN or a repository rust-toolchain(.toml), this branch runs
rustup component add <component>without--toolchain.rustup component addtargets rustup's default toolchain, not the toolchain selected by RUSTUP_TOOLCHAIN or by a toolchain file, so clippy/rustfmt/etc. can be installed onto the wrong toolchain and the subsequentcargo clippy/cargo fmtchecks can still fail.
This issue also appears on line 715 of the same file.
crates/cargo-anvil/templates/justfiles/anvil/tools.just:633
- When the stable selection is provided via RUSTUP_TOOLCHAIN or a repository rust-toolchain(.toml), this branch runs
rustup component add <component>without--toolchain.rustup component addtargets rustup's default toolchain, not the toolchain selected by RUSTUP_TOOLCHAIN or by a toolchain file, so clippy/rustfmt/etc. can be installed onto the wrong toolchain and the subsequentcargo clippy/cargo fmtchecks can still fail.
This issue also appears on line 715 of the same file.
justfiles/anvil/tools.just:719
- The remediation hint for missing components suggests
rustup component add <component>for thedefaulttoolchain when the stable selection comes from RUSTUP_TOOLCHAIN or a repository rust-toolchain(.toml). That command installs onto rustup's default toolchain, which may not be the toolchain Anvil is actually using, so the suggested fix can be ineffective.
crates/cargo-anvil/templates/justfiles/anvil/tools.just:719 - The remediation hint for missing components suggests
rustup component add <component>for thedefaulttoolchain when the stable selection comes from RUSTUP_TOOLCHAIN or a repository rust-toolchain(.toml). That command installs onto rustup's default toolchain, which may not be the toolchain Anvil is actually using, so the suggested fix can be ineffective.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7996e6f-5c20-4d7a-b2f7-690af95e557e
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 93 out of 94 changed files in this pull request and generated no new comments.
Suppressed comments (2)
justfiles/anvil/tools.just:254
- Test-ToolchainInstalled() only matches toolchain list entries that are exactly '-' or '' at the start of the line. For MSRV values like "1.95" (this repo uses rust-version = "1.95"), rustup typically lists the installed toolchain as "1.95.0-", so this check will incorrectly report the toolchain as not installed and can break validate-workspace-msrv / re-run installs repeatedly. Consider also matching a dot after the requested prefix so "1.95" matches "1.95.0-…".
crates/cargo-anvil/templates/justfiles/anvil/tools.just:254 - Same as the emitted justfile: Test-ToolchainInstalled() only matches '-' or '' at line start. For MSRV values like "1.95" rustup typically lists the installed toolchain as "1.95.0-", so this check can incorrectly report the MSRV toolchain as missing and break validate-workspace-msrv / repeat installs. Match a dot as well so "1.95" matches "1.95.0-…".
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f7996e6f-5c20-4d7a-b2f7-690af95e557e
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 93 out of 94 changed files in this pull request and generated 2 comments.
Suppressed comments (1)
justfiles/anvil/tools.just:695
- In
_check-component, whentoolchain="default"and stable selection resolves to an explicit MSRV (via_anvil_stable_toolchain_args), failures in therustc ... --print sysrootprobe reporttoolchain 'default' not installedand suggestrustup toolchain install default, which is not actionable ("default" isn't a rustup toolchain name).
🤖 Fixes runner-dependent stable Rust selection in cargo-anvil and adds explicit MSRV testing.
What changed
RUSTUP_TOOLCHAIN, then a selecting rootrust-toolchain/rust-toolchain.toml, then the root MSRVANVIL_MSRV_TOOLCHAINAdopter migration
Ambient runner stable is no longer accepted. Adopters must provide one of:
[workspace.package].rust-versionor[package].rust-versionshared by every workspace packagerust-toolchainorrust-toolchain.tomlRUSTUP_TOOLCHAINWorkspaces with missing or heterogeneous package MSRVs cannot use MSRV fallback and must select a catalog toolchain explicitly. Internal builds can override public selection with
RUSTUP_TOOLCHAINand map the public MSRV test run to a provisioned compiler withANVIL_MSRV_TOOLCHAIN.Motivation
Oxidizer PR #698 passed the legacy Rust 1.96.1 job but failed Anvil on a Windows ARM runner that had inherited Rust 1.98.0 and its new Clippy lints. Stable checks should not change behavior based on runner image rollout timing.
Coverage executes the ordinary test suite on the catalog nightly. The dedicated
pr-msrvgroup runs in parallel and ensures that the same affected unit and integration tests continue to compile and pass on the minimum supported compiler across every supported host configuration.