Skip to content

fix(anvil): restrict scoped doctests to library packages - #177

Open
Evgenii (Vaiz) wants to merge 6 commits into
mainfrom
u/vaiz/2026/09/11/anvil-doctest-repairs
Open

Evgenii (Vaiz) wants to merge 6 commits into
mainfrom
u/vaiz/2026/09/11/anvil-doctest-repairs

Conversation

@Vaiz

@Vaiz Evgenii (Vaiz) commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

🤖 Clawpilot here! Posted automatically by Clawpilot (an AI agent), not by a human. Please verify before acting.

What this changes

anvil-doc-test now filters explicit affected-package selections to workspace members with library targets. GitHub setup now builds the pinned cargo-binstall from source if its release action fails.

Details

  • Load locked Cargo metadata for explicit package selections and match exact workspace member IDs.
  • Keep library, proc-macro, rlib, dylib, cdylib, and staticlib targets with version-qualified package specs.
  • Skip all-binary selections. Reject malformed, unknown, version-mismatched, and non-workspace package selections.
  • Run doctests with all features and default features. Workspace-wide runs retain --workspace.
  • Gate three cargo-gamma-lib doctest bodies on the internals feature that exposes their imports.
  • Keep the cargo-binstall release action as the fast path. Build version 1.21.0 with --force after a release failure.
  • Regenerate owned recipes, GitHub setup, catalog checksums, and backend snapshots.

Effects

  • Binary-only affected packages no longer make scoped doctest runs fail.
  • Explicit selections add one cargo metadata --locked invocation before the two doctest runs.
  • Non-workspace dependencies cannot enter scoped doctest runs when Cargo metadata lists them in packages.
  • A failed cargo-binstall release download starts a slower source build instead of stopping setup.
  • The source fallback replaces an older cached cargo-binstall executable before continuing.
  • No public Rust API changes. The cargo-gamma-lib examples compile only when internals exposes their imports.

Copilot AI lite review requested due to automatic review settings September 11, 2026 18:25

Copilot AI 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.

🟢 Approval recommended

No unresolved blocking issues were identified in the final review.

Pull request overview

This PR restricts scoped Anvil doctest runs to packages with library targets while preserving feature coverage and workspace behavior.

Changes:

  • Add locked metadata filtering and validation.
  • Gate internal cargo-gamma-lib doctests.
  • Update recipes, tests, snapshots, documentation, and checksums.
File summaries
File Description
justfiles/anvil/checks/doc-test.just Adds scoped doctest filtering.
crates/cargo-gamma-lib/src/cfg/mod.rs Gates internal doctest examples.
crates/cargo-gamma-lib/src/cfg/features.rs Gates the internal API example.
crates/cargo-anvil/tests/snapshots/snapshots__local_only.snap Refreshes local output.
crates/cargo-anvil/tests/snapshots/snapshots__github_backend.snap Refreshes GitHub output.
crates/cargo-anvil/tests/snapshots/snapshots__ado_backend.snap Refreshes ADO output.
crates/cargo-anvil/tests/recipe_contracts.rs Adds recipe behavior coverage.
crates/cargo-anvil/templates/justfiles/anvil/checks/doc-test.just Updates the recipe source.
crates/cargo-anvil/docs/design/checks.md Documents updated doctest behavior.
.anvil.lock Updates generated checksums.
Review details
  • Files reviewed: 9/10 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@codecov-commenter

Codecov Comments Bot (codecov-commenter) commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.7%. Comparing base (924730a) to head (0b5a48d).

❌ 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    #177     +/-   ##
=======================================
+ Coverage   97.5%   97.7%   +0.1%     
=======================================
  Files        300     295      -5     
  Lines      69314   65121   -4193     
