Skip to content

Commit e9fbba5

Browse files
committed
Sync eng/common directory with azure-sdk-tools repository
1 parent ffefbbb commit e9fbba5

19 files changed

+548
-85
lines changed

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

+17
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,23 @@ Accept pipeline input: False
412412
Accept wildcard characters: False
413413
```
414414
415+
### -OutFile
416+
save test environment settings into a test-resources.json.env file next to test-resources.json.
417+
The file is protected via DPAPI. The environment file would be scoped to the current repository directory.
418+
Note: Supported only on Windows.
419+
420+
```yaml
421+
Type: SwitchParameter
422+
Parameter Sets: (All)
423+
Aliases:
424+
425+
Required: False
426+
Position: Named
427+
Default value: None
428+
Accept pipeline input: False
429+
Accept wildcard characters: False
430+
```
431+
415432
### CommonParameters
416433
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
417434

eng/common/TestResources/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ eng\common\TestResources\New-TestResources.ps1 `
3535
-TestApplicationSecret (ConvertFrom-SecureString $sp.Secret -AsPlainText)
3636
```
3737

38+
If you are running this for a .NET project on Windows, the recommended method is to
39+
add the `-OutFile` switch to the above command. This will save test environment settings
40+
into a test-resources.json.env file next to test-resources.json. The file is protected via DPAPI.
41+
The environment file would be scoped to the current repository directory and avoids the need to
42+
set environment variables or restart your IDE to recognize them.
43+
3844
Along with some log messages, this will output environment variables based on
3945
your current shell like in the following example:
4046

eng/common/pipelines/templates/steps/create-pull-request.yml

+24-20
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,31 @@ steps:
3535
workingDirectory: ${{ parameters.WorkingDirectory }}
3636
ignoreLASTEXITCODE: true
3737

38-
- pwsh: |
39-
${{ parameters.ScriptDirectory }}/git-branch-push.ps1 `
40-
-PRBranchName "${{ parameters.PRBranchName }}" `
41-
-CommitMsg "${{ parameters.CommitMsg }}" `
42-
-GitUrl "https://$(azuresdk-github-pat)@github.com/${{ parameters.PROwner }}/${{ parameters.RepoName }}.git" `
43-
-PushArgs "${{ parameters.PushArgs }}"
44-
38+
- task: PowerShell@2
4539
displayName: Push changes
46-
workingDirectory: ${{ parameters.WorkingDirectory }}
4740
condition: and(succeeded(), eq(variables['HasChanges'], 'true'))
41+
inputs:
42+
pwsh: true
43+
workingDirectory: ${{ parameters.WorkingDirectory }}
44+
filePath: ${{ parameters.ScriptDirectory }}/git-branch-push.ps1
45+
arguments: >
46+
-PRBranchName "${{ parameters.PRBranchName }}"
47+
-CommitMsg "${{ parameters.CommitMsg }}"
48+
-GitUrl "https://$(azuresdk-github-pat)@github.com/${{ parameters.PROwner }}/${{ parameters.RepoName }}.git"
49+
-PushArgs "${{ parameters.PushArgs }}"
4850
49-
- pwsh: |
50-
${{ parameters.ScriptDirectory }}/Submit-PullRequest.ps1 `
51-
-RepoOwner "${{ parameters.RepoOwner }}" `
52-
-RepoName "${{ parameters.RepoName }}" `
53-
-BaseBranch "${{ parameters.BaseBranchName }}" `
54-
-PROwner "${{ parameters.PROwner }}" `
55-
-PRBranch "${{ parameters.PRBranchName }}" `
56-
-AuthToken "$(azuresdk-github-pat)" `
57-
-PRTitle "${{ parameters.PRTitle }}"
58-
51+
- task: PowerShell@2
5952
displayName: Create pull request
60-
workingDirectory: ${{ parameters.WorkingDirectory }}
61-
condition: and(succeeded(), eq(variables['HasChanges'], 'true'))
53+
condition: and(succeeded(), eq(variables['HasChanges'], 'true'))
54+
inputs:
55+
pwsh: true
56+
workingDirectory: ${{ parameters.WorkingDirectory }}
57+
filePath: ${{ parameters.ScriptDirectory }}/Submit-PullRequest.ps1
58+
arguments: >
59+
-RepoOwner "${{ parameters.RepoOwner }}"
60+
-RepoName "${{ parameters.RepoName }}"
61+
-BaseBranch "${{ parameters.BaseBranchName }}"
62+
-PROwner "${{ parameters.PROwner }}"
63+
-PRBranch "${{ parameters.PRBranchName }}"
64+
-AuthToken "$(azuresdk-github-pat)"
65+
-PRTitle "${{ parameters.PRTitle }}"

eng/common/pipelines/templates/steps/create-tags-and-git-release.yml

