Skip to content

Commit d6b2752

Browse files
azure-sdkscbedd
andauthored
Sync eng/common directory with azure-sdk-tools for PR 9699 (Azure#47992)
* allow the sparse matrix to generate fully based on new parameter to generate-job-matrix --------- Co-authored-by: Scott Beddall <[email protected]>
1 parent d467db5 commit d6b2752

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

eng/common/pipelines/templates/jobs/generate-job-matrix.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ parameters:
5454
- name: PRMatrixIndirectFilters
5555
type: object
5656
default: []
57+
- name: PRMatrixSparseIndirect
58+
type: boolean
59+
default: true
5760
# Mappings to OS name required at template compile time by 1es pipeline templates
5861
- name: Pools
5962
type: object
@@ -142,7 +145,8 @@ jobs:
142145
-Filters '${{ join(''',''', parameters.MatrixFilters) }}', 'container=^$', 'SupportedClouds=^$|${{ parameters.CloudConfig.Cloud }}', 'Pool=${{ pool.filter }}' `
143146
-IndirectFilters '${{ join(''',''', parameters.PRMatrixIndirectFilters) }}' `
144147
-Replace '${{ join(''',''', parameters.MatrixReplace) }}' `
145-
-PackagesPerPRJob ${{ parameters.PRJobBatchSize }}
148+
-PackagesPerPRJob ${{ parameters.PRJobBatchSize }} `
149+
-SparseIndirect $${{ parameters.PRMatrixSparseIndirect }}
146150
displayName: Create ${{ pool.name }} PR Matrix
147151
name: vm_job_matrix_pr_${{ pool.name }}
148152

eng/common/scripts/job-matrix/Create-PrJobMatrix.ps1

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ param (
4444
[Parameter(Mandatory = $False)][array] $Filters,
4545
[Parameter(Mandatory = $False)][array] $IndirectFilters,
4646
[Parameter(Mandatory = $False)][array] $Replace,
47+
[Parameter(Mandatory = $False)][bool] $SparseIndirect = $true,
4748
[Parameter(Mandatory = $False)][int] $PackagesPerPRJob = 10,
4849
[Parameter()][switch] $CI = ($null -ne $env:SYSTEM_TEAMPROJECTID)
4950
)
@@ -72,7 +73,8 @@ function QueuePop([ref]$queue) {
7273

7374
function GeneratePRMatrixForBatch {
7475
param (
75-
[Parameter(Mandatory = $true)][array] $Packages
76+
[Parameter(Mandatory = $true)][array] $Packages,
77+
[Parameter(Mandatory = $false)][bool] $FullSparseMatrix = $false
7678
)
7779

7880
$OverallResult = @()
@@ -85,6 +87,8 @@ function GeneratePRMatrixForBatch {
8587
$directBatch = $Packages[0].IncludedForValidation -eq $false
8688
Write-Host "Generating matrix for $($directBatch ? 'direct' : 'indirect') packages"
8789

90+
$batchNamePrefix = $($directBatch ? 'b' : 'ib')
91+
8892
# The key here is that after we group the packages by the matrix config objects, we can use the first item's MatrixConfig
8993
# to generate the matrix for the group, no reason to have to parse the key value backwards to get the matrix config.
9094
$matrixBatchesByConfig = Group-ByObjectKey $Packages "CIMatrixConfigs"
@@ -134,10 +138,10 @@ function GeneratePRMatrixForBatch {
134138
# we only need to modify the generated job name if there is more than one matrix config + batch
135139
$matrixSuffixNecessary = $matrixBatchesByConfig.Keys.Count -gt 1
136140

137-
# if we are doing direct packages, we need to walk the batches and duplicate the matrix config for each batch, fully assigning
141+
# if we are doing direct packages (or a full indirect matrix), we need to walk the batches and duplicate the matrix config for each batch, fully assigning
138142
# the each batch's packages to the matrix config. This will generate a _non-sparse_ matrix for the incoming packages
139-
if ($directBatch) {
140-
$batchSuffixNecessary = $packageBatches.Length -gt 1
143+
if ($directBatch -or $FullSparseMatrix) {
144+
$batchSuffixNecessary = $packageBatches.Length -gt $($directBatch ? 1 : 0)
141145
$batchCounter = 1
142146

143147
foreach ($batch in $packageBatches) {
@@ -155,7 +159,7 @@ function GeneratePRMatrixForBatch {
155159
}
156160

157161
if ($batchSuffixNecessary) {
158-
$outputItem["name"] = $outputItem["name"] + "_b$batchCounter"
162+
$outputItem["name"] = $outputItem["name"] + "$batchNamePrefix$batchCounter"
159163
}
160164

161165
$OverallResult += $outputItem
@@ -180,7 +184,7 @@ function GeneratePRMatrixForBatch {
180184
}
181185

182186
if ($batchSuffixNecessary) {
183-
$outputItem["name"] = $outputItem["name"] + "_ib$batchCounter"
187+
$outputItem["name"] = $outputItem["name"] + "_$batchNamePrefix$batchCounter"
184188
}
185189
# now we need to take an item from the front of the matrix results, clone it, and add it to the back of the matrix results
186190
# we will add the cloned version to OverallResult
@@ -236,7 +240,7 @@ if ($indirectPackages) {
236240
foreach($artifact in $indirectPackages) {
237241
Write-Host "-> $($artifact.ArtifactName)"
238242
}
239-
$OverallResult += GeneratePRMatrixForBatch -Packages $indirectPackages
243+
$OverallResult += GeneratePRMatrixForBatch -Packages $indirectPackages -FullSparseMatrix (-not $SparseIndirect)
240244
}
241245
$serialized = SerializePipelineMatrix $OverallResult
242246

0 commit comments

Comments
 (0)