Skip to content

Commit 500b2be

Browse files
committed
Merge remote-tracking branch 'origin/master' into lro_continuation_token
2 parents 52ba1d8 + 1d28b02 commit 500b2be

File tree

302 files changed

+47949
-22869
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

302 files changed

+47949
-22869
lines changed

eng/autorest_req.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ pytest-cov==2.8.1
44
pytest-asyncio==0.10.0; python_version >= '3.5'
55
isodate==0.6.0
66
msrest==0.6.13
7-
aiohttp==3.6.2
7+
aiohttp==3.6.2
8+
wheel

eng/common/TestResources/New-TestResources.ps1

Lines changed: 71 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ param (
6262
[switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID),
6363

6464
[Parameter()]
65-
[switch] $Force
65+
[switch] $Force,
66+
67+
[Parameter()]
68+
[switch] $OutFile
6669
)
6770

6871
# By default stop for any error.
@@ -108,7 +111,8 @@ trap {
108111
}
109112

110113
# Enumerate test resources to deploy. Fail if none found.
111-
$root = [System.IO.Path]::Combine("$PSScriptRoot/../../../sdk", $ServiceDirectory) | Resolve-Path
114+
$repositoryRoot = "$PSScriptRoot/../../.." | Resolve-Path
115+
$root = [System.IO.Path]::Combine($repositoryRoot, "sdk", $ServiceDirectory) | Resolve-Path
112116
$templateFileName = 'test-resources.json'
113117
$templateFiles = @()
114118

@@ -172,19 +176,20 @@ if ($TestApplicationId -and !$TestApplicationOid) {
172176
}
173177
}
174178

