Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
13 changes: 13 additions & 0 deletions azure-pipelines/e2e-assets/ci-skipped-ports/baseline.fail.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# fail means skip with --skip-failures
always-skip:arm64-osx=fail
always-skip:x64-linux=fail
always-skip:x64-osx=fail
always-skip:x64-windows=fail
always-skip:x86-windows=fail

# fail means skip here, but cached artifacts exists
maybe-skip:arm64-osx=fail
maybe-skip:x64-linux=fail
maybe-skip:x64-osx=fail
maybe-skip:x64-windows=fail
maybe-skip:x86-windows=fail
13 changes: 13 additions & 0 deletions azure-pipelines/e2e-assets/ci-skipped-ports/baseline.skip.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# actual test
always-skip:arm64-osx=skip
always-skip:x64-linux=skip
always-skip:x64-osx=skip
always-skip:x64-windows=skip
always-skip:x86-windows=skip

# don't build cached artifact
maybe-transitive-cascade:arm64-osx=skip
maybe-transitive-cascade:x64-linux=skip
maybe-transitive-cascade:x64-osx=skip
maybe-transitive-cascade:x64-windows=skip
maybe-transitive-cascade:x86-windows=skip
5 changes: 0 additions & 5 deletions azure-pipelines/e2e-assets/ci-skipped-ports/baseline.txt

This file was deleted.

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,7 @@
{
"name": "maybe-direct-cascade",
"version": "1.0.0",
"dependencies": [
"maybe-skip"
]
}
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,4 @@
{
"name": "maybe-skip",
"version": "1.0.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
if(NOT EXISTS "${CURRENT_INSTALLED_DIR}/share/maybe-skip")
message(FATAL_ERROR "Installation order violation")
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "maybe-transitive-cascade",
"version": "1.0.0",
"dependencies": [
"maybe-direct-cascade"
]
}
41 changes: 33 additions & 8 deletions azure-pipelines/end-to-end-tests-dir/ci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,51 @@ SUMMARY FOR $Triplet

# test that skipped ports aren't "put back" by downstream dependencies that aren't skipped
Refresh-TestRoot
$Output = Run-VcpkgAndCaptureOutput ci @commonArgs --x-builtin-ports-root="$PSScriptRoot/../e2e-assets/ci-skipped-ports" --binarysource=clear --ci-baseline="$PSScriptRoot/../e2e-assets/ci-skipped-ports/baseline.txt"
$Output = Run-VcpkgAndCaptureOutput ci @commonArgs --x-builtin-ports-root="$PSScriptRoot/../e2e-assets/ci-skipped-ports" --binarysource="clear;files,$ArchiveRoot,readwrite" --ci-baseline="$PSScriptRoot/../e2e-assets/ci-skipped-ports/baseline.skip.txt"
Throw-IfFailed
if (-not ($Output -match 'always-built:[^:]+: \*:' -and $Output -match 'Building always-built:[^@]+@1\.0\.0\.\.\.')) {
throw 'did not attempt to build always-built'
}
if (-not ($Output -match 'always-skip:[^:]+: skip\n')) {
throw 'tried to build skipped'
throw 'did not identify always-skip as skipped'
}
if (-not ($Output -match 'always-cascade:[^:]+: cascade\n')) {
throw 'did not identify always-cascade as cascaded'
}
# This should be statically determinable but at the moment we do not
# if (-not ($Output -match 'always-cascade:[^:]+: cascade\n')) {
# throw 'tried to build cascaded'
# }
Comment on lines +106 to -107
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now it does statically determine the cascade and no longer adds always-cascade to the installation plan.

Throw-IfNonContains -Actual $Output -Expected @"
SUMMARY FOR $Triplet
SUCCEEDED: 1
SUCCEEDED: 3
CASCADED_DUE_TO_MISSING_DEPENDENCIES: 1
EXCLUDED: 1
EXCLUDED: 2
"@
# prerequisite for next test
if (-not ($Output -match 'maybe-transitive-cascade:[^:]+: skip\n')) {
throw 'did not identify maybe-transitive-cascade as skip'
}
# test with --skip-failures and cached artifacts
Remove-Item -Recurse -Force $installRoot -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Path $installRoot -Force | Out-Null
$Output = Run-VcpkgAndCaptureOutput ci --skip-failures @commonArgs --x-builtin-ports-root="$PSScriptRoot/../e2e-assets/ci-skipped-ports" --binarysource="clear;files,$ArchiveRoot" --ci-baseline="$PSScriptRoot/../e2e-assets/ci-skipped-ports/baseline.fail.txt"
Throw-IfFailed
if (-not ($Output -match 'always-built:[^:]+: cached:') -or $Output -match 'Building always-built:[^@]+@1\.0\.0\.\.\.') {
throw 'did not reuse the cached artifact for always-built'
}
if (-not ($Output -match 'always-skip:[^:]+: skip\n')) {
throw 'did not identify always-skip as skipped'
}
if (-not ($Output -match 'always-cascade:[^:]+: cascade\n')) {
throw 'did not identify always-cascade as cascaded'
}
if (-not ($Output -match 'maybe-skip:[^:]+: skip\n')) {
throw 'did not identify maybe-skip as skipped'
}
# not cached and transitive dependency on maybe-skip which is excluded
if (-not ($Output -match 'maybe-transitive-cascade:[^:]+: cascade\n')) {
throw 'did not identify maybe-transitive-cascade as cascaded'
}

# test that features included only by skipped ports are not included
Refresh-TestRoot
$xunitFile = Join-Path $TestingRoot 'xunit.xml'
Refresh-TestRoot
Remove-Problem-Matchers
Expand Down
24 changes: 21 additions & 3 deletions src/vcpkg/commands.ci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,18 @@ namespace
return supports_expression.evaluate(var_provider.get_dep_info_vars(spec).value_or_exit(VCPKG_LINE_INFO));
}

bool cascade_for_triplet(const std::vector<InstallPlanAction>& install_actions,
const SortedVector<std::string>* triplet_exclusions)
{
if (!triplet_exclusions) return false;

return std::any_of(
install_actions.begin(), install_actions.end(), [triplet_exclusions](const InstallPlanAction& action) {
return action.source_control_file_and_location.has_value() &&
triplet_exclusions->contains(action.source_control_file_and_location.get()->to_name());
});
}

ActionPlan compute_full_plan(const VcpkgPaths& paths,
const PortFileProvider& provider,
const CMakeVars::CMakeVarProvider& var_provider,
Expand Down Expand Up @@ -332,9 +344,9 @@ namespace
}

PackagesDirAssigner this_packages_dir_not_used{""};
if (!create_feature_install_plan(
provider, var_provider, {&full_package_spec, 1}, {}, this_packages_dir_not_used, serialize_options)
.unsupported_features.empty())
const ActionPlan action_plan = create_feature_install_plan(
provider, var_provider, {&full_package_spec, 1}, {}, this_packages_dir_not_used, serialize_options);
if (!action_plan.unsupported_features.empty())
{
result.excluded.insert_or_assign(
std::move(full_package_spec.package_spec),
Expand All @@ -344,6 +356,12 @@ namespace
continue;
}

if (cascade_for_triplet(action_plan.install_actions, target_triplet_exclusions))
{
result.excluded.insert_or_assign(std::move(full_package_spec.package_spec), ExcludeReason::Cascade);
continue;
}

result.requested.emplace_back(std::move(full_package_spec));
}

Expand Down
Loading