Skip to content

Commit 1c4ff1d

Browse files
committed
Make xtask-prepush configurably verbose
1 parent 31feeca commit 1c4ff1d

File tree

3 files changed

+43
-15
lines changed

3 files changed

+43
-15
lines changed

README.md

+21
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,27 @@ implementation details, consumed by Propolis components.
4141
to the `propolis` library
4242
- viona-api: API (ioctls & structs) for the illumos viona driver
4343

44+
## xtasks
45+
46+
Propolis uses the `cargo xtask` pattern in order to conveniently expose certain
47+
tasks to developers.
48+
49+
- `clippy`: Run suite of clippy checks. This performs more than a simple
50+
`cargo clippy`, since there are several combinations of feature flags which
51+
must be checked.
52+
- `fmt`: Check style according to `rustfmt`
53+
- `license`: Check (crudely) that files bear appropriate license headers
54+
- `phd`: Run the PHD test suite
55+
- `style`: Perform miscellaneous style checks
56+
- `prepush`: Preform pre-push checks (`clippy`, `fmt`, `license`, `style`) in a
57+
manner which resembles (but does not exactly match) how they are run in CI.
58+
Running tests (unit, integration, or phd) are not included and are left to
59+
the user.
60+
61+
It is recommended that developers run the `prepush` test before pushing a
62+
branch which will be subsequently checked by CI. Doing so currently requires
63+
an x86\_64 UNIX/Linux machine.
64+
4465
## License
4566

4667
Unless otherwise noted, all components are licensed under the [Mozilla Public

xtask/src/main.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ enum Cmds {
3838
/// (Crudely) Check for appropriate license headers
3939
License,
4040
/// Preform pre-push checks (clippy, license, fmt, etc)
41-
Prepush,
41+
Prepush {
42+
/// Suppress non-essential output
43+
#[arg(short, long)]
44+
quiet: bool,
45+
},
4246
/// Run the PHD test suite
4347
Phd {
4448
#[clap(subcommand)]
@@ -61,8 +65,8 @@ fn main() -> Result<()> {
6165
Ok(())
6266
}
6367
Cmds::Phd { cmd } => cmd.run(),
64-
Cmds::Prepush => {
65-
task_prepush::cmd_prepush()?;
68+
Cmds::Prepush { quiet } => {
69+
task_prepush::cmd_prepush(quiet)?;
6670

6771
println!("Pre-push checks pass");
6872
Ok(())

xtask/src/task_prepush.rs

+15-12
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,22 @@ use anyhow::{bail, Result};
66

77
use crate::{task_clippy, task_fmt, task_license, task_style};
88

9-
pub(crate) fn cmd_prepush() -> Result<()> {
9+
pub(crate) fn cmd_prepush(quiet: bool) -> Result<()> {
1010
let mut errs = Vec::new();
11-
if task_clippy::cmd_clippy(true, true).is_err() {
12-
errs.push("clippy");
13-
}
14-
if task_fmt::cmd_fmt().is_err() {
15-
errs.push("fmt");
16-
}
17-
if task_license::cmd_license().is_err() {
18-
errs.push("license");
19-
}
20-
if task_style::cmd_style().is_err() {
21-
errs.push("style");
11+
let checks: [(&str, &dyn Fn() -> bool); 4] = [
12+
("clippy", &|| task_clippy::cmd_clippy(true, quiet).is_err()),
13+
("fmt", &|| task_fmt::cmd_fmt().is_err()),
14+
("license", &|| task_license::cmd_license().is_err()),
15+
("style", &|| task_style::cmd_style().is_err()),
16+
];
17+
18+
for (name, func) in checks {
19+
if !quiet {
20+
println!("Checking {name}...");
21+
}
22+
if func() {
23+
errs.push(name);
24+
}
2225
}
2326

2427
if !errs.is_empty() {

0 commit comments

Comments
 (0)