+6-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ steps:
1010
- task: PowerShell@2
1111
displayName: 'Verify Package Tags and Create Git Releases'
1212
inputs:
13-
targetType: filePath
1413
filePath: ${{ parameters.ScriptDirectory }}/create-tags-and-git-release.ps1
15-
arguments: -artifactLocation ${{parameters.ArtifactLocation}} -packageRepository ${{parameters.PackageRepository}} -releaseSha ${{parameters.ReleaseSha}} -repoId ${{parameters.RepoId}} -workingDirectory '${{parameters.WorkingDirectory}}'
14+
arguments: >
15+
-artifactLocation ${{ parameters.ArtifactLocation }}
16+
-packageRepository ${{ parameters.PackageRepository }}
17+
-releaseSha ${{ parameters.ReleaseSha }}
18+
-repoId ${{ parameters.RepoId }}
19+
-workingDirectory '${{ parameters.WorkingDirectory }}'
1620
pwsh: true
1721
timeoutInMinutes: 5
1822
env:

eng/common/pipelines/templates/steps/docs-metadata-release.yml

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ parameters:
1616
steps:
1717
- pwsh: |
1818
git clone https://github.com/${{ parameters.TargetDocRepoOwner }}/${{ parameters.TargetDocRepoName }} ${{ parameters.WorkingDirectory }}/repo
19-
19+
2020
try {
2121
Push-Location ${{ parameters.WorkingDirectory }}/repo
22-
22+
2323
Write-Host "git checkout smoke-test"
2424
git checkout smoke-test
2525
} finally {
@@ -33,14 +33,14 @@ steps:
3333
inputs:
3434
targetType: filePath
3535
filePath: ${{ parameters.ScriptDirectory }}/update-docs-metadata.ps1
36-
arguments: >
37-
-ArtifactLocation ${{parameters.ArtifactLocation}}
38-
-Repository ${{parameters.PackageRepository}}
39-
-ReleaseSHA ${{parameters.ReleaseSha}}
40-
-RepoId ${{parameters.RepoId}}
41-
-WorkDirectory '${{parameters.WorkingDirectory}}'
42-
-DocRepoLocation "${{parameters.WorkingDirectory}}/repo"
43-
-Language "${{parameters.Language}}"
36+
arguments: >
37+
-ArtifactLocation ${{ parameters.ArtifactLocation }}
38+
-Repository ${{ parameters.PackageRepository }}
39+
-ReleaseSHA ${{ parameters.ReleaseSha }}
40+
-RepoId ${{ parameters.RepoId }}
41+
-WorkDirectory "${{ parameters.WorkingDirectory }}"
42+
-DocRepoLocation "${{ parameters.WorkingDirectory }}/repo"
43+
-Language "${{parameters.Language}}"
4444
-DocRepoContentLocation ${{ parameters.DocRepoDestinationPath }}
4545
pwsh: true
4646
env:
@@ -54,5 +54,5 @@ steps:
5454
CommitMsg: "Update readme content for ${{ parameters.ArtifactName }}"
5555
PRTitle: "Docs.MS Readme Update."
5656
BaseBranchName: smoke-test
57-
WorkingDirectory: ${{parameters.WorkingDirectory}}/repo
58-
ScriptDirectory: ${{parameters.WorkingDirectory}}/${{parameters.ScriptDirectory}}
57+
WorkingDirectory: ${{ parameters.WorkingDirectory }}/repo
58+
ScriptDirectory: ${{ parameters.WorkingDirectory }}/${{ parameters.ScriptDirectory }}

eng/common/pipelines/templates/steps/publish-blobs.yml

+8-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@ parameters:
77

88
steps:
99
- pwsh: |
10-
Invoke-WebRequest -MaximumRetryCount 10 -Uri "https://aka.ms/downloadazcopy-v10-windows" `
11-
-OutFile "azcopy.zip" | Wait-Process; Expand-Archive -Path "azcopy.zip" -DestinationPath "$(Build.BinariesDirectory)/azcopy/"
10+
Invoke-WebRequest -MaximumRetryCount 10 -Uri "https://aka.ms/downloadazcopy-v10-windows" -OutFile "azcopy.zip" | Wait-Process;
11+
Expand-Archive -Path "azcopy.zip" -DestinationPath "$(Build.BinariesDirectory)/azcopy/"
1212
workingDirectory: $(Build.BinariesDirectory)
1313
displayName: Download and Extract azcopy Zip
1414

1515
- task: Powershell@2
1616
inputs:
17-
targetType: 'filePath'
1817
filePath: ${{ parameters.ScriptPath }}
19-
arguments: -AzCopy $(Resolve-Path "$(Build.BinariesDirectory)/azcopy/azcopy_windows_amd64_*/azcopy.exe")[0] -DocLocation "${{ parameters.FolderForUpload }}" -SASKey "${{ parameters.BlobSASKey }}" -Language "${{ parameters.TargetLanguage }}" -BlobName "${{ parameters.BlobName }}"
18+
arguments: >
19+
-AzCopy $(Resolve-Path "$(Build.BinariesDirectory)/azcopy/azcopy_windows_amd64_*/azcopy.exe")[0]
20+
-DocLocation "${{ parameters.FolderForUpload }}"
21+
-SASKey "${{ parameters.BlobSASKey }}"
22+
-Language "${{ parameters.TargetLanguage }}"
23+
-BlobName "${{ parameters.BlobName }}"
2024
pwsh: true
2125
workingDirectory: $(Pipeline.Workspace)
2226
displayName: Copy Docs to Blob

eng/common/pipelines/templates/steps/verify-agent-os.yml

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# Template for all Python Scripts in this repository
21
parameters:
32
OSVmImage: $(OSVmImage)
43

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
parameters:
2+
- name: PackageName
3+
type: string
4+
default: 'not-specified'
5+
- name: ServiceName
6+
type: string
7+
default: 'not-specified'
8+
- name: ForRelease
9+
type: boolean
10+
default: false
11+
12+
steps:
13+
- task: Powershell@2
14+
inputs:
15+
filePath: /eng/common/scripts/Verify-ChangeLog.ps1
16+
arguments: >
17+
-PackageName ${{ parameters.PackageName }}
18+
-ServiceName ${{ parameters.ServiceName }}
19+
-RepoRoot $(Build.SourcesDirectory)
20+
-RepoName $(Build.Repository.Name)
21+
-ForRelease ${{ parameters.ForRelease }}
22+
pwsh: true
23+
workingDirectory: $(Pipeline.Workspace)
24+
displayName: Verify ChangeLog / Release Notes
25+
continueOnError: false
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
parameters:
2+
Directory: 'not-specified'
3+
4+
steps:
5+
- task: PowerShell@2
6+
displayName: Link verification check
7+
inputs:
8+
pwsh: true
9+
workingDirectory: $(Build.SourcesDirectory)/${{ parameters.Directory }}
10+
filePath: eng/common/scripts/Verify-Links.ps1
11+
arguments: >
12+
-urls $(dir -r -i *.md) -rootUrl "file://$(Build.SourcesDirectory)/${{ parameters.Directory }}"

eng/common/scripts/Submit-PullRequest.ps1

+20-9
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,25 @@ param(
4141
$PRBody = $PRTitle
4242
)
4343

44-
Write-Host "> $PSCommandPath $args"
44+
$headers = @{
45+
Authorization = "bearer $AuthToken"
46+
}
4547

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

48-
$resp = Invoke-RestMethod "https://api.github.com/repos/$RepoOwner/$RepoName/pulls?$query"
50+
try {
51+
$resp = Invoke-RestMethod -Headers $headers "https://api.github.com/repos/$RepoOwner/$RepoName/pulls?$query"
52+
}
53+
catch {
54+
Write-Error "Invoke-RestMethod [https://api.github.com/repos/$RepoOwner/$RepoName/pulls?$query] failed with exception:`n$_"
55+
exit 1
56+
}
4957
$resp | Write-Verbose
5058

