Skip to content

Commit d96cea6

Browse files
Sync eng/common directory with azure-sdk-tools for PR 16660 (#10253)
* Add Get-PackageApprovalStatus script. * Add Create-APIViewRevision.ps1 script * Add Mark-PackageReleased.ps1 script. * Update proposoal and scripts. Add step templates. * Updates. * Code review feedback. * Feedback. * Update get-package-approval-status condition. * Updates. * Ensure Get-PackageApprovalStatus does not fail for packages that aren't ready for release. * Code review feedback. * Code review feedback. * Validate SDK language for package approval --------- Co-authored-by: Travis Prescott <trpresco@microsoft.com> Co-authored-by: Travis Prescott <tjprescott@users.noreply.github.com>
1 parent 5458c66 commit d96cea6

11 files changed

Lines changed: 1348 additions & 0 deletions
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
parameters:
2+
- name: ArtifactPath
3+
type: string
4+
default: $(Build.ArtifactStagingDirectory)
5+
- name: Artifacts
6+
type: object
7+
default: []
8+
- name: ConfigFileDir
9+
type: string
10+
default: $(Build.ArtifactStagingDirectory)/PackageInfo
11+
- name: GenerateApiReviewForManualOnly
12+
type: boolean
13+
default: false
14+
- name: ArtifactName
15+
type: string
16+
default: "packages"
17+
- name: PackageName
18+
type: string
19+
default: ""
20+
- name: SourceRootPath
21+
type: string
22+
default: $(Build.SourcesDirectory)
23+
- name: PackageInfoFiles
24+
type: object
25+
default: []
26+
27+
steps:
28+
# Automatic APIView revisions are created regardless of how the pipeline is triggered.
29+
# This condition limits revision creation to manual runs when GenerateApiReviewForManualOnly is true.
30+
- ${{ if or(ne(parameters.GenerateApiReviewForManualOnly, true), eq(variables['Build.Reason'], 'Manual')) }}:
31+
# Ideally this should be an initial step in the caller job.
32+
# Remove this step once all callers set the default branch themselves.
33+
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml
34+
parameters:
35+
WorkingDirectory: ${{ parameters.SourceRootPath }}
36+
37+
- ${{ if and(eq(variables['System.TeamProject'], 'internal'), ne(variables['Build.Reason'], 'PullRequest'), not(endsWith(variables['Build.Repository.Name'], '-pr'))) }}:
38+
- task: AzureCLI@2
39+
inputs:
40+
azureSubscription: "APIView prod deployment"
41+
scriptType: pscore
42+
scriptLocation: scriptPath
43+
scriptPath: ${{ parameters.SourceRootPath }}/eng/common/scripts/Create-APIViewRevision.ps1
44+
# PackageInfoFiles example: @('a/file1.json','a/file2.json')
45+
arguments: >
46+
-PackageInfoFiles @('${{ join(''',''', parameters.PackageInfoFiles) }}')
47+
-ArtifactList ('${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json | Select-Object Name)
48+
-ArtifactPath '${{ parameters.ArtifactPath }}'
49+
-ArtifactName '${{ parameters.ArtifactName }}'
50+
-PackageName '${{ parameters.PackageName }}'
51+
-SourceBranch '$(Build.SourceBranchName)'
52+
-DefaultBranch '$(DefaultBranch)'
53+
-ConfigFileDir '${{ parameters.ConfigFileDir }}'
54+
-BuildId '$(Build.BuildId)'
55+
-RepoName '$(Build.Repository.Name)'
56+
displayName: Create APIView Revision
57+
condition: >-
58+
and(
59+
succeededOrFailed(),
60+
not(
61+
and(
62+
eq(variables['Skip.CreateApiReview'], 'true'),
63+
eq(variables['IsRequesterAuthorizedToSkipApiReview'], 'true')
64+
)
65+
)
66+
)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
parameters:
2+
- name: PackageInfoFiles
3+
type: object
4+
- name: RepoOwner
5+
type: string
6+
default: ""
7+
- name: SourceRootPath
8+
type: string
9+
default: $(Build.SourcesDirectory)
10+
11+
steps:
12+
# The consuming pipeline must install the Azure SDK Tools CLI before including this template.
13+
# Use install-azsdk-cli.yml or otherwise set $(AZSDK) to the azsdk executable path.
14+
- task: AzureCLI@2
15+
displayName: Check Package Approval Status
16+
# Keep this predicate aligned with the release-stage inclusion condition in archetype-python-release.yml.
17+
condition: >-
18+
and(
19+
succeeded(),
20+
eq(variables['System.TeamProject'], 'internal'),
21+
or(
22+
in(variables['Build.Reason'], 'Manual', ''),
23+
and(
24+
eq(variables['Build.Reason'], 'IndividualCI'),
25+
eq(variables['Build.SourceBranch'], 'refs/heads/main')
26+
)
27+
),
28+
not(
29+
and(
30+
eq(variables['Skip.CheckPackageApproval'], 'true'),
31+
eq(variables['IsRequesterAuthorizedToSkipApiReview'], 'true')
32+
)
33+
)
34+
)
35+
inputs:
36+
azureSubscription: "ADO to ARH Service Connection"
37+
scriptType: pscore
38+
scriptLocation: scriptPath
39+
scriptPath: ${{ parameters.SourceRootPath }}/eng/common/scripts/Get-PackageApprovalStatus.ps1
40+
# PackageInfoFiles example: @('a/file1.json','a/file2.json')
41+
arguments: >
42+
-PackageInfoFiles @('${{ join(''',''', parameters.PackageInfoFiles) }}')
43+
-RepoOwner '${{ parameters.RepoOwner }}'
44+
-AzSdkExePath '$(AZSDK)'
45+
workingDirectory: $(Pipeline.Workspace)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
parameters:
2+
- name: PackageInfoFiles
3+
type: object
4+
- name: RepoOwner
5+
type: string
6+
default: ""
7+
- name: SourceRootPath
8+
type: string
9+
default: $(Build.SourcesDirectory)
10+
11+
steps:
12+
# Include this template only after package publishing in the release stage.
13+
# The consuming pipeline must install the Azure SDK Tools CLI before including this template.
14+
# Use install-azsdk-cli.yml or otherwise set $(AZSDK) to the azsdk executable path.
15+
- task: AzureCLI@2
16+
displayName: Mark Packages Released
17+
condition: >-
18+
and(
19+
succeeded(),
20+
not(
21+
and(
22+
eq(variables['Skip.MarkPackageReleased'], 'true'),
23+
eq(variables['IsRequesterAuthorizedToSkipApiReview'], 'true')
24+
)
25+
)
26+
)
27+
inputs:
28+
azureSubscription: "ADO to ARH Service Connection"
29+
scriptType: pscore
30+
scriptLocation: scriptPath
31+
scriptPath: ${{ parameters.SourceRootPath }}/eng/common/scripts/Mark-PackageReleased.ps1
32+
# PackageInfoFiles example: @('a/file1.json','a/file2.json')
33+
arguments: >
34+
-PackageInfoFiles @('${{ join(''',''', parameters.PackageInfoFiles) }}')
35+
-RepoOwner '${{ parameters.RepoOwner }}'
36+
-AzSdkExePath '$(AZSDK)'
37+
workingDirectory: $(Pipeline.Workspace)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
variables:
2+
IsRequesterAuthorizedToSkipApiReview: >-
3+
$[in(
4+
lower(variables['Build.RequestedForEmail']),
5+
'bebroder@microsoft.com',
6+
'mharder@microsoft.com',
7+
'djurek@microsoft.com',
8+
'chononiw@microsoft.com',
9+
'raychen@microsoft.com',
10+
'trpresco@microsoft.com',
11+
'prmarott@microsoft.com'
12+
)]

0 commit comments

Comments
 (0)