Skip to content

feat(cargo-each): add target-aware selection - #153

Open
martin-kolinek wants to merge 37 commits into
mainfrom
cargo-each-target-selection
Open

feat(cargo-each): add target-aware selection#153
martin-kolinek wants to merge 37 commits into
mainfrom
cargo-each-target-selection

Conversation

@martin-kolinek

@martin-kolinek martin-kolinek commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

🤖 Extends cargo-each with Cargo-metadata-aware selection needed by more workspace recipes.

  • adds publishable, feature:, and target-kind: package predicates
  • adds a repeatable --filter-any OR group combined with existing AND filters
  • adds per-target execution via --each-target, --target-required-feature, and {target}
  • preserves deterministic ordering, empty-set success, --chdir, and --keep-going semantics

Depends on #151 so Anvil doctests exclude intentionally bin-only packages.

martin-kolinek and others added 4 commits September 3, 2026 10:20
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>
Copilot AI lite review requested due to automatic review settings September 3, 2026 08:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

There are a few concrete issues to address (a doc comment typo and a now-misleading error type name), plus the README update should be confirmed as generated per repository policy.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR extends cargo-each’s selection/execution pipeline to be more Cargo-metadata-aware, adding richer package predicates, an optional OR-group for filters, and a new per-target execution mode with {target} substitution. This supports more workspace automation recipes while preserving deterministic ordering and “empty set is success” behavior.

Changes:

  • Added package predicates backed by cargo metadata (e.g., publishable, feature:<name>, target-kind:<kind>) and introduced --filter-any as an OR-group combined with existing --filter AND semantics.
  • Introduced per-target execution via --each-target, --target-required-feature, and {target} placeholder substitution, with validation/error handling for invalid target kinds and placeholder misuse.
  • Updated docs and end-to-end CLI tests to cover the new filter grammar and per-target mode behavior.
File summaries
File Description
crates/cargo-each/tests/cli.rs Expands the fixture workspace and adds new end-to-end tests for --filter-any, richer predicates, and per-target mode.
crates/cargo-each/src/workspace.rs Extends workspace member facts gathered from cargo_metadata (publishable/features/targets) and target-kind normalization/validation helpers.
crates/cargo-each/src/substitute.rs Adds {target} placeholder support and mode-aware placeholder validation for per-target execution.
crates/cargo-each/src/select.rs Updates test helpers to account for new Member fields used by selection/filter logic.
crates/cargo-each/src/run.rs Implements --filter-any semantics, per-target mode selection, and target-kind parsing/validation.
crates/cargo-each/src/plan.rs Adds Mode::PerTarget planning: target filtering, {target} substitution, and per-target invocation construction.
crates/cargo-each/src/main.rs Updates crate-level docs to describe new predicates, --filter-any, and per-target execution mode/placeholders.
crates/cargo-each/src/filter.rs Extends predicate parsing/matching to include target-kind, publishable, and feature:<name>.
crates/cargo-each/src/error.rs Adds InvalidTargetKindError and updates --chdir/--once error messaging to reflect per-target support.
crates/cargo-each/src/cli.rs Adds CLI flags for --filter-any, --each-target, and --target-required-feature with clap-level validation.
crates/cargo-each/README.md Updates user-facing README text to reflect new filter grammar and per-target mode.
crates/cargo-each/docs/design/README.md Updates the design contract to include per-target mode, new predicate set, and --filter-any semantics.
Review details
  • Files reviewed: 12/12 changed files
  • Comments generated: 3
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/cargo-each/README.md
Comment thread crates/cargo-each/src/error.rs Outdated
Comment thread crates/cargo-each/src/run.rs Outdated
@codecov-commenter

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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.6%. Comparing base (cad5174) to head (5e7ecbb).

❌ 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    #153    +/-   ##
======================================
  Coverage   97.6%   97.6%            
======================================
  Files        298     298            
  Lines      67348   67471   +123     
======================================
+ Hits       65763   65886   +123     
  Misses      1585    1585            
Flag Coverage Δ
linux 97.6% <100.0%> (?)
linux-arm 97.6% <100.0%> (?)
windows 97.8% <100.0%> (?)

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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 3, 2026 08:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are cohesive, well-tested (unit + E2E), and the remaining feedback is limited to minor help-text/error-message clarity improvements.

Review details

