Skip to content

Commit e61c4b8

Browse files
committed
cargo-rail
- feat(cli): add --ignore-bin-crates to affected/test (#10) - fix(workspace): invalidate metadata cache on member manifest changes (#9) - feat(unify): support -o/--output in --check mode (#1 for the cargo-rail-action) - ci(release): publish SHA256SUMS and SHA256SUMS.json; drop macOS x86_64
1 parent 5a0fc67 commit e61c4b8

File tree

13 files changed

+586
-163
lines changed

13 files changed

+586
-163
lines changed

.github/actions/setup/action.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ runs:
6464
# Shared prefix: stable across commits (invalidates on bump)
6565
shared-key: "cargo-rail-v1"
6666

67-
# Workflow and platform-specific suffix: commit-ubuntu-latest, commit-macos-latest, etc.
67+
# Workflow and platform-specific suffix: commit-ubuntu-latest, commit-macos-14, etc.
6868
# Ensures each workflow and platform maintains separate cache
6969
key: ${{ inputs.cache-key }}
7070

.github/workflows/release.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# Triggered by pushing a version tag (v0.1.0, v1.0.0, etc.)
44
#
55
# This workflow builds pre-built binaries and uploads them to GitHub Releases.
6+
# It also publishes `SHA256SUMS` and `SHA256SUMS.json` so downstream packagers can
7+
# verify assets without downloading everything just to compute hashes.
68
# The version bump, changelog, tagging, and crates.io publish are done locally
79
# via `cargo rail release run cargo-rail --bump <version>`.
810
#
@@ -130,3 +132,72 @@ jobs:
130132
tar: all
131133
zip: windows
132134
token: ${{ secrets.GITHUB_TOKEN }}
135+
136+
# ==========================================================================
137+
# Job 3: Publish SHA256SUMS for release assets
138+
# ==========================================================================
139+
publish-checksums:
140+
name: Publish SHA256SUMS
141+
needs: upload-assets
142+
runs-on: ubuntu-latest
143+
permissions:
144+
contents: write
145+
steps:
146+
- name: Download release assets
147+
env:
148+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
149+
run: |
150+
set -euo pipefail
151+
152+
# Only include platform archives produced by the release workflow.
153+
gh release download "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --pattern "cargo-rail-*.tar.*"
154+
gh release download "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --pattern "cargo-rail-*.zip" || true
155+
156+
shopt -s nullglob
157+
files=(cargo-rail-*.tar.* cargo-rail-*.zip)
158+
if [ "${#files[@]}" -eq 0 ]; then
159+
echo "No matching release assets found to checksum." >&2
160+
exit 1
161+
fi
162+
163+
- name: Generate SHA256SUMS and SHA256SUMS.json
164+
run: |
165+
set -euo pipefail
166+
shopt -s nullglob
167+
168+
files=(cargo-rail-*.tar.* cargo-rail-*.zip)
169+
sha256sum "${files[@]}" | sort -k2 > SHA256SUMS
170+
171+
python3 - <<'PY'
172+
import json
173+
import os
174+
import pathlib
175+
import time
176+
177+
tag = os.environ.get("GITHUB_REF_NAME", "")
178+
lines = pathlib.Path("SHA256SUMS").read_text().splitlines()
179+
entries = []
180+
for line in lines:
181+
line = line.strip()
182+
if not line:
183+
continue
184+
# sha256sum format: "<hash> <filename>"
185+
digest, filename = line.split(maxsplit=1)
186+
filename = filename.lstrip("*").strip()
187+
entries.append({"file": filename, "sha256": digest})
188+
189+
payload = {
190+
"tool": "cargo-rail",
191+
"tag": tag,
192+
"generated_at_utc": time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime()),
193+
"entries": entries,
194+
}
195+
pathlib.Path("SHA256SUMS.json").write_text(json.dumps(payload, indent=2, sort_keys=True) + "\n")
196+
PY
197+
198+
- name: Upload checksum assets to GitHub Release
199+
env:
200+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
201+
run: |
202+
set -euo pipefail
203+
gh release upload "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" SHA256SUMS SHA256SUMS.json --clobber

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ Thumbs.db
1919
notes/
2020
**/demo.cast
2121
distribution/
22+
todo.md
23+
AGENTS.md

docs/commands.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ Options:
8686
-a, --all
8787
Show all workspace crates (ignore changes)
8888
89+
--ignore-bin-crates
90+
Ignore binary-only crates (packages with [[bin]] but no lib target)
91+
8992
-o, --output <PATH>
9093
Write output to file (appends to existing content)
9194
@@ -103,6 +106,7 @@ Examples:
103106
cargo rail affected --merge-base # Changes since branch point (CI recommended)
104107
cargo rail affected --since HEAD~5 # Changes in last 5 commits
105108
cargo rail affected --from abc --to def # Changes between two SHAs
109+
cargo rail affected --ignore-bin-crates # Skip binary-only crates (no lib target)
106110
cargo rail affected --explain # Show why each crate is affected
107111
cargo rail affected -f github-matrix # Output for GitHub Actions matrix
108112
cargo rail affected -f names-only # Just crate names, one per line
@@ -140,6 +144,9 @@ Options:
140144
-a, --all
141145
Skip change detection and run all tests
142146
147+
--ignore-bin-crates
148+
Ignore binary-only crates (packages with [[bin]] but no lib target)
149+
143150
--config <PATH>
144151
Path to rail.toml config file (bypass search order)
145152
@@ -162,6 +169,7 @@ Examples:
162169
cargo rail test # Test affected crates
163170
cargo rail test --merge-base # Test changes since branch point (CI)
164171
cargo rail test --all # Test all crates
172+
cargo rail test --ignore-bin-crates # Skip binary-only crates (no lib target)
165173
cargo rail test -- --nocapture # Pass args to test runner
166174
cargo rail test --explain # Show why each crate is tested
167175
```
@@ -198,11 +206,6 @@ Options:
198206
Possible values:
199207
- text: Human-readable text output (default)
200208
- json: Machine-readable JSON output
201-
- names-only: Names only, one per line
202-
- cargo-args: Cargo -p flag format: -p crate1 -p crate2
203-
- github: GitHub Actions output format for $GITHUB_OUTPUT
204-
- github-matrix: GitHub Actions matrix format for strategy.matrix
205-
- jsonl: JSON Lines format (one object per line)
206209
207210
[default: text]
208211
@@ -218,6 +221,9 @@ Options:
218221
--report-path <REPORT_PATH>
219222
Custom path for the unify report (default: target/cargo-rail/unify-report.md)
220223
224+
-o, --output <PATH>
225+
Write output to file (appends to existing content)
226+
221227
--show-diff
222228
Show diff of changes to each manifest
223229
@@ -233,6 +239,7 @@ Options:
233239
Examples:
234240
cargo rail unify --check # Preview changes (CI mode)
235241
cargo rail unify --check --explain # Show why each decision was made
242+
cargo rail unify --check -f json -o out.json # Write JSON output to file
236243
cargo rail unify # Apply changes
237244
cargo rail unify --backup # Apply with backup
238245
cargo rail unify --show-diff # Show manifest changes

src/cargo/unify/unused_finder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ mod tests {
272272

273273
#[test]
274274
fn test_target_constraint_matches_unix() {
275-
let targets = ["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
275+
let targets = ["x86_64-unknown-linux-gnu", "aarch64-apple-darwin"];
276276
assert!(target_constraint_matches_any("cfg(unix)", &targets));
277277
assert!(!target_constraint_matches_any("cfg(windows)", &targets));
278278
}

0 commit comments

Comments
 (0)