aboutsummaryrefslogtreecommitdiff
path: root/mingling_ci/src/task/cmd_docs_check.rs
blob: 3a77d4d309d110166ecc0882921d0c13123a05aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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;
    }
}