Suppressed comments (2)

Previously missed (2) — in code that hasn't changed since the last review.

crates/cargo-each/src/cli.rs:29

  • long_about still says "filter it by a metadata predicate", but the tool now supports broader package/target predicates and per-target mode; aligning the help text with the updated terminology will reduce confusion in --help output.
    crates/cargo-each/src/run.rs:97
  • All predicate parse failures are currently wrapped with the same context string ("invalid filter predicate"), even for --filter-any and --exclude-filter. Including the flag name in the context makes CLI errors more actionable when multiple predicate sources are present.
  • Files reviewed: 12/12 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 3, 2026 09:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are coherent and well-tested, with only a minor maintainability nit (duplicate supported-kind spelling list) called out in review comments.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

crates/cargo-each/src/filter.rs:71

  • target-kind: predicate parsing hard-codes the supported-target-kind list here, while the same list is also embedded in InvalidTargetKindError’s Display. Keeping these strings in sync is easy to miss; consider reusing InvalidTargetKindError to generate the reason instead of duplicating the list.
  • Files reviewed: 12/12 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@martin-kolinek
martin-kolinek changed the base branch from main to cargo-each-in-anvil September 3, 2026 09:12
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@martin-kolinek
martin-kolinek changed the base branch from cargo-each-in-anvil to main September 3, 2026 09:14
martin-kolinek and others added 3 commits September 3, 2026 11:14
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	.anvil.lock
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	.anvil.lock
Copilot AI review requested due to automatic review settings September 3, 2026 10:29
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It introduces new cargo-each execution/filter semantics and rewires many Anvil checks/templates around a new selector-cache format, which is broad and cross-cutting enough to warrant final human review.

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

martin-kolinek and others added 2 commits September 3, 2026 12:46
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	.anvil.lock
Copilot AI review requested due to automatic review settings September 3, 2026 10:47
martin-kolinek and others added 2 commits September 3, 2026 15:37
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 3, 2026 13:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes consistently apply the new selector/token contract across cargo-each, Anvil recipes/templates, and accompanying tests/docs without leaving obvious behavioral gaps in the updated surfaces.

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

martin-kolinek and others added 2 commits September 3, 2026 16:09
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

# Conflicts:
#	.anvil.lock
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings September 3, 2026 14:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes appear consistent across cargo-each, Anvil recipes, and the updated contract tests/docs, with no concrete correctness issues found in the reviewed diffs.

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

martin-kolinek and others added 2 commits September 3, 2026 16:22
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 3, 2026 14:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It introduces new selection/execution semantics in cargo-each and rewires a large set of Anvil recipes, so it warrants final human review for end-to-end behavioral consistency across workflows.

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

Comment thread crates/cargo-anvil/templates/justfiles/anvil/checks/msrv-test.just
Comment thread justfiles/anvil/impact.just
martin-kolinek and others added 2 commits September 3, 2026 16:45
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 3, 2026 14:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes core selection/execution semantics in cargo-each and rewires a large set of Anvil CI recipes, so a final human review is warranted despite only minor concrete issues found.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

crates/cargo-each/src/workspace.rs:129

  • MemberTarget sorting is intended to make per-target execution deterministic, but the current comparator only orders by name and kinds. Since MemberTarget also carries required_features, leaving it out means two targets that tie on name/kinds could end up with an order that depends on the upstream cargo_metadata iteration order rather than on a fully deterministic key. Including required_features as a final tie-breaker makes the ordering total over the captured target facts.
  • Files reviewed: 78/79 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Comment thread crates/cargo-each/src/run.rs
Comment thread crates/cargo-anvil/templates/justfiles/anvil/checks/doc-test.just
martin-kolinek and others added 3 commits September 3, 2026 17:32
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>
Copilot AI review requested due to automatic review settings September 3, 2026 15:33

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are well-covered by updated tests/docs and the only remaining feedback is a minor per-target log-label disambiguation improvement.

Review details

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

crates/cargo-each/src/plan.rs:143

  • In per-target mode the progress label is based only on {package}::{target_name}. Cargo packages can have multiple targets with the same name across different kinds (e.g., a lib target and the default bin target often share the package name), so this can produce duplicate labels and make logs/debugging ambiguous when multiple kinds are selected.
  • Files reviewed: 78/79 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.

3 participants