Skip to content

Commit 5e7f6f0

Browse files
authored
More pr pipeline prep (Azure#43822)
* More prep for the PR pipeline * fix daily-dev-build-variable.yml condition to only skip the PR pipline * fiddle with the daily-dev-build-variable.yml condition
1 parent 3e3a1e4 commit 5e7f6f0

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

eng/pipelines/scripts/generate-project-list.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,38 @@ if ($env:ADDITIONALMODULESJSON -and $env:ADDITIONALMODULESJSON -notlike '*Additi
1919
}
2020
}
2121

22+
# If the project list is empty this is because the Artifacts and AdditionalModules are both empty
23+
# which means this is running as part of the pullrequest pipeline and the project list needs to
24+
# be figured out from the packageInfo files.
25+
if ($projectList.Length -eq 0 -and $ENV:PACKAGEINFODIR) {
26+
[array]$packageInfoFiles = Get-ChildItem -Path $ENV:PACKAGEINFODIR "*.json"
27+
foreach($packageInfoFile in $packageInfoFiles) {
28+
$packageInfoJson = Get-Content $packageInfoFile -Raw
29+
$packageInfo = ConvertFrom-Json $packageInfoJson
30+
$fullArtifactName = "$($packageInfo.Group):$($packageInfo.ArtifactName)"
31+
$projectList += $fullArtifactName
32+
$artifactsList += $fullArtifactName
33+
# The AdditionalValidationPackages are stored as <group>:<artifact>
34+
foreach($additionalModule in $packageInfo.AdditionalValidationPackages)
35+
{
36+
$projectList += $additionalModule
37+
$additionalModulesList += $additionalModule
38+
}
39+
}
40+
}
41+
42+
$projectList = $projectList | Select-Object -Unique
2243
$projects = $projectList -join ','
2344
if (!$projects) {
2445
throw "parameters.Artifacts cannot be empty"
2546
}
2647

48+
$artifactsList = $artifactsList | Select-Object -Unique
2749
$artifactsString = $artifactsList -join ','
2850
Write-Host "ArtifactsList = $artifactsString"
2951
Write-Host "##vso[task.setvariable variable=ArtifactsList;]$artifactsString"
3052

53+
$additionalModulesList = $additionalModulesList | Select-Object -Unique
3154
$additionalModulesString = $additionalModulesList -join ','
3255
Write-Host "AdditionalModulesList = $additionalModulesString"
3356
Write-Host "##vso[task.setvariable variable=AdditionalModulesList;]$additionalModulesString"

eng/pipelines/templates/jobs/ci.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ jobs:
6767

6868
variables:
6969
ArtifactName: 'packages'
70+
# The ServiceDirectory is an identifier. The pullrequest's ServiceDirectory of
71+
# 'auto' shouldn't cause any problems
7072
Codeql.Enabled: true
7173
Codeql.BuildIdentifier: ${{ parameters.ServiceDirectory }}
7274
Codeql.SkipTaskAutoInjection: false
@@ -86,9 +88,18 @@ jobs:
8688
Paths:
8789
- '**/*.xml'
8890
- '**/*.md'
91+
- '**/ci*.yml' # necessary for save-package-properties.yml
8992
- '!sdk/**/test-recordings'
9093
- '!sdk/**/session-records'
9194

95+
# This is the case for the PullReqest pipeline which has a ServiceDirectory of 'auto'.
96+
# For the PullRequest pipeline, the packageInfo files generated from the diff end up
97+
# being the source of truth for the artifacts list.
98+
- ${{ if and(eq(variables['Build.Reason'], 'PullRequest'), eq(parameters.ServiceDirectory, 'auto')) }}:
99+
- template: /eng/common/pipelines/templates/steps/save-package-properties.yml
100+
parameters:
101+
ServiceDirectory: ${{parameters.ServiceDirectory}}
102+
92103
- template: /eng/pipelines/templates/steps/generate-project-list-and-cache-maven-repository.yml
93104
parameters:
94105
JobType: 'Build'
@@ -130,9 +141,13 @@ jobs:
130141
ServiceDirectory: "template"
131142
TestPipeline: ${{ parameters.TestPipeline }}
132143

133-
- template: /eng/common/pipelines/templates/steps/daily-dev-build-variable.yml
134-
parameters:
135-
ServiceDirectory: ${{parameters.ServiceDirectory}}
144+
# The daily dev build variable isn't used for the PullRequests pipeline but is currently used
145+
# to save off the packageInfo files for all ci pipeline. This needs to be skipped for the
146+
# PR pipeline, whose ServiceDirectory is 'auto' since the packageInfo files will be generated above.
147+
- ${{if ne(parameters.ServiceDirectory, 'auto')}}:
148+
- template: /eng/common/pipelines/templates/steps/daily-dev-build-variable.yml
149+
parameters:
150+
ServiceDirectory: ${{parameters.ServiceDirectory}}
136151

137152
- task: PowerShell@2
138153
displayName: Setup Dev versioning
@@ -234,8 +249,6 @@ jobs:
234249
Artifacts: ${{parameters.ReleaseArtifacts}}
235250

236251
- template: /eng/common/pipelines/templates/steps/detect-api-changes.yml
237-
parameters:
238-
Artifacts: ${{parameters.Artifacts}}
239252

240253
- template: /eng/common/pipelines/templates/steps/validate-all-packages.yml
241254
parameters:

eng/pipelines/templates/steps/generate-project-list-and-cache-maven-repository.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ steps:
2929
env:
3030
ARTIFACTSJSON: $(ArtifactsJson)
3131
ADDITIONALMODULESJSON: $(AdditionalModulesJson)
32+
PACKAGEINFODIR: $(Build.ArtifactStagingDirectory)/PackageInfo
3233

3334
# The Cache task, when restoring, can have a miss and still pass but, if nothing is built, the
3435
# Post-Job Cache will fail because there's no .m2/repository

0 commit comments

Comments
 (0)