Skip to content

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

Merged
martin-kolinek merged 53 commits into
mainfrom
cargo-each-target-selection
Sep 11, 2026
Merged

feat(cargo-each): add target-aware selection#153
martin-kolinek merged 53 commits into
mainfrom
cargo-each-target-selection

Conversation

@martin-kolinek

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

Copy link
Copy Markdown
Collaborator

🤖 Releases cargo-each 0.2.0 with Cargo-metadata-aware selection and target iteration.

  • adds publishable, feature:<name>, and target-kind:<kind> package predicates
  • adds Boolean filter expressions with not, and, or, parentheses, and conventional precedence
  • keeps repeated --filter expressions AND-combined and repeated --exclude-filter expressions OR-combined
  • adds per-target execution via --each-target, --target-required-feature, and {target}
  • makes relative child executable lookup honor inherited PATH order on Windows
  • preserves deterministic ordering, empty-set success, --chdir, and --keep-going semantics

This change is independent of the cargo-anvil adoption in #151.

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
Contributor

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 (26e5c60) to head (3b010fd).
⚠️ Report is 9 commits behind head on main.

❌ 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.5%   97.6%            
======================================
  Files        300     300            
  Lines      68538   69314   +776     
======================================
+ Hits       66876   67652   +776     
  Misses      1662    1662            
Flag Coverage Δ
linux 97.5% <100.0%> (+<0.1%) ⬆️
linux-arm 97.5% <100.0%> (+<0.1%) ⬆️
scheduled ?
windows 97.7% <100.0%> (+<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.

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
Contributor

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
Contributor

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
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

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

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

It includes a crate version/lockfile bump that appears to conflict with the repo’s “separate release PR” convention and needs to be separated or explicitly confirmed as intended.

Review details

Suppressed comments (1)

crates/cargo-each/Cargo.toml:7

  • This PR bumps cargo-each’s crate version to 0.2.0. Repo guidance is to keep version bumps in dedicated release PRs (so feature PRs don’t mix behavior changes with release bookkeeping). If this isn’t meant to be the release PR, please revert the version/lockfile bump and do it in a separate release-only PR.
version = "0.2.0"
  • Files reviewed: 13/14 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Exercise exact diagnostics and the nesting limit so coverage and mutation gates detect parser regressions.

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

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

The new filter/execution semantics, docs, and tests appear consistent with each other, and the changes are covered by focused unit and end-to-end tests in the touched areas.

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

Copilot AI review requested due to automatic review settings September 8, 2026 15:46

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 design doc’s quoting guidance for metadata:<key>=<value> doesn’t fully match the implemented tokenizer behavior (metadata values containing whitespace also need quoting in compound expressions).

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

Review details
  • Files reviewed: 13/14 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread crates/cargo-each/docs/design/README.md
Keep parser decisions mutation-tested while excluding backward cursor mutations that can only time out.

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

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 filter expression parser’s “all-atoms” fast-path can be adjusted to preserve space-in-value support while producing more helpful diagnostics for invalid multi-token inputs.

Review details

Suppressed comments (1)

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

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

  • The all(Token::Atom) fast-path is important for supporting atomic predicates whose values contain spaces (e.g. metadata:role=script only). However, when Predicate::parse_atom(self.spec.trim()) fails (e.g. lib bin), the current early-return produces a less specific "unknown predicate" error instead of the parser's more helpful unexpected-token diagnostics. Consider attempting parse_atom first and, on failure, falling back to the full expression parser so multi-token invalid inputs get better error messages without losing the space-in-value behavior.
  • Files reviewed: 13/14 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 8, 2026 16:11

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 crate version bump to 0.2.0 appears to be a release change but does not follow the documented release flow (including generating/updating the crate CHANGELOG via scripts/release-crate.ps1).

Review details

Suppressed comments (1)

crates/cargo-each/Cargo.toml:8

  • This PR bumps cargo-each to 0.2.0, but the repository’s documented release flow expects version bumps to be done via scripts/release-crate.ps1, which also generates the crate’s CHANGELOG.md, and then submitted as a dedicated release PR after the releasable changes are already on the branch (root README.md:68-85, 98-99). In this PR the crate changelog is still empty (crates/cargo-each/CHANGELOG.md), so either drop the version bump from this feature PR or run the release script and include the generated changelog updates (and any other release artifacts) here.
name = "cargo-each"
description = "A cargo subcommand that runs a command over a cargo-style selection of workspace members"
version = "0.2.0"
readme = "README.md"
  • Files reviewed: 13/14 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

Comment thread crates/cargo-each/docs/design/README.md
Comment thread crates/cargo-each/src/filter.rs
Document per-target execution in the overview and represent lib/bin filters through the shared target-kind predicate.

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

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 crate version bump to 0.2.0 appears to be a release-oriented change but the corresponding release artifacts/process (notably the crate CHANGELOG update expected by the documented flow) are not included, so the intent needs to be clarified and made consistent.

Review details

Suppressed comments (1)

crates/cargo-each/Cargo.toml:7

  • cargo-each is bumped to 0.2.0 here, but the repo’s documented publishing flow expects version bumps to be produced by ./scripts/release-crate.ps1 <crate_name> [new_version], which also updates the crate CHANGELOG.md (README.md “Publishing Crates”, steps 3–4). This PR updates Cargo.toml/Cargo.lock but doesn’t update crates/cargo-each/CHANGELOG.md, so it’s unclear whether this is meant to be a feature PR or a release PR.

Consider either (a) reverting the version/lock bumps and doing a separate release PR via release-crate.ps1, or (b) running release-crate.ps1 cargo-each 0.2.0 and committing the resulting changelog + lock updates so the release is self-contained.

version = "0.2.0"
  • Files reviewed: 13/14 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@martin-kolinek
martin-kolinek merged commit 91d2c99 into main Sep 11, 2026
29 checks passed
@martin-kolinek
martin-kolinek deleted the cargo-each-target-selection branch September 11, 2026 11:49
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