Sync eng/common directory with azure-sdk-tools repository (#66)
This commit is contained in:
Родитель
55deee50ec
Коммит
c7eab3a3ba
|
@ -33,6 +33,10 @@ param (
|
|||
[ValidateNotNullOrEmpty()]
|
||||
[string] $TenantId,
|
||||
|
||||
[Parameter(ParameterSetName = 'Provisioner')]
|
||||
[ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')]
|
||||
[string] $SubscriptionId,
|
||||
|
||||
[Parameter(ParameterSetName = 'Provisioner', Mandatory = $true)]
|
||||
[ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')]
|
||||
[string] $ProvisionerApplicationId,
|
||||
|
@ -48,7 +52,7 @@ param (
|
|||
[string] $Location = '',
|
||||
|
||||
[Parameter()]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud')]
|
||||
[string] $Environment = 'AzureCloud',
|
||||
|
||||
[Parameter()]
|
||||
|
@ -126,17 +130,11 @@ if (!$templateFiles) {
|
|||
# environment. If no matching environment is found $Location remains an empty
|
||||
# string.
|
||||
if (!$Location) {
|
||||
$defaultLocations = @{
|
||||
$Location = @{
|
||||
'AzureCloud' = 'westus2';
|
||||
'AzureUSGovernment' = 'usgovvirginia';
|
||||
'AzureChinaCloud' = 'chinaeast2';
|
||||
}
|
||||
|
||||
if ($defaultLocations.ContainsKey($Environment)) {
|
||||
$Location = $defaultLocations[$Environment]
|
||||
} else {
|
||||
Write-Error "Location cannot be empty and there is no default location for Environment: '$Environment'"
|
||||
}
|
||||
}[$Environment]
|
||||
|
||||
Write-Verbose "Location was not set. Using default location for environment: '$Location'"
|
||||
}
|
||||
|
@ -149,8 +147,13 @@ if ($ProvisionerApplicationId) {
|
|||
$provisionerSecret = ConvertTo-SecureString -String $ProvisionerApplicationSecret -AsPlainText -Force
|
||||
$provisionerCredential = [System.Management.Automation.PSCredential]::new($ProvisionerApplicationId, $provisionerSecret)
|
||||
|
||||
# Use the given subscription ID if provided.
|
||||
$subscriptionArgs = if ($SubscriptionId) {
|
||||
@{SubscriptionId = $SubscriptionId}
|
||||
}
|
||||
|
||||
$provisionerAccount = Retry {
|
||||
Connect-AzAccount -Tenant $TenantId -Credential $provisionerCredential -ServicePrincipal -Environment $Environment
|
||||
Connect-AzAccount -Tenant $TenantId -Credential $provisionerCredential -ServicePrincipal @subscriptionArgs
|
||||
}
|
||||
|
||||
$exitActions += {
|
||||
|
@ -418,13 +421,13 @@ This isused for CI automation.
|
|||
Optional location where resources should be created. By default this is
|
||||
'westus2'.
|
||||
|
||||
.PARAMETER AdditionalParameters
|
||||
Optional key-value pairs of parameters to pass to the ARM template(s).
|
||||
|
||||
.PARAMETER Environment
|
||||
Name of the cloud environment. The default is the Azure Public Cloud
|
||||
('PublicCloud')
|
||||
|
||||
.PARAMETER AdditionalParameters
|
||||
Optional key-value pairs of parameters to pass to the ARM template(s).
|
||||
|
||||
.PARAMETER CI
|
||||
Indicates the script is run as part of a Continuous Integration / Continuous
|
||||
Deployment (CI/CD) build (only Azure Pipelines is currently supported).
|
||||
|
@ -433,10 +436,9 @@ Deployment (CI/CD) build (only Azure Pipelines is currently supported).
|
|||
Force creation of resources instead of being prompted.
|
||||
|
||||
.EXAMPLE
|
||||
$subscriptionId = "REPLACE_WITH_SUBSCRIPTION_ID"
|
||||
Connect-AzAccount -Subscription $subscriptionId
|
||||
Connect-AzAccount -Subscription "REPLACE_WITH_SUBSCRIPTION_ID"
|
||||
$testAadApp = New-AzADServicePrincipal -Role Owner -DisplayName 'azure-sdk-live-test-app'
|
||||
.\eng\common\LiveTestResources\New-TestResources.ps1 `
|
||||
New-TestResources.ps1 `
|
||||
-BaseName 'myalias' `
|
||||
-ServiceDirectory 'keyvault' `
|
||||
-TestApplicationId $testAadApp.ApplicationId.ToString() `
|
||||
|
@ -449,7 +451,7 @@ Requires PowerShell 7 to use ConvertFrom-SecureString -AsPlainText or convert
|
|||
the SecureString to plaintext by another means.
|
||||
|
||||
.EXAMPLE
|
||||
eng/New-TestResources.ps1 `
|
||||
New-TestResources.ps1 `
|
||||
-BaseName 'Generated' `
|
||||
-ServiceDirectory '$(ServiceDirectory)' `
|
||||
-TenantId '$(TenantId)' `
|
||||
|
|
|
@ -25,6 +25,11 @@ param (
|
|||
[ValidateNotNullOrEmpty()]
|
||||
[string] $TenantId,
|
||||
|
||||
[Parameter(ParameterSetName = 'Default+Provisioner')]
|
||||
[Parameter(ParameterSetName = 'ResourceGroup+Provisioner')]
|
||||
[ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')]
|
||||
[string] $SubscriptionId,
|
||||
|
||||
[Parameter(ParameterSetName = 'Default+Provisioner', Mandatory = $true)]
|
||||
[Parameter(ParameterSetName = 'ResourceGroup+Provisioner', Mandatory = $true)]
|
||||
[ValidatePattern('^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$')]
|
||||
|
@ -35,7 +40,7 @@ param (
|
|||
[string] $ProvisionerApplicationSecret,
|
||||
|
||||
[Parameter()]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud')]
|
||||
[string] $Environment = 'AzureCloud',
|
||||
|
||||
[Parameter()]
|
||||
|
@ -90,8 +95,14 @@ if ($ProvisionerApplicationId) {
|
|||
Log "Logging into service principal '$ProvisionerApplicationId'"
|
||||
$provisionerSecret = ConvertTo-SecureString -String $ProvisionerApplicationSecret -AsPlainText -Force
|
||||
$provisionerCredential = [System.Management.Automation.PSCredential]::new($ProvisionerApplicationId, $provisionerSecret)
|
||||
|
||||
# Use the given subscription ID if provided.
|
||||
$subscriptionArgs = if ($SubscriptionId) {
|
||||
@{SubscriptionId = $SubscriptionId}
|
||||
}
|
||||
|
||||
$provisionerAccount = Retry {
|
||||
Connect-AzAccount -Tenant $TenantId -Credential $provisionerCredential -ServicePrincipal -Environment $Environment
|
||||
Connect-AzAccount -Tenant $TenantId -Credential $provisionerCredential -ServicePrincipal @subscriptionArgs
|
||||
}
|
||||
|
||||
$exitActions += {
|
||||
|
@ -136,6 +147,10 @@ The name of the resource group to delete.
|
|||
.PARAMETER TenantId
|
||||
The tenant ID of a service principal when a provisioner is specified.
|
||||
|
||||
.PARAMETER SubscriptionId
|
||||
Optional subscription ID to use for new resources when logging in as a provisioner.
|
||||
You can also use Set-AzContext if not provisioning.
|
||||
|
||||
.PARAMETER ProvisionerApplicationId
|
||||
A service principal ID to provision test resources when a provisioner is specified.
|
||||
|
||||
|
@ -156,7 +171,7 @@ Use the currently logged-in account to delete the resource group by the name of
|
|||
'rg-uuid123'
|
||||
|
||||
.EXAMPLE
|
||||
eng/Remove-TestResources.ps1 `
|
||||
Remove-TestResources.ps1 `
|
||||
-ResourceGroupName "${env:AZURE_RESOURCEGROUP_NAME}" `
|
||||
-TenantId '$(TenantId)' `
|
||||
-ProvisionerApplicationId '$(AppId)' `
|
||||
|
|
|
@ -20,6 +20,7 @@ steps:
|
|||
-BaseName 'Generated'
|
||||
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
|
||||
-TenantId '$(aad-azure-sdk-test-tenant-id)'
|
||||
-SubscriptionId '$(azure-subscription-id)'
|
||||
-TestApplicationId '$(aad-azure-sdk-test-client-id)'
|
||||
-TestApplicationSecret '$(aad-azure-sdk-test-client-secret)'
|
||||
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id)'
|
||||
|
@ -39,6 +40,7 @@ steps:
|
|||
-BaseName 'Generated'
|
||||
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
|
||||
-TenantId '$(aad-azure-sdk-test-tenant-id-gov)'
|
||||
-SubscriptionId '$(azure-subscription-id)'
|
||||
-TestApplicationId '$(aad-azure-sdk-test-client-id-gov)'
|
||||
-TestApplicationSecret '$(aad-azure-sdk-test-client-secret-gov)'
|
||||
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id-gov)'
|
||||
|
@ -58,6 +60,7 @@ steps:
|
|||
-BaseName 'Generated'
|
||||
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
|
||||
-TenantId '$(aad-azure-sdk-test-tenant-id-cn)'
|
||||
-SubscriptionId '$(azure-subscription-id)'
|
||||
-TestApplicationId '$(aad-azure-sdk-test-client-id-cn)'
|
||||
-TestApplicationSecret '$(aad-azure-sdk-test-client-secret-cn)'
|
||||
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id-cn)'
|
||||
|
|
|
@ -12,6 +12,7 @@ steps:
|
|||
eng/common/TestResources/Remove-TestResources.ps1
|
||||
-ResourceGroupName "${env:AZURE_RESOURCEGROUP_NAME}"
|
||||
-TenantId '$(aad-azure-sdk-test-tenant-id)'
|
||||
-SubscriptionId '$(azure-subscription-id)'
|
||||
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id)'
|
||||
-ProvisionerApplicationSecret '$(aad-azure-sdk-test-client-secret)'
|
||||
-Environment 'AzureCloud'
|
||||
|
@ -25,6 +26,7 @@ steps:
|
|||
eng/common/TestResources/Remove-TestResources.ps1
|
||||
-ResourceGroupName "${env:AZURE_RESOURCEGROUP_NAME}"
|
||||
-TenantId '$(aad-azure-sdk-test-tenant-id-gov)'
|
||||
-SubscriptionId '$(azure-subscription-id)'
|
||||
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id-gov)'
|
||||
-ProvisionerApplicationSecret '$(aad-azure-sdk-test-client-secret-gov)'
|
||||
-Environment 'AzureUSGovernment'
|
||||
|
@ -38,6 +40,7 @@ steps:
|
|||
eng/common/TestResources/Remove-TestResources.ps1
|
||||
-ResourceGroupName "${env:AZURE_RESOURCEGROUP_NAME}"
|
||||
-TenantId '$(aad-azure-sdk-test-tenant-id-cn)'
|
||||
-SubscriptionId '$(azure-subscription-id)'
|
||||
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id-cn)'
|
||||
-ProvisionerApplicationSecret '$(aad-azure-sdk-test-client-secret-cn)'
|
||||
-Environment 'AzureChinaCloud'
|
||||
|
|
|
@ -41,6 +41,8 @@ param(
|
|||
$PRBody = $PRTitle
|
||||
)
|
||||
|
||||
Write-Host $MyInvocation.Line
|
||||
|
||||
$query = "state=open&head=${PROwner}:${PRBranch}&base=${BaseBranch}"
|
||||
|
||||
$resp = Invoke-RestMethod "https://api.github.com/repos/$RepoOwner/$RepoName/pulls?$query"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# Note, due to how `Expand-Archive` is leveraged in this script,
|
||||
# powershell core is a requirement for successful execution.
|
||||
# Note, due to how `Expand-Archive` is leveraged in this script,
|
||||
# powershell core is a requirement for successful execution.
|
||||
param (
|
||||
$AzCopy,
|
||||
$DocLocation,
|
||||
|
@ -9,6 +9,9 @@ param (
|
|||
$ExitOnError=1,
|
||||
$UploadLatest=1
|
||||
)
|
||||
|
||||
Write-Host $MyInvocation.Line
|
||||
|
||||
$Language = $Language.ToLower()
|
||||
|
||||
# Regex inspired but simplified from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
|
||||
|
@ -51,14 +54,14 @@ function ToSemVer($version){
|
|||
{
|
||||
throw "Unable to convert $version to valid semver and hard exit on error is enabled. Exiting."
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
return $null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function SortSemVersions($versions)
|
||||
function SortSemVersions($versions)
|
||||
{
|
||||
return $versions | Sort -Property Major, Minor, Patch, PrereleaseLabel, PrereleaseNumber -Descending
|
||||
}
|
||||
|
@ -68,7 +71,7 @@ function Sort-Versions
|
|||
Param (
|
||||
[Parameter(Mandatory=$true)] [string[]]$VersionArray
|
||||
)
|
||||
|
||||
|
||||
# standard init and sorting existing
|
||||
$versionsObject = New-Object PSObject -Property @{
|
||||
OriginalVersionArray = $VersionArray
|
||||
|
@ -78,16 +81,16 @@ function Sort-Versions
|
|||
LatestPreviewPackage = ""
|
||||
}
|
||||
|
||||
if ($VersionArray.Count -eq 0)
|
||||
{
|
||||
return $versionsObject
|
||||
if ($VersionArray.Count -eq 0)
|
||||
{
|
||||
return $versionsObject
|
||||
}
|
||||
|
||||
$versionsObject.SortedVersionArray = @(SortSemVersions -versions ($VersionArray | % { ToSemVer $_}))
|
||||
$versionsObject.RawVersionsList = $versionsObject.SortedVersionArray | % { $_.RawVersion }
|
||||
|
||||
# handle latest and preview
|
||||
# we only want to hold onto the latest preview if its NEWER than the latest GA.
|
||||
# we only want to hold onto the latest preview if its NEWER than the latest GA.
|
||||
# this means that the latest preview package either A) has to be the latest value in the VersionArray
|
||||
# or B) set to nothing. We'll handle the set to nothing case a bit later.
|
||||
$versionsObject.LatestPreviewPackage = $versionsObject.SortedVersionArray[0].RawVersion
|
||||
|
@ -100,7 +103,7 @@ function Sort-Versions
|
|||
$versionsObject.LatestGAPackage = $gaVersions[0].RawVersion
|
||||
|
||||
# in the case where latest preview == latestGA (because of our default selection earlier)
|
||||
if ($versionsObject.LatestGAPackage -eq $versionsObject.LatestPreviewPackage)
|
||||
if ($versionsObject.LatestGAPackage -eq $versionsObject.LatestPreviewPackage)
|
||||
{
|
||||
# latest is newest, unset latest preview
|
||||
$versionsObject.LatestPreviewPackage = ""
|
||||
|
@ -152,7 +155,7 @@ function Update-Existing-Versions
|
|||
$existingVersions += $PkgVersion
|
||||
Write-Host "No existing versions. Adding $PkgVersion."
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
$existingVersions += $pkgVersion
|
||||
Write-Host "Already Existing Versions. Adding $PkgVersion."
|
||||
|
@ -167,7 +170,7 @@ function Update-Existing-Versions
|
|||
Write-Host $sortedVersionObj.LatestGAPackage
|
||||
Write-Host $sortedVersionObj.LatestPreviewPackage
|
||||
|
||||
# write to file. to get the correct performance with "actually empty" files, we gotta do the newline
|
||||
# write to file. to get the correct performance with "actually empty" files, we gotta do the newline
|
||||
# join ourselves. This way we have absolute control over the trailing whitespace.
|
||||
$sortedVersionObj.RawVersionsList -join "`n" | Out-File -File "$($DocLocation)/versions" -Force -NoNewLine
|
||||
$sortedVersionObj.LatestGAPackage | Out-File -File "$($DocLocation)/latest-ga" -Force -NoNewLine
|
||||
|
@ -205,7 +208,7 @@ function Upload-Blobs
|
|||
# we can safely assume we have AT LEAST one version here. Reason being we just completed Update-Existing-Versions
|
||||
$latestVersion = ($versionsObj.SortedVersionArray | Select-Object -First 1).RawVersion
|
||||
|
||||
if ($UploadLatest -and ($latestVersion -eq $DocVersion))
|
||||
if ($UploadLatest -and ($latestVersion -eq $DocVersion))
|
||||
{
|
||||
Write-Host "Uploading $($PkgName) to latest folder in $($DocDest)..."
|
||||
& $($AzCopy) cp "$($DocDir)/**" "$($DocDest)/$($PkgName)/latest$($SASKey)" --recursive=true
|
||||
|
@ -222,7 +225,7 @@ if ($Language -eq "javascript")
|
|||
Write-Host $PkgName
|
||||
Expand-Archive -Force -Path "$($DocLocation)/documentation/$($Item.Name)" -DestinationPath "$($DocLocation)/documentation/$($Item.BaseName)"
|
||||
$dirList = Get-ChildItem "$($DocLocation)/documentation/$($Item.BaseName)/$($Item.BaseName)" -Attributes Directory
|
||||
|
||||
|
||||
if($dirList.Length -eq 1){
|
||||
$DocVersion = $dirList[0].Name
|
||||
Write-Host "Uploading Doc for $($PkgName) Version:- $($DocVersion)..."
|
||||
|
@ -243,7 +246,7 @@ if ($Language -eq "dotnet")
|
|||
$PkgName = $Item.Name.Remove(0, 5)
|
||||
$PkgFullName = $PublishedPkgs | Where-Object -FilterScript {$_.Name -match "$($PkgName).\d"}
|
||||
|
||||
if (($PkgFullName | Measure-Object).count -eq 1)
|
||||
if (($PkgFullName | Measure-Object).count -eq 1)
|
||||
{
|
||||
$DocVersion = $PkgFullName[0].BaseName.Remove(0, $PkgName.Length + 1)
|
||||
|
||||
|
@ -264,12 +267,12 @@ if ($Language -eq "dotnet")
|
|||
if ($Language -eq "python")
|
||||
{
|
||||
$PublishedDocs = Get-ChildItem "$DocLocation" | Where-Object -FilterScript {$_.Name.EndsWith(".zip")}
|
||||
|
||||
|
||||
foreach ($Item in $PublishedDocs) {
|
||||
$PkgName = $Item.BaseName
|
||||
$ZippedDocumentationPath = Join-Path -Path $DocLocation -ChildPath $Item.Name
|
||||
$UnzippedDocumentationPath = Join-Path -Path $DocLocation -ChildPath $PkgName
|
||||
$VersionFileLocation = Join-Path -Path $UnzippedDocumentationPath -ChildPath "version.txt"
|
||||
$VersionFileLocation = Join-Path -Path $UnzippedDocumentationPath -ChildPath "version.txt"
|
||||
|
||||
Expand-Archive -Force -Path $ZippedDocumentationPath -DestinationPath $UnzippedDocumentationPath
|
||||
|
||||
|
|
|
@ -18,6 +18,8 @@ param (
|
|||
[switch]$forceCreate = $false
|
||||
)
|
||||
|
||||
Write-Host $MyInvocation.Line
|
||||
|
||||
$VERSION_REGEX = "(?<major>\d+)(\.(?<minor>\d+))?(\.(?<patch>\d+))?((?<pre>[^0-9][^\s]+))?"
|
||||
$SDIST_PACKAGE_REGEX = "^(?<package>.*)\-(?<versionstring>$VERSION_REGEX$)"
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@ param(
|
|||
[string] $PushArgs = ""
|
||||
)
|
||||
|
||||
Write-Host $MyInvocation.Line
|
||||
|
||||
# This is necessay because of the janky git command output writing to stderr.
|
||||
# Without explicitly setting the ErrorActionPreference to continue the script
|
||||
# would fail the first time git wrote command output.
|
||||
|
@ -73,8 +75,8 @@ if ($LASTEXITCODE -ne 0)
|
|||
$numberOfRetries = 10
|
||||
$needsRetry = $false
|
||||
$tryNumber = 0
|
||||
do
|
||||
{
|
||||
do
|
||||
{
|
||||
$needsRetry = $false
|
||||
Write-Host "git push azure-sdk-fork $PRBranchName $PushArgs"
|
||||
git push azure-sdk-fork $PRBranchName $PushArgs
|
||||
|
@ -91,7 +93,7 @@ do
|
|||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
try
|
||||
try
|
||||
{
|
||||
$TempPatchFile = New-TemporaryFile
|
||||
Write-Host "git diff ${PRBranchName}~ ${PRBranchName} --output $TempPatchFile"
|
||||
|
@ -136,7 +138,7 @@ do
|
|||
}
|
||||
}
|
||||
|
||||
} while($needsRetry -and $tryNumber -le $numberOfRetries)
|
||||
} while($needsRetry -and $tryNumber -le $numberOfRetries)
|
||||
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче