mirror of
https://github.com/bevyengine/bevy
synced 2025-02-17 14:38:34 +00:00
use --jobs
This commit is contained in:
parent
e2c30c3320
commit
3a06f8e1a5
12 changed files with 78 additions and 31 deletions
|
@ -1,5 +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<u8>,
|
||||
pub test_threads: Option<usize>,
|
||||
pub jobs: Option<i32>,
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ pub struct CI {
|
|||
|
||||
/// parallelism of `cargo test`
|
||||
#[argh(option)]
|
||||
test_threads: Option<u8>,
|
||||
test_threads: Option<usize>,
|
||||
|
||||
/// sets `RUST_BUILD_JOBS`
|
||||
/// number of build jobs
|
||||
#[argh(option)]
|
||||
build_jobs: Option<u8>,
|
||||
jobs: Option<i32>,
|
||||
}
|
||||
|
||||
impl From<&CI> for Args {
|
||||
|
@ -29,6 +29,7 @@ impl From<&CI> for Args {
|
|||
Args {
|
||||
keep_going: value.keep_going,
|
||||
test_threads: value.test_threads,
|
||||
jobs: value.jobs,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,14 +41,8 @@ impl CI {
|
|||
/// This is usually related to differing toolchains and configuration.
|
||||
pub fn run(self) {
|
||||
let sh = xshell::Shell::new().unwrap();
|
||||
let mut prepared_commands = self.prepare(&sh);
|
||||
let prepared_commands = self.prepare(&sh);
|
||||
|
||||
if let Some(build_jobs) = self.build_jobs {
|
||||
prepared_commands = prepared_commands
|
||||
.into_iter()
|
||||
.map(|pc| pc.with_env_var("RUST_BUILD_JOBS", build_jobs.to_string().leak()))
|
||||
.collect();
|
||||
}
|
||||
let mut failures = vec![];
|
||||
|
||||
for command in prepared_commands {
|
||||
|
|
|
@ -8,11 +8,16 @@ use xshell::cmd;
|
|||
pub struct BenchCheckCommand {}
|
||||
|
||||
impl Prepare for BenchCheckCommand {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
let jobs = args
|
||||
.jobs
|
||||
.map(|jobs| format!("--jobs {jobs}"))
|
||||
.unwrap_or_default();
|
||||
|
||||
vec![PreparedCommand::new::<Self>(
|
||||
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.",
|
||||
)]
|
||||
|
|
|
@ -8,11 +8,16 @@ use xshell::cmd;
|
|||
pub struct ClippyCommand {}
|
||||
|
||||
impl Prepare for ClippyCommand {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
let jobs = args
|
||||
.jobs
|
||||
.map(|jobs| format!("--jobs {jobs}"))
|
||||
.unwrap_or_default();
|
||||
|
||||
vec![PreparedCommand::new::<Self>(
|
||||
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.",
|
||||
)]
|
||||
|
|
|
@ -8,9 +8,14 @@ use xshell::cmd;
|
|||
pub struct CompileCheckCommand {}
|
||||
|
||||
impl Prepare for CompileCheckCommand {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
let jobs = args
|
||||
.jobs
|
||||
.map(|jobs| format!("--jobs {jobs}"))
|
||||
.unwrap_or_default();
|
||||
|
||||
vec![PreparedCommand::new::<Self>(
|
||||
cmd!(sh, "cargo check --workspace"),
|
||||
cmd!(sh, "cargo check --workspace {jobs}"),
|
||||
"Please fix compiler errors in output above.",
|
||||
)]
|
||||
}
|
||||
|
|
|
@ -27,7 +27,12 @@ impl Default for CompileCheckNoStdCommand {
|
|||
}
|
||||
|
||||
impl Prepare for CompileCheckNoStdCommand {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
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::<Self>(
|
||||
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::<Self>(
|
||||
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::<Self>(
|
||||
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.",
|
||||
));
|
||||
|
|
|
@ -8,11 +8,16 @@ use xshell::cmd;
|
|||
pub struct DocCheckCommand {}
|
||||
|
||||
impl Prepare for DocCheckCommand {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
let jobs = args
|
||||
.jobs
|
||||
.map(|jobs| format!("--jobs {jobs}"))
|
||||
.unwrap_or_default();
|
||||
|
||||
vec![PreparedCommand::new::<Self>(
|
||||
cmd!(
|
||||
sh,
|
||||
"cargo doc --workspace --all-features --no-deps --document-private-items --keep-going"
|
||||
"cargo doc --workspace --all-features --no-deps --document-private-items --keep-going {jobs}"
|
||||
),
|
||||
"Please fix doc warnings in output above.",
|
||||
)
|
||||
|
|
|
@ -14,6 +14,11 @@ impl Prepare for DocTestCommand {
|
|||
.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}"))
|
||||
|
@ -22,7 +27,7 @@ impl Prepare for DocTestCommand {
|
|||
vec![PreparedCommand::new::<Self>(
|
||||
cmd!(
|
||||
sh,
|
||||
"cargo test --workspace --doc {no_fail_fast} -- {test_threads}"
|
||||
"cargo test --workspace --doc {no_fail_fast} {jobs} -- {test_threads}"
|
||||
),
|
||||
"Please fix failing doc tests in output above.",
|
||||
)]
|
||||
|
|
|
@ -8,9 +8,14 @@ use xshell::cmd;
|
|||
pub struct ExampleCheckCommand {}
|
||||
|
||||
impl Prepare for ExampleCheckCommand {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
let jobs = args
|
||||
.jobs
|
||||
.map(|jobs| format!("--jobs {jobs}"))
|
||||
.unwrap_or_default();
|
||||
|
||||
vec![PreparedCommand::new::<Self>(
|
||||
cmd!(sh, "cargo check --workspace --examples"),
|
||||
cmd!(sh, "cargo check --workspace --examples {jobs}"),
|
||||
"Please fix compiler errors for examples in output above.",
|
||||
)]
|
||||
}
|
||||
|
|
|
@ -8,9 +8,14 @@ use xshell::cmd;
|
|||
pub struct FormatCommand {}
|
||||
|
||||
impl Prepare for FormatCommand {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
let jobs = args
|
||||
.jobs
|
||||
.map(|jobs| format!("--jobs {jobs}"))
|
||||
.unwrap_or_default();
|
||||
|
||||
vec![PreparedCommand::new::<Self>(
|
||||
cmd!(sh, "cargo fmt --all -- --check"),
|
||||
cmd!(sh, "cargo fmt --all {jobs} -- --check"),
|
||||
"Please run 'cargo fmt --all' to format your code.",
|
||||
)]
|
||||
}
|
||||
|
|
|
@ -14,6 +14,11 @@ impl Prepare for TestCommand {
|
|||
.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}"))
|
||||
|
@ -22,7 +27,7 @@ impl Prepare for TestCommand {
|
|||
vec![PreparedCommand::new::<Self>(
|
||||
cmd!(
|
||||
sh,
|
||||
"cargo test --workspace --lib --bins --tests --benches {no_fail_fast} -- {test_threads}"
|
||||
"cargo test --workspace --lib --bins --tests --benches {no_fail_fast} {jobs} -- {test_threads}"
|
||||
),
|
||||
"Please fix failing tests in output above.",
|
||||
)]
|
||||
|
|
|
@ -8,9 +8,14 @@ use xshell::cmd;
|
|||
pub struct TestCheckCommand {}
|
||||
|
||||
impl Prepare for TestCheckCommand {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, _args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
fn prepare<'a>(&self, sh: &'a xshell::Shell, args: Args) -> Vec<PreparedCommand<'a>> {
|
||||
let jobs = args
|
||||
.jobs
|
||||
.map(|jobs| format!("--jobs {jobs}"))
|
||||
.unwrap_or_default();
|
||||
|
||||
vec![PreparedCommand::new::<Self>(
|
||||
cmd!(sh, "cargo check --workspace --tests"),
|
||||
cmd!(sh, "cargo check --workspace --tests {jobs}"),
|
||||
"Please fix compiler examples for tests in output above.",
|
||||
)]
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue