Skip to content

Commit

Permalink
ci: Don't pull in ports that causes cascades (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
autoantwort authored Feb 14, 2023
1 parent 0dcfb79 commit 2f3a6b4
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 9 deletions.
1 change: 1 addition & 0 deletions azure-pipelines/e2e_ports/ci/base-port/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
4 changes: 4 additions & 0 deletions azure-pipelines/e2e_ports/ci/base-port/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "base-port",
"version": "1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "dep-on-feature-not-sup",
"version": "1",
"dependencies": [{
"name": "feature-not-sup",
"features": ["not-sup"]
}]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
11 changes: 11 additions & 0 deletions azure-pipelines/e2e_ports/ci/feature-not-sup/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "feature-not-sup",
"version": "1",
"dependencies": [],
"features": {
"not-sup": {
"description": "not supported",
"supports": "x64 & !x64"
}
}
}
1 change: 1 addition & 0 deletions azure-pipelines/e2e_ports/ci/not-sup-host-b/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
9 changes: 9 additions & 0 deletions azure-pipelines/e2e_ports/ci/not-sup-host-b/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "not-sup-host-b",
"version": "1",
"supports": "x64 & !x64",
"dependencies": [{
"name": "base-port",
"host": true
}]
}
22 changes: 19 additions & 3 deletions azure-pipelines/end-to-end-tests-dir/ci.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
. $PSScriptRoot/../end-to-end-tests-prelude.ps1

# Not a number
Run-Vcpkg ci --triplet=$Triplet --x-skipped-cascade-count=fish
Run-Vcpkg ci --dry-run --triplet=$Triplet --x-skipped-cascade-count=fish
Throw-IfNotFailed

# Negative
Run-Vcpkg ci --triplet=$Triplet --x-skipped-cascade-count=-1
Run-Vcpkg ci --dry-run --triplet=$Triplet --x-skipped-cascade-count=-1
Throw-IfNotFailed

# Clearly not the correct answer
Run-Vcpkg ci --triplet=$Triplet --x-skipped-cascade-count=1000
Run-Vcpkg ci --dry-run --triplet=$Triplet --x-skipped-cascade-count=1000
Throw-IfNotFailed

# test skipped ports
$Output = Run-VcpkgAndCaptureOutput ci --dry-run --triplet=$Triplet --x-builtin-ports-root="$PSScriptRoot/../e2e_ports/ci" --binarysource=clear
Throw-IfFailed
if (-not ($Output.Contains("dep-on-feature-not-sup:${Triplet}: cascade"))) {
throw 'dep-on-feature-not-sup must cascade because it depends on a features that is not supported'
}
if (-not ($Output.Contains("not-sup-host-b:${Triplet}: skip"))) {
throw 'not-sup-host-b must be skipped because it is not supported'
}
if (-not ($Output.Contains("feature-not-sup:${Triplet}: *"))) {
throw 'feature-not-sup must be build because the port that causes this port to skip should not be installed'
}
if ($Output.Split("*").Length -ne 3) {
throw 'base-port should not be installed for the host'
}
47 changes: 41 additions & 6 deletions src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,32 @@ namespace vcpkg::Commands::CI
int cascade_count = 0;
};

static bool supported_for_triplet(const CMakeVars::CMakeVarProvider& var_provider,
const SourceControlFile& source_control_file,
PackageSpec spec)
{
const auto& supports_expression = source_control_file.core_paragraph->supports_expression;
if (supports_expression.is_empty())
{
return true;
}
PlatformExpression::Context context = var_provider.get_dep_info_vars(spec).value_or_exit(VCPKG_LINE_INFO);
return supports_expression.evaluate(context);
}

static bool supported_for_triplet(const CMakeVars::CMakeVarProvider& var_provider,
const InstallPlanAction* install_plan)
{
auto&& scfl = install_plan->source_control_file_and_location.value_or_exit(VCPKG_LINE_INFO);
const auto& supports_expression = scfl.source_control_file->core_paragraph->supports_expression;
PlatformExpression::Context context =
var_provider.get_tag_vars(install_plan->spec).value_or_exit(VCPKG_LINE_INFO);
return supported_for_triplet(var_provider, *scfl.source_control_file, install_plan->spec);
}

return supports_expression.evaluate(context);
static bool supported_for_triplet(const CMakeVars::CMakeVarProvider& var_provider,
const PortFileProvider& provider,
PackageSpec spec)
{
auto&& scf = provider.get_control_file(spec.name()).value_or_exit(VCPKG_LINE_INFO).source_control_file;
return supported_for_triplet(var_provider, *scf, spec);
}

static ActionPlan compute_full_plan(const VcpkgPaths& paths,
Expand All @@ -152,15 +169,21 @@ namespace vcpkg::Commands::CI
for (auto&& spec : specs)
{
auto&& scfl = provider.get_control_file(spec.package_spec.name()).value_or_exit(VCPKG_LINE_INFO);
if (scfl.source_control_file->has_qualified_dependencies())
if (scfl.source_control_file->has_qualified_dependencies() ||
!scfl.source_control_file->core_paragraph->supports_expression.is_empty())
{
packages_with_qualified_deps.push_back(spec.package_spec);
}
}

var_provider.load_dep_info_vars(packages_with_qualified_deps, serialize_options.host_triplet);
auto action_plan = create_feature_install_plan(provider, var_provider, specs, {}, serialize_options);

const auto applicable_specs = Util::filter(specs, [&](auto& spec) -> bool {
return create_feature_install_plan(provider, var_provider, {&spec, 1}, {}, serialize_options)
.warnings.empty();
});

auto action_plan = create_feature_install_plan(provider, var_provider, applicable_specs, {}, serialize_options);
var_provider.load_tag_vars(action_plan, provider, serialize_options.host_triplet);

Checks::check_exit(VCPKG_LINE_INFO, action_plan.already_installed.empty());
Expand Down Expand Up @@ -431,6 +454,18 @@ namespace vcpkg::Commands::CI

{
std::string msg;
for (const auto& spec : all_default_full_specs)
{
if (!Util::Sets::contains(split_specs->abi_map, spec.package_spec))
{
bool supp = supported_for_triplet(var_provider, provider, spec.package_spec);
split_specs->known.emplace(spec.package_spec,
supp ? BuildResult::CASCADED_DUE_TO_MISSING_DEPENDENCIES
: BuildResult::EXCLUDED);
if (supp) ++split_specs->cascade_count;
msg += Strings::format("%40s: %8s\n", spec.package_spec, supp ? "cascade" : "skip");
}
}
for (size_t i = 0; i < action_plan.install_actions.size(); ++i)
{
auto&& action = action_plan.install_actions[i];
Expand Down

0 comments on commit 2f3a6b4

Please sign in to comment.