bevy/tools/ci/src/args.rs
Lucas Franca c8cb7bdf57
Allow passing number of thread for building and testing to CI (#19359)
# Objective

Fixes #16051
Closes #16145

## Solution

Allow passing `--build-jobs` and `--test-threads` to `ci`
i.e.
```
cargo run -p ci -- --build-jobs 4 --test-threads 4
```

## Testing

running ci locally

---------

Co-authored-by: Benjamin Brienen <Benjamin.Brienen@outlook.com>
2025-06-16 21:19:47 +00:00

38 lines
892 B
Rust

use crate::CI;
/// Arguments that are available to CI commands.
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Args {
keep_going: bool,
test_threads: Option<usize>,
build_jobs: Option<usize>,
}
impl Args {
#[inline(always)]
pub fn keep_going(&self) -> Option<&'static str> {
self.keep_going.then_some("--no-fail-fast")
}
#[inline(always)]
pub fn build_jobs(&self) -> Option<String> {
self.build_jobs.map(|jobs| format!("--jobs={jobs}"))
}
#[inline(always)]
pub fn test_threads(&self) -> Option<String> {
self.test_threads
.map(|threads| format!("--test-threads={threads}"))
}
}
impl From<&CI> for Args {
fn from(value: &CI) -> Self {
Args {
keep_going: value.keep_going,
test_threads: value.test_threads,
build_jobs: value.build_jobs,
}
}
}