=======================================
- Hits       67647   63674   -3973     
+ Misses      1667    1447    -220     
Flag Coverage Δ
linux ?
linux-arm ?
scheduled ?
windows 97.7% <ø> (+<0.1%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sgalkin Sergey Galkin (sgalkin) 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.

The scoped doctest filtering correctly implements the PR intent and is safe to approve on code merits. Required Linux checks still need the cross-platform diagnostic assertion fixed and rerun before merge.

Copilot AI review requested due to automatic review settings September 14, 2026 14:03

Copilot AI 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.

🟢 Approval recommended

No unresolved review comments remain.

Review details
  • Files reviewed: 9/10 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 14, 2026 14:18

Copilot AI 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.

🟢 Approval recommended

No unresolved blocking issues were identified in the final review.

Review details
  • Files reviewed: 9/10 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 14, 2026 14:43

Copilot AI 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.

🔵 Needs a closer look

Restrict package lookup to workspace members before approval.

Review details

Suppressed comments (1)

crates/cargo-anvil/templates/justfiles/anvil/checks/doc-test.just:36

  • This should iterate only over workspace members before building the lookup. The repository's metadata fixture explicitly models packages that appear in packages but not workspace_members (recipe_contracts.rs:215-228); with the current loop, a stale or malformed --package external-dep@0.1.0 selection is accepted whenever that non-member has a library target and is passed to both doctest runs instead of being rejected as outside the affected workspace.
        foreach ($package in $metadata.packages) {
  • Files reviewed: 9/10 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 14, 2026 15:44

Copilot AI 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.

🟡 Changes recommended

The installer fallback introduces an additional behavior change and can fail when cached binaries already exist.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (1)

crates/cargo-anvil/templates/github/setup-action.yml:126

  • On a warm runner, this action restores ~/.cargo/bin/ before this step (the cache path is configured earlier in the same action), so a failed release install can leave an older cached cargo-binstall executable in place. The fallback invokes cargo install without replacing existing binaries; this repository's installer documents that cached binaries can make cargo install fail with binary already exists in destination (justfiles/anvil/tools.just:432-437). The intended release-failure fallback therefore can fail on the cache-hit path instead of recovering. Install with an overwrite mode or remove the stale executable before the source build.
        cargo install --locked --version 1.21.0 cargo-binstall
  • Files reviewed: 13/14 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread crates/cargo-anvil/templates/github/setup-action.yml Outdated
Evgenii (Vaiz) and others added 6 commits September 15, 2026 07:43
Extract the doctest repairs from #174 without installer changes.
Preserve locked metadata, exact package specs, both feature runs,
and recipe diagnostics. Gate gamma-lib examples on internals.

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>
The fake-Cargo contracts cover recipe diagnostics. Keep the real-Cargo case focused on the cross-platform exit behavior instead of pwsh's terminal-width-dependent rendering.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Fall back to building the same pinned cargo-binstall version when the immutable release action cannot download its binary. Keep the degraded path visible and regenerate the GitHub setup action, snapshot, and Anvil lock.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 15, 2026 06:59
@Vaiz
Evgenii (Vaiz) force-pushed the u/vaiz/2026/09/11/anvil-doctest-repairs branch from 0ac9f80 to 0b5a48d Compare September 15, 2026 06:59
@Vaiz

Copy link
Copy Markdown
Contributor Author

Addressed both suppressed Copilot findings in 0b5a48d.

  • Valid: anvil-doc-test built its lookup from every package in Cargo metadata. It now accepts only exact workspace_members IDs and rejects non-workspace selections.
  • Valid: the cargo-binstall source fallback could conflict with an older cached binary. It now installs with --force.

Copilot AI 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.

🔵 Needs a closer look

The GitHub setup behavior change needs to be removed or explicitly scoped and documented.

Review details

Suppressed comments (1)

crates/cargo-anvil/templates/github/setup-action.yml:116

  • This changes the generated GitHub setup behavior by making the release install non-fatal and adding a source-build fallback, but the PR description explicitly says installer behavior and workflow setup remain unchanged while the title scopes this change to doctest selection. Please either remove this unrelated fallback and its generated/docs changes, or update the PR description/scope so this behavior change is intentional and reviewable separately.
      id: cargo-binstall
      continue-on-error: true
      uses: cargo-bins/cargo-binstall@v1.21.0 # pinned by tag: this release is an immutable release (GitHub locks the tag to a commit)
      with:
        version: "1.21.0"
  • Files reviewed: 13/14 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants