Skip to content

Commit 64561ad

Browse files
committed
Move style checks up to top-level fmt xtask.
I'm in the CI weeds anyway, better make something that fails extraordinarily quickly.
1 parent bccfd77 commit 64561ad

File tree

8 files changed

+32
-24
lines changed

8 files changed

+32
-24
lines changed

.github/buildomat/jobs/lint.sh

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
#:
3+
#: name = "lint"
4+
#: variety = "basic"
5+
#: target = "helios-2.0"
6+
#: rust_toolchain = "nightly-2024-05-12"
7+
#: access_repos = [
8+
#: "oxidecomputer/illumos-rs",
9+
#: ]
10+
#:
11+
12+
set -o errexit
13+
set -o pipefail
14+
set -o xtrace
15+
16+
header "check style"
17+
ptime -m cargo xtask fmt --check

.github/buildomat/jobs/opte-api.sh

-3
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ cd crates/opte-api
2626
header "check API_VERSION"
2727
./check-api-version.sh
2828

29-
header "check style"
30-
ptime -m cargo +nightly-2024-05-12 fmt -- --check
31-
3229
header "analyze std"
3330
ptime -m cargo clippy --all-targets
3431

.github/buildomat/jobs/opte-ioctl.sh

-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,5 @@ rustc --version
2323

2424
cd lib/opte-ioctl
2525

26-
header "check style"
27-
ptime -m cargo +nightly-2024-05-12 fmt -- --check
28-
2926
header "analyze"
3027
ptime -m cargo clippy --all-targets

.github/buildomat/jobs/opte.sh

-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ rustc --version
2525

2626
cd lib/opte
2727

28-
header "check style"
29-
ptime -m cargo +nightly-2024-05-12 fmt -- --check
30-
3128
header "check docs"
3229
#
3330
# I believe this means any doc warnings in deps will cause this to

.github/buildomat/jobs/opteadm.sh

-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ rustc --version
2828

2929
pushd bin/opteadm
3030

31-
header "check style"
32-
ptime -m cargo +nightly-2024-05-12 fmt -- --check
33-
3431
header "analyze"
3532
ptime -m cargo clippy --all-targets
3633

.github/buildomat/jobs/oxide-vpc.sh

-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ rustc --version
2525

2626
cd lib/oxide-vpc
2727

28-
header "check style"
29-
ptime -m cargo +nightly-2024-05-12 fmt -- --check
30-
3128
header "check docs"
3229
#
3330
# I believe this means any doc warnings in deps will cause this to

.github/buildomat/jobs/xde.sh

-3
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ pushd xde
7878

7979
cp xde.conf /work/xde.conf
8080

81-
header "check style"
82-
ptime -m cargo +nightly-2024-05-12 fmt -p xde -p xde-link -- --check
83-
8481
header "analyze"
8582
ptime -m cargo clippy -- \
8683
--allow clippy::uninlined-format-args --allow clippy::bad_bit_mask

xtask/src/main.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ enum Xtask {
6161
},
6262

6363
/// Format the repository with `rustfmt`.
64-
Fmt,
64+
Fmt {
65+
/// Run rustfmt in check mode.
66+
#[arg(long)]
67+
check: bool,
68+
},
6569
}
6670

6771
#[derive(Debug, Args)]
@@ -140,17 +144,22 @@ fn main() -> anyhow::Result<()> {
140144

141145
Ok(())
142146
}
143-
Xtask::Fmt => {
147+
Xtask::Fmt { check } => {
144148
let meta = cargo_meta();
145149

146150
// This is explicitly `cargo` rather than CARGO as we might
147151
// be swapping toolchains to do this from the current cargo.
148-
Command::new("cargo")
149-
.arg(format!("+{}", get_current_nightly_toolchain()?))
152+
let mut c = Command::new("cargo");
153+
c.arg(format!("+{}", get_current_nightly_toolchain()?))
150154
.args(["fmt", "--all"])
151155
.env_remove("RUSTUP_TOOLCHAIN")
152-
.current_dir(&meta.workspace_root)
153-
.output_nocapture()?;
156+
.current_dir(&meta.workspace_root);
157+
158+
if check {
159+
c.arg("--check");
160+
}
161+
162+
c.output_nocapture()?;
154163

155164
Ok(())
156165
}

0 commit comments

Comments
 (0)