Skip to content

Commit a6b221a

Browse files
haonantttHaonan Tang
andauthored
Move matrix extraction to Build stage (#5615)
Move matrix extraction to Build stage --------- Co-authored-by: Haonan Tang <haonantang@microsoft.com>
1 parent 9eae4fb commit a6b221a

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

build/AzurePipelinesTemplates/WindowsAppSDK-Build-Per-Platform-Stage.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ parameters:
1414
- name: buildPlatform
1515
type: string
1616
default: x64
17+
- name: testMatrix
18+
type: string
19+
default: ''
1720

1821
stages:
1922
- stage: ${{ format(iif(parameters.runPREfast, 'PREfast_{0}', 'Build_{0}'), parameters.buildPlatform) }}
@@ -185,3 +188,26 @@ stages:
185188
- script: |
186189
md "C:\__t\NativeCompilerPrefast"
187190
displayName: 'Creating C:\__t\NativeCompilerPrefast to prevent errors from Guardian PREfast'
191+
192+
- job: ExtractMatrix
193+
pool:
194+
type: windows
195+
isCustom: true
196+
name: 'ProjectReunionESPool-2022'
197+
steps:
198+
- powershell: |
199+
$testMatrix = "${{ parameters.testMatrix }}" | ConvertFrom-Json
200+
$targetPlatform = "${{ parameters.buildPlatform }}"
201+
$filteredMatrix = @{}
202+
foreach ($entry in $testMatrix.PSObject.Properties) {
203+
if ($entry.Value.buildPlatform -eq $targetPlatform) {
204+
$filteredMatrix[$entry.Name] = $entry.Value
205+
}
206+
}
207+
$matrixJson = $filteredMatrix | ConvertTo-Json -Compress
208+
Write-Host "##vso[task.setvariable variable=filteredTestMatrix;isOutput=true]$matrixJson"
209+
name: filterByPlatformStep
210+
displayName: "Extract matrix as json value filtering by build platform"
211+
- script: echo $(filterByPlatformStep.filteredTestMatrix)
212+
name: echoMatrix
213+
displayName: "Echo filtered matrix"

build/AzurePipelinesTemplates/WindowsAppSDK-Build-Stage.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ parameters:
1111
- name: runPREfast
1212
type: boolean
1313
default: false
14+
- name: testMatrix
15+
type: string
16+
default: ''
1417

1518
stages:
1619
- stage: ${{ iif(parameters.runPREfast, 'PREfast_AnyCPU', 'Build_AnyCPU') }}
@@ -79,6 +82,7 @@ stages:
7982
runPREfast : ${{ parameters.runPREfast }}
8083
runApiScan : ${{ parameters.runApiScan }}
8184
BuildPlatform: x64
85+
testMatrix: ${{ parameters.testMatrix }}
8286

8387
- ${{ if not(parameters.runPREfast) }}:
8488
- template: WindowsAppSDK-Build-Per-Platform-Stage.yml@self
@@ -88,6 +92,7 @@ stages:
8892
runPREfast : ${{ parameters.runPREfast }}
8993
runApiScan : ${{ parameters.runApiScan }}
9094
BuildPlatform: x86
95+
testMatrix: ${{ parameters.testMatrix }}
9196

9297
- template: WindowsAppSDK-Build-Per-Platform-Stage.yml@self
9398
parameters:
@@ -96,3 +101,4 @@ stages:
96101
runPREfast : ${{ parameters.runPREfast }}
97102
runApiScan : ${{ parameters.runApiScan }}
98103
BuildPlatform: arm64
104+
testMatrix: ${{ parameters.testMatrix }}

build/AzurePipelinesTemplates/WindowsAppSDK-RunTestsInPipeline-Job.yml

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,34 +19,9 @@ parameters:
1919
default: x64
2020

2121
jobs:
22-
- job: ExtractMatrix
23-
pool:
24-
type: windows
25-
isCustom: true
26-
name: 'ProjectReunionESPool-2022'
27-
steps:
28-
- powershell: |
29-
$testMatrix = "${{ parameters.testMatrix }}" | ConvertFrom-Json
30-
$targetPlatform = "${{ parameters.buildPlatform }}"
31-
$filteredMatrix = @{}
32-
foreach ($entry in $testMatrix.PSObject.Properties) {
33-
if ($entry.Value.buildPlatform -eq $targetPlatform) {
34-
$filteredMatrix[$entry.Name] = $entry.Value
35-
}
36-
}
37-
$matrixJson = $filteredMatrix | ConvertTo-Json -Compress
38-
Write-Host "##vso[task.setvariable variable=matrixJson;isOutput=true]$matrixJson"
39-
name: filterByPlatformStep
40-
displayName: "Extract matrix as json value filtering by build platform and pass the extracted matrix to next job"
41-
- script: echo $(filterByPlatformStep.matrixJson)
42-
name: echoMatrix
43-
displayName: "Echo filtered matrix"
44-
45-
4622
- job: ${{ parameters.jobName }}
47-
dependsOn: ExtractMatrix
4823
strategy:
49-
matrix: $[ dependencies.ExtractMatrix.outputs['filterByPlatformStep.matrixJson'] ]
24+
matrix: ${{ parameters.TestMatrix }}
5025
pool:
5126
type: windows
5227
isCustom: true

build/AzurePipelinesTemplates/WindowsAppSDK-Test-Stage.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ stages:
66
- template: WindowsAppSDK-RunTestsInPipeline-Job.yml@self
77
parameters:
88
jobName: PipelineTests
9-
testMatrix: ${{ parameters.testMatrix }} # testMatrix is supplied by WindowsAppSDKConfig/WindowsAppSDK-Foundation-TestConfig.yml
9+
testMatrix: $[ stageDependencies.Build_x86.ExtractMatrix.outputs['filterByPlatformStep.filteredTestMatrix'] ] # testMatrix is supplied by WindowsAppSDKConfig/WindowsAppSDK-Foundation-TestConfig.yml
1010
buildPlatform: x86
1111

1212
- stage: Test_x64
@@ -16,7 +16,7 @@ stages:
1616
- template: WindowsAppSDK-RunTestsInPipeline-Job.yml@self
1717
parameters:
1818
jobName: PipelineTests
19-
testMatrix: ${{ parameters.testMatrix }} # testMatrix is supplied by WindowsAppSDKConfig/WindowsAppSDK-Foundation-TestConfig.yml
19+
testMatrix: $[ stageDependencies.Build_x64.ExtractMatrix.outputs['filterByPlatformStep.filteredTestMatrix'] ] # testMatrix is supplied by WindowsAppSDKConfig/WindowsAppSDK-Foundation-TestConfig.yml
2020
buildPlatform: x64
2121

2222
- stage: Test_arm64
@@ -26,5 +26,5 @@ stages:
2626
- template: WindowsAppSDK-RunTestsInPipeline-Job.yml@self
2727
parameters:
2828
jobName: PipelineTests
29-
testMatrix: ${{ parameters.testMatrix }} # testMatrix is supplied by WindowsAppSDKConfig/WindowsAppSDK-Foundation-TestConfig.yml
29+
testMatrix: $[ stageDependencies.Build_arm64.ExtractMatrix.outputs['filterByPlatformStep.filteredTestMatrix'] ] # testMatrix is supplied by WindowsAppSDKConfig/WindowsAppSDK-Foundation-TestConfig.yml
3030
buildPlatform: arm64

build/ProjectReunion-BuildFoundation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ stages:
3232
IsOneBranch: false
3333
runApiScan: true
3434
runPREFast: false
35+
testMatrix: ${{ variables.PipelineTests }}
3536

3637
- template: AzurePipelinesTemplates\WindowsAppSDK-Build-Stage.yml@self
3738
parameters:
3839
SignOutput: false
3940
IsOneBranch: false
4041
runApiScan: false
4142
runPREFast: true
43+
testMatrix: ${{ variables.PipelineTests }}
4244

4345
- template: AzurePipelinesTemplates\WindowsAppSDK-Test-Stage.yml@self
44-
parameters:
45-
testMatrix: ${{ variables.PipelineTests }}
4646

4747
- template: AzurePipelinesTemplates\WindowsAppSDK-PackTransportPackage-Stage.yml@self
4848
parameters:

0 commit comments

Comments
 (0)