Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 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
9 changes: 9 additions & 0 deletions azure-pipelines/e2e-assets/ci/ci-baseline-test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CI Baseline for testing early filtering
# qtwayland-test should be skipped on all triplets
qtwayland-test:x86-windows=skip
qtwayland-test:x64-windows=skip
qtwayland-test:arm64-windows=skip
qtwayland-test:x64-linux=skip
qtwayland-test:arm64-linux=skip
qtwayland-test:x64-osx=skip
qtwayland-test:arm64-osx=skip
8 changes: 8 additions & 0 deletions azure-pipelines/e2e-assets/ci/ci.feature.baseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CI Feature Baseline for testing
# This file contains features that should be skipped during CI testing

# qtbase-test port has 'wayland' feature marked as skip
qtbase-test[wayland] = skip

# qtwayland-test should cascade (skip if any dependency is skipped)
qtwayland-test = cascade
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vcpkg_minimum_required(VERSION 2024-11-01)

message(STATUS "Installing qtbase-test")

file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" "Test port")

set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "qtbase-test",
"version": "1.0.0",
"description": "Test port simulating qtbase with wayland feature",
"features": {
"wayland": {
"description": "Wayland support (should be skipped on macOS in CI)"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vcpkg_minimum_required(VERSION 2024-11-01)

message(STATUS "Installing qtwayland-test")

file(WRITE "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright" "Test port")

set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "qtwayland-test",
"version": "1.0.0",
"description": "Test port simulating qtwayland that depends on qtbase[wayland]",
"dependencies": [
{
"name": "qtbase-test",
"features": ["wayland"]
}
]
}
28 changes: 28 additions & 0 deletions azure-pipelines/end-to-end-tests-dir/ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,31 @@ New-Item -ItemType Directory -Path $emptyDir -Force | Out-Null
$Output = Run-VcpkgAndCaptureOutput ci --triplet=$Triplet --x-builtin-ports-root="$emptyDir" --binarysource=clear --overlay-ports="$PSScriptRoot/../e2e-ports/duplicate-file-a" --overlay-ports="$PSScriptRoot/../e2e-ports/duplicate-file-b"
Throw-IfNotFailed
Restore-Problem-Matchers

# Test CI baseline early filtering functionality
# Test that ports marked as skip in ci.baseline.txt are excluded early from CI
$Output = Run-VcpkgAndCaptureOutput ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/ci-feature-baseline" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci/ci-baseline-test.txt"
Throw-IfFailed
# qtwayland-test should be marked as skip
if (-not ($Output -match "qtwayland-test:${Triplet}:\s+skip:")) {
throw 'qtwayland-test should be marked as skip in ci.baseline.txt'
}
# qtbase-test should be in the installation list (not skipped)
if (-not ($Output -match "qtbase-test:${Triplet}@")) {
throw 'qtbase-test should be in the installation list'
}
# qtwayland-test should NOT be in the installation list
if ($Output -match "qtwayland-test:${Triplet}@") {
throw 'qtwayland-test should NOT be in the installation list (marked as skip)'
}

# Test that without CI baseline, both ports are included
$Output2 = Run-VcpkgAndCaptureOutput ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e-ports/ci-feature-baseline" --binarysource=clear
Throw-IfFailed
# Both ports should be in the installation list (may have features like [core,wayland])
if (-not ($Output2 -match "qtbase-test(\[.+?\])?:${Triplet}@")) {
throw 'qtbase-test should be in the installation list without baseline'
}
if (-not ($Output2 -match "qtwayland-test(\[.+?\])?:${Triplet}@")) {
throw 'qtwayland-test should be in the installation list without baseline'
}
48 changes: 45 additions & 3 deletions src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,23 @@ namespace vcpkg

auto registry_set = paths.make_registry_set();
PathsPortFileProvider provider(*registry_set, make_overlay_provider(fs, paths.overlay_ports));

// Build a set of ports to exclude based on the exclusions_map for the target triplet
SortedVector<PackageSpec> ports_to_exclude;
std::vector<PackageSpec> exclude_list;
for (const auto& triplet_exclusions : exclusions_map.triplets)
{
if (triplet_exclusions.triplet == target_triplet)
{
for (const auto& port_name : triplet_exclusions.exclusions)
{
exclude_list.emplace_back(port_name, target_triplet);
}
break;
}
}
ports_to_exclude = SortedVector<PackageSpec>(std::move(exclude_list));

auto var_provider_storage = CMakeVars::make_triplet_cmake_var_provider(paths);
auto& var_provider = *var_provider_storage;

Expand All @@ -361,9 +378,22 @@ namespace vcpkg
std::vector<FullPackageSpec> all_default_full_specs;
for (auto scfl : provider.load_all_control_files())
{
all_default_full_specs.emplace_back(
PackageSpec{scfl->to_name(), target_triplet},
InternalFeatureSet{FeatureNameCore.to_string(), FeatureNameDefault.to_string()});
PackageSpec pkg_spec{scfl->to_name(), target_triplet};

// Check if this port is excluded (should already be filtered by provider, but double-check)
if (ports_to_exclude.contains(pkg_spec))
{
// Port is marked to skip, don't add it to the test list
continue;
}

InternalFeatureSet features;
// Always add core feature
features.push_back(FeatureNameCore.to_string());
// Add default feature
features.push_back(FeatureNameDefault.to_string());

all_default_full_specs.emplace_back(pkg_spec, std::move(features));
}

struct RandomizerInstance : GraphRandomizer
Expand Down Expand Up @@ -400,6 +430,18 @@ namespace vcpkg
LocalizedString not_supported_regressions;
{
std::string msg;

// First, print ports that were excluded early (before dependency resolution)
for (const auto& excluded_spec : ports_to_exclude)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea I missed in my version of the same #1822 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In #1822 (comment) in addition to fixing this problem I also fixed the "Summary" at the end to properly note that these were EXCLUDED

{
split_specs->known.emplace(excluded_spec, BuildResult::Excluded);
// Generate a simple hash for excluded ports (they don't get real ABIs)
std::string fake_abi = "0000000000000000000000000000000000000000000000000000000000000000";
split_specs->abi_map.emplace(excluded_spec, fake_abi);
split_specs->features.emplace(excluded_spec, std::vector<std::string>{"core"});
msg += fmt::format("{:>40}: {:>8}: {}\n", excluded_spec, "skip", fake_abi);
}

for (const auto& spec : all_default_full_specs)
{
if (!Util::Sets::contains(split_specs->abi_map, spec.package_spec))
Expand Down
Loading