11# cargo-rail-action
22
3- > GitHub Action wrapper for ` cargo rail plan -f github ` .
3+ > GitHub Action wrapper for planner gates and ` scope-json ` .
44
55[ ![ Test] ( https://github.com/loadingalias/cargo-rail-action/actions/workflows/test.yaml/badge.svg )] ( https://github.com/loadingalias/cargo-rail-action/actions/workflows/test.yaml ) [ ![ License: MIT] ( https://img.shields.io/badge/license-MIT-blue.svg )] ( LICENSE )
66
77## What It Does
88
9- - Runs ` cargo rail plan ... -f github ` .
10- - Publishes planner outputs for job gating.
9+ - Runs ` cargo rail plan ` in planner-owned GitHub transport mode .
10+ - Publishes planner gates and ` scope-json ` for job gating.
1111- Keeps CI behavior aligned with local ` plan ` + ` run ` workflows.
1212
13- Minimum planner contract: ` cargo-rail >= 0.10.0 ` .
13+ Minimum planner contract: ` cargo-rail >= 0.10.12 ` .
1414
1515## Quick Start
1616
@@ -29,11 +29,26 @@ jobs:
2929 - uses : loadingalias/cargo-rail-action@v3
3030 id : rail
3131 with :
32- version : " 0.10.8 "
32+ version : " 0.10.12 "
3333
3434 - name : Run targeted tests
3535 if : steps.rail.outputs.test == 'true'
36- run : cargo rail run --since "${{ steps.rail.outputs.base-ref }}" --profile ci
36+ env :
37+ SCOPE_JSON : ${{ steps.rail.outputs.scope-json }}
38+ run : |
39+ MODE=$(echo "$SCOPE_JSON" | jq -r '.mode')
40+ if [ "$MODE" = "workspace" ]; then
41+ cargo nextest run --workspace
42+ elif [ "$MODE" = "crates" ]; then
43+ mapfile -t CRATES < <(echo "$SCOPE_JSON" | jq -r '.crates[]')
44+ ARGS=()
45+ for crate in "${CRATES[@]}"; do
46+ ARGS+=(-p "$crate")
47+ done
48+ cargo nextest run "${ARGS[@]}"
49+ else
50+ echo "planner enabled test surface, but no package-scoped work was selected"
51+ fi
3752
3853 - name : Run docs pipeline
3954 if : steps.rail.outputs.docs == 'true'
@@ -47,13 +62,13 @@ Use the stable major tag `@v3`, or pin a commit SHA for maximum reproducibility.
4762
4863| Input | Default | Description |
4964|---|---|---|
50- | `version` | `0.10.8 ` | `cargo-rail` version to install (use `latest` only if you intentionally want floating upgrades) |
65+ | `version` | `0.10.12 ` | `cargo-rail` version to install (use `latest` only if you intentionally want floating upgrades) |
5166| `checksum` | `required` | `required`, `if-available`, or `off` |
5267| `since` | auto | Git ref for planner comparison |
53- | `args` | `""` | Extra planner args (see below) |
68+ | `args` | `""` | Extra planner args except `-f`/`--format`, `--json`, and `-o`/`--output` |
5469| `working-directory` | `.` | Workspace directory |
5570| `token` | `${{ github.token }}` | Token for release download API |
56- | `mode` | `minimal` | `minimal` (recommended) or `full ` |
71+ | `mode` | `minimal` | `minimal` (recommended) or `debug ` |
5772
5873**Optional `args` examples:**
5974
@@ -63,11 +78,6 @@ Use the stable major tag `@v3`, or pin a commit SHA for maximum reproducibility.
6378 with:
6479 args: '--explain'
6580
66- # Custom format (default is github for this action)
67- - uses: loadingalias/cargo-rail-action@v3
68- with:
69- args: '-f json'
70-
7181# Use different comparison ref
7282- uses: loadingalias/cargo-rail-action@v3
7383 with:
@@ -92,8 +102,8 @@ Use the stable major tag `@v3`, or pin a commit SHA for maximum reproducibility.
92102- Composable : combine gates (`if: steps.rail.outputs.build == 'true' || steps.rail.outputs.infra == 'true'`)
93103
94104**Modes** control what outputs are published:
95- - `minimal` (default) : only gates, matrix, base-ref, plan-json — optimized for modern workflows
96- - `full ` : includes all minimal outputs plus legacy compatibility fields (counts, file lists, etc.)
105+ - `minimal` (default) : gates, `scope-json`, ` base-ref`, and per-custom-surface booleans
106+ - `debug ` : minimal outputs plus `plan-json`
97107
98108# ## Minimal mode (default)
99109
@@ -104,32 +114,34 @@ Use the stable major tag `@v3`, or pin a commit SHA for maximum reproducibility.
104114| `bench` | `true`/`false` | Gate benchmark jobs — set when changes affect performance tests |
105115| `docs` | `true`/`false` | Gate docs jobs — set for doc comments, README, markdown changes |
106116| `infra` | `true`/`false` | Gate infra jobs — set for CI config, scripts, toolchain changes |
107- | `matrix ` | JSON | `strategy.matrix` for dynamic job matrices (crate-level parallelism) |
117+ | `scope-json ` | JSON | Compact execution-scope payload emitted by `cargo-rail` |
108118| `base-ref` | string | Git ref for downstream `run` calls (`--since "${{ steps.rail.outputs.base-ref }}"`) |
109- | `plan-json` | JSON | Full deterministic planner output (all surfaces, crates, files, metadata) |
110-
111- # ## Full mode (`mode: full`)
119+ | `custom_<name>` | `true`/`false` | Custom surface gates, with punctuation normalized to `_` |
112120
113- Includes all minimal outputs plus additional fields for compatibility and debugging.
121+ # ## Debug mode (`mode: debug`)
114122
115- **When to use full mode:**
116- - Migrating from legacy workflows that parse file lists or crate counts
117- - Debugging plan decisions (use `trace` output)
118- - Building custom CI logic that needs raw file/crate lists
119-
120- **Additional outputs in full mode:**
123+ Includes all minimal outputs plus the full planner contract.
121124
122125| Output | Type | Description |
123126|---|---|---|
124- | `count` | number | Total number of affected crates (for logging/metrics) |
125- | `crates` | string | Space-separated list of affected crate names |
126- | `files` | JSON | JSON array of changed workspace-relative file paths |
127- | `surfaces` | JSON | JSON object of surface decisions (`enabled` + `reasons`) |
128- | `trace` | JSON | Detailed trace of plan decisions (why each surface enabled/disabled) |
129- | `install-method` | string | Installation source (`cached`, `binary`, `binstall`, `cargo-install`) |
130- | `cargo-rail-version` | string | Installed `cargo-rail` version |
131-
132- **Note:** Most workflows should use `minimal` mode. The `plan-json` output contains all plan data in structured form — use `jq` to extract what you need rather than relying on legacy string outputs.
127+ | `plan-json` | JSON | Full deterministic planner contract for debugging and deep inspection |
128+
129+ **Note:** Most workflows should use `minimal` mode. `scope-json` is the execution handoff; use it for package selection in scripts and jobs. `plan-json` is forensic/debug output only.
130+
131+ Example :
132+
133+ ` ` ` yaml
134+ - name: Show targeted crates
135+ run: echo '${{ steps.rail.outputs.scope-json }}' | jq -r '.crates[]'
136+ ` ` `
137+
138+ Custom surfaces are exported as `custom_<name>` outputs. Example :
139+
140+ ` ` ` yaml
141+ - name: Run benchmark suite
142+ if: steps.rail.outputs.custom_benchmarks == 'true'
143+ run: cargo bench --workspace
144+ ` ` `
133145
134146# # Security and Runtime
135147
0 commit comments