Skip to content

Commit

Permalink
Move style checks up to top-level fmt xtask.
Browse files Browse the repository at this point in the history
I'm in the CI weeds anyway, better make something that fails
extraordinarily quickly.
  • Loading branch information
FelixMcFelix committed Jul 19, 2024
1 parent bccfd77 commit b5c7c91
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 24 deletions.
17 changes: 17 additions & 0 deletions .github/buildomat/jobs/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
#:
#: name = "lint"
#: variety = "basic"
#: target = "helios-2.0"
#: rust_toolchain = "nightly-2024-05-12"
#: access_repos = [
#: "oxidecomputer/illumos-rs",
#: ]
#:

set -o errexit
set -o pipefail
set -o xtrace

header "check style"
ptime -m cargo xtask fmt --check
3 changes: 0 additions & 3 deletions .github/buildomat/jobs/opte-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ cd crates/opte-api
header "check API_VERSION"
./check-api-version.sh

header "check style"
ptime -m cargo +nightly-2024-05-12 fmt -- --check

header "analyze std"
ptime -m cargo clippy --all-targets

Expand Down
3 changes: 0 additions & 3 deletions .github/buildomat/jobs/opte-ioctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,5 @@ rustc --version

cd lib/opte-ioctl

header "check style"
ptime -m cargo +nightly-2024-05-12 fmt -- --check

header "analyze"
ptime -m cargo clippy --all-targets
3 changes: 0 additions & 3 deletions .github/buildomat/jobs/opte.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ rustc --version

cd lib/opte

header "check style"
ptime -m cargo +nightly-2024-05-12 fmt -- --check

header "check docs"
#
# I believe this means any doc warnings in deps will cause this to
Expand Down
3 changes: 0 additions & 3 deletions .github/buildomat/jobs/opteadm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ rustc --version

pushd bin/opteadm

header "check style"
ptime -m cargo +nightly-2024-05-12 fmt -- --check

header "analyze"
ptime -m cargo clippy --all-targets

Expand Down
3 changes: 0 additions & 3 deletions .github/buildomat/jobs/oxide-vpc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ rustc --version

cd lib/oxide-vpc

header "check style"
ptime -m cargo +nightly-2024-05-12 fmt -- --check

header "check docs"
#
# I believe this means any doc warnings in deps will cause this to
Expand Down
3 changes: 0 additions & 3 deletions .github/buildomat/jobs/xde.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ pushd xde

cp xde.conf /work/xde.conf

header "check style"
ptime -m cargo +nightly-2024-05-12 fmt -p xde -p xde-link -- --check

header "analyze"
ptime -m cargo clippy -- \
--allow clippy::uninlined-format-args --allow clippy::bad_bit_mask
Expand Down
21 changes: 15 additions & 6 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ enum Xtask {
},

/// Format the repository with `rustfmt`.
Fmt,
Fmt {
/// Run rustfmt in check mode.
#[arg(long)]
check: bool,
},
}

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

Ok(())
}
Xtask::Fmt => {
Xtask::Fmt { check } => {
let meta = cargo_meta();

// This is explicitly `cargo` rather than CARGO as we might
// be swapping toolchains to do this from the current cargo.
Command::new("cargo")
.arg(format!("+{}", get_current_nightly_toolchain()?))
let mut c = Command::new("cargo");
c.arg(format!("+{}", get_current_nightly_toolchain()?))
.args(["fmt", "--all"])
.env_remove("RUSTUP_TOOLCHAIN")
.current_dir(&meta.workspace_root)
.output_nocapture()?;
.current_dir(&meta.workspace_root);

if check {
c.arg("--check");
}

c.output_nocapture()?;

Ok(())
}
Expand Down

0 comments on commit b5c7c91

Please sign in to comment.