Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/component_features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0

- run: sudo -E bash scripts/environment/bootstrap-ubuntu-24.04.sh
- run: bash scripts/environment/prepare.sh --modules=rustup
- run: bash scripts/environment/prepare.sh --modules=rustup,cargo-hack
- run: echo "::add-matcher::.github/matchers/rust.json"
- run: make check-component-features

Expand Down
65 changes: 0 additions & 65 deletions scripts/check-one-feature

This file was deleted.

10 changes: 9 additions & 1 deletion scripts/environment/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ ALL_MODULES=(
cargo-nextest
cargo-deny
cargo-msrv
cargo-hack
dd-rust-license-tool
wasm-pack
markdownlint
Expand Down Expand Up @@ -72,6 +73,7 @@ Modules:
cargo-nextest
cargo-deny
cargo-msrv
cargo-hack
dd-rust-license-tool
wasm-pack
markdownlint
Expand Down Expand Up @@ -105,7 +107,7 @@ contains_module() {
# Always ensure git safe.directory is set
git config --global --add safe.directory "$(pwd)"

REQUIRES_RUSTUP=(dd-rust-license-tool cargo-deb cross cargo-nextest cargo-deny cargo-msrv wasm-pack vdev)
REQUIRES_RUSTUP=(dd-rust-license-tool cargo-deb cross cargo-nextest cargo-deny cargo-msrv cargo-hack wasm-pack vdev)

REQUIRES_BINSTALL=("${REQUIRES_RUSTUP[@]}")
unset -v 'REQUIRES_BINSTALL[0]' # remove dd-rust-license-tool
Expand Down Expand Up @@ -174,6 +176,12 @@ if contains_module cargo-msrv; then
fi
fi

if contains_module cargo-hack; then
if ! cargo-hack --version 2>/dev/null | grep -q '^cargo-hack 0.6.39'; then
cargo "${install[@]}" cargo-hack --version 0.6.39 --force --locked
fi
fi

if contains_module dd-rust-license-tool; then
if ! dd-rust-license-tool --help &>/dev/null; then
cargo install dd-rust-license-tool --version 1.0.2 --force --locked
Expand Down
78 changes: 31 additions & 47 deletions vdev/src/commands/check/component_features.rs
Original file line number Diff line number Diff line change
@@ -1,77 +1,61 @@
use std::env;

use anyhow::Result;

use crate::{app, util::CargoToml};

const CARGO: &str = "cargo";
const BASE_ARGS: [&str; 5] = [
"check",
"--tests",
"--bin",
"vector",
"--no-default-features",
];
const PARALLEL_ARGS: [&str; 7] = [
"--group",
"--verbose",
"--retries",
"2",
"scripts/check-one-feature",
"{}",
":::",
];

/// Check that all component features are set up properly
#[derive(clap::Args, Debug)]
#[command()]
pub struct Cli {}

impl Cli {
#[allow(clippy::dbg_macro)]
pub fn exec(self) -> Result<()> {
app::set_repo_dir()?;

let features = extract_features()?;
let feature_list = features.join(",");

// Prime the pump to build most of the artifacts
app::exec(CARGO, BASE_ARGS, true)?;
app::exec(
CARGO,
BASE_ARGS.into_iter().chain(["--features", "default"]),
true,
)?;
// cargo-hack will check each feature individually
app::exec(
CARGO,
BASE_ARGS
.into_iter()
.chain(["--features", "all-integration-tests"]),
true,
)?;

// The feature builds already run in parallel below, so don't overload the parallelism
unsafe {
env::set_var("CARGO_BUILD_JOBS", "1");
}

app::exec(
"parallel",
PARALLEL_ARGS
.into_iter()
.chain(features.iter().map(String::as_str)),
"cargo",
[
"hack",
"check",
"--tests",
"--bin",
"vector",
"--each-feature",
"--include-features",
&feature_list,
],
true,
)
}
}

fn extract_features() -> Result<Vec<String>> {
use std::collections::HashSet;

// Exclude default feature - already tested separately and is a cargo convention
let excluded_defaults: HashSet<&str> = ["default"].into();

// Exclude meta-features - aggregate features that enable multiple components together
// Testing these would check all features at once, not in isolation
let excluded_meta_features: HashSet<&str> = [
"all-integration-tests",
"all-e2e-tests",
"vector-api-tests",
"vector-unit-test-tests",
]
.into();

Ok(CargoToml::load()?
.features
.into_keys()
.filter(|feature| {
// Exclude utility features - internal helpers not meant to be enabled standalone
!feature.contains("-utils")
&& feature != "default"
&& feature != "all-integration-tests"
&& !excluded_defaults.contains(feature.as_str())
&& !excluded_meta_features.contains(feature.as_str())
})
.collect())
}
Loading