From 2f3a6b407e0312c22c0c0dc4b542015f2e2d9ba2 Mon Sep 17 00:00:00 2001 From: autoantwort <41973254+autoantwort@users.noreply.github.com> Date: Tue, 14 Feb 2023 21:45:40 +0100 Subject: [PATCH] ci: Don't pull in ports that causes cascades (#856) --- .../e2e_ports/ci/base-port/portfile.cmake | 1 + .../e2e_ports/ci/base-port/vcpkg.json | 4 ++ .../ci/dep-on-feature-not-sup/portfile.cmake | 1 + .../ci/dep-on-feature-not-sup/vcpkg.json | 8 ++++ .../ci/feature-not-sup/portfile.cmake | 1 + .../e2e_ports/ci/feature-not-sup/vcpkg.json | 11 +++++ .../ci/not-sup-host-b/portfile.cmake | 1 + .../e2e_ports/ci/not-sup-host-b/vcpkg.json | 9 ++++ azure-pipelines/end-to-end-tests-dir/ci.ps1 | 22 +++++++-- src/vcpkg/commands.ci.cpp | 47 ++++++++++++++++--- 10 files changed, 96 insertions(+), 9 deletions(-) create mode 100644 azure-pipelines/e2e_ports/ci/base-port/portfile.cmake create mode 100644 azure-pipelines/e2e_ports/ci/base-port/vcpkg.json create mode 100644 azure-pipelines/e2e_ports/ci/dep-on-feature-not-sup/portfile.cmake create mode 100644 azure-pipelines/e2e_ports/ci/dep-on-feature-not-sup/vcpkg.json create mode 100644 azure-pipelines/e2e_ports/ci/feature-not-sup/portfile.cmake create mode 100644 azure-pipelines/e2e_ports/ci/feature-not-sup/vcpkg.json create mode 100644 azure-pipelines/e2e_ports/ci/not-sup-host-b/portfile.cmake create mode 100644 azure-pipelines/e2e_ports/ci/not-sup-host-b/vcpkg.json diff --git a/azure-pipelines/e2e_ports/ci/base-port/portfile.cmake b/azure-pipelines/e2e_ports/ci/base-port/portfile.cmake new file mode 100644 index 0000000000..9aefc82414 --- /dev/null +++ b/azure-pipelines/e2e_ports/ci/base-port/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e_ports/ci/base-port/vcpkg.json b/azure-pipelines/e2e_ports/ci/base-port/vcpkg.json new file mode 100644 index 0000000000..930c50247c --- /dev/null +++ b/azure-pipelines/e2e_ports/ci/base-port/vcpkg.json @@ -0,0 +1,4 @@ +{ + "name": "base-port", + "version": "1" +} diff --git a/azure-pipelines/e2e_ports/ci/dep-on-feature-not-sup/portfile.cmake b/azure-pipelines/e2e_ports/ci/dep-on-feature-not-sup/portfile.cmake new file mode 100644 index 0000000000..9aefc82414 --- /dev/null +++ b/azure-pipelines/e2e_ports/ci/dep-on-feature-not-sup/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e_ports/ci/dep-on-feature-not-sup/vcpkg.json b/azure-pipelines/e2e_ports/ci/dep-on-feature-not-sup/vcpkg.json new file mode 100644 index 0000000000..31706c4a2b --- /dev/null +++ b/azure-pipelines/e2e_ports/ci/dep-on-feature-not-sup/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "dep-on-feature-not-sup", + "version": "1", + "dependencies": [{ + "name": "feature-not-sup", + "features": ["not-sup"] + }] +} diff --git a/azure-pipelines/e2e_ports/ci/feature-not-sup/portfile.cmake b/azure-pipelines/e2e_ports/ci/feature-not-sup/portfile.cmake new file mode 100644 index 0000000000..9aefc82414 --- /dev/null +++ b/azure-pipelines/e2e_ports/ci/feature-not-sup/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e_ports/ci/feature-not-sup/vcpkg.json b/azure-pipelines/e2e_ports/ci/feature-not-sup/vcpkg.json new file mode 100644 index 0000000000..44ca543910 --- /dev/null +++ b/azure-pipelines/e2e_ports/ci/feature-not-sup/vcpkg.json @@ -0,0 +1,11 @@ +{ + "name": "feature-not-sup", + "version": "1", + "dependencies": [], + "features": { + "not-sup": { + "description": "not supported", + "supports": "x64 & !x64" + } + } +} diff --git a/azure-pipelines/e2e_ports/ci/not-sup-host-b/portfile.cmake b/azure-pipelines/e2e_ports/ci/not-sup-host-b/portfile.cmake new file mode 100644 index 0000000000..9aefc82414 --- /dev/null +++ b/azure-pipelines/e2e_ports/ci/not-sup-host-b/portfile.cmake @@ -0,0 +1 @@ +set(VCPKG_POLICY_EMPTY_PACKAGE enabled) diff --git a/azure-pipelines/e2e_ports/ci/not-sup-host-b/vcpkg.json b/azure-pipelines/e2e_ports/ci/not-sup-host-b/vcpkg.json new file mode 100644 index 0000000000..2a6bf447a5 --- /dev/null +++ b/azure-pipelines/e2e_ports/ci/not-sup-host-b/vcpkg.json @@ -0,0 +1,9 @@ +{ + "name": "not-sup-host-b", + "version": "1", + "supports": "x64 & !x64", + "dependencies": [{ + "name": "base-port", + "host": true + }] +} diff --git a/azure-pipelines/end-to-end-tests-dir/ci.ps1 b/azure-pipelines/end-to-end-tests-dir/ci.ps1 index 660fbb868f..e7c3b4bf79 100644 --- a/azure-pipelines/end-to-end-tests-dir/ci.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/ci.ps1 @@ -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' +} \ No newline at end of file diff --git a/src/vcpkg/commands.ci.cpp b/src/vcpkg/commands.ci.cpp index 9752d3b0bf..6fd61fe38d 100644 --- a/src/vcpkg/commands.ci.cpp +++ b/src/vcpkg/commands.ci.cpp @@ -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, @@ -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()); @@ -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];