Skip to content

Commit 73db7aa

Browse files
committed
feat(matrix): nest user metadata under metadata and drop serde_json_merge
- `cargo fc matrix` rows now expose cargo-fc-owned `name`, `target`, `features`, and `metadata`; user matrix config moves under `metadata` instead of being merged at the top level (breaking schema change). - replace the `serde_json_merge` dependency with a small recursive `serde_json::Map` deep-merge (nested objects merge; arrays and scalars replace) and store matrix metadata as `serde_json::Map` so one merge serves every level. - emit matrix rows with deterministically sorted keys, independent of serde_json's `preserve_order` feature. - regenerate screenshots, refresh README/docs/plan, add CHANGELOG, and scope the `udeps` task to `--workspace --all-targets`.
1 parent b5817bd commit 73db7aa

17 files changed

Lines changed: 241 additions & 137 deletions

CHANGELOG.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Changelog
2+
3+
## [0.1.0]
4+
5+
### Breaking Changes
6+
7+
- Changed `cargo fc matrix` row shape. cargo-fc now owns the top-level
8+
`name`, `target`, `features`, and `metadata` fields. Custom package matrix
9+
fields from `[package.metadata.cargo-fc].matrix` or
10+
`[package.metadata.cargo-fc.matrix]` now appear under `metadata` instead of
11+
being merged at the top level.
12+
- Added `target` to every `cargo fc matrix` row. Matrix consumers should use
13+
`row.target` for the effective target triple and `row.metadata.<key>` for
14+
user-defined fields.
15+
- Made `targets`, workspace `target.'cfg(...)'`, and workspace `subcommands`
16+
cargo-fc metadata keys active. Repositories that previously used those keys
17+
for unrelated local data must rename them.
18+
- Configured target lists now apply to all target-capable Cargo commands by
19+
default, including `build`, `check`, `clippy`, `doc`, `test`, and `run`.
20+
Foreign-target `test` and `run` usually fail unless narrowed with
21+
`--target`, disabled with `--no-targets`, or disabled for that command in
22+
workspace metadata.
23+
- Unknown Cargo aliases and custom subcommands do not receive configured
24+
targets unless explicitly opted in with
25+
`[workspace.metadata.cargo-fc.subcommands.<name>] targets = true`.
26+
- Removed the redundant public target-detector API in favor of
27+
`TargetEnvironment`, `parse_cli_target`, and `host_triple`.
28+
29+
### Added
30+
31+
- Added workspace-level configured targets:
32+
`[workspace.metadata.cargo-fc] targets = ["<triple>", ...]`.
33+
- Added package-level configured targets:
34+
`[package.metadata.cargo-fc] targets = ["<triple>", ...]`.
35+
- Added package-level target opt-out with `targets = []`, which falls back to
36+
the single effective Cargo target for that package.
37+
- Added target-specific workspace package selection via
38+
`[workspace.metadata.cargo-fc.target.'cfg(...)']` with `exclude_packages`
39+
patches.
40+
- Added per-subcommand target capability overrides via
41+
`[workspace.metadata.cargo-fc.subcommands.<name>] targets = true|false`.
42+
- Added `--no-targets` to ignore configured target lists for one invocation.
43+
- Added `--aggregate-targets` to batch compatible configured targets for the
44+
same package and feature combination into one Cargo invocation.
45+
- Added per-target execution planning so `cargo fc check`, `cargo fc clippy`,
46+
and other target-capable commands can cover each configured target's cfg view
47+
in one command.
48+
- Added per-target attribution in command headers, summaries, diagnostics-only
49+
output, and dedupe reporting when target selection is explicit or configured.
50+
- Added GitHub Actions documentation for generating target-aware matrices and
51+
for using one `cargo fc check` or `cargo fc clippy` invocation in CI.
52+
53+
### Changed
54+
55+
- Explicit Cargo `--target <triple>` wins globally over configured target
56+
lists. Without an explicit CLI target, configured package/workspace targets
57+
take precedence over `CARGO_BUILD_TARGET`, then fall back to
58+
`CARGO_BUILD_TARGET`, then the host target.
59+
- Matrix generation now goes through the same target and execution planning path
60+
as command execution, so target-specific package config and workspace package
61+
exclusions are resolved consistently.
62+
- Matrix JSON object keys are serialized in deterministic sorted order.
63+
- Target-specific matrix metadata merges tables recursively; arrays and scalar
64+
values replace the base value.
65+
- Summary totals and pruned-combination summaries are keyed by package, target,
66+
and feature set so identical feature sets across targets no longer collapse.
67+
- Invalid or unavailable target cfg evaluation errors now surface rustc's reason
68+
at the cfg-evaluator boundary.

Cargo.lock

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

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ cfg-expr = "0.20"
8686
# serde
8787
serde = "1"
8888
serde_json = "1"
89-
serde_json_merge = "0"
9089

9190
# terminal colors
9291
termcolor = "1.4"

