Skip to content

Commit 5a7337a

Browse files
committed
crgo-rail: feat: added 'exclude' to the features pruning; updated cfg in rail.toml; upgraded the 'msrv' detection, resolution w/ cfg in rail.toml && added strict testing; fixed the 'quiche' issue where target-triples aren't defined in any TOML, but instead are in '.github/workflows' in yaml/yml files - validated against CF's quiche repo. add cargo-args output format
1 parent e4b0f4a commit 5a7337a

File tree

18 files changed

+1004
-47
lines changed

18 files changed

+1004
-47
lines changed

Cargo.lock

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ exclude = ["docs/", "tests/", ".github/", ".config/", "examples/"]
2222
clap = { version = "4.5.53", features = ["derive", "cargo"] }
2323
cargo_metadata = "0.23.1"
2424
petgraph = "0.8.3"
25-
toml_edit = { version = "0.23.7", features = ["serde"] }
25+
toml_edit = { version = "0.23.9", features = ["serde"] }
2626
serde = { version = "1.0.228", features = ["derive"] }
2727
serde_json = "1.0.145"
2828
semver = "1.0.27"

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,11 @@ cargo-rail takes a different approach:
9595
Graph-aware. Only test what's affected by your changes:
9696

9797
```bash
98-
cargo rail affected # Show affected crates
98+
cargo rail affected # Show affected crates
9999
cargo rail affected -f names-only # Just names (for scripting)
100-
cargo rail test # Run tests for affected crates only
101-
cargo rail test --all # Override: test everything
100+
cargo rail affected -f cargo-args # -p crate1 -p crate2 (for cargo commands)
101+
cargo rail test # Run tests for affected crates only
102+
cargo rail test --all # Override: test everything
102103
```
103104

