- 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
36 lines
1.1 KiB
Rust
36 lines
1.1 KiB
Rust
//! Handle running `cargo fmt` on the sources.
|
|
use crate::{flags, WorkspaceMember};
|
|
use anyhow::Context;
|
|
use std::path::{Path, PathBuf};
|
|
use xshell::{cmd, Shell};
|
|
|
|
pub fn format(sh: &Shell, flags: flags::Format) -> anyhow::Result<()> {
|
|
let _pd = sh.push_dir(crate::project_root());
|
|
|
|
let cargo = check_rustfmt()
|
|
.and_then(|_| crate::cargo())
|
|
.context("failed to run task 'format'")?;
|
|
|
|
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!(">> Formatting '{crate_name}'");
|
|
crate::status(&msg);
|
|
println!("{}", msg);
|
|
|
|
let mut cmd = cmd!(sh, "{cargo} fmt");
|
|
if flags.check {
|
|
cmd = cmd.arg("--check");
|
|
}
|
|
cmd.run()
|
|
.with_context(|| format!("Failed to format '{crate_name}'"))?;
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
fn check_rustfmt() -> anyhow::Result<PathBuf> {
|
|
which::which("rustfmt").context(
|
|
"Couldn't find 'rustfmt' executable. Please install it with `cargo install rustfmt`",
|
|
)
|
|
}
|