diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-24 11:23:32 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-24 11:23:32 +0800 |
| commit | addfbbf0b33a6251605990da73c2de5131766827 (patch) | |
| tree | 99f8eb03be44157fef250c1d77d801c14be48c23 /dev_tools/src/bin/ci.rs | |
| parent | daf29a92ed88135589a49dea4f370d98ac29462d (diff) | |
Run CI tasks in parallel with progress bars
Diffstat (limited to 'dev_tools/src/bin/ci.rs')
| -rw-r--r-- | dev_tools/src/bin/ci.rs | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/dev_tools/src/bin/ci.rs b/dev_tools/src/bin/ci.rs index d1071ab..1f536c9 100644 --- a/dev_tools/src/bin/ci.rs +++ b/dev_tools/src/bin/ci.rs @@ -2,7 +2,7 @@ use std::io::Write as _; use std::process::exit; use tools::{ - cargo_tomls, eprintln_cargo_style, println_cargo_style, run_cmd, wprintln_cargo_style, + cargo_tomls, crate_name_from, eprintln_cargo_style, println_cargo_style, run_cmd, run_parallel, }; fn get_ignore_dirs() -> Vec<String> { @@ -128,73 +128,76 @@ fn ci(test_docs: bool, test_codes: bool, run_all: bool) -> Result<(), i32> { } fn test_examples() -> Result<(), i32> { - println_cargo_style!("Testing: examples"); - run_cmd!("cargo run --manifest-path dev_tools/Cargo.toml --bin test-examples") + run_cmd!("cargo run --manifest-path dev_tools/Cargo.toml --color always --bin test-examples") } fn test_docs_code_blocks() -> Result<(), i32> { - println_cargo_style!("Testing: documentation code blocks"); - run_cmd!("cargo run --manifest-path dev_tools/Cargo.toml --bin test-all-markdown-code") + run_cmd!( + "cargo run --manifest-path dev_tools/Cargo.toml --color always --bin test-all-markdown-code" + ) } fn build_all() -> Result<(), i32> { let ignore_dirs = get_ignore_dirs(); let cargo_tomls = cargo_tomls(); + let mut tasks = Vec::new(); for cargo_toml in cargo_tomls { let path = cargo_toml.parent().unwrap_or(std::path::Path::new("")); let path_str = path.to_string_lossy(); if ignore_dirs.iter().any(|d| path_str.contains(d.as_str())) { - wprintln_cargo_style!("Skipping: {} (ignored dir)", cargo_toml.to_string_lossy()); continue; } - println_cargo_style!("Build: {}", cargo_toml.to_string_lossy()); - run_cmd!( - "cargo build --manifest-path {}", + let label = format!("Build: {}", cargo_toml.to_string_lossy()); + let crate_name = crate_name_from(&cargo_toml); + let cmd = format!( + "cargo build --manifest-path {} --color always", cargo_toml.to_string_lossy() - )?; + ); + tasks.push((label, crate_name, cmd)); } - - Ok(()) + run_parallel("Building", tasks) } fn clippy_all() -> Result<(), i32> { let ignore_dirs = get_ignore_dirs(); let cargo_tomls = cargo_tomls(); + let mut tasks = Vec::new(); for cargo_toml in cargo_tomls { let path = cargo_toml.parent().unwrap_or(std::path::Path::new("")); let path_str = path.to_string_lossy(); if ignore_dirs.iter().any(|d| path_str.contains(d.as_str())) { - println_cargo_style!("Skipping: {} (ignored dir)", cargo_toml.to_string_lossy()); continue; } - println_cargo_style!("Clippy: {}", cargo_toml.to_string_lossy()); - run_cmd!( - "cargo clippy --manifest-path {} -- -D warnings", + let label = format!("Clippy: {}", cargo_toml.to_string_lossy()); + let crate_name = crate_name_from(&cargo_toml); + let cmd = format!( + "cargo clippy --manifest-path {} --color always -- -D warnings", cargo_toml.to_string_lossy() - )?; + ); + tasks.push((label, crate_name, cmd)); } - - Ok(()) + run_parallel("Clippy", tasks) } fn test_all() -> Result<(), i32> { let ignore_dirs = get_ignore_dirs(); let cargo_tomls = cargo_tomls(); + let mut tasks = Vec::new(); for cargo_toml in cargo_tomls { let path = cargo_toml.parent().unwrap_or(std::path::Path::new("")); let path_str = path.to_string_lossy(); if ignore_dirs.iter().any(|d| path_str.contains(d.as_str())) { - println_cargo_style!("Skipping: {} (ignored dir)", cargo_toml.to_string_lossy()); continue; } - println_cargo_style!("Testing: {}", cargo_toml.to_string_lossy()); - run_cmd!( - "cargo test --manifest-path {}", + let label = format!("Testing: {}", cargo_toml.to_string_lossy()); + let crate_name = crate_name_from(&cargo_toml); + let cmd = format!( + "cargo test --manifest-path {} --color always", cargo_toml.to_string_lossy() - )?; + ); + tasks.push((label, crate_name, cmd)); } - - Ok(()) + run_parallel("Testing", tasks) } fn docs_refresh() -> Result<(), i32> { |
