zellij/xtask/src/clippy.rs
Thomas Linford f598ca3738
improve build/ci times (#2396)
- avoid building all workspace crates with `cargo x build` (only plugins and main binary)
- only set the target triple in tests for plugins
- add new profile for `cargo x run` to build with optimized dependencies => FAST plugins when developing (thanks [Bevy Book](https://bevyengine.org/learn/book/getting-started/setup/#compile-with-performance-optimizations) for the idea)
- use https://github.com/Swatinem/rust-cache to avoid rebuilding dependencies every time in ci
- split `Build & Test` job into two so they run in parallel
- hopefully improve the flaky tests situation, this also makes the e2e tests run much faster (some tests produced correct snapshots but had some logic errors causing them to loop for much longer than necessary). Add some output to the tests so it is easier to see if something goes wrong.
- remove verbose build output from e2e test build
2023-05-03 21:16:38 +02:00

43 lines
1.3 KiB
Rust

//! Handle running `cargo clippy` on the sources.
use crate::{build, flags, WorkspaceMember};
use anyhow::Context;
use std::path::{Path, PathBuf};
use xshell::{cmd, Shell};
pub fn clippy(sh: &Shell, _flags: flags::Clippy) -> anyhow::Result<()> {
let _pd = sh.push_dir(crate::project_root());
build::build(
sh,
flags::Build {
release: false,
no_plugins: false,
plugins_only: true,
},
)
.context("failed to run task 'clippy'")?;
let cargo = check_clippy()
.and_then(|_| crate::cargo())
.context("failed to run task 'clippy'")?;
for WorkspaceMember { crate_name, .. } in crate::WORKSPACE_MEMBERS.iter() {
let _pd = sh.push_dir(Path::new(crate_name));
// Tell the user where we are now
println!();
let msg = format!(">> Running clippy on '{crate_name}'");
crate::status(&msg);
println!("{}", msg);
cmd!(sh, "{cargo} clippy --all-targets --all-features")
.run()
.with_context(|| format!("failed to run task 'clippy' on '{crate_name}'"))?;
}
Ok(())
}
fn check_clippy() -> anyhow::Result<PathBuf> {
which::which("cargo-clippy").context(
"Couldn't find 'clippy' executable. Please install it with `rustup component add clippy`",
)
}