fix(cargo-anvil): propagate impact scope failures - #189
martinhavelka (wukchung) wants to merge 4 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: de5be740-9c27-4201-9ca8-19180fed8871
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: de5be740-9c27-4201-9ca8-19180fed8871
|
…e contract The scoped-check propagation test never exercised the recipe: its fixture omitted anvil-fmt's dependency recipes, so just failed to load the justfile and the test passed with the propagation guard removed. Give the fixture the full dependency set and assert the resolver's own cache-missing error reaches stderr, so the test fails when the guard is dropped. Also scan every resolver call site per check file rather than the first, and document the exit-code contract where the resolver's output is specified. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 71082801-1485-4f7a-a732-6331e761e6bb
There was a problem hiding this comment.
🟡 Changes recommended
The byte-exact local, GitHub, and ADO snapshots still contain the pre-change recipe bodies.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
This PR makes impact-scoped Anvil checks fail when scope resolution fails instead of silently widening to workspace scope.
Changes:
- Propagates
_anvil-impact-includeexit codes across all scoped checks. - Adds structural and runtime regression coverage.
- Updates documentation and generated artifact checksums.
File summaries
| File | Description |
|---|---|
justfiles/anvil/... |
Generated scoped-check guards |
crates/cargo-anvil/templates/justfiles/anvil/... |
Canonical recipe/template guards |
crates/cargo-anvil/tests/recipe_contracts.rs |
Runtime regression test |
crates/cargo-anvil/src/anvil/artifacts/justfile.rs |
Template contract test |
crates/cargo-anvil/docs/design/checks.md |
Documents failure propagation |
.anvil.lock |
Updates generated artifact checksums |
Review details
- Files reviewed: 45/46 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| # Those three values are only meaningful when the resolver succeeded, so every | ||
| # caller captures its exit code and propagates it before reading `$include`: | ||
| # | ||
| # $impactExit = $LASTEXITCODE | ||
| # if ($impactExit -ne 0) { exit $impactExit } |
The propagation guard and the helpers.just contract note change generated content, so the full-tree snapshots no longer matched. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 71082801-1485-4f7a-a732-6331e761e6bb
There was a problem hiding this comment.
🟢 Approval recommended
All 21 scoped resolver call sites are guarded, with synchronized templates, generated outputs, snapshots, and regression coverage.
Review details
- Files reviewed: 48/49 changed files
- Comments generated: 0 new
- Review effort level: Lite
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 #189 +/- ##
=====================================
Coverage 97.6% 97.6%
=====================================
Files 304 304
Lines 69671 69683 +12
=====================================
+ Hits 68005 68021 +16
+ Misses 1666 1662 -4
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:
|
🤖 A scoped check resolves its package scope by calling
_anvil-impact-include <tier>. That resolver can fail: a missing cache underANVIL_IMPACT=consume, an unreadable include file, an unrecognizedANVIL_IMPACTvalue.$ErrorActionPreference = 'Stop'does not fail a recipe on a native command's nonzero exit, so the failure was swallowed,$includestayed empty, and the check silently widened to its unscoped default and passed. That is the same silent-widening failureanvil-impactalready refuses in consume mode, so reading the cache it asserts should refuse it too.Changes
msrv-testalready usedanvil-fmtbefore cargo runshelpers.justandchecks.md, and refresh the full-tree snapshots the generated-content change invalidatedValidation
cargo test -p cargo-anvil— 494 lib tests and all integration suites passjust anvil-pr-fast— passfmt.just,scoped_check_propagates_missing_consumed_impact_cachefails; with it restored, it passesThe runtime test originally asserted nothing: its fixture omitted
anvil-fmt's dependency recipes, sojustfailed to load the justfile and the recipe never ran, leaving the test green with the guard removed. It now supplies the full dependency set and asserts the resolver's own cache-missing error reaches stderr, which only the in-recipe propagation path can produce.