vdev/commands/check/
component_features.rs

1use std::env;
2
3use anyhow::Result;
4
5use crate::{app, util::CargoToml};
6
7const CARGO: &str = "cargo";
8const BASE_ARGS: [&str; 5] = [
9    "check",
10    "--tests",
11    "--bin",
12    "vector",
13    "--no-default-features",
14];
15const PARALLEL_ARGS: [&str; 7] = [
16    "--group",
17    "--verbose",
18    "--retries",
19    "2",
20    "scripts/check-one-feature",
21    "{}",
22    ":::",
23];
24
25/// Check that all component features are set up properly
26#[derive(clap::Args, Debug)]
27#[command()]
28pub struct Cli {}
29
30impl Cli {
31    #[allow(clippy::dbg_macro)]
32    pub fn exec(self) -> Result<()> {
33        app::set_repo_dir()?;
34
35        let features = extract_features()?;
36
37        // Prime the pump to build most of the artifacts
38        app::exec(CARGO, BASE_ARGS, true)?;
39        app::exec(
40            CARGO,
41            BASE_ARGS.into_iter().chain(["--features", "default"]),
42            true,
43        )?;
44        app::exec(
45            CARGO,
46            BASE_ARGS
47                .into_iter()
48                .chain(["--features", "all-integration-tests"]),
49            true,
50        )?;
51
52        // The feature builds already run in parallel below, so don't overload the parallelism
53        env::set_var("CARGO_BUILD_JOBS", "1");
54
55        app::exec(
56            "parallel",
57            PARALLEL_ARGS
58                .into_iter()
59                .chain(features.iter().map(String::as_str)),
60            true,
61        )
62    }
63}
64
65fn extract_features() -> Result<Vec<String>> {
66    Ok(CargoToml::load()?
67        .features
68        .into_keys()
69        .filter(|feature| {
70            !feature.contains("-utils")
71                && feature != "default"
72                && feature != "all-integration-tests"
73        })
74        .collect())
75}