Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools repository for Tools P…
Browse files Browse the repository at this point in the history
…R 1032
  • Loading branch information
azure-sdk committed Sep 30, 2020
1 parent c60f08c commit 2be7447
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 14 deletions.
4 changes: 3 additions & 1 deletion eng/common/TestResources/New-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ param (
[string] $Location = '',

[Parameter()]
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud')]
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud', 'Dogfood')]
[string] $Environment = 'AzureCloud',

[Parameter()]
Expand Down Expand Up @@ -141,6 +141,7 @@ if (!$Location) {
'AzureCloud' = 'westus2';
'AzureUSGovernment' = 'usgovvirginia';
'AzureChinaCloud' = 'chinaeast2';
'Dogfood' = 'westus'
}[$Environment]

Write-Verbose "Location was not set. Using default location for environment: '$Location'"
Expand Down Expand Up @@ -512,6 +513,7 @@ is based on the cloud to which the template is being deployed:
* AzureCloud -> 'westus2'
* AzureUSGovernment -> 'usgovvirginia'
* AzureChinaCloud -> 'chinaeast2'
* Dogfood -> 'westus'
.PARAMETER Environment
Name of the cloud environment. The default is the Azure Public Cloud
Expand Down
1 change: 1 addition & 0 deletions eng/common/TestResources/New-TestResources.ps1.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ is based on the cloud to which the template is being deployed:
* AzureCloud -\> 'westus2'
* AzureUSGovernment -\> 'usgovvirginia'
* AzureChinaCloud -\> 'chinaeast2'
* Dogfood -\> 'westus'
```yaml
Type: String
Expand Down
2 changes: 1 addition & 1 deletion eng/common/TestResources/Remove-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ param (
[string] $ServiceDirectory,

[Parameter()]
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud')]
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud', 'Dogfood')]
[string] $Environment = 'AzureCloud',

[Parameter()]
Expand Down
4 changes: 1 addition & 3 deletions eng/common/TestResources/deploy-test-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@ parameters:
# }

steps:
# New-TestResources command requires Az module
- pwsh: Install-Module -Name Az -Scope CurrentUser -AllowClobber -Force -Verbose
displayName: Install Azure PowerShell module
- template: /eng/common/TestResources/setup-az-modules.yml

- pwsh: |
$subscriptionConfiguration = @"
Expand Down
36 changes: 36 additions & 0 deletions eng/common/TestResources/setup-az-modules.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Cloud Configuration will be splat into parameters of `Add-AzEnvironment`. It
# should be JSON in the form (not all fields are required):
# {
# "Name": "<environment name>",
# "PublishSettingsFileUrl": "<publish settings file url>",
# "ServiceEndpoint": "<service endpoint>",
# "ManagementPortalUrl": "<management portal url>",
# "ActiveDirectoryEndpoint": "<active directory endpoint>",
# "ActiveDirectoryServiceEndpointResourceId": "<active directory service endpoint resource id>",
# "ResourceManagerEndpoint": "<resource manager endpoint>",
# "GalleryEndpoint": "<gallery endpoint>",
# "GraphEndpoint": "<graph endpoint>",
# "GraphAudience": "<graph audience>",
# "AzureKeyVaultDnsSuffix": "<key vault suffix>",
# "AzureKeyVaultServiceEndpointResourceId": "<key vault service endpoint resource id>"
# }

steps:
- bash: sudo chown -R runner ~/.Azure
displayName: (MacOS) Grant access to ~/.Azure
condition: contains(variables['OSVmImage'], 'mac')

# New-TestResources command requires Az module
- pwsh: Install-Module -Name Az -Scope CurrentUser -AllowClobber -Force -Verbose
displayName: Install Azure PowerShell module

- task: Powershell@2
inputs:
displayName: Register Dogfood environment
targetType: inline
pwsh: true
script: |
$environmentSpec = @"
$(env-config-dogfood)
"@ | ConvertFrom-Json -AsHashtable;
Add-AzEnvironment @environmentSpec
12 changes: 3 additions & 9 deletions eng/common/scripts/Submit-PullRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ $headers = @{

$query = "state=open&head=${PROwner}:${PRBranch}&base=${BaseBranch}"

function AddLabels([int] $prNumber, [string] $prLabelString, [array] $existingLabels)
function AddLabels([int] $prNumber, [string] $prLabelString)
{
# Adding labels to the pr.
if (-not $prLabelString) {
Expand All @@ -68,12 +68,6 @@ function AddLabels([int] $prNumber, [string] $prLabelString, [array] $existingLa

# Parse the labels from string to array
$prLabelArray = @($prLabelString.Split(",") | % { $_.Trim() } | ? { return $_ })
foreach ($label in $existingLabels) {
if ($prLabelArray -contains $label.name) {
continue
}
$prLabelArray += $label.name
}
$prLabelUri = "https://api.github.com/repos/$RepoOwner/$RepoName/issues/$prNumber"
$labelRequestData = @{
labels = $prLabelArray
Expand Down Expand Up @@ -103,7 +97,7 @@ if ($resp.Count -gt 0) {

# setting variable to reference the pull request by number
Write-Host "##vso[task.setvariable variable=Submitted.PullRequest.Number]$($resp[0].number)"
AddLabels $resp[0].number $PRLabels $resp[0].labels
AddLabels $resp[0].number $PRLabels
}
else {
$data = @{
Expand All @@ -130,5 +124,5 @@ else {
# setting variable to reference the pull request by number
Write-Host "##vso[task.setvariable variable=Submitted.PullRequest.Number]$($resp.number)"

AddLabels $resp.number $PRLabels $resp.labels
AddLabels $resp.number $PRLabels
}

0 comments on commit 2be7447

Please sign in to comment.