vcpkg/scripts/azure-pipelines/test-modified-ports.ps1
Billy O'Neal 5395ad9a4f
Add "cascades" enforcement (#20140)
* Add "cascades" enforcement as requested by https://github.com/microsoft/vcpkg/pull/20074#issuecomment-916565430

* Add counts.

* Fix arm-uwp count.

* Update counts.

* Update counts
2021-09-14 17:46:38 -07:00

181 lines
5.9 KiB
PowerShell
Executable File

# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: MIT
#
<#
.SYNOPSIS
Runs the 'Test Modified Ports' part of the vcpkg CI system for all platforms.
.PARAMETER Triplet
The triplet to test.
.PARAMETER WorkingRoot
The location used as scratch space for 'installed', 'packages', and 'buildtrees' vcpkg directories.
.PARAMETER ArtifactStagingDirectory
The Azure Pipelines artifacts directory. If not supplied, defaults to the current directory.
.PARAMETER ArchivesRoot
Equivalent to '-BinarySourceStub "files,$ArchivesRoot"'
.PARAMETER BinarySourceStub
The type and parameters of the binary source. Shared across runs of this script. If
this parameter is not set, binary caching will not be used. Example: "files,W:\"
.PARAMETER BuildReason
The reason Azure Pipelines is running this script (controls in which mode Binary Caching is used).
If BinarySourceStub is not set, this parameter has no effect. If BinarySourceStub is set and this is
not, binary caching will default to read-write mode.
.PARAMETER PassingIsPassing
Indicates that 'Passing, remove from fail list' results should not be emitted as failures. (For example, this is used
when using vcpkg to test a prerelease MSVC++ compiler)
.PARAMETER EnforceCascades
Enforces that the cascade count from ci.baseline.txt and "supports" is consistent with last known values.
#>
[CmdletBinding(DefaultParameterSetName="ArchivesRoot")]
Param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Triplet,
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
$WorkingRoot,
[ValidateNotNullOrEmpty()]
$ArtifactStagingDirectory = '.',
[Parameter(ParameterSetName='ArchivesRoot')]
$ArchivesRoot = $null,
[Parameter(ParameterSetName='BinarySourceStub')]
$BinarySourceStub = $null,
$BuildReason = $null,
[switch]
$PassingIsPassing = $false,
[switch]
$EnforceCascades = $false
)
if (-Not ((Test-Path "triplets/$Triplet.cmake") -or (Test-Path "triplets/community/$Triplet.cmake"))) {
Write-Error "Incorrect triplet '$Triplet', please supply a valid triplet."
throw
}
if ((-Not [string]::IsNullOrWhiteSpace($ArchivesRoot))) {
if ((-Not [string]::IsNullOrWhiteSpace($BinarySourceStub))) {
Write-Error "Only one binary caching setting may be used."
throw
}
$BinarySourceStub = "files,$ArchivesRoot"
}
$env:VCPKG_DOWNLOADS = Join-Path $WorkingRoot 'downloads'
$buildtreesRoot = Join-Path $WorkingRoot 'buildtrees'
$installRoot = Join-Path $WorkingRoot 'installed'
$packagesRoot = Join-Path $WorkingRoot 'packages'
$commonArgs = @(
"--x-buildtrees-root=$buildtreesRoot",
"--x-install-root=$installRoot",
"--x-packages-root=$packagesRoot",
"--overlay-ports=scripts/test_ports"
)
$skipFailures = $false
if ([string]::IsNullOrWhiteSpace($BinarySourceStub)) {
$commonArgs += @('--no-binarycaching')
} else {
$commonArgs += @('--binarycaching')
$binaryCachingMode = 'readwrite'
if ([string]::IsNullOrWhiteSpace($BuildReason)) {
Write-Host 'Build reason not specified, defaulting to using binary caching in read write mode.'
}
elseif ($BuildReason -eq 'PullRequest') {
Write-Host 'Build reason was Pull Request, using binary caching in read write mode, skipping failures.'
$skipFailures = $true
}
else {
Write-Host "Build reason was $BuildReason, using binary caching in write only mode."
$binaryCachingMode = 'write'
}
$commonArgs += @("--binarysource=clear;$BinarySourceStub,$binaryCachingMode")
}
if ($Triplet -eq 'x64-linux') {
$env:HOME = '/home/agent'
$executableExtension = [string]::Empty
}
elseif ($Triplet -eq 'x64-osx') {
$executableExtension = [string]::Empty
}
else {
$executableExtension = '.exe'
}
$xmlResults = Join-Path $ArtifactStagingDirectory 'xml-results'
mkdir $xmlResults
$xmlFile = Join-Path $xmlResults "$Triplet.xml"
$failureLogs = Join-Path $ArtifactStagingDirectory 'failure-logs'
& "./vcpkg$executableExtension" x-ci-clean @commonArgs
if ($LASTEXITCODE -ne 0)
{
throw "vcpkg clean failed"
}
$skipList = . "$PSScriptRoot/generate-skip-list.ps1" `
-Triplet $Triplet `
-BaselineFile "$PSScriptRoot/../ci.baseline.txt" `
-SkipFailures:$skipFailures
$ciArgs = $commonArgs
if ($EnforceCascades) {
if ($Triplet -eq 'x86-windows') {
$cascades = 28
} elseif ($Triplet -eq 'x64-windows') {
$cascades = 21
} elseif ($Triplet -eq 'x64-windows-static') {
$cascades = 59
} elseif ($Triplet -eq 'x64-windows-static-md') {
$cascades = 53
} elseif ($Triplet -eq 'x64-uwp') {
$cascades = 345
} elseif ($Triplet -eq 'arm64-windows') {
$cascades = 228
} elseif ($Triplet -eq 'arm-uwp') {
$cascades = 345
} elseif ($Triplet -eq 'x64-osx') {
$cascades = 61
} elseif ($Triplet -eq 'x64-linux') {
$cascades = 31
} else {
throw "Unknown triplet ($Triplet); could not determine expected cascade count. Update test-modified-ports.ps1."
}
$ciArgs += @("--x-skipped-cascade-count=$cascades")
}
if ($Triplet -in @('x64-windows', 'x64-osx', 'x64-linux'))
{
# WORKAROUND: These triplets are native-targetting which triggers an issue in how vcpkg handles the skip list.
# The workaround is to pass the skip list as host-excludes as well.
& "./vcpkg$executableExtension" ci $Triplet --x-xunit=$xmlFile --exclude=$skipList --host-exclude=$skipList --failure-logs=$failureLogs @ciArgs
}
else
{
& "./vcpkg$executableExtension" ci $Triplet --x-xunit=$xmlFile --exclude=$skipList --failure-logs=$failureLogs @ciArgs
}
if ($LASTEXITCODE -ne 0)
{
throw "vcpkg ci failed"
}
& "$PSScriptRoot/analyze-test-results.ps1" -logDir $xmlResults `
-triplet $Triplet `
-baselineFile .\scripts\ci.baseline.txt `
-passingIsPassing:$PassingIsPassing