179+
180+
# If the ServiceDirectory is an absolute path use the last directory name
181+
# (e.g. D:\foo\bar\ -> bar)
182+
$serviceName = if (Split-Path -IsAbsolute $ServiceDirectory) {
183+
Split-Path -Leaf $ServiceDirectory
184+
} else {
185+
$ServiceDirectory
186+
}
187+
175188
# Format the resource group name based on resource group naming recommendations and limitations.
176189
$resourceGroupName = if ($CI) {
177190
$BaseName = 't' + (New-Guid).ToString('n').Substring(0, 16)
178191
Write-Verbose "Generated base name '$BaseName' for CI build"
179192

180-
# If the ServiceDirectory is an absolute path use the last directory name
181-
# (e.g. D:\foo\bar\ -> bar)
182-
$serviceName = if (Split-Path -IsAbsolute $ServiceDirectory) {
183-
Split-Path -Leaf $ServiceDirectory
184-
} else {
185-
$ServiceDirectory
186-
}
187-
188193
"rg-{0}-$BaseName" -f ($serviceName -replace '[\\\/:]', '-').Substring(0, [Math]::Min($serviceName.Length, 90 - $BaseName.Length - 4)).Trim('-')
189194
} else {
190195
"rg-$BaseName"
@@ -281,12 +286,21 @@ foreach ($templateFile in $templateFiles) {
281286
Write-Verbose "Successfully deployed template '$templateFile' to resource group '$($resourceGroup.ResourceGroupName)'"
282287
}
283288

284-
if ($deployment.Outputs.Count -and !$CI) {
285-
# Write an extra new line to isolate the environment variables for easy reading.
286-
Log "Persist the following environment variables based on your detected shell ($shell):`n"
289+
$serviceDirectoryPrefix = $serviceName.ToUpperInvariant() + "_"
290+
291+
$context = Get-AzContext;
292+
293+
# Add default values
294+
$deploymentOutputs = @{
295+
"$($serviceDirectoryPrefix)CLIENT_ID" = $TestApplicationId;
296+
"$($serviceDirectoryPrefix)CLIENT_SECRET" = $TestApplicationSecret;
297+
"$($serviceDirectoryPrefix)TENANT_ID" = $context.Tenant.Id;
298+
"$($serviceDirectoryPrefix)SUBSCRIPTION_ID" = $context.Subscription.Id;
299+
"$($serviceDirectoryPrefix)RESOURCE_GROUP" = $resourceGroup.ResourceGroupName;
300+
"$($serviceDirectoryPrefix)LOCATION" = $resourceGroup.Location;
301+
"$($serviceDirectoryPrefix)ENVIRONMENT" = $context.Environment.Name;
287302
}
288303

289-
$deploymentOutputs = @{}
290304
foreach ($key in $deployment.Outputs.Keys) {
291305
$variable = $deployment.Outputs[$key]
292306

@@ -295,23 +309,54 @@ foreach ($templateFile in $templateFiles) {
295309

296310
if ($variable.Type -eq 'String' -or $variable.Type -eq 'SecureString') {
297311
$deploymentOutputs[$key] = $variable.Value
312+
}
313+
}
298314

315+
if ($OutFile)
316+
{
317+
if (!$IsWindows)
318+
{
319+
Write-Host "File option is supported only on Windows"
320+
}
321+
322+
$outputFile = "$templateFile.env"
323+
324+
$environmentText = $deploymentOutputs | ConvertTo-Json;
325+
$bytes = ([System.Text.Encoding]::UTF8).GetBytes($environmentText)
326+
$protectedBytes = [Security.Cryptography.ProtectedData]::Protect($bytes, $null, [Security.Cryptography.DataProtectionScope]::CurrentUser)
327+
328+
Set-Content $outputFile -Value $protectedBytes -AsByteStream -Force
329+
330+
Write-Host "Test environment settings`n $environmentText`nstored into encrypted $outputFile"
331+
}
332+
else
333+
{
334+
335+
if (!$CI) {
336+
# Write an extra new line to isolate the environment variables for easy reading.
337+
Log "Persist the following environment variables based on your detected shell ($shell):`n"
338+
}
339+
340+
foreach ($key in $deploymentOutputs.Keys)
341+
{
342+
$value = $deploymentOutputs[$key]
343+
299344
if ($CI) {
300345
# Treat all ARM template output variables as secrets since "SecureString" variables do not set values.
301346
# In order to mask secrets but set environment variables for any given ARM template, we set variables twice as shown below.
302347
Write-Host "Setting variable '$key': ***"
303-
Write-Host "##vso[task.setvariable variable=_$key;issecret=true;]$($variable.Value)"
304-
Write-Host "##vso[task.setvariable variable=$key;]$($variable.Value)"
348+
Write-Host "##vso[task.setvariable variable=_$key;issecret=true;]$($value)"
349+
Write-Host "##vso[task.setvariable variable=$key;]$($value)"
305350
} else {
306-
Write-Host ($shellExportFormat -f $key, $variable.Value)
351+
Write-Host ($shellExportFormat -f $key, $value)
307352
}
308353
}
309-
}
310354

311-
if ($key) {
312-
# Isolate the environment variables for easy reading.
313-
Write-Host "`n"
314-
$key = $null
355+
if ($key) {
356+
# Isolate the environment variables for easy reading.
357+
Write-Host "`n"
358+
$key = $null
359+
}
315360
}
316361

317362
$postDeploymentScript = $templateFile | Split-Path | Join-Path -ChildPath 'test-resources-post.ps1'
@@ -442,6 +487,10 @@ Deployment (CI/CD) build (only Azure Pipelines is currently supported).
442487
.PARAMETER Force
443488
Force creation of resources instead of being prompted.
444489
490+
.PARAMETER OutFile
491+
Save test environment settings into a test-resources.json.env file next to test-resources.json. File is protected via DPAPI. Supported only on windows.
492+
The environment file would be scoped to the current repository directory.
493+
445494
.EXAMPLE
446495
Connect-AzAccount -Subscription "REPLACE_WITH_SUBSCRIPTION_ID"
447496
$testAadApp = New-AzADServicePrincipal -Role Owner -DisplayName 'azure-sdk-live-test-app'

eng/common/TestResources/Remove-TestResources.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ param (
3838
[Parameter(ParameterSetName = 'Default+Provisioner', Mandatory = $true)]
3939
[Parameter(ParameterSetName = 'ResourceGroup+Provisioner', Mandatory = $true)]
4040
[string] $ProvisionerApplicationSecret,
41+
42+
[Parameter()]
43+
[string] $ServiceDirectory,
4144

4245
[Parameter()]
4346
[ValidateSet('AzureCloud', 'AzureUSGovernment', 'AzureChinaCloud')]
@@ -116,6 +119,15 @@ if (!$ResourceGroupName) {
116119
$ResourceGroupName = "rg-$BaseName"
117120
}
118121

122+
if (![string]::IsNullOrWhiteSpace($ServiceDirectory)) {
123+
$root = [System.IO.Path]::Combine("$PSScriptRoot/../../../sdk", $ServiceDirectory) | Resolve-Path
124+
$preRemovalScript = Join-Path -Path $root -ChildPath 'remove-test-resources-pre.ps1'
125+
if (Test-Path $preRemovalScript) {
126+
Log "Invoking pre resource removal script '$preRemovalScript'"
127+
&$preRemovalScript -ResourceGroupName $ResourceGroupName @PSBoundParameters
128+
}
129+
}
130+
119131
Log "Deleting resource group '$ResourceGroupName'"
120132
if (Retry { Remove-AzResourceGroup -Name "$ResourceGroupName" -Force:$Force }) {
121133
Write-Verbose "Successfully deleted resource group '$ResourceGroupName'"
@@ -157,6 +169,10 @@ A service principal ID to provision test resources when a provisioner is specifi
157169
.PARAMETER ProvisionerApplicationSecret
158170
A service principal secret (password) to provision test resources when a provisioner is specified.
159171
172+
.PARAMETER ServiceDirectory
173+
A directory under 'sdk' in the repository root - optionally with subdirectories
174+
specified - in which to discover pre removal script named 'remove-test-resources-pre.json'.
175+
160176
.PARAMETER Environment
161177
Name of the cloud environment. The default is the Azure Public Cloud
162178
('PublicCloud')

eng/common/TestResources/Remove-TestResources.ps1.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,22 @@ Accept pipeline input: False
169169
Accept wildcard characters: False
170170
```
171171
172+
### -ServiceDirectory
173+
A directory under 'sdk' in the repository root - optionally with subdirectories
174+
specified - specified - in which to discover pre removal script named 'remove-test-resources-pre.json'.
175+
176+
```yaml
177+
Type: String
178+
Parameter Sets: (All)
179+
Aliases:
180+
181+
Required: False
182+
Position: Named
183+
Default value: None
184+
Accept pipeline input: False
185+
Accept wildcard characters: False
186+
```
187+
172188
### -Environment
173189
Name of the cloud environment.
174190
The default is the Azure Public Cloud

eng/common/TestResources/remove-test-resources.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
# Assumes steps in deploy-test-resources.yml was run previously. Requires
88
# environment variable: AZURE_RESOURCEGROUP_NAME and Az PowerShell module
99

10+
parameters:
11+
ServiceDirectory: ''
12+
1013
steps:
1114
- pwsh: >
1215
eng/common/TestResources/Remove-TestResources.ps1
@@ -15,6 +18,7 @@ steps:
1518
-SubscriptionId '$(azure-subscription-id)'
1619
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id)'
1720
-ProvisionerApplicationSecret '$(aad-azure-sdk-test-client-secret)'
21+
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
1822
-Environment 'AzureCloud'
1923
-Force
2024
-Verbose
@@ -29,6 +33,7 @@ steps:
2933
-SubscriptionId '$(azure-subscription-id-gov)'
3034
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id-gov)'
3135
-ProvisionerApplicationSecret '$(aad-azure-sdk-test-client-secret-gov)'
36+
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
3237
-Environment 'AzureUSGovernment'
3338
-Force
3439
-Verbose
@@ -43,6 +48,7 @@ steps:
4348
-SubscriptionId '$(azure-subscription-id-cn)'
4449
-ProvisionerApplicationId '$(aad-azure-sdk-test-client-id-cn)'
4550
-ProvisionerApplicationSecret '$(aad-azure-sdk-test-client-secret-cn)'
51+
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
4652
-Environment 'AzureChinaCloud'
4753
-Force
4854
-Verbose
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
steps:
3+
# https://github.com/actions/virtual-environments/issues/798
4+
- script: sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
5+
displayName: Bypass local DNS server to workaround issue resolving cognitiveservices names
6+
condition: and(succeededOrFailed(), eq(variables['OSVmImage'], 'ubuntu-18.04'))
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Example Usage: ./copy-readmes-to-docs.ps1 -CodeRepo C:/repo/sdk-for-python -DocRepo C:/repo/azure-docs-sdk-python
2+
# run the link updating script before this to get links fixed to the release
3+
# Highly recommended that you use Powershell Core.
4+
# git reset --hard origin/smoke-test on the doc repo prior to running this
5+
6+
param (
7+
[String]$CodeRepo,
8+
[String]$DocRepo,
9+
[String]$TargetServices
10+
)
11+
12+
$PACKAGE_README_REGEX = ".*[\/\\]sdk[\\\/][^\/\\]+[\\\/][^\/\\]+[\/\\]README\.md"
13+
14+
Write-Host "repo is $CodeRepo"
15+
16+
$date = Get-Date -Format "MM/dd/yyyy"
17+
18+
if ($CodeRepo -Match "net")
19+
{
20+
$lang = ".NET"
21+
$TARGET_FOLDER = Join-Path -Path $DocRepo -ChildPath "api/overview/azure"
22+
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/dotnet-packages.csv"
23+
}
24+
if ($CodeRepo -Match "python"){
25+
$lang = "Python"
26+
$TARGET_FOLDER = Join-Path -Path $DocRepo -ChildPath "docs-ref-services"
27+
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/python-packages.csv"
28+
}
29+
if ($CodeRepo -Match "java"){
30+
$lang = "Java"
31+
$TARGET_FOLDER = Join-Path -Path $DocRepo -ChildPath "docs-ref-services"
32+
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/java-packages.csv"
33+
}
34+
if ($CodeRepo -Match "js"){
35+
$lang = "JavaScript"
36+
$TARGET_FOLDER = Join-Path -Path $DocRepo -ChildPath "docs-ref-services"
37+
$metadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/js-packages.csv"
38+
}
39+
40+
41+
42+
$metadataResponse = Invoke-WebRequest -Uri $metadataUri | ConvertFrom-Csv
43+
44+
if ([string]::IsNullOrWhiteSpace($TargetServices))
45+
{
46+
$selectedServices = $metadataResponse | ForEach-Object -Process {$_.RepoPath} | Get-Unique
47+
}
48+
else {
49+
$selectedServices = $TargetServices -Split "," | % { return $_.Trim() }
50+
}
51+
52+
53+
foreach($service in $selectedServices){
54+
$readmePath = Join-Path -Path $CodeRepo -ChildPath "sdk/$service"
55+
Write-Host "Examining: $readmePath"
56+
57+
$libraries = $metadataResponse | Where-Object { $_.RepoPath -eq $service }
58+
59+
foreach($library in $libraries){
60+
61+
$package = $library.Package
62+
$version = If ([string]::IsNullOrWhiteSpace($library.VersionGA)) {$library.VersionPreview} Else {$library.VersionGA}
63+
64+
$file = Join-Path -Path $readmePath -ChildPath "/$package/README.md" | Get-Item
65+
Write-Host "`tOutputting $($file.FullName)"
66+
67+
$fileContent = Get-Content $file
68+
69+
$fileContent = $fileContent -Join "`n"
70+
71+
$fileMatch = (Select-String -InputObject $fileContent -Pattern 'Azure .+? (client|plugin|shared) library for (JavaScript|Java|Python|\.NET)').Matches[0]
72+
73+
$header = "---`r`ntitle: $fileMatch`r`nkeywords: Azure, $lang, SDK, API, $service, $package`r`nauthor: maggiepint`r`nms.author: magpint`r`nms.date: $date`r`nms.topic: article`r`nms.prod: azure`r`nms.technology: azure`r`nms.devlang: $lang`r`nms.service: $service`r`n---`r`n"
74+
75+
$fileContent = $fileContent -replace $fileMatch, "$fileMatch - Version $version `r`n"
76+
77+
$fileContent = "$header $fileContent"
78+
79+
$readmeName = "$($file.Directory.Name.Replace('azure-','').Replace('Azure.', '').ToLower())-readme.md"
80+
81+
$readmeOutputLocation = Join-Path $TARGET_FOLDER -ChildPath $readmeName
82+
83+
Set-Content -Path $readmeOutputLocation -Value $fileContent
84+
}
85+
}

eng/pipelines/autorest_checks.yml

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ variables:
1717
NodeVersion: '10.x'
1818
PythonVersion: '3.6'
1919
auto_rest_clone_url: 'https://github.com/Azure/autorest.python.git'
20-
repo_branch: 'azure-core'
21-
source_path: 'sdk/core/azure-core'
20+
repo_branch: 'autorestv3'
21+
source_path_azure_core: 'sdk/core/azure-core'
22+
source_path_azure_mgmt_core: 'sdk/core/azure-mgmt-core'
2223

2324
jobs:
2425
- job: 'Run_AutoRest'
@@ -40,13 +41,24 @@ jobs:
4041

4142
- script: |
4243
pip install -r eng/autorest_req.txt
43-
pip install $(Build.SourcesDirectory)/$(source_path)
44-
displayName: 'Prepare Environment'
45-
46-
- script: |
47-
git clone --recursive $(auto_rest_clone_url)
44+
git clone $(auto_rest_clone_url)
4845
cd autorest.python
4946
git checkout $(repo_branch)
5047
npm install
51-
pytest test/vanilla
52-
displayName: 'Run Test'
48+
displayName: 'Prepare Environment'
49+
50+
- script: |
51+
cd $(Build.SourcesDirectory)/autorest.python/test/vanilla
52+
pip install $(Build.SourcesDirectory)/$(source_path_azure_core)
53+
pip install -r requirements.txt
54+
pip freeze
55+
pytest $(Build.SourcesDirectory)/autorest.python/test/vanilla
56+
displayName: 'Install azure-core and Test Vanilla'
57+
58+
- script: |
59+
cd $(Build.SourcesDirectory)/autorest.python/test/azure
60+
pip install $(Build.SourcesDirectory)/$(source_path_azure_mgmt_core)
61+
pip install -r requirements.txt
62+
pip freeze
63+
pytest $(Build.SourcesDirectory)/autorest.python/test/azure
64+
displayName: 'Install azure-mgmt-core and Test Azure'

0 commit comments

Comments
 (0)