Skip to content

Commit

Permalink
Silence annoying rustfmt config warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
CleanCut committed Feb 23, 2021
1 parent bc4fe9b commit 545d36a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tools/ci/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
xshell = "0.1"
duct = "0.13"
34 changes: 31 additions & 3 deletions tools/ci/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,47 @@
use xshell::cmd;
use std::io::BufRead;

use duct::cmd;

fn main() {
// When run locally, results may from actual CI runs triggered by .github/workflows/ci.yml
// - Official CI runs latest stable
// - Local runs use whatever the default Rust is locally

// See if any code needs to be formatted
cmd!("cargo fmt --all -- --check")
println!("$ cargo fmt --all -- --check");
let errput = cmd!("cargo", "fmt", "--all", "--", "--check")
.stderr_capture()
.run()
.expect("Please run 'cargo fmt --all' to format your code.");
// Capture stderr, filter out lines starting with "Warning:" that complain about nightly-only
// options in rustfmt.toml -- we can remove this (and maybe switch back to `xshell` instead of
// `duct`) once either rustfmt.toml doesn't cause warnings in stable or nightly rust, or rustfmt
// learns an option to silence warnings provoked by the config file.
errput
.stderr
.lines()
.filter_map(|l| l.ok())
.filter(|l| !l.starts_with("Warning"))
.for_each(|l| eprintln!("{}", l));

// See if clippy has any complaints.
// - Type complexity must be ignored because we use huge templates for queries
// - `-A clippy::manual-strip` strip_prefix support was added in 1.45
cmd!("cargo clippy --workspace --all-targets --all-features -- -D warnings -A clippy::type_complexity -A clippy::manual-strip")
println!("$ cargo clippy --workspace --all-targets --all-features -- -D warnings -A clippy::type_complexity -A clippy::manual-strip");
cmd!(
"cargo",
"clippy",
"--workspace",
"--all-targets",
"--all-features",
"--",
"-D",
"warnings",
"-A",
"clippy::type_complexity",
"-A",
"clippy::manual-strip"
)
.run()
.expect("Please fix clippy errors in output above.");
}

0 comments on commit 545d36a

Please sign in to comment.