Skip to content

Commit 77bf3ae

Browse files
Add an option to support creating automatic APIreview from manual pipe… (Azure#28981)
* Add an option to support creating automatic API review from manual pipeline run only
1 parent 2eaee59 commit 77bf3ae

File tree

5 files changed

+44
-26
lines changed

5 files changed

+44
-26
lines changed

eng/pipelines/templates/jobs/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ parameters:
6161
- name: TestProxy
6262
type: boolean
6363
default: false
64+
- name: GenerateApiReviewForManualOnly
65+
type: boolean
66+
default: false
6467

6568
jobs:
6669
- job: 'Build'
@@ -132,6 +135,7 @@ jobs:
132135
Artifacts: ${{ parameters.Artifacts }}
133136
VerifyAutorest: ${{ parameters.VerifyAutorest }}
134137
ValidateFormatting: ${{ parameters.ValidateFormatting }}
138+
GenerateApiReviewForManualOnly: ${{ parameters.GenerateApiReviewForManualOnly }}
135139

136140
- job: Compliance
137141
pool:

eng/pipelines/templates/stages/archetype-sdk-client.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ parameters:
7272
- name: TestProxy
7373
type: boolean
7474
default: false
75+
- name: GenerateApiReviewForManualOnly
76+
type: boolean
77+
default: false
7578

7679
variables:
7780
- template: /eng/pipelines/templates/variables/globals.yml
@@ -106,6 +109,7 @@ stages:
106109
VerifyAutorest: ${{ parameters.VerifyAutorest }}
107110
ValidateFormatting: ${{ parameters.ValidateFormatting }}
108111
TestProxy: ${{ parameters.TestProxy }}
112+
GenerateApiReviewForManualOnly: ${{ parameters.GenerateApiReviewForManualOnly }}
109113

110114
# The Prerelease and Release stages are conditioned on whether we are building a pull request and the branch.
111115
- ${{if and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))}}:

eng/pipelines/templates/steps/analyze.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ parameters:
66
TestPipeline: false
77
VerifyAutorest: false
88
ValidateFormatting: false
9+
GenerateApiReviewForManualOnly: false
910

1011
# The variable TargetingString is set by template `eng/pipelines/templates/steps/targeting-string-resolve.yml`. This template is invoked from yml files:
1112
# eng/pipelines/templates/jobs/ci.tests.yml
@@ -140,6 +141,7 @@ steps:
140141
- template: /eng/pipelines/templates/steps/create-apireview.yml
141142
parameters:
142143
Artifacts: ${{ parameters.Artifacts }}
144+
GenerateApiReviewForManualOnly: ${{ parameters.GenerateApiReviewForManualOnly }}
143145

144146
- template: /eng/common/pipelines/templates/steps/detect-api-changes.yml
145147
parameters:

eng/pipelines/templates/steps/create-apireview.yml

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,38 @@ parameters:
44
ConfigFileDir: $(Build.ArtifactStagingDirectory)/PackageInfo
55
Language: 'Python'
66
APIViewUri: 'https://apiview.dev/AutoReview/CreateApiReview'
7+
GenerateApiReviewForManualOnly: false
78

89
steps:
910
# ideally this should be done as initial step of a job in caller template
1011
# We can remove this step later once it is added in caller
1112
- template: /eng/common/pipelines/templates/steps/set-default-branch.yml
12-
13-
- task: Powershell@2
14-
inputs:
15-
filePath: $(Build.SourcesDirectory)/eng/scripts/Create-ApiReview.ps1
16-
arguments: >
17-
-ArtifactList ('${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json | Select-Object Name)
18-
-ArtifactPath ${{ parameters.ArtifactPath }}
19-
-APIViewUri ${{ parameters.APIViewUri }}
20-
-APIKey $(azuresdk-apiview-apikey)
21-
-SourceBranch $(Build.SourceBranchName)
22-
-DefaultBranch $(DefaultBranch)
23-
-ConfigFileDir '${{ parameters.ConfigFileDir }}'
24-
-BuildId $(Build.BuildId)
25-
-RepoName $(Build.Repository.Name)
26-
-Language ${{ parameters.Language }}
27-
pwsh: true
28-
workingDirectory: $(Pipeline.Workspace)
29-
displayName: Create Automatic API Review
30-
condition: >-
31-
and(
32-
succeededOrFailed(),
33-
ne(variables['Skip.CreateApiReview'], 'true'),
34-
ne(variables['Build.Reason'],'PullRequest'),
35-
eq(variables['System.TeamProject'], 'internal'),
36-
not(endsWith(variables['Build.Repository.Name'], '-pr'))
37-
)
13+
14+
# Automatic API review is generated for a package when pipeline runs irrespective of how pipeline gets triggered.
15+
# Below condition ensures that API review is generated only for manual pipeline runs when flag GenerateApiReviewForManualOnly is set to true.
16+
- ${{ if or(ne(parameters.GenerateApiReviewForManualOnly, true), eq(variables['Build.Reason'], 'Manual')) }}:
17+
- task: Powershell@2
18+
inputs:
19+
filePath: $(Build.SourcesDirectory)/eng/scripts/Create-ApiReview.ps1
20+
arguments: >
21+
-ArtifactList ('${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json | Select-Object Name)
22+
-ArtifactPath ${{ parameters.ArtifactPath }}
23+
-APIViewUri ${{ parameters.APIViewUri }}
24+
-APIKey $(azuresdk-apiview-apikey)
25+
-SourceBranch $(Build.SourceBranchName)
26+
-DefaultBranch $(DefaultBranch)
27+
-ConfigFileDir '${{ parameters.ConfigFileDir }}'
28+
-BuildId $(Build.BuildId)
29+
-RepoName $(Build.Repository.Name)
30+
-Language ${{ parameters.Language }}
31+
pwsh: true
32+
workingDirectory: $(Pipeline.Workspace)
33+
displayName: Create Automatic API Review
34+
condition: >-
35+
and(
36+
succeededOrFailed(),
37+
ne(variables['Skip.CreateApiReview'], 'true'),
38+
ne(variables['Build.Reason'],'PullRequest'),
39+
eq(variables['System.TeamProject'], 'internal'),
40+
not(endsWith(variables['Build.Repository.Name'], '-pr'))
41+
)

sdk/ml/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ extends:
3131
ValidateFormatting: true
3232
TestTimeoutInMinutes: 75
3333
TestProxy: true
34+
# This is a short term solution to create API review for python azure-ml package only when running pipeline manually
35+
# Long term solution should be to have different versions on main branch and release branch for python package so APIView can have different revisions for each version.
36+
# Tracking issue: https://github.com/Azure/azure-sdk-for-python/issues/29196
37+
GenerateApiReviewForManualOnly: true
3438
Artifacts:
3539
- name: azure-ai-ml
3640
safeName: azureaiml

0 commit comments

Comments
 (0)