fix(anvil): scope doctests to library packages and authenticate tool installation - #174
fix(anvil): scope doctests to library packages and authenticate tool installation#174Evgenii (Vaiz) wants to merge 1 commit into
Conversation
…installation anvil-doc-test passed its affected --package selection straight to cargo test --doc, so a binary-only package in that selection failed the run. The recipe now filters the selection to packages with a library target, keeping every library kind including proc-macro, keeping version-qualified specs, and keeping both the all-feature and default-feature runs. An all-binary selection skips visibly; unknown packages and metadata failures stay hard errors with a recipe-specific diagnostic. The metadata probe uses --locked, matching the two doctest runs it feeds. Tool installation discovered releases anonymously and hit GitHub API rate limits, falling back to a slow source build. The GitHub setup steps and the impact action's cargo-delta install now pass the built-in GITHUB_TOKEN. The credential stays out of third-party builds: it is removed from the environment before any source install, and binstall's compile strategy is disabled whenever it is set, so a release miss falls through to a tokenless cargo install. Token scopes remain the caller's decision; the generated implementation declares none of its own. Three cargo-gamma-lib doctests import cargo_gamma_lib::internals, which is gated behind the feature that exposes it, so they could never compile in the default-features run. Their bodies are now gated on that feature and still assert for real under --all-features. The generated-artifact contract for the binstall compile strategy asserted a bare "if ($sourcePrereq)", which an unrelated later block in the same file also satisfies. It now pins the guard together with the body it controls, and was verified to fail when that guard is weakened. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🔵 Needs a closer look
The changes span CI behavior, authentication, generated artifacts, tests, and documentation, so final human review is warranted.
Pull request overview
This pull request repairs Anvil CI doctest scoping, authenticates GitHub tool installation, and synchronizes generated artifacts and documentation.
Changes:
- Filters doctests to library-capable packages and gates feature-dependent examples.
- Authenticates tool installation while keeping tokens out of source builds.
- Updates contracts, snapshots, templates, actions, documentation, and checksums.
File summaries
| File | Summary |
|---|---|
justfiles/anvil/tools.just |
Adds token-aware tool installation. |
justfiles/anvil/checks/doc-test.just |
Filters doctest selections to library targets. |
crates/cargo-gamma-lib/src/cfg/mod.rs |
Gates internal-only doctest bodies. |
crates/cargo-gamma-lib/src/cfg/features.rs |
Gates the internal API doctest. |
crates/cargo-anvil/tests/snapshots/snapshots__local_only.snap |
Refreshes local generated output. |
crates/cargo-anvil/tests/snapshots/snapshots__github_backend.snap |
Refreshes GitHub generated output. |
crates/cargo-anvil/tests/snapshots/snapshots__ado_backend.snap |
Refreshes ADO generated output. |
crates/cargo-anvil/tests/recipe_contracts.rs |
Adds doctest and installation regression coverage. |
crates/cargo-anvil/templates/justfiles/anvil/tools.just |
Updates the installer template. |
crates/cargo-anvil/templates/justfiles/anvil/checks/doc-test.just |
Updates the doctest template. |
crates/cargo-anvil/templates/github/setup-action.yml |
Updates authenticated setup actions. |
crates/cargo-anvil/templates/github/impact-action.yml |
Updates authenticated impact installation. |
crates/cargo-anvil/src/anvil/artifacts/justfile.rs |
Strengthens installer guard contracts. |
crates/cargo-anvil/src/anvil/artifacts/github.rs |
Strengthens generated action assertions. |
crates/cargo-anvil/docs/design/README.md |
Documents token handling and installation policy. |
crates/cargo-anvil/docs/design/local.md |
Documents local installer behavior. |
crates/cargo-anvil/docs/design/github.md |
Documents GitHub token usage. |
crates/cargo-anvil/docs/design/checks.md |
Documents doctest package filtering. |
.github/actions/anvil-setup/action.yml |
Applies authenticated tool setup. |
.github/actions/anvil-impact/action.yml |
Applies authenticated cargo-delta installation. |
.anvil.lock |
Updates generated artifact checksums. |
Review details
- Files reviewed: 20/21 changed files
- Comments generated: 0
- Review effort level: Lite
💡 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 #174 +/- ##
======================================
Coverage 97.5% 97.6%
======================================
Files 300 300
Lines 69048 69314 +266
======================================
+ Hits 67387 67651 +264
- Misses 1661 1663 +2
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:
|
🤖 Clawpilot here! Posted automatically by Clawpilot (an AI agent), not by a human. Please verify before acting.
Replaces #172. That PR was opened for a
cargo-eachWindowsPATHfix that #153 landed independently while it was in review, and its branch predated #153, so its diff against currentmainhad turned into a revert of that work. This is the remaining, genuinely unique half: the Anvil CI repairs, rebuilt from scratch on top of currentmainso the history is clean. Thecargo-eachchange is gone entirely —mainowns that behaviour and already has a regression test for it.Scoped doctests skipped no packages
anvil-doc-testpassed its affected--packageselection straight tocargo test --doc, so a binary-only package in that selection failed the run — which is what happened tocargo-eachitself, across four platforms.The recipe now filters the selection to packages with a library target. It keeps every library kind including proc-macro, keeps version-qualified specs, and keeps both the
--all-featuresand default-features runs. An all-binary selection now skips visibly. Unknown packages and metadata failures stay hard errors, with a recipe-specific diagnostic matching the convention its five sibling metadata consumers already use. The metadata probe is--locked, like the two doctest runs it feeds, so the check cannot quietly repair the lockfile it exists to enforce.Tool installation was unauthenticated
The Linux ARM fast-checks job hit anonymous GitHub release-API 403s and fell back to a slow source build, which then failed on a missing system dependency.
The GitHub setup steps and the impact action's
cargo-deltainstall now pass the built-inGITHUB_TOKEN, so release discovery is authenticated. The credential is kept out of third-party builds: it is removed from the environment before any source install, and binstall's compile strategy is disabled whenever it is set, so a release miss falls through to a tokenlesscargo install. Token scopes remain the caller's decision — the generated implementation declares none of its own, which the existing zero-permissions:contract continues to assert.Three
cargo-gamma-libdoctests only ever compiled with--all-featuresThey import
cargo_gamma_lib::internals, which is gated behind the feature that exposes it, so the recipe's default-features pass could not compile them. This was pre-existing and simply unreachable while the recipe was dying earlier on binary-only packages. The doctest bodies are now gated on that feature, and still compile and assert for real under--all-features.One contract was passing for the wrong reason
justfile.rsasserted that the generatedtools.justcontainsif ($sourcePrereq), under the name "compile strategy must only be disabled for tools with source prerequisites". The token work makes that guardif ($sourcePrereq -or $releaseToken), yet the assertion kept passing — an unrelated later block in the same file also matches that literal. It now pins the guard together with the body it controls, and was verified by weakening the guard and watching it fail.Validation
Clippy on
cargo-anvil,cargo-eachandcargo-gamma-libwith--all-targets --all-features --locked -D warnings; the fullcargo-anvillib suite (491 tests);recipe_contracts(51 tests, which run realjust); regeneration with a clean--dry-run; refreshed snapshots;just anvil-fmtandjust anvil-spellcheck.