README.md

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cargo fc build
4343
cargo fc check -p <my-crate> --all-targets
4444
```
4545

46-
In addition, there are a few new flags and the `matrix` subcommand.
46+
In addition, cargo-fc provides these flags and the `matrix` subcommand.
4747
To get an idea, consider these examples:
4848

4949
```bash
@@ -142,14 +142,14 @@ For example:
142142
[package.metadata.cargo-fc]
143143

144144
# Exclude groupings of features that are incompatible or do not make sense
145-
exclude_feature_sets = [ ["foo", "bar"], ] # formerly "skip_feature_sets"
145+
exclude_feature_sets = [["foo", "bar"]]
146146

147147
# To exclude only the empty feature set from the matrix, you can either enable
148148
# `no_empty_feature_set = true` or explicitly list an empty set here:
149149
exclude_feature_sets = [[]]
150150

151151
# Exclude features from the feature combination matrix
152-
exclude_features = ["default", "full"] # formerly "denylist"
152+
exclude_features = ["default", "full"]
153153

154154
# Skip implicit features that correspond to optional dependencies from the
155155
# matrix.
@@ -180,7 +180,7 @@ only_features = ["default", "full"]
180180
# Non-existent features are ignored. Other configuration options are ignored.
181181
include_feature_sets = [
182182
["foo-a", "bar-a", "other-a"],
183-
] # formerly "exact_combinations"
183+
]
184184

185185
# Allow only the listed feature sets.
186186
#
@@ -213,22 +213,27 @@ isolated_feature_sets = [
213213
["other-a", "other-b", "other-c"],
214214
]
215215

216-
# Optional: Additional metadata merged into `cargo fc matrix` output
216+
# Optional: Custom metadata for `cargo fc matrix` output.
217+
# It appears under the row's `metadata` key.
217218
# $ cargo fc matrix --pretty
218219
# [
219-
# { "name": "my-crate", "features": "", "kind": "ci" },
220-
# { "name": "my-crate", "features": "a", "kind": "ci" },
221-
# { "name": "my-crate", "features": "b", "kind": "ci" },
222-
# { "name": "my-crate", "features": "a,b", "kind": "ci" },
220+
# { "features": "", "metadata": { "kind": "ci" }, "name": "my-crate", "target": "x86_64-unknown-linux-gnu" },
221+
# { "features": "a", "metadata": { "kind": "ci" }, "name": "my-crate", "target": "x86_64-unknown-linux-gnu" },
222+
# { "features": "b", "metadata": { "kind": "ci" }, "name": "my-crate", "target": "x86_64-unknown-linux-gnu" },
223+
# { "features": "a,b", "metadata": { "kind": "ci" }, "name": "my-crate", "target": "x86_64-unknown-linux-gnu" },
223224
# ]
224225
matrix = { kind = "ci" }
225226

226-
# Optional: The `matrix` metadata from before can also be its own section
227+
# Optional: Matrix metadata can also be configured in its own section.
227228
# $ cargo fc matrix --pretty
228229
# [{
229-
# "requires-gpu": false,
230-
# "value-for-this-crate": "will show up in the feature matrix",
231-
# ..
230+
# "features": "",
231+
# "metadata": {
232+
# "requires-gpu": false,
233+
# "value-for-this-crate": "will show up in the feature matrix"
234+
# },
235+
# "name": "my-crate",
236+
# "target": "x86_64-unknown-linux-gnu"
232237
# }, .. ]
233238
[package.metadata.cargo-fc.matrix]
234239
value-for-this-crate = "will show up in the feature matrix"
@@ -434,6 +439,9 @@ If a value appears in both `add` and `remove`, add wins.
434439
When multiple target override sections match (e.g. `cfg(unix)` and `cfg(target_os = "linux")`),
435440
their `add` and `remove` sets are unioned. Conflicting `override` values result in an error.
436441

442+
Matrix metadata tables merge recursively. Other matrix metadata values,
443+
including arrays, replace the base value.
444+
437445
##### `replace = true`
438446

439447
If a matching target override sets `replace = true`, resolution starts from a fresh default

docs/GITHUB_ACTIONS.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ jobs:
6666
--all-targets
6767
```
6868

69+
If you configure custom package matrix metadata, it is available under
70+
`matrix.package.metadata`:
71+
72+
```yaml
73+
name: build ${{ matrix.package.name }} (${{ matrix.package.metadata.kind }})
74+
```
75+
6976
Of course you can also apply the same approach for your `test.yaml` or `lint.yaml` workflows!
7077
Per job, up to 256 feature sets can be processed in parallel.
7178

@@ -105,4 +112,3 @@ feature combination for you (no GitHub Actions matrix required):
105112
Add `--aggregate-targets` to batch each combination's targets into one Cargo
106113
invocation for extra throughput on many-core runners.
107114

108-

docs/check.png

-15.2 KB
Loading

docs/dedupe.png

-7.36 KB
Loading

docs/diagnostics.png

-8.5 KB
Loading

docs/matrix.png

289 Bytes
Loading

docs/pruned.png

-9.52 KB
Loading

0 commit comments

Comments
 (0)