axodotdev / axodotdev/cargo-dist
Make the "plan" phase as similar to the "build" phase as possible
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 149
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 32
Description
The ultimate goal of this is to try to catch as many problems that aren't build failures in the plan phase.
## Sub-goals to achieve that:
1. [ ] Implement a `--dry-run` flag for `dist build`.
2. [ ] Make generated workflows use the same matrix for the "plan" phase as for the "build" phase, just with `--dry-run`.
3. [ ] Implement `dist plan` in terms of `dist build --dry-run`
4. [ ] Split out a `dist env-test` command out of `dist build`, like was done with `dist migrate` and `dist init`. (Partially done in #1640.)
## 1. `dist build --dry-run`
If `--dry-run` is passed, anything that would change the state of the system should be explained but not actually run.
## 2. Make workflows have more consistent "plan" and "build" matrices
There's two ways to approach this:
- just generate almost the same exact thing twice
- move it to a separate workflow where you can specify additional `dist build` flags, and use workflow-dispatch twice
Part of the goal of doing this is to fail in the plan phase if tools can't be installed.
## 3. Implement `dist plan` in terms of `dist build --dry-run`
If we have `dist build` implemented in terms of `do_build(cfg: &Config, dry_run: bool, incoherent_tags: bool)`, then `dist build` can be implemented as `do_build(&config, dry_run, false)` and `dist plan` can be implemented as `do_build(&config, dry_run, true)`.
## 4. Split out a `dist env-test` command from `dist build`, like was done with `dist migrate` and `dist init`
Having a separate command that basically goes "can i even theoretically use this environment?" and failing early if the answer is no, would be very useful.
E.g., there's no point going through like 3/4ths of the build process only to fail when finding omnibor, if we can just have something that starts with `if needs_omnibor { print_tool_status(dist_graph.tools.omnibor()); }`
assuming print_tool_status() is something like this
```rust
fn print_tool_status(tool: DistResult<&Tool>) {
match tool {
Ok(tool) => println!("✅ located {}", tool.cmd),
Err(err) => println!("🗙 missing {}", err.tool),
}
}
```
Contributor guide
Research direction
Start by tracing the existing dist build, dist plan, dist migrate, and dist init entry points, then inspect do_build and generated workflows. Define how --dry-run avoids state changes, aligns plan and build matrices, and supports a separate dist env-test command. Done means the plan phase catches relevant environment and tool failures without changing system state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, ci-cd
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100