Skip to content

Commit 669941d

Browse files
committed
Add feature testing script and feature testing for PR builds.
1 parent 8740c84 commit 669941d

File tree

3 files changed

+105
-4
lines changed

3 files changed

+105
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# SPDX-License-Identifier: MIT
3+
#
4+
5+
<#
6+
.SYNOPSIS
7+
Runs the 'Test Modified Ports' part of the vcpkg CI system for all platforms.
8+
9+
.PARAMETER Triplet
10+
The triplet to test.
11+
12+
.PARAMETER WorkingRoot
13+
The location used as scratch space for 'installed', 'packages', and 'buildtrees' vcpkg directories.
14+
15+
.PARAMETER FailureLogs
16+
The location to write failure logs. Defaults to current directory / failure-logs
17+
18+
.PARAMETER ArchivesRoot
19+
Equivalent to '-BinarySourceStub "files,$ArchivesRoot"'
20+
21+
.PARAMETER BinarySourceStub
22+
The type and parameters of the binary source. Shared across runs of this script. If
23+
this parameter is not set, binary caching will not be used. Example: "files,W:\"
24+
#>
25+
26+
[CmdletBinding(DefaultParameterSetName="ArchivesRoot")]
27+
Param(
28+
[Parameter(Mandatory = $true)]
29+
[ValidateNotNullOrEmpty()]
30+
[string]$Triplet,
31+
[Parameter(Mandatory = $true)]
32+
[ValidateNotNullOrEmpty()]
33+
$WorkingRoot,
34+
[ValidateNotNullOrEmpty()]
35+
$FailureLogs = './failure-logs',
36+
[Parameter(ParameterSetName='ArchivesRoot')]
37+
$ArchivesRoot = $null,
38+
[Parameter(ParameterSetName='BinarySourceStub')]
39+
$BinarySourceStub = $null
40+
)
41+
42+
if (-Not ((Test-Path "triplets/$Triplet.cmake") -or (Test-Path "triplets/community/$Triplet.cmake"))) {
43+
Write-Error "Incorrect triplet '$Triplet', please supply a valid triplet."
44+
exit 1
45+
}
46+
47+
if ((-Not [string]::IsNullOrWhiteSpace($ArchivesRoot))) {
48+
if ((-Not [string]::IsNullOrWhiteSpace($BinarySourceStub))) {
49+
Write-Error "Only one binary caching setting may be used."
50+
exit 1
51+
}
52+
53+
$BinarySourceStub = "files,$ArchivesRoot"
54+
}
55+
56+
$buildtreesRoot = Join-Path $WorkingRoot 'b'
57+
$installRoot = Join-Path $WorkingRoot 'installed'
58+
$packagesRoot = Join-Path $WorkingRoot 'p'
59+
60+
$commonArgs = @(
61+
"--x-buildtrees-root=$buildtreesRoot",
62+
"--x-install-root=$installRoot",
63+
"--x-packages-root=$packagesRoot",
64+
"--overlay-ports=scripts/test_ports"
65+
)
66+
67+
$cachingArgs = @()
68+
if ([string]::IsNullOrWhiteSpace($BinarySourceStub)) {
69+
$cachingArgs = @('--no-binarycaching')
70+
} else {
71+
$cachingArgs += "--binarysource=clear;$BinarySourceStub,readwrite"
72+
}
73+
74+
if ($IsWindows) {
75+
$vcpkgExe = './vcpkg.exe'
76+
} else {
77+
$vcpkgExe = './vcpkg'
78+
}
79+
80+
$ciBaselineFile = "$PSScriptRoot/../ci.feature.baseline.txt"
81+
$ciBaselineArg = "--ci-feature-baseline=$ciBaselineFile"
82+
83+
if ($Triplet -eq 'x64-windows-release') {
84+
$tripletArg = "--host-triplet=$Triplet"
85+
} else {
86+
$tripletArg = "--triplet=$Triplet"
87+
}
88+
89+
& $vcpkgExe x-check-features --for-merge-with origin/master $tripletArg "--failure-logs=$FailureLogs" $ciBaselineArg @commonArgs @cachingArgs
90+
$lastLastExitCode = $LASTEXITCODE
91+
if ($lastLastExitCode -ne 0)
92+
{
93+
Write-Error "vcpkg feature testing failed; this is usually a bug in a port. Check for failure logs attached to the run in Azure Pipelines."
94+
}
95+
96+
exit $lastLastExitCode

scripts/azure-pipelines/test-modified-ports.ps1

-3
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,6 @@ Add-ToolchainToTestCMake
192192
& $vcpkgExe ci $tripletArg "--failure-logs=$failureLogs" "--x-xunit=$xunitFile" $ciBaselineArg @commonArgs @cachingArgs @parentHashesArgs @skipFailuresArgs @allowUnexpectedPassingArgs
193193
$lastLastExitCode = $LASTEXITCODE
194194

195-
$failureLogsEmpty = (-Not (Test-Path $failureLogs) -Or ((Get-ChildItem $failureLogs).Count -eq 0))
196-
Write-Host "##vso[task.setvariable variable=FAILURE_LOGS_EMPTY]$failureLogsEmpty"
197-
198195
Write-Host "##vso[task.setvariable variable=XML_RESULTS_FILE]$xunitFile"
199196

200197
if ($lastLastExitCode -ne 0)

scripts/azure-pipelines/windows/azure-pipelines.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,16 @@ jobs:
6969
$binarySas = az storage container generate-sas --name cache --account-name vcpkgbinarycachewus --as-user --auth-mode login --https-only --permissions rclw --expiry $end -o tsv | Out-String
7070
$binarySas = $binarySas.Trim()
7171
$env:X_VCPKG_ASSET_SOURCES = "x-azurl,https://vcpkgassetcachewus.blob.core.windows.net/cache,$assetSas,readwrite"
72+
$binarySourceStub = "x-azblob,https://vcpkgbinarycachewus.blob.core.windows.net/cache,$binarySas"
73+
$triplet = "${{ replace(parameters.jobName, '_', '-') }}"
7274
./vcpkg.exe fetch python3
73-
& scripts/azure-pipelines/test-modified-ports.ps1 -Triplet ${{ replace(parameters.jobName, '_', '-') }} -BuildReason $(Build.Reason) -BinarySourceStub "x-azblob,https://vcpkgbinarycachewus.blob.core.windows.net/cache,$binarySas" -WorkingRoot $env:WORKING_ROOT -ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)
75+
$failureLogs = '$(Build.ArtifactStagingDirectory)/failure-logs'
76+
& scripts/azure-pipelines/test-modified-ports.ps1 -Triplet $triplet -BuildReason $(Build.Reason) -BinarySourceStub $binarySourceStub -WorkingRoot $env:WORKING_ROOT -ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)
77+
if ('$(Build.Reason)' -eq 'PullRequest') {
78+
& scripts/azure-pipelines/test-modified-features.ps1 -Triplet $triplet -BinarySourceStub $binarySourceStub -WorkingRoot $env:WORKING_ROOT -FailureLogs $failureLogs
79+
}
80+
$failureLogsEmpty = (-Not (Test-Path $failureLogs) -Or ((Get-ChildItem $failureLogs).Count -eq 0))
81+
Write-Host "##vso[task.setvariable variable=FAILURE_LOGS_EMPTY]$failureLogsEmpty"
7482
- task: PowerShell@2
7583
displayName: 'Validate version files'
7684
condition: eq('${{ replace(parameters.jobName, '_', '-') }}', '${{ variables.ExtraChecksTriplet }}')

0 commit comments

Comments
 (0)