axodotdev / axodotdev/cargo-dist
Add pattern to `pr-run-mode`
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 149
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 32
Description
## Summary
I would like to be able to conditionally set `pr-run-mode` based on the branch it is running from.
The primary motivation being that I would like to minimize CI time on regular PRs, while enabling a sort of 'dry run' on release PRs.
## Proposal
At the moment, the following configuration options are available, which apply globally for every PR:
```toml
[dist]
pr-run-mode = "upload"
pr-run-mode = "plan"
pr-run-mode = "skip"
```
I am suggesting we allow richer data, so that the behaviour can be changed based on the branch. For example, one way to configure this could be:
```toml
[dist]
pr-run-mode = {
"release/*" = "upload",
"renovate/*" = "skip",
"*" = "plan, # fallback
}
```
Dist would go through each pattern, and stop at the first matching pattern. So in this case, dist would:
- Compile all binaries on any release PR (to perform a dry run)
- Skip entirely Renovate PRs (automated, low risk)
- Use the standard plan mode for all other PRs.
## Draft PRs
I would _ideally_ also like to incorporate whether the PR is a draft or not. My typical workflow maintains a release PR at all times in draft mode, and most CI is configured to skip most jobs if the PR is a draft. When the PR is marked as 'ready', then all CI runs as usual. This is rather important since the release PR is updated after every merge to `main`, which would then consume a lot of CI time.
To incorporate such patterns (and open up possibility of further config), I would suggestion an alternative config:
```toml
[dist]
pr-run-mode = [
{ branch = "release/*", draft = true, mode = "skip" },
{ branch = "release/*", mode = "upload" },
{ branch = "renovate/*", mode = "skip" },
# fallback matches everything else
{ mode = "plan" },
]
```
## Implementation
I would be happy to take some time and look at how/if this could be done.
From a backward compatibility perspective, this would be a strict schema expansion. Existing behaviour would be kept.
Contributor guide
Research direction
The issue names no files or tests; start by locating the existing `pr-run-mode` configuration handling and schema. Compare the proposed pattern and draft-PR forms with the required backward compatibility. Done means the configuration shape and matching behavior are agreed and implemented for branch and, if supported, draft conditions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- release
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100