diff --git a/tools/ci/Cargo.toml b/tools/ci/Cargo.toml index baf019789570e..a52dfa40a73d1 100644 --- a/tools/ci/Cargo.toml +++ b/tools/ci/Cargo.toml @@ -8,7 +8,6 @@ license = "MIT OR Apache-2.0" [dependencies] argh = "0.1" xshell = "0.2" -bitflags = "2.3" [lints] workspace = true diff --git a/tools/ci/src/args.rs b/tools/ci/src/args.rs new file mode 100644 index 0000000000000..c18500f7d10db --- /dev/null +++ b/tools/ci/src/args.rs @@ -0,0 +1,7 @@ +/// Arguments that are available to CI commands. +#[derive(Copy, Clone, PartialEq, Eq)] +pub struct Args { + pub keep_going: bool, + pub test_threads: Option, + pub jobs: Option, +} diff --git a/tools/ci/src/ci.rs b/tools/ci/src/ci.rs index 043a887e37ec7..86bc7c2828381 100644 --- a/tools/ci/src/ci.rs +++ b/tools/ci/src/ci.rs @@ -1,6 +1,7 @@ use crate::{ + args::Args, commands, - prepare::{Flag, Prepare, PreparedCommand}, + prepare::{Prepare, PreparedCommand}, }; use argh::FromArgs; @@ -13,6 +14,24 @@ pub struct CI { /// continue running commands even if one fails #[argh(switch)] keep_going: bool, + + /// parallelism of `cargo test` + #[argh(option)] + test_threads: Option, + + /// number of build jobs + #[argh(option)] + jobs: Option, +} + +impl From<&CI> for Args { + fn from(value: &CI) -> Self { + Args { + keep_going: value.keep_going, + test_threads: value.test_threads, + jobs: value.jobs, + } + } } impl CI { @@ -22,7 +41,6 @@ impl CI { /// This is usually related to differing toolchains and configuration. pub fn run(self) { let sh = xshell::Shell::new().unwrap(); - let prepared_commands = self.prepare(&sh); let mut failures = vec![]; @@ -59,28 +77,23 @@ impl CI { } fn prepare<'a>(&self, sh: &'a xshell::Shell) -> Vec> { - let mut flags = Flag::empty(); - - if self.keep_going { - flags |= Flag::KEEP_GOING; - } - + let args = self.into(); match &self.command { - Some(command) => command.prepare(sh, flags), + Some(command) => command.prepare(sh, args), None => { // Note that we are running the subcommands directly rather than using any aliases let mut cmds = vec![]; - cmds.append(&mut commands::FormatCommand::default().prepare(sh, flags)); - cmds.append(&mut commands::ClippyCommand::default().prepare(sh, flags)); - cmds.append(&mut commands::TestCommand::default().prepare(sh, flags)); - cmds.append(&mut commands::TestCheckCommand::default().prepare(sh, flags)); - cmds.append(&mut commands::DocCheckCommand::default().prepare(sh, flags)); - cmds.append(&mut commands::DocTestCommand::default().prepare(sh, flags)); - cmds.append(&mut commands::CompileCheckCommand::default().prepare(sh, flags)); - cmds.append(&mut commands::CompileCheckNoStdCommand::default().prepare(sh, flags)); - cmds.append(&mut commands::CompileFailCommand::default().prepare(sh, flags)); - cmds.append(&mut commands::BenchCheckCommand::default().prepare(sh, flags)); - cmds.append(&mut commands::ExampleCheckCommand::default().prepare(sh, flags)); + cmds.append(&mut commands::FormatCommand::default().prepare(sh, args)); + cmds.append(&mut commands::ClippyCommand::default().prepare(sh, args)); + cmds.append(&mut commands::TestCommand::default().prepare(sh, args)); + cmds.append(&mut commands::TestCheckCommand::default().prepare(sh, args)); + cmds.append(&mut commands::DocCheckCommand::default().prepare(sh, args)); + cmds.append(&mut commands::DocTestCommand::default().prepare(sh, args)); + cmds.append(&mut commands::CompileCheckCommand::default().prepare(sh, args)); + cmds.append(&mut commands::CompileCheckNoStdCommand::default().prepare(sh, args)); + cmds.append(&mut commands::CompileFailCommand::default().prepare(sh, args)); + cmds.append(&mut commands::BenchCheckCommand::default().prepare(sh, args)); + cmds.append(&mut commands::ExampleCheckCommand::default().prepare(sh, args)); cmds } } @@ -110,23 +123,23 @@ enum Commands { } impl Prepare for Commands { - fn prepare<'a>(&self, sh: &'a xshell::Shell, flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { match self { - Commands::Lints(subcommand) => subcommand.prepare(sh, flags), - Commands::Doc(subcommand) => subcommand.prepare(sh, flags), - Commands::Compile(subcommand) => subcommand.prepare(sh, flags), - - Commands::Format(subcommand) => subcommand.prepare(sh, flags), - Commands::Clippy(subcommand) => subcommand.prepare(sh, flags), - Commands::Test(subcommand) => subcommand.prepare(sh, flags), - Commands::TestCheck(subcommand) => subcommand.prepare(sh, flags), - Commands::DocCheck(subcommand) => subcommand.prepare(sh, flags), - Commands::DocTest(subcommand) => subcommand.prepare(sh, flags), - Commands::CompileCheck(subcommand) => subcommand.prepare(sh, flags), - Commands::CompileCheckNoStd(subcommand) => subcommand.prepare(sh, flags), - Commands::CompileFail(subcommand) => subcommand.prepare(sh, flags), - Commands::BenchCheck(subcommand) => subcommand.prepare(sh, flags), - Commands::ExampleCheck(subcommand) => subcommand.prepare(sh, flags), + Commands::Lints(subcommand) => subcommand.prepare(sh, args), + Commands::Doc(subcommand) => subcommand.prepare(sh, args), + Commands::Compile(subcommand) => subcommand.prepare(sh, args), + + Commands::Format(subcommand) => subcommand.prepare(sh, args), + Commands::Clippy(subcommand) => subcommand.prepare(sh, args), + Commands::Test(subcommand) => subcommand.prepare(sh, args), + Commands::TestCheck(subcommand) => subcommand.prepare(sh, args), + Commands::DocCheck(subcommand) => subcommand.prepare(sh, args), + Commands::DocTest(subcommand) => subcommand.prepare(sh, args), + Commands::CompileCheck(subcommand) => subcommand.prepare(sh, args), + Commands::CompileCheckNoStd(subcommand) => subcommand.prepare(sh, args), + Commands::CompileFail(subcommand) => subcommand.prepare(sh, args), + Commands::BenchCheck(subcommand) => subcommand.prepare(sh, args), + Commands::ExampleCheck(subcommand) => subcommand.prepare(sh, args), } } } diff --git a/tools/ci/src/commands/bench_check.rs b/tools/ci/src/commands/bench_check.rs index 9e72ab0a64ec3..19f43f72742c9 100644 --- a/tools/ci/src/commands/bench_check.rs +++ b/tools/ci/src/commands/bench_check.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -8,11 +8,16 @@ use xshell::cmd; pub struct BenchCheckCommand {} impl Prepare for BenchCheckCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { + let jobs = args + .jobs + .map(|jobs| format!(" --jobs {jobs}")) + .unwrap_or_default(); + vec![PreparedCommand::new::( cmd!( sh, - "cargo check --benches --target-dir ../target --manifest-path ./benches/Cargo.toml" + "cargo check --benches --target-dir ../target --manifest-path ./benches/Cargo.toml{jobs}" ), "Failed to check the benches.", )] diff --git a/tools/ci/src/commands/clippy.rs b/tools/ci/src/commands/clippy.rs index 5e097c05a13fb..cf6f68e2284ba 100644 --- a/tools/ci/src/commands/clippy.rs +++ b/tools/ci/src/commands/clippy.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -8,11 +8,16 @@ use xshell::cmd; pub struct ClippyCommand {} impl Prepare for ClippyCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { + let jobs = args + .jobs + .map(|jobs| format!(" --jobs {jobs}")) + .unwrap_or_default(); + vec![PreparedCommand::new::( cmd!( sh, - "cargo clippy --workspace --all-targets --all-features -- -Dwarnings" + "cargo clippy --workspace --all-targets --all-features{jobs} -- -Dwarnings" ), "Please fix clippy errors in output above.", )] diff --git a/tools/ci/src/commands/compile.rs b/tools/ci/src/commands/compile.rs index f3fcefabb153e..dab0e6d59b60c 100644 --- a/tools/ci/src/commands/compile.rs +++ b/tools/ci/src/commands/compile.rs @@ -1,9 +1,10 @@ use crate::{ + args::Args, commands::{ BenchCheckCommand, CompileCheckCommand, CompileFailCommand, ExampleCheckCommand, TestCheckCommand, }, - Flag, Prepare, PreparedCommand, + Prepare, PreparedCommand, }; use argh::FromArgs; @@ -13,13 +14,13 @@ use argh::FromArgs; pub struct CompileCommand {} impl Prepare for CompileCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { let mut commands = vec![]; - commands.append(&mut CompileFailCommand::default().prepare(sh, flags)); - commands.append(&mut BenchCheckCommand::default().prepare(sh, flags)); - commands.append(&mut ExampleCheckCommand::default().prepare(sh, flags)); - commands.append(&mut CompileCheckCommand::default().prepare(sh, flags)); - commands.append(&mut TestCheckCommand::default().prepare(sh, flags)); + commands.append(&mut CompileFailCommand::default().prepare(sh, args)); + commands.append(&mut BenchCheckCommand::default().prepare(sh, args)); + commands.append(&mut ExampleCheckCommand::default().prepare(sh, args)); + commands.append(&mut CompileCheckCommand::default().prepare(sh, args)); + commands.append(&mut TestCheckCommand::default().prepare(sh, args)); commands } } diff --git a/tools/ci/src/commands/compile_check.rs b/tools/ci/src/commands/compile_check.rs index 62d8a8da75475..be4f8ab432daa 100644 --- a/tools/ci/src/commands/compile_check.rs +++ b/tools/ci/src/commands/compile_check.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -8,9 +8,14 @@ use xshell::cmd; pub struct CompileCheckCommand {} impl Prepare for CompileCheckCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { + let jobs = args + .jobs + .map(|jobs| format!(" --jobs {jobs}")) + .unwrap_or_default(); + vec![PreparedCommand::new::( - cmd!(sh, "cargo check --workspace"), + cmd!(sh, "cargo check --workspace{jobs}"), "Please fix compiler errors in output above.", )] } diff --git a/tools/ci/src/commands/compile_check_no_std.rs b/tools/ci/src/commands/compile_check_no_std.rs index 83c9aec0d062e..919203f29db22 100644 --- a/tools/ci/src/commands/compile_check_no_std.rs +++ b/tools/ci/src/commands/compile_check_no_std.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -27,7 +27,12 @@ impl Default for CompileCheckNoStdCommand { } impl Prepare for CompileCheckNoStdCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { + let jobs = args + .jobs + .map(|jobs| format!(" --jobs {jobs}")) + .unwrap_or_default(); + let target = self.target.as_str(); let mut commands = Vec::new(); @@ -41,7 +46,7 @@ impl Prepare for CompileCheckNoStdCommand { commands.push(PreparedCommand::new::( cmd!( sh, - "cargo check -p bevy_ptr --no-default-features --target {target}" + "cargo check -p bevy_ptr --no-default-features --target {target}{jobs}" ), "Please fix compiler errors in output above for bevy_ptr no_std compatibility.", )); @@ -49,7 +54,7 @@ impl Prepare for CompileCheckNoStdCommand { commands.push(PreparedCommand::new::( cmd!( sh, - "cargo check -p bevy_utils --no-default-features --target {target}" + "cargo check -p bevy_utils --no-default-features --target {target}{jobs}" ), "Please fix compiler errors in output above for bevy_utils no_std compatibility.", )); @@ -57,7 +62,7 @@ impl Prepare for CompileCheckNoStdCommand { commands.push(PreparedCommand::new::( cmd!( sh, - "cargo check -p bevy_mikktspace --no-default-features --features libm --target {target}" + "cargo check -p bevy_mikktspace --no-default-features --features libm --target {target}{jobs}" ), "Please fix compiler errors in output above for bevy_mikktspace no_std compatibility.", )); diff --git a/tools/ci/src/commands/compile_fail.rs b/tools/ci/src/commands/compile_fail.rs index 65a91e6d2f039..906f0d4811766 100644 --- a/tools/ci/src/commands/compile_fail.rs +++ b/tools/ci/src/commands/compile_fail.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -8,9 +8,9 @@ use xshell::cmd; pub struct CompileFailCommand {} impl Prepare for CompileFailCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, flags: Flag) -> Vec> { - let no_fail_fast = flags - .contains(Flag::KEEP_GOING) + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { + let no_fail_fast = args + .keep_going .then_some("--no-fail-fast") .unwrap_or_default(); diff --git a/tools/ci/src/commands/doc.rs b/tools/ci/src/commands/doc.rs index fb8074ca8cf48..90fbbd30a592b 100644 --- a/tools/ci/src/commands/doc.rs +++ b/tools/ci/src/commands/doc.rs @@ -1,6 +1,7 @@ use crate::{ + args::Args, commands::{DocCheckCommand, DocTestCommand}, - Flag, Prepare, PreparedCommand, + Prepare, PreparedCommand, }; use argh::FromArgs; @@ -10,10 +11,10 @@ use argh::FromArgs; pub struct DocCommand {} impl Prepare for DocCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { let mut commands = vec![]; - commands.append(&mut DocTestCommand::default().prepare(sh, flags)); - commands.append(&mut DocCheckCommand::default().prepare(sh, flags)); + commands.append(&mut DocTestCommand::default().prepare(sh, args)); + commands.append(&mut DocCheckCommand::default().prepare(sh, args)); commands } } diff --git a/tools/ci/src/commands/doc_check.rs b/tools/ci/src/commands/doc_check.rs index ef5fc502df579..6ba3859ce477b 100644 --- a/tools/ci/src/commands/doc_check.rs +++ b/tools/ci/src/commands/doc_check.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -8,7 +8,7 @@ use xshell::cmd; pub struct DocCheckCommand {} impl Prepare for DocCheckCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, _args: Args) -> Vec> { vec![PreparedCommand::new::( cmd!( sh, diff --git a/tools/ci/src/commands/doc_test.rs b/tools/ci/src/commands/doc_test.rs index c1ce22c3e64a7..db99f82237fb2 100644 --- a/tools/ci/src/commands/doc_test.rs +++ b/tools/ci/src/commands/doc_test.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -8,14 +8,27 @@ use xshell::cmd; pub struct DocTestCommand {} impl Prepare for DocTestCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, flags: Flag) -> Vec> { - let no_fail_fast = flags - .contains(Flag::KEEP_GOING) + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { + let no_fail_fast = args + .keep_going .then_some("--no-fail-fast") .unwrap_or_default(); + let jobs = args + .jobs + .map(|jobs| format!(" --jobs {jobs}")) + .unwrap_or_default(); + + let test_threads = args + .test_threads + .map(|test_threads| format!("--test-threads={test_threads}")) + .unwrap_or_default(); + vec![PreparedCommand::new::( - cmd!(sh, "cargo test --workspace --doc {no_fail_fast}"), + cmd!( + sh, + "cargo test --workspace --doc {no_fail_fast}{jobs} -- {test_threads}" + ), "Please fix failing doc tests in output above.", )] } diff --git a/tools/ci/src/commands/example_check.rs b/tools/ci/src/commands/example_check.rs index d3d3f5ddf29be..ab7740cd41239 100644 --- a/tools/ci/src/commands/example_check.rs +++ b/tools/ci/src/commands/example_check.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -8,9 +8,14 @@ use xshell::cmd; pub struct ExampleCheckCommand {} impl Prepare for ExampleCheckCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { + let jobs = args + .jobs + .map(|jobs| format!(" --jobs {jobs}")) + .unwrap_or_default(); + vec![PreparedCommand::new::( - cmd!(sh, "cargo check --workspace --examples"), + cmd!(sh, "cargo check --workspace --examples{jobs}"), "Please fix compiler errors for examples in output above.", )] } diff --git a/tools/ci/src/commands/format.rs b/tools/ci/src/commands/format.rs index f5aacc53012e8..a6ae00cf1f930 100644 --- a/tools/ci/src/commands/format.rs +++ b/tools/ci/src/commands/format.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -8,7 +8,7 @@ use xshell::cmd; pub struct FormatCommand {} impl Prepare for FormatCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, _args: Args) -> Vec> { vec![PreparedCommand::new::( cmd!(sh, "cargo fmt --all -- --check"), "Please run 'cargo fmt --all' to format your code.", diff --git a/tools/ci/src/commands/lints.rs b/tools/ci/src/commands/lints.rs index befdaf5fc5d48..f21bb1b8ef217 100644 --- a/tools/ci/src/commands/lints.rs +++ b/tools/ci/src/commands/lints.rs @@ -1,6 +1,7 @@ use crate::{ + args::Args, commands::{ClippyCommand, FormatCommand}, - Flag, Prepare, PreparedCommand, + Prepare, PreparedCommand, }; use argh::FromArgs; @@ -10,10 +11,10 @@ use argh::FromArgs; pub struct LintsCommand {} impl Prepare for LintsCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { let mut commands = vec![]; - commands.append(&mut FormatCommand::default().prepare(sh, flags)); - commands.append(&mut ClippyCommand::default().prepare(sh, flags)); + commands.append(&mut FormatCommand::default().prepare(sh, args)); + commands.append(&mut ClippyCommand::default().prepare(sh, args)); commands } } diff --git a/tools/ci/src/commands/test.rs b/tools/ci/src/commands/test.rs index bdb4b663d1429..9c737db545468 100644 --- a/tools/ci/src/commands/test.rs +++ b/tools/ci/src/commands/test.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -8,18 +8,28 @@ use xshell::cmd; pub struct TestCommand {} impl Prepare for TestCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, flags: Flag) -> Vec> { - let no_fail_fast = flags - .contains(Flag::KEEP_GOING) + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { + let no_fail_fast = args + .keep_going .then_some("--no-fail-fast") .unwrap_or_default(); + let jobs = args + .jobs + .map(|jobs| format!(" --jobs {jobs}")) + .unwrap_or_default(); + + let test_threads = args + .test_threads + .map(|test_threads| format!(" -- --test-threads={test_threads}")) + .unwrap_or_default(); + vec![PreparedCommand::new::( cmd!( sh, // `--benches` runs each benchmark once in order to verify that they behave // correctly and do not panic. - "cargo test --workspace --lib --bins --tests --benches {no_fail_fast}" + "cargo test --workspace --lib --bins --tests --benches {no_fail_fast}{jobs}{test_threads}" ), "Please fix failing tests in output above.", )] diff --git a/tools/ci/src/commands/test_check.rs b/tools/ci/src/commands/test_check.rs index 81f11c214a8fa..270f35c1770d1 100644 --- a/tools/ci/src/commands/test_check.rs +++ b/tools/ci/src/commands/test_check.rs @@ -1,4 +1,4 @@ -use crate::{Flag, Prepare, PreparedCommand}; +use crate::{args::Args, Prepare, PreparedCommand}; use argh::FromArgs; use xshell::cmd; @@ -8,9 +8,14 @@ use xshell::cmd; pub struct TestCheckCommand {} impl Prepare for TestCheckCommand { - fn prepare<'a>(&self, sh: &'a xshell::Shell, _flags: Flag) -> Vec> { + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec> { + let jobs = args + .jobs + .map(|jobs| format!(" --jobs {jobs}")) + .unwrap_or_default(); + vec![PreparedCommand::new::( - cmd!(sh, "cargo check --workspace --tests"), + cmd!(sh, "cargo check --workspace --tests{jobs}"), "Please fix compiler examples for tests in output above.", )] } diff --git a/tools/ci/src/main.rs b/tools/ci/src/main.rs index 40893a528d4cd..7758fc9202317 100644 --- a/tools/ci/src/main.rs +++ b/tools/ci/src/main.rs @@ -1,5 +1,6 @@ //! CI script used for Bevy. +mod args; mod ci; mod commands; mod prepare; diff --git a/tools/ci/src/prepare.rs b/tools/ci/src/prepare.rs index 923bc33f8012f..b3a3d8f5688f5 100644 --- a/tools/ci/src/prepare.rs +++ b/tools/ci/src/prepare.rs @@ -1,4 +1,4 @@ -use bitflags::bitflags; +use crate::args::Args; /// Trait for preparing a subcommand to be run. pub trait Prepare { @@ -7,7 +7,7 @@ pub trait Prepare { /// # Example /// /// ``` - /// # use crate::{Flag, Prepare, PreparedCommand}; + /// # use crate::{args::Args, Prepare, PreparedCommand}; /// # use argh::FromArgs; /// # use xshell::Shell; /// # @@ -16,7 +16,7 @@ pub trait Prepare { /// struct CheckCommand {} /// /// impl Prepare for CheckCommand { - /// fn prepare<'a>(&self, sh: &'a Shell, flags: Flag) -> Vec> { + /// fn prepare<'a>(&self, sh: &'a Shell, args: Args) -> Vec> { /// vec![PreparedCommand::new::( /// cmd!(sh, "cargo check --workspace"), /// "Please fix linter errors", @@ -24,16 +24,7 @@ pub trait Prepare { /// } /// } /// ``` - fn prepare<'a>(&self, sh: &'a xshell::Shell, flags: Flag) -> Vec>; -} - -bitflags! { - /// Flags that modify how commands are run. - #[derive(Clone, Copy, Debug, PartialEq, Eq)] - pub struct Flag: u32 { - /// Forces certain checks to continue running even if they hit an error. - const KEEP_GOING = 1 << 0; - } + fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec>; } /// A command with associated metadata, created from a command that implements [`Prepare`].