2020-06-26 07:36:28 +08:00
|
|
|
# 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.
|
|
|
|
|
2020-09-22 08:27:35 +08:00
|
|
|
.PARAMETER ArtifactStagingDirectory
|
2020-06-26 07:36:28 +08:00
|
|
|
The Azure Pipelines artifacts directory. If not supplied, defaults to the current directory.
|
|
|
|
|
2020-09-29 04:54:10 +08:00
|
|
|
.PARAMETER ArchivesRoot
|
2020-11-19 04:21:23 +08:00
|
|
|
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:\"
|
2020-09-29 04:54:10 +08:00
|
|
|
|
2020-06-26 07:36:28 +08:00
|
|
|
.PARAMETER BuildReason
|
2021-11-02 03:18:28 +08:00
|
|
|
The reason Azure Pipelines is running this script. For invocations caused by `PullRequest`,
|
|
|
|
modified ports are identified by changed hashes with regard to git HEAD~1 (subject to NoParentHashes),
|
|
|
|
and ports marked as failing in the CI baseline (or which depend on such ports) are skipped.
|
|
|
|
If BinarySourceStub is set and this parameter is set to a non-empty value other than `PullRequest`,
|
|
|
|
binary caching will be in write-only mode.
|
|
|
|
|
|
|
|
.PARAMETER NoParentHashes
|
|
|
|
Indicates to not use parent hashes even for pull requests.
|
2021-07-20 10:55:00 +08:00
|
|
|
|
|
|
|
.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)
|
2020-06-26 07:36:28 +08:00
|
|
|
#>
|
|
|
|
|
2020-11-19 04:21:23 +08:00
|
|
|
[CmdletBinding(DefaultParameterSetName="ArchivesRoot")]
|
2020-06-26 07:36:28 +08:00
|
|
|
Param(
|
2020-06-27 03:37:53 +08:00
|
|
|
[Parameter(Mandatory = $true)]
|
2020-06-26 07:36:28 +08:00
|
|
|
[ValidateNotNullOrEmpty()]
|
|
|
|
[string]$Triplet,
|
2020-06-27 03:37:53 +08:00
|
|
|
[Parameter(Mandatory = $true)]
|
2020-06-26 07:36:28 +08:00
|
|
|
[ValidateNotNullOrEmpty()]
|
|
|
|
$WorkingRoot,
|
|
|
|
[ValidateNotNullOrEmpty()]
|
2020-09-22 08:27:35 +08:00
|
|
|
$ArtifactStagingDirectory = '.',
|
2020-11-19 04:21:23 +08:00
|
|
|
[Parameter(ParameterSetName='ArchivesRoot')]
|
2020-09-29 04:54:10 +08:00
|
|
|
$ArchivesRoot = $null,
|
2020-11-19 04:21:23 +08:00
|
|
|
[Parameter(ParameterSetName='BinarySourceStub')]
|
|
|
|
$BinarySourceStub = $null,
|
2021-09-30 04:15:25 +08:00
|
|
|
[String]$BuildReason = $null,
|
2021-11-02 03:18:28 +08:00
|
|
|
[switch]$NoParentHashes = $false,
|
2023-04-25 12:22:59 +08:00
|
|
|
[switch]$PassingIsPassing = $false,
|
|
|
|
[switch]$IsLinuxHost = $false
|
2020-06-26 07:36:28 +08:00
|
|
|
)
|
|
|
|
|
2021-01-09 03:55:31 +08:00
|
|
|
if (-Not ((Test-Path "triplets/$Triplet.cmake") -or (Test-Path "triplets/community/$Triplet.cmake"))) {
|
2020-06-26 07:36:28 +08:00
|
|
|
Write-Error "Incorrect triplet '$Triplet', please supply a valid triplet."
|
2020-07-02 01:53:10 +08:00
|
|
|
throw
|
2020-06-26 07:36:28 +08:00
|
|
|
}
|
|
|
|
|
2021-09-03 15:02:29 +08:00
|
|
|
if ((-Not [string]::IsNullOrWhiteSpace($ArchivesRoot))) {
|
|
|
|
if ((-Not [string]::IsNullOrWhiteSpace($BinarySourceStub))) {
|
|
|
|
Write-Error "Only one binary caching setting may be used."
|
|
|
|
throw
|
2020-12-23 06:52:58 +08:00
|
|
|
}
|
2021-09-03 15:02:29 +08:00
|
|
|
|
|
|
|
$BinarySourceStub = "files,$ArchivesRoot"
|
2020-12-23 06:52:58 +08:00
|
|
|
}
|
|
|
|
|
2020-06-26 07:36:28 +08:00
|
|
|
$env:VCPKG_DOWNLOADS = Join-Path $WorkingRoot 'downloads'
|
|
|
|
$buildtreesRoot = Join-Path $WorkingRoot 'buildtrees'
|
|
|
|
$installRoot = Join-Path $WorkingRoot 'installed'
|
|
|
|
$packagesRoot = Join-Path $WorkingRoot 'packages'
|
2020-09-29 04:54:10 +08:00
|
|
|
|
2021-09-03 15:02:29 +08:00
|
|
|
$commonArgs = @(
|
2020-06-26 07:36:28 +08:00
|
|
|
"--x-buildtrees-root=$buildtreesRoot",
|
|
|
|
"--x-install-root=$installRoot",
|
2020-08-01 07:48:52 +08:00
|
|
|
"--x-packages-root=$packagesRoot",
|
|
|
|
"--overlay-ports=scripts/test_ports"
|
2020-06-26 07:36:28 +08:00
|
|
|
)
|
2021-11-02 03:18:28 +08:00
|
|
|
$cachingArgs = @()
|
2020-06-26 07:36:28 +08:00
|
|
|
|
2022-04-01 10:08:09 +08:00
|
|
|
$skipFailuresArg = @()
|
2021-09-03 15:02:29 +08:00
|
|
|
if ([string]::IsNullOrWhiteSpace($BinarySourceStub)) {
|
2021-11-02 03:18:28 +08:00
|
|
|
$cachingArgs = @('--no-binarycaching')
|
2021-09-03 15:02:29 +08:00
|
|
|
} else {
|
2021-11-02 03:18:28 +08:00
|
|
|
$cachingArgs = @('--binarycaching')
|
2020-09-29 04:54:10 +08:00
|
|
|
$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.'
|
2022-04-01 10:08:09 +08:00
|
|
|
$skipFailuresArg = @('--skip-failures')
|
2020-09-29 04:54:10 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
Write-Host "Build reason was $BuildReason, using binary caching in write only mode."
|
|
|
|
$binaryCachingMode = 'write'
|
|
|
|
}
|
2020-12-23 06:52:58 +08:00
|
|
|
|
2021-11-02 03:18:28 +08:00
|
|
|
$cachingArgs += @("--binarysource=clear;$BinarySourceStub,$binaryCachingMode")
|
2020-09-29 04:54:10 +08:00
|
|
|
}
|
2020-06-27 03:37:53 +08:00
|
|
|
|
2023-04-25 12:22:59 +08:00
|
|
|
if ($IsLinuxHost) {
|
2020-06-26 07:36:28 +08:00
|
|
|
$env:HOME = '/home/agent'
|
|
|
|
$executableExtension = [string]::Empty
|
2020-06-27 03:37:53 +08:00
|
|
|
}
|
|
|
|
elseif ($Triplet -eq 'x64-osx') {
|
2020-06-26 07:36:28 +08:00
|
|
|
$executableExtension = [string]::Empty
|
2020-06-27 03:37:53 +08:00
|
|
|
}
|
|
|
|
else {
|
2020-06-26 07:36:28 +08:00
|
|
|
$executableExtension = '.exe'
|
|
|
|
}
|
|
|
|
|
2020-09-22 08:27:35 +08:00
|
|
|
$failureLogs = Join-Path $ArtifactStagingDirectory 'failure-logs'
|
2022-06-16 02:20:52 +08:00
|
|
|
$xunitFile = Join-Path $ArtifactStagingDirectory "$Triplet-results.xml"
|
2020-07-03 11:20:07 +08:00
|
|
|
|
2021-10-21 13:51:29 +08:00
|
|
|
if ($IsWindows)
|
|
|
|
{
|
|
|
|
mkdir empty
|
|
|
|
cmd /c "robocopy.exe empty `"$buildtreesRoot`" /MIR /NFL /NDL /NC /NP > nul"
|
|
|
|
cmd /c "robocopy.exe empty `"$packagesRoot`" /MIR /NFL /NDL /NC /NP > nul"
|
|
|
|
cmd /c "robocopy.exe empty `"$installRoot`" /MIR /NFL /NDL /NC /NP > nul"
|
|
|
|
rmdir empty
|
|
|
|
}
|
|
|
|
|
2020-06-26 07:36:28 +08:00
|
|
|
& "./vcpkg$executableExtension" x-ci-clean @commonArgs
|
2021-09-15 08:46:38 +08:00
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
|
|
{
|
|
|
|
throw "vcpkg clean failed"
|
|
|
|
}
|
|
|
|
|
2021-12-14 04:54:16 +08:00
|
|
|
$parentHashes = @()
|
|
|
|
if (($BuildReason -eq 'PullRequest') -and -not $NoParentHashes)
|
|
|
|
{
|
2023-04-12 14:11:59 +08:00
|
|
|
$headBaseline = Get-Content "$PSScriptRoot/../ci.baseline.txt" -Raw
|
|
|
|
|
2021-12-14 04:54:16 +08:00
|
|
|
# Prefetch tools for better output
|
2022-03-08 03:39:32 +08:00
|
|
|
foreach ($tool in @('cmake', 'ninja', 'git')) {
|
|
|
|
& "./vcpkg$executableExtension" fetch $tool
|
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
|
|
{
|
|
|
|
throw "Failed to fetch $tool"
|
|
|
|
}
|
|
|
|
}
|
2021-12-14 04:54:16 +08:00
|
|
|
|
2023-04-12 14:11:59 +08:00
|
|
|
Write-Host "Comparing with HEAD~1"
|
2022-03-08 03:39:32 +08:00
|
|
|
& git revert -n -m 1 HEAD | Out-Null
|
2023-04-12 14:11:59 +08:00
|
|
|
$parentBaseline = Get-Content "$PSScriptRoot/../ci.baseline.txt" -Raw
|
|
|
|
if ($parentBaseline -eq $headBaseline)
|
|
|
|
{
|
|
|
|
Write-Host "CI baseline unchanged, determining parent hashes"
|
|
|
|
$parentHashesFile = Join-Path $ArtifactStagingDirectory 'parent-hashes.json'
|
|
|
|
$parentHashes = @("--parent-hashes=$parentHashesFile")
|
|
|
|
# The vcpkg.cmake toolchain file is not part of ABI hashing,
|
|
|
|
# but changes must trigger at least some testing.
|
|
|
|
Copy-Item "scripts/buildsystems/vcpkg.cmake" -Destination "scripts/test_ports/cmake"
|
|
|
|
Copy-Item "scripts/buildsystems/vcpkg.cmake" -Destination "scripts/test_ports/cmake-user"
|
|
|
|
& "./vcpkg$executableExtension" ci "--triplet=$Triplet" --dry-run "--ci-baseline=$PSScriptRoot/../ci.baseline.txt" @commonArgs --no-binarycaching "--output-hashes=$parentHashesFile"
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Write-Host "CI baseline was modified, not using parent hashes"
|
|
|
|
}
|
|
|
|
Write-Host "Running CI for HEAD"
|
2022-03-08 03:39:32 +08:00
|
|
|
& git reset --hard HEAD
|
2021-12-14 04:54:16 +08:00
|
|
|
}
|
2021-11-02 03:18:28 +08:00
|
|
|
|
2022-03-24 07:16:17 +08:00
|
|
|
# The vcpkg.cmake toolchain file is not part of ABI hashing,
|
|
|
|
# but changes must trigger at least some testing.
|
|
|
|
Copy-Item "scripts/buildsystems/vcpkg.cmake" -Destination "scripts/test_ports/cmake"
|
|
|
|
Copy-Item "scripts/buildsystems/vcpkg.cmake" -Destination "scripts/test_ports/cmake-user"
|
2022-06-16 02:20:52 +08:00
|
|
|
& "./vcpkg$executableExtension" ci "--triplet=$Triplet" --failure-logs=$failureLogs --x-xunit=$xunitFile "--ci-baseline=$PSScriptRoot/../ci.baseline.txt" @commonArgs @cachingArgs @parentHashes @skipFailuresArg
|
2021-09-29 05:00:33 +08:00
|
|
|
|
2021-12-14 04:54:16 +08:00
|
|
|
$failureLogsEmpty = (-Not (Test-Path $failureLogs) -Or ((Get-ChildItem $failureLogs).count -eq 0))
|
|
|
|
Write-Host "##vso[task.setvariable variable=FAILURE_LOGS_EMPTY]$failureLogsEmpty"
|
2021-09-15 08:46:38 +08:00
|
|
|
|
2021-12-14 04:54:16 +08:00
|
|
|
if ($LASTEXITCODE -ne 0)
|
|
|
|
{
|
|
|
|
throw "vcpkg ci failed"
|
2021-09-30 04:15:25 +08:00
|
|
|
}
|
2022-06-16 02:20:52 +08:00
|
|
|
|
|
|
|
Write-Host "##vso[task.setvariable variable=XML_RESULTS_FILE]$xunitFile"
|