Decouple the storage account used for binary caching from the images. (#19912)

* Decouple the storage account used for binary caching from the images.

We are being forced to change infrastructure somewhat more frequently than we would like, so change the binary caches to use a shared storage account like we already use for asset caching.

* blob blob blob

* Add quotes

* Avoid name stomping.
This commit is contained in:
Billy O'Neal 2021-09-03 00:02:29 -07:00 committed by GitHub
parent 887cc9c15a
commit f78c96f706
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 34 deletions

View File

@ -17,6 +17,9 @@ jobs:
- group: vcpkg-asset-caching-credentials - group: vcpkg-asset-caching-credentials
- name: X_VCPKG_ASSET_SOURCES - name: X_VCPKG_ASSET_SOURCES
value: "x-azurl,$(root-url),$(sas),readwrite" value: "x-azurl,$(root-url),$(sas),readwrite"
- group: vcpkg-binary-caching-credentials
- name: X_VCPKG_BINARY_SOURCE_STUB
value: "x-azblob,$(root-bin-url),$(sas-bin)"
steps: steps:
- bash: df -h - bash: df -h
@ -42,7 +45,7 @@ jobs:
inputs: inputs:
failOnStderr: true failOnStderr: true
filePath: 'scripts/azure-pipelines/test-modified-ports.ps1' filePath: 'scripts/azure-pipelines/test-modified-ports.ps1'
arguments: '-Triplet x64-linux -BuildReason $(Build.Reason) -UseEnvironmentSasToken -WorkingRoot ${{ variables.WORKING_ROOT }} -ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)' arguments: '-Triplet x64-linux -BuildReason $(Build.Reason) -BinarySourceStub "$(X_VCPKG_BINARY_SOURCE_STUB)" -WorkingRoot ${{ variables.WORKING_ROOT }} -ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)'
pwsh: true pwsh: true
- bash: | - bash: |
df -h df -h

View File

@ -18,9 +18,6 @@ The Azure Pipelines artifacts directory. If not supplied, defaults to the curren
.PARAMETER ArchivesRoot .PARAMETER ArchivesRoot
Equivalent to '-BinarySourceStub "files,$ArchivesRoot"' Equivalent to '-BinarySourceStub "files,$ArchivesRoot"'
.PARAMETER UseEnvironmentSasToken
Equivalent to '-BinarySourceStub "x-azblob,https://$($env:PROVISIONED_AZURE_STORAGE_NAME).blob.core.windows.net/archives,$($env:PROVISIONED_AZURE_STORAGE_SAS_TOKEN)"'
.PARAMETER BinarySourceStub .PARAMETER BinarySourceStub
The type and parameters of the binary source. Shared across runs of this script. If 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:\" this parameter is not set, binary caching will not be used. Example: "files,W:\"
@ -47,8 +44,6 @@ Param(
$ArtifactStagingDirectory = '.', $ArtifactStagingDirectory = '.',
[Parameter(ParameterSetName='ArchivesRoot')] [Parameter(ParameterSetName='ArchivesRoot')]
$ArchivesRoot = $null, $ArchivesRoot = $null,
[switch]
$UseEnvironmentSasToken = $false,
[Parameter(ParameterSetName='BinarySourceStub')] [Parameter(ParameterSetName='BinarySourceStub')]
$BinarySourceStub = $null, $BinarySourceStub = $null,
$BuildReason = $null, $BuildReason = $null,
@ -61,40 +56,21 @@ if (-Not ((Test-Path "triplets/$Triplet.cmake") -or (Test-Path "triplets/communi
throw throw
} }
$usingBinaryCaching = $true if ((-Not [string]::IsNullOrWhiteSpace($ArchivesRoot))) {
if ([string]::IsNullOrWhiteSpace($BinarySourceStub)) { if ((-Not [string]::IsNullOrWhiteSpace($BinarySourceStub))) {
if ([string]::IsNullOrWhiteSpace($ArchivesRoot)) {
if ($UseEnvironmentSasToken) {
$BinarySourceStub = "x-azblob,https://$($env:PROVISIONED_AZURE_STORAGE_NAME).blob.core.windows.net/archives,$($env:PROVISIONED_AZURE_STORAGE_SAS_TOKEN)"
} else {
$usingBinaryCaching = $false
}
} else {
if ($UseEnvironmentSasToken) {
Write-Error "Only one binary caching setting may be used." Write-Error "Only one binary caching setting may be used."
throw throw
} else { }
$BinarySourceStub = "files,$ArchivesRoot" $BinarySourceStub = "files,$ArchivesRoot"
} }
}
} elseif ((-Not [string]::IsNullOrWhiteSpace($ArchivesRoot)) -Or $UseEnvironmentSasToken) {
Write-Error "Only one binary caching setting may be used."
throw
}
$env:VCPKG_DOWNLOADS = Join-Path $WorkingRoot 'downloads' $env:VCPKG_DOWNLOADS = Join-Path $WorkingRoot 'downloads'
$buildtreesRoot = Join-Path $WorkingRoot 'buildtrees' $buildtreesRoot = Join-Path $WorkingRoot 'buildtrees'
$installRoot = Join-Path $WorkingRoot 'installed' $installRoot = Join-Path $WorkingRoot 'installed'
$packagesRoot = Join-Path $WorkingRoot 'packages' $packagesRoot = Join-Path $WorkingRoot 'packages'
$commonArgs = @() $commonArgs = @(
if ($usingBinaryCaching) {
$commonArgs += @('--binarycaching')
} else {
$commonArgs += @('--no-binarycaching')
}
$commonArgs += @(
"--x-buildtrees-root=$buildtreesRoot", "--x-buildtrees-root=$buildtreesRoot",
"--x-install-root=$installRoot", "--x-install-root=$installRoot",
"--x-packages-root=$packagesRoot", "--x-packages-root=$packagesRoot",
@ -102,7 +78,10 @@ $commonArgs += @(
) )
$skipFailures = $false $skipFailures = $false
if ($usingBinaryCaching) { if ([string]::IsNullOrWhiteSpace($BinarySourceStub)) {
$commonArgs += @('--no-binarycaching')
} else {
$commonArgs += @('--binarycaching')
$binaryCachingMode = 'readwrite' $binaryCachingMode = 'readwrite'
if ([string]::IsNullOrWhiteSpace($BuildReason)) { if ([string]::IsNullOrWhiteSpace($BuildReason)) {
Write-Host 'Build reason not specified, defaulting to using binary caching in read write mode.' Write-Host 'Build reason not specified, defaulting to using binary caching in read write mode.'

View File

@ -17,6 +17,9 @@ jobs:
- group: vcpkg-asset-caching-credentials - group: vcpkg-asset-caching-credentials
- name: X_VCPKG_ASSET_SOURCES - name: X_VCPKG_ASSET_SOURCES
value: "x-azurl,$(root-url),$(sas),readwrite" value: "x-azurl,$(root-url),$(sas),readwrite"
- group: vcpkg-binary-caching-credentials
- name: X_VCPKG_BINARY_SOURCE_STUB
value: "x-azblob,$(root-bin-url),$(sas-bin)"
steps: steps:
- task: PowerShell@2 - task: PowerShell@2
@ -36,7 +39,7 @@ jobs:
inputs: inputs:
failOnStderr: true failOnStderr: true
filePath: 'scripts/azure-pipelines/test-modified-ports.ps1' filePath: 'scripts/azure-pipelines/test-modified-ports.ps1'
arguments: '-Triplet ${{ parameters.triplet }} -BuildReason $(Build.Reason) -UseEnvironmentSasToken -WorkingRoot ${{ variables.WORKING_ROOT }} -ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)' arguments: '-Triplet ${{ parameters.triplet }} -BuildReason $(Build.Reason) -BinarySourceStub "$(X_VCPKG_BINARY_SOURCE_STUB)" -WorkingRoot ${{ variables.WORKING_ROOT }} -ArtifactStagingDirectory $(Build.ArtifactStagingDirectory)'
pwsh: true pwsh: true
- task: PowerShell@2 - task: PowerShell@2
displayName: 'Validate version files' displayName: 'Validate version files'