104105
**For CI:** Use [`cargo-rail-action`](https://github.com/loadingalias/cargo-rail-action):

docs/commands.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Options:
6464
- text: Human-readable text output (default)
6565
- json: Machine-readable JSON output
6666
- names-only: Names only, one per line
67+
- cargo-args: Cargo -p flag format: -p crate1 -p crate2
6768
- github: GitHub Actions output format for $GITHUB_OUTPUT
6869
- github-matrix: GitHub Actions matrix format for strategy.matrix
6970
- jsonl: JSON Lines format (one object per line)
@@ -170,6 +171,7 @@ Options:
170171
- text: Human-readable text output (default)
171172
- json: Machine-readable JSON output
172173
- names-only: Names only, one per line
174+
- cargo-args: Cargo -p flag format: -p crate1 -p crate2
173175
- github: GitHub Actions output format for $GITHUB_OUTPUT
174176
- github-matrix: GitHub Actions matrix format for strategy.matrix
175177
- jsonl: JSON Lines format (one object per line)
@@ -382,6 +384,7 @@ Options:
382384
- text: Human-readable text output (default)
383385
- json: Machine-readable JSON output
384386
- names-only: Names only, one per line
387+
- cargo-args: Cargo -p flag format: -p crate1 -p crate2
385388
- github: GitHub Actions output format for $GITHUB_OUTPUT
386389
- github-matrix: GitHub Actions matrix format for strategy.matrix
387390
- jsonl: JSON Lines format (one object per line)
@@ -448,6 +451,7 @@ Options:
448451
- text: Human-readable text output (default)
449452
- json: Machine-readable JSON output
450453
- names-only: Names only, one per line
454+
- cargo-args: Cargo -p flag format: -p crate1 -p crate2
451455
- github: GitHub Actions output format for $GITHUB_OUTPUT
452456
- github-matrix: GitHub Actions matrix format for strategy.matrix
453457
- jsonl: JSON Lines format (one object per line)
@@ -572,6 +576,7 @@ Options:
572576
- text: Human-readable text output (default)
573577
- json: Machine-readable JSON output
574578
- names-only: Names only, one per line
579+
- cargo-args: Cargo -p flag format: -p crate1 -p crate2
575580
- github: GitHub Actions output format for $GITHUB_OUTPUT
576581
- github-matrix: GitHub Actions matrix format for strategy.matrix
577582
- jsonl: JSON Lines format (one object per line)
@@ -618,6 +623,7 @@ Options:
618623
- text: Human-readable text output (default)
619624
- json: Machine-readable JSON output
620625
- names-only: Names only, one per line
626+
- cargo-args: Cargo -p flag format: -p crate1 -p crate2
621627
- github: GitHub Actions output format for $GITHUB_OUTPUT
622628
- github-matrix: GitHub Actions matrix format for strategy.matrix
623629
- jsonl: JSON Lines format (one object per line)
@@ -666,6 +672,7 @@ Options:
666672
- text: Human-readable text output (default)
667673
- json: Machine-readable JSON output
668674
- names-only: Names only, one per line
675+
- cargo-args: Cargo -p flag format: -p crate1 -p crate2
669676
- github: GitHub Actions output format for $GITHUB_OUTPUT
670677
- github-matrix: GitHub Actions matrix format for strategy.matrix
671678
- jsonl: JSON Lines format (one object per line)
@@ -734,6 +741,7 @@ Options:
734741
- text: Human-readable text output (default)
735742
- json: Machine-readable JSON output
736743
- names-only: Names only, one per line
744+
- cargo-args: Cargo -p flag format: -p crate1 -p crate2
737745
- github: GitHub Actions output format for $GITHUB_OUTPUT
738746
- github-matrix: GitHub Actions matrix format for strategy.matrix
739747
- jsonl: JSON Lines format (one object per line)

docs/config.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,20 +101,24 @@ Controls workspace dependency unification behavior. All options are optional wit
101101

102102
| Option | Type | Default | Description |
103103
|--------|------|---------|-------------|
104-
| `msrv` | `bool` | `true` | Compute and write MSRV to `[workspace.package].rust-version`. The MSRV is the maximum `rust-version` from all resolved dependencies - your buildable floor. |
104+
| `msrv` | `bool` | `true` | Compute and write MSRV to `[workspace.package].rust-version`. The MSRV is determined by `msrv_source`. |
105+
| `msrv_source` | `enum` | `"max"` | How to compute the final MSRV:<br>• `"deps"` - Use maximum from dependencies only (original behavior)<br>• `"workspace"` - Preserve existing rust-version, warn if deps need higher<br>• `"max"` - Take max(workspace, deps) - your explicit setting wins if higher |
105106
| `detect_unused` | `bool` | `true` | Detect dependencies declared in manifests but absent from the resolved cargo graph. |
106107
| `remove_unused` | `bool` | `true` | Automatically remove unused dependencies during unification. Requires `detect_unused = true`. |
107108
| `prune_dead_features` | `bool` | `true` | Remove features that are never enabled in the resolved dependency graph across all targets. Only prunes empty no-ops (`feature = []`). Features with actual dependencies are preserved. |
109+
| `preserve_features` | `string[]` | `[]` | Features to preserve from dead feature pruning. Supports glob patterns (e.g., `"unstable-*"`, `"bench*"`). Use this to keep features intended for future use or external consumers. |
108110
| `max_backups` | `usize` | `3` | Maximum number of backup archives to keep. Older backups are automatically cleaned up after successful operations. Set to `0` to disable backup creation entirely. |
109111

110112
**Example:**
111113

112114
```toml
113115
[unify]
114116
msrv = true
117+
msrv_source = "max" # "deps" | "workspace" | "max"
115118
detect_unused = true
116119
remove_unused = true
117120
prune_dead_features = true
121+
preserve_features = ["future-api", "unstable-*"] # Keep these from pruning
118122
max_backups = 5
119123
```
120124

@@ -182,9 +186,11 @@ transitive_host = "root"
182186
[unify]
183187
# Core options (defaults shown)
184188
msrv = true
189+
msrv_source = "max" # "deps" | "workspace" | "max"
185190
detect_unused = true
186191
remove_unused = true
187192
prune_dead_features = true
193+
preserve_features = [] # Glob patterns to preserve from pruning
188194
max_backups = 3
189195

190196
# Version handling
@@ -455,9 +461,11 @@ targets = [
455461
[unify]
456462
# Core
457463
msrv = true
464+
msrv_source = "max" # "deps" | "workspace" | "max"
458465
detect_unused = true
459466
remove_unused = true
460467
prune_dead_features = true
468+
preserve_features = [] # Glob patterns: ["unstable-*", "future-api"]
461469
max_backups = 3
462470
463471
# Version handling

src/cargo/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub use cargo_transform::{CargoTransform, TransformContext};
2222
pub use feature_scanner::{FeatureScanResult, FeatureScanner};
2323
pub use manifest_analyzer::{DepKey, DepKind, DepUsage, ManifestAnalyzer};
2424
pub use manifest_writer::ManifestWriter;
25-
pub use multi_target_metadata::{ComputedMsrv, FragmentedTransitive, MultiTargetMetadata};
25+
pub use multi_target_metadata::{ComputedMsrv, FragmentedTransitive, MsrvSourceUsed, MultiTargetMetadata};
2626
pub use unify_analyzer::UnifyAnalyzer;
2727
pub use unify_report::UnifyReport;
2828
pub use unify_types::{

0 commit comments

Comments
 (0)