1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
# 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. 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.
.PARAMETER AllowUnexpectedPassing
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 KnownFailuresAbiLog
If present, the path to a file containing a list of known ABI failing ABI hashes, typically generated
by the `vcpkg x-check-features` command.
#>
[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,
[String]$BuildReason = $null,
[switch]$NoParentHashes = $false,
[switch]$AllowUnexpectedPassing = $false
)
function Add-ToolchainToTestCMake {
# 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"
}
if (-Not ((Test-Path "triplets/$Triplet.cmake") -or (Test-Path "triplets/community/$Triplet.cmake"))) {
Write-Error "Incorrect triplet '$Triplet', please supply a valid triplet."
exit 1
}
if ((-Not [string]::IsNullOrWhiteSpace($ArchivesRoot))) {
if ((-Not [string]::IsNullOrWhiteSpace($BinarySourceStub))) {
Write-Error "Only one binary caching setting may be used."
exit 1
}
$BinarySourceStub = "files,$ArchivesRoot"
}
$buildtreesRoot = Join-Path $WorkingRoot 'b'
$installRoot = Join-Path $WorkingRoot 'installed'
$packagesRoot = Join-Path $WorkingRoot 'p'
$env:AZCOPY_LOG_LOCATION = Join-Path $WorkingRoot 'azcopy-logs'
$env:AZCOPY_JOB_PLAN_LOCATION = Join-Path $WorkingRoot 'azcopy-plans'
if ($Triplet -eq 'x64-osx') {
$env:AZCOPY_BUFFER_GB = 2
$env:AZCOPY_CONCURRENCY_VALUE = 8
}
if (!(Test-Path $env:AZCOPY_LOG_LOCATION))
{
New-Item -ItemType Directory -Path $env:AZCOPY_LOG_LOCATION | Out-Null
}
Write-Host "AzCopy logs location: $env:AZCOPY_LOG_LOCATION"
Write-Host "##vso[task.setvariable variable=AZCOPY_LOGS_EMPTY]$true"
$commonArgs = @(
"--x-buildtrees-root=$buildtreesRoot",
"--x-install-root=$installRoot",
"--x-packages-root=$packagesRoot",
"--overlay-ports=scripts/test_ports"
)
$testFeatures = $false
$cachingArgs = @()
$skipFailuresArgs = @()
if ([string]::IsNullOrWhiteSpace($BinarySourceStub)) {
$cachingArgs = @('--binarysource', 'clear')
} else {
$cachingArgs = @()
$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, testing features, skipping failures.'
$skipFailuresArgs = @('--skip-failures')
$testFeatures = $true
}
else {
Write-Host "Build reason was $BuildReason, using binary caching in write only mode."
$binaryCachingMode = 'write'
}
$cachingArgs += "--binarysource=clear;$BinarySourceStub,$binaryCachingMode"
}
if ($IsWindows) {
$vcpkgExe = './vcpkg.exe'
} else {
$vcpkgExe = './vcpkg'
}
if ($Triplet -eq 'x64-windows-release') {
$tripletArg = "--host-triplet=$Triplet"
} else {
$tripletArg = "--triplet=$Triplet"
}
$failureLogs = Join-Path $ArtifactStagingDirectory 'failure-logs'
$failureLogsArg = "--failure-logs=$failureLogs"
$knownFailuresFromArgs = @()
if ($testFeatures) {
& $vcpkgExe x-ci-clean @commonArgs
$lastLastExitCode = $LASTEXITCODE
if ($lastLastExitCode -ne 0)
{
Write-Error "vcpkg x-ci-clean failed. This is usually an infrastructure problem; trying again may help."
exit $lastLastExitCode
}
$ciFeatureBaselineFile = "$PSScriptRoot/../ci.feature.baseline.txt"
$ciFeatureBaselineArg = "--ci-feature-baseline=$ciFeatureBaselineFile"
$knownFailingAbisFile = Join-Path $ArtifactStagingDirectory 'failing-abi-log.txt'
$failingAbiLogArg = "--failing-abi-log=$knownFailingAbisFile"
& $vcpkgExe x-test-features --for-merge-with origin/master $tripletArg $failureLogsArg $ciBaselineArg $failingAbiLogArg $ciFeatureBaselineArg @commonArgs @cachingArgs
$lastLastExitCode = $LASTEXITCODE
$azcopyLogsEmpty = ((Get-ChildItem $env:AZCOPY_LOG_LOCATION).Count -eq 0)
Write-Host "##vso[task.setvariable variable=AZCOPY_LOGS_EMPTY]$azcopyLogsEmpty"
if ($lastLastExitCode -ne 0)
{
Write-Host "##vso[task.setvariable variable=FAILURE_LOGS_EMPTY]$false"
Write-Host "##vso[task.logissue type=error]vcpkg feature testing failed; this is usually a bug in one of the features in the port(s) edited in this pull request. See https://github.com/microsoft/vcpkg/discussions/31357 for how to access AZP failure logs."
exit $lastLastExitCode
}
$knownFailuresFromArgs += "--known-failures-from=$knownFailingAbisFile"
}
$ciBaselineFile = "$PSScriptRoot/../ci.baseline.txt"
$ciBaselineArg = "--ci-baseline=$ciBaselineFile"
$toolMetadataFile = "$PSScriptRoot/../vcpkg-tool-metadata.txt"
& $vcpkgExe x-ci-clean @commonArgs
$lastLastExitCode = $LASTEXITCODE
if ($lastLastExitCode -ne 0)
{
Write-Error "vcpkg x-ci-clean failed. This is usually an infrastructure problem; trying again may help."
exit $lastLastExitCode
}
if ($IsMacOS)
{
Write-Host "macOS disk space report:"
& df -h | Where-Object { $_ -match "Avail|/System/Volumes/Data$" }
& du -sh $WorkingRoot
}
$parentHashesArgs = @()
if (($BuildReason -eq 'PullRequest') -and -not $NoParentHashes)
{
$headBaseline = Get-Content $ciBaselineFile -Raw
$headTool = Get-Content $toolMetadataFile -Raw
Write-Host "Comparing with HEAD~1"
& git revert -n -m 1 HEAD | Out-Null
$lastLastExitCode = $LASTEXITCODE
if ($lastLastExitCode -ne 0)
{
Write-Error "git revert -n -m 1 HEAD failed"
exit $lastLastExitCode
}
$parentBaseline = Get-Content $ciBaselineFile -Raw
$parentTool = Get-Content $toolMetadataFile -Raw
if (($parentBaseline -eq $headBaseline) -and ($parentTool -eq $headTool))
{
Write-Host "CI baseline unchanged, determining parent hashes"
$parentHashesFile = Join-Path $ArtifactStagingDirectory 'parent-hashes.json'
$parentHashesArgs += "--parent-hashes=$parentHashesFile"
Add-ToolchainToTestCMake
& $vcpkgExe ci $tripletArg --dry-run $ciBaselineArg @commonArgs --no-binarycaching "--output-hashes=$parentHashesFile"
$lastLastExitCode = $LASTEXITCODE
if ($lastLastExitCode -ne 0)
{
Write-Error "Generating parent hashes failed; this is usually an infrastructure problem with vcpkg"
exit $lastLastExitCode
}
}
else
{
Write-Host "Tool or baseline modified, not using parent hashes"
}
Write-Host "Running CI for HEAD"
& git reset --hard HEAD
$lastLastExitCode = $LASTEXITCODE
if ($lastLastExitCode -ne 0)
{
Write-Error "git reset --hard HEAD failed"
exit $lastLastExitCode
}
}
$allowUnexpectedPassingArgs = @()
if ($AllowUnexpectedPassing) {
$allowUnexpectedPassingArgs = @('--allow-unexpected-passing')
}
Add-ToolchainToTestCMake
$xunitFile = Join-Path $ArtifactStagingDirectory "$Triplet-results.xml"
$xunitArg = "--x-xunit=$xunitFile"
$prHashesFile = Join-Path $ArtifactStagingDirectory "pr-hashes.json"
& $vcpkgExe ci `
$tripletArg `
$failureLogsArg `
"--output-hashes=$prHashesFile" `
$xunitArg `
$ciBaselineArg `
@commonArgs `
@cachingArgs `
@parentHashesArgs `
@skipFailuresArgs `
@knownFailuresFromArgs `
@allowUnexpectedPassingArgs
$lastLastExitCode = $LASTEXITCODE
$failureLogsEmpty = (-Not (Test-Path $failureLogs) -Or ((Get-ChildItem $failureLogs).Count -eq 0))
Write-Host "##vso[task.setvariable variable=FAILURE_LOGS_EMPTY]$failureLogsEmpty"
$azcopyLogsEmpty = ((Get-ChildItem $env:AZCOPY_LOG_LOCATION).Count -eq 0)
Write-Host "##vso[task.setvariable variable=AZCOPY_LOGS_EMPTY]$azcopyLogsEmpty"
Write-Host "##vso[task.setvariable variable=XML_RESULTS_FILE]$xunitFile"
if ($lastLastExitCode -ne 0)
{
if (-Not $failureLogsEmpty)
{
Write-Host "##vso[task.logissue type=error]vcpkg ci testing failed; this is usually a bug in a port. See https://github.com/microsoft/vcpkg/discussions/31357 for how to access AZP failure logs."
}
else
{
Write-Host "##vso[task.logissue type=error]vcpkg ci testing failed, but no build failure logs were created for this error."
}
}
exit $lastLastExitCode
|