5159
if ($resp.Count -gt 0) {
5260
Write-Host -f green "Pull request already exists $($resp[0].html_url)"
5361
}
5462
else {
55-
$headers = @{
56-
Authorization = "bearer $AuthToken"
57-
}
58-
5963
$data = @{
6064
title = $PRTitle
6165
head = "${PROwner}:${PRBranch}"
@@ -64,9 +68,16 @@ else {
6468
maintainer_can_modify = $true
6569
}
6670

67-
$resp = Invoke-RestMethod -Method POST -Headers $headers `
68-
https://api.github.com/repos/$RepoOwner/$RepoName/pulls `
69-
-Body ($data | ConvertTo-Json)
71+
try {
72+
$resp = Invoke-RestMethod -Method POST -Headers $headers `
73+
"https://api.github.com/repos/$RepoOwner/$RepoName/pulls" `
74+
-Body ($data | ConvertTo-Json)
75+
}
76+
catch {
77+
Write-Error "Invoke-RestMethod [https://api.github.com/repos/$RepoOwner/$RepoName/pulls] failed with exception:`n$_"
78+
exit 1
79+
}
80+
7081
$resp | Write-Verbose
7182
Write-Host -f green "Pull request created https://github.com/$RepoOwner/$RepoName/pull/$($resp.number)"
7283
}
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Wrapper Script for ChangeLog Verification
2+
param (
3+
[Parameter(Mandatory=$true)]
4+
[string]$PackageName,
5+
[Parameter(Mandatory=$true)]
6+
[string]$ServiceName,
7+
[string]$RepoRoot,
8+
[ValidateSet("net","java","js","python")]
9+
[string]$Language,
10+
[string]$RepoName,
11+
[boolean]$ForRelease=$False
12+
)
13+
14+
Import-Module "${PSScriptRoot}/modules/common-manifest.psd1"
15+
16+
if ([System.String]::IsNullOrEmpty($Language))
17+
{
18+
$Language = $RepoName.Substring($RepoName.LastIndexOf('-') + 1)
19+
}
20+
21+
$PackageProp = Get-PkgProperties -PackageName $PackageName -ServiceName $ServiceName -Language $Language -RepoRoot $RepoRoot
22+
Confirm-ChangeLog -ChangeLogLocation $PackageProp.pkgChangeLogPath -VersionString $PackageProp.pkgReadMePath -ForRelease $ForRelease

0 commit comments

Comments
 (0)