diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-18 11:09:23 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-18 11:09:23 +0800 |
| commit | b1102be2682feb2d2182ead0fcc7ce12f8d0c865 (patch) | |
| tree | 6bb68f2a79600aa1144d05394b89de9286d385c9 /mingling_ci/src/task | |
| parent | 65464029958facf58c886a3ab5d4b9ab176f4e1c (diff) | |
refactor(mingling_ci): rename build, clippy, and docs commands to -check
suffix
Diffstat (limited to 'mingling_ci/src/task')
| -rw-r--r-- | mingling_ci/src/task/cmd_build_check.rs (renamed from mingling_ci/src/task/cmd_build.rs) | 12 | ||||
| -rw-r--r-- | mingling_ci/src/task/cmd_clippy_check.rs (renamed from mingling_ci/src/task/cmd_clippy.rs) | 12 | ||||
| -rw-r--r-- | mingling_ci/src/task/cmd_docs_check.rs | 44 | ||||
| -rw-r--r-- | mingling_ci/src/task/cmd_example_check.rs | 69 |
4 files changed, 125 insertions, 12 deletions
diff --git a/mingling_ci/src/task/cmd_build.rs b/mingling_ci/src/task/cmd_build_check.rs index f37699c..f67fe2e 100644 --- a/mingling_ci/src/task/cmd_build.rs +++ b/mingling_ci/src/task/cmd_build_check.rs @@ -11,15 +11,15 @@ use crate::Next; use crate::res::Manifests; use crate::task::run::{location, run_parallel_checks}; -#[command(node = "build-all")] -pub async fn build_all(manifests: &Manifests) -> Next { +#[command(node = "build-check")] +pub async fn build_check(manifests: &Manifests) -> Next { let tasks = manifests .package_dirs .iter() .map(|(name, path)| (name.clone(), location(path), build_args(path))) .collect(); - let fail_count = run_parallel_checks("Build-All", "Building", tasks).await; - ResultBuildAll { fail_count }.to_chain() + let fail_count = run_parallel_checks("Build-Check", "Building", tasks).await; + ResultBuildCheck { fail_count }.to_chain() } /// `cargo build --manifest-path <path>` @@ -34,13 +34,13 @@ fn build_args(path: &Path) -> Vec<OsString> { /// Number of packages that failed to build. #[derive(Grouped)] -pub struct ResultBuildAll { +pub struct ResultBuildCheck { pub fail_count: usize, } /// Silently sets a non-zero exit code when any build failed. #[renderer(buffer)] -pub fn render_build_all(r: ResultBuildAll, exit_code: &mut ResExitCode) { +pub fn render_build_check(r: ResultBuildCheck, exit_code: &mut ResExitCode) { if r.fail_count > 0 { exit_code.exit_code = 1; } diff --git a/mingling_ci/src/task/cmd_clippy.rs b/mingling_ci/src/task/cmd_clippy_check.rs index 7256bef..a0dd46e 100644 --- a/mingling_ci/src/task/cmd_clippy.rs +++ b/mingling_ci/src/task/cmd_clippy_check.rs @@ -11,15 +11,15 @@ use crate::Next; use crate::res::Manifests; use crate::task::run::{location, run_parallel_checks}; -#[command(node = "clippy-all")] -pub async fn clippy_all(manifests: &Manifests) -> Next { +#[command(node = "clippy-check")] +pub async fn clippy_check(manifests: &Manifests) -> Next { let tasks = manifests .package_dirs .iter() .map(|(name, path)| (name.clone(), location(path), clippy_args(path))) .collect(); - let fail_count = run_parallel_checks("Clippy-All", "Clippy", tasks).await; - ResultClippyAll { fail_count }.to_chain() + let fail_count = run_parallel_checks("Clippy-Check", "Clippy", tasks).await; + ResultClippyCheck { fail_count }.to_chain() } /// `cargo clippy --manifest-path <path> -- -D warnings` @@ -37,13 +37,13 @@ fn clippy_args(path: &Path) -> Vec<OsString> { /// Number of packages that failed clippy. #[derive(Grouped)] -pub struct ResultClippyAll { +pub struct ResultClippyCheck { pub fail_count: usize, } /// Silently sets a non-zero exit code when any clippy check failed. #[renderer(buffer)] -pub fn render_clippy_all(r: ResultClippyAll, exit_code: &mut ResExitCode) { +pub fn render_clippy_check(r: ResultClippyCheck, exit_code: &mut ResExitCode) { if r.fail_count > 0 { exit_code.exit_code = 1; } diff --git a/mingling_ci/src/task/cmd_docs_check.rs b/mingling_ci/src/task/cmd_docs_check.rs new file mode 100644 index 0000000..3a77d4d --- /dev/null +++ b/mingling_ci/src/task/cmd_docs_check.rs @@ -0,0 +1,44 @@ +use std::ffi::OsString; + +use mingling::{ + Grouped, Routable, + macros::{buffer, command, renderer}, + res::ResExitCode, +}; + +use crate::Next; +use crate::res::ResFeatureList; +use crate::task::run::run_parallel_checks; + +#[command(node = "docs-check")] +pub async fn docs_check(features: &ResFeatureList) -> Next { + let args = vec![ + OsString::from("cargo"), + OsString::from("rustdoc"), + OsString::from("--features"), + OsString::from(features.list.join(",")), + OsString::from("-p"), + OsString::from("mingling"), + OsString::from("--"), + OsString::from("-D"), + OsString::from("warnings"), + ]; + let tasks = vec![("mingling".to_string(), "./mingling".to_string(), args)]; + let fail_count = run_parallel_checks("Docs-Check", "Docs", tasks).await; + + ResultDocsCheck { fail_count }.to_chain() +} + +/// Number of failed doc builds (0 or 1). +#[derive(Grouped)] +pub struct ResultDocsCheck { + pub fail_count: usize, +} + +/// Silently sets a non-zero exit code when the doc build failed. +#[renderer(buffer)] +pub fn render_docs_check(r: ResultDocsCheck, exit_code: &mut ResExitCode) { + if r.fail_count > 0 { + exit_code.exit_code = 1; + } +} diff --git a/mingling_ci/src/task/cmd_example_check.rs b/mingling_ci/src/task/cmd_example_check.rs new file mode 100644 index 0000000..1b9f440 --- /dev/null +++ b/mingling_ci/src/task/cmd_example_check.rs @@ -0,0 +1,69 @@ +use colored::Colorize; +use mingling::{ + Grouped, Routable, + macros::{buffer, command, renderer}, + res::ResExitCode, +}; + +use crate::Next; +use crate::examples::{check_example, load_test_configs}; +use crate::progress::task_progress_bar; +use crate::reporter::{self, ReportResult}; + +#[command(node = "example-check")] +pub async fn example_check() -> Next { + reporter::set_task("Example-Check"); + + let configs = load_test_configs(); + let total = configs.len(); + let pb = task_progress_bar(total, "Testing"); + pb.set_message("examples"); + + // One blocking task per example: build + run its test cases. + let mut handles = Vec::new(); + for example in configs { + handles.push(tokio::task::spawn_blocking(move || check_example(example))); + } + + let mut fail_count = 0; + for handle in handles { + let Ok(outcome) = handle.await else { + continue; + }; + pb.set_message(outcome.name.clone()); + pb.inc(1); + + if outcome.ok { + reporter::export(&outcome.name, &outcome.location, ReportResult::Ok); + } else { + fail_count += 1; + // Plain stderr: `pb.println` is swallowed on non-TTY (CI). + eprintln!(" {} {}", "failed".bright_red(), outcome.name); + eprintln!(" {}", outcome.output); + reporter::export( + &outcome.name, + &outcome.location, + ReportResult::Error(outcome.output), + ); + } + } + + pb.finish_and_clear(); + reporter::flush(); + + ResultExampleCheck { fail_count }.to_chain() +} + +/// Number of examples that failed to build or pass their tests. +#[derive(Grouped)] +pub struct ResultExampleCheck { + pub fail_count: usize, +} + +/// Silently sets a non-zero exit code when any example failed. +#[renderer(buffer)] +pub fn render_example_check(r: ResultExampleCheck, exit_code: &mut ResExitCode) { + if r.fail_count > 0 { + exit_code.exit_code = 1; + } +} |
