Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - Silence annoying rustfmt config warnings #1508

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[alias]
CleanCut marked this conversation as resolved.
Show resolved Hide resolved
ci = "run --package ci"
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:

- name: Check the format
# See tools/ci/src/main.rs for the commands this runs
run: cargo run --package ci
run: cargo ci
if: runner.os == 'linux' && matrix.toolchain == 'stable'

- name: Build & run tests
Expand Down
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"
36 changes: 32 additions & 4 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
// When run locally, results may differ 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")
CleanCut marked this conversation as resolved.
Show resolved Hide resolved
.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"))
CleanCut marked this conversation as resolved.
Show resolved Hide resolved
.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.");
}