|
1 | 1 | # cargo-rail |
2 | 2 |
|
3 | | -**Hyper-efficient Rust monorepo orchestration.** |
| 3 | +**Rust monorepo orchestration. Zero waste.** |
4 | 4 |
|
5 | 5 | --- |
6 | 6 |
|
7 | | -## Status |
| 7 | +## What It Does |
8 | 8 |
|
9 | | -**NOT READY FOR PUBLIC USE.** Active development. Internal testing only. |
| 9 | +### 1. Replace cargo-hakari |
10 | 10 |
|
11 | | ---- |
| 11 | +```bash |
| 12 | +cargo rail unify |
| 13 | +``` |
12 | 14 |
|
13 | | -## What It Does |
| 15 | +Native `[workspace.dependencies]` unification. No workspace-hack crates. No guppy. No maintenance. |
14 | 16 |
|
15 | | -### 1. Workspace Dependency Unification |
| 17 | +### 2. Distribute Crates |
16 | 18 |
|
17 | | -**Replaces cargo-hakari and workspace-hack crates.** |
| 19 | +```bash |
| 20 | +cargo rail split my-crate |
| 21 | +cargo rail sync my-crate |
| 22 | +``` |
| 23 | + |
| 24 | +Split monorepo crates to standalone repos. Sync bidirectionally. Full git history preserved. |
18 | 25 |
|
19 | | -- Native Cargo `[workspace.dependencies]` unification |
20 | | -- No fake crates, no guppy, no runtime overhead |
21 | | -- CI-enforceable via `cargo rail unify check` |
22 | | -- Invisible after initial application |
| 26 | +**Replaces:** Copybara, git-filter-repo, bash scripts |
| 27 | + |
| 28 | +### 3. Test Only What Changed |
23 | 29 |
|
24 | 30 | ```bash |
25 | | -cargo rail unify analyze # Dry-run analysis |
26 | | -cargo rail unify apply --backup # Apply unification |
27 | | -cargo rail unify check # CI verification (exit 0 = unified) |
| 31 | +cargo rail test |
28 | 32 | ``` |
29 | 33 |
|
30 | | -### 2. Split & Sync |
| 34 | +Graph-aware change detection. Docs-only changes skip tests. Source changes test affected crates only. |
| 35 | + |
| 36 | +**Nextest/Cargo native. Saves CI costs.** |
31 | 37 |
|
32 | | -**Split crates from monorepo to standalone repos. Sync bidirectionally.** |
| 38 | +### 4. Release & Changelog |
33 | 39 |
|
34 | 40 | ```bash |
35 | | -# Split: Monorepo → Standalone Repo (with full git history) |
36 | | -cargo rail split my-crate --apply |
| 41 | +cargo rail release my-crate |
| 42 | +``` |
37 | 43 |
|
38 | | -# Sync: Monorepo → Split Repo (direct push to main) |
39 | | -cargo rail sync my-crate --to-remote --apply |
| 44 | +Validates edition, MSRV, dependencies. Publishes to crates.io. Tags releases. Generates changelogs. |
40 | 45 |
|
41 | | -# Sync: Split Repo → Monorepo (creates PR branch, never commits to main) |
42 | | -cargo rail sync my-crate --from-remote --apply |
43 | | -``` |
| 46 | +--- |
44 | 47 |
|
45 | | -**Modes:** |
46 | | -- **Single crate** → Single repo |
47 | | -- **Multiple crates** → Single repo |
48 | | -- **Multiple crates** → Separate monorepo |
| 48 | +## Why It Matters |
49 | 49 |
|
50 | | -### 3. Centralized Configuration Management |
| 50 | +| Problem | cargo-rail | |
| 51 | +|---------|------------| |
| 52 | +| Fragmented features → slow builds | Native workspace unification | |
| 53 | +| Distributing crates from monorepo | Split/sync with full history | |
| 54 | +| Testing everything on every PR | Graph-aware test runner | |
| 55 | +| Version drift across workspace | Enforced policies | |
51 | 56 |
|
52 | | -**Enforce uniform policies across all workspace crates.** |
| 57 | +--- |
53 | 58 |
|
54 | | -- Edition, MSRV, resolver version |
55 | | -- Dependency version consistency |
56 | | -- Workspace inheritance validation |
| 59 | +## Install |
57 | 60 |
|
58 | | -```toml |
59 | | -# rail.toml |
60 | | -[policy] |
61 | | -edition = "2024" |
62 | | -msrv = "1.76.0" |
63 | | -resolver = "2" |
64 | | -forbid_multiple_versions = ["tokio", "serde"] |
| 61 | +```bash |
| 62 | +cargo install cargo-rail |
65 | 63 | ``` |
66 | 64 |
|
67 | 65 | --- |
68 | 66 |
|
69 | | -## Architecture |
| 67 | +## Quick Start |
70 | 68 |
|
71 | | -- **Git + Cargo + Petgraph** - Core foundation |
72 | | -- **Zero libgit2/gitoxide** - System git binary only |
73 | | -- **Zero guppy** - Direct cargo_metadata usage |
74 | | -- **Workspace-aware graph** - Dependency + reverse-dependency tracking |
| 69 | +```bash |
| 70 | +# Unify dependencies |
| 71 | +cargo rail unify |
| 72 | + |
| 73 | +# Split a crate (one-time) |
| 74 | +cargo rail split my-crate |
| 75 | + |
| 76 | +# Sync changes |
| 77 | +cargo rail sync my-crate |
| 78 | + |
| 79 | +# Test what changed |
| 80 | +cargo rail test |
| 81 | + |
| 82 | +# Release a crate |
| 83 | +cargo rail release my-crate |
| 84 | +``` |
75 | 85 |
|
76 | 86 | --- |
77 | 87 |
|
78 | 88 | ## Configuration |
79 | 89 |
|
80 | | -`rail.toml`: |
81 | | - |
82 | 90 | ```toml |
83 | | -[workspace] |
84 | | -root = "." |
85 | | - |
86 | | -# Split configuration |
| 91 | +# rail.toml |
87 | 92 | [[splits]] |
88 | 93 | name = "my-crate" |
89 | 94 | remote = "[email protected]:user/my-crate.git" |
90 | | -branch = "main" |
91 | | -mode = "single" |
92 | 95 | paths = [{ crate = "crates/my-crate" }] |
93 | 96 |
|
94 | | -# Unification configuration (optional) |
95 | | -[unify] |
96 | | -strategy = "all" |
97 | | -normal_only = false |
98 | | -exclude = ["some-special-dep"] |
99 | | - |
100 | | -# Policy enforcement |
101 | 97 | [policy] |
102 | 98 | edition = "2024" |
103 | | -msrv = "1.76.0" |
104 | | -resolver = "2" |
| 99 | +msrv = "1.83.0" |
105 | 100 | forbid_multiple_versions = ["tokio"] |
106 | 101 | ``` |
107 | 102 |
|
108 | 103 | --- |
109 | 104 |
|
110 | | -## Security |
| 105 | +## How It Works |
| 106 | + |
| 107 | +- **Zero libgit2/gitoxide** - System git only |
| 108 | +- **Zero guppy** - cargo_metadata + petgraph |
| 109 | +- **Graph-first** - Dependency graph drives everything |
| 110 | +- **Minimal deps** - Supply-chain security matters |
| 111 | +- **Deterministic** - Same input = same git SHAs |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## Safety |
| 116 | + |
| 117 | +- Syncs from remote create PR branches, never commit to main |
| 118 | +- Destructive operations require explicit flags |
| 119 | +- Backups created automatically |
| 120 | + |
| 121 | +--- |
| 122 | + |
| 123 | +## Status |
| 124 | + |
| 125 | +**Beta:** |
| 126 | + |
| 127 | +- ✅ Dependency unification |
| 128 | +- ✅ Split/sync with history preservation |
| 129 | +- ✅ Graph-aware change detection |
111 | 130 |
|
112 | | -**Split → Mono:** Creates PR branch `rail/sync/{name}/{timestamp}`. Never commits to main. |
| 131 | +**Coming soon:** |
113 | 132 |
|
114 | | -**Mono → Split:** Direct push. Use SSH keys + branch protection. |
| 133 | +- 🚧 Release/publish/changelog automation |
115 | 134 |
|
116 | 135 | --- |
117 | 136 |
|
|
0 commit comments