Skip to content

Commit 5ae5061

Browse files
azure-sdkscbedd
authored andcommitted
batching adjustments for create-prjobmatrix (Azure#38597)
Co-authored-by: Scott Beddall <[email protected]>
1 parent 6f8115b commit 5ae5061

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

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

+9-7
Original file line numberDiff line numberDiff line change
@@ -90,31 +90,33 @@ foreach ($matrixBatchKey in $matrixBatchesByConfig.Keys) {
9090

9191
$packageBatches = Split-ArrayIntoBatches -InputArray $matrixBatch -BatchSize $BATCHSIZE
9292

93-
# we only need to modify the generated job name if there is more than one matrix config or batch in the matrix
94-
$matrixSuffixNecessary = $matrixConfigs.Count -gt 1
93+
# we only need to modify the generated job name if there is more than one matrix config + batch
94+
$matrixSuffixNecessary = $matrixBatchesByConfig.Keys.Count -gt 1
9595
$batchSuffixNecessary = $packageBatches.Length -gt 1
9696
$batchCounter = 1
9797

9898
foreach ($batch in $packageBatches) {
99+
$namesForBatch = ($batch | ForEach-Object { $_.ArtifactName }) -join ","
99100
# to understand this iteration, one must understand that the matrix is a list of hashtables, each with a couple keys:
100101
# [
101102
# { "name": "jobname", "parameters": { matrixSetting1: matrixValue1, ...} },
102103
# ]
103104
foreach ($matrixOutputItem in $matrixResults) {
104-
$namesForBatch = ($batch | ForEach-Object { $_.ArtifactName }) -join ","
105+
# we need to clone this, as each item is an object with possible children
106+
$outputItem = $matrixOutputItem | ConvertTo-Json -Depth 100 | ConvertFrom-Json -AsHashtable
105107
# we just need to iterate across them, grab the parameters hashtable, and add the new key
106108
# if there is more than one batch, we will need to add a suffix including the batch name to the job name
107-
$matrixOutputItem["parameters"]["$PRMatrixSetting"] = $namesForBatch
109+
$outputItem["parameters"]["$PRMatrixSetting"] = $namesForBatch
108110

109111
if ($matrixSuffixNecessary) {
110-
$matrixOutputItem["name"] = $matrixOutputItem["name"] + $matrixConfig.Name
112+
$outputItem["name"] = $outputItem["name"] + "_" + $matrixConfig.Name
111113
}
112114

113115
if ($batchSuffixNecessary) {
114-
$matrixOutputItem["name"] = $matrixOutputItem["name"] + "b$batchCounter"
116+
$outputItem["name"] = $outputItem["name"] + "_b$batchCounter"
115117
}
116118

117-
$OverallResult += $matrixOutputItem
119+
$OverallResult += $outputItem
118120
}
119121
$batchCounter += 1
120122
}

eng/common/scripts/job-matrix/job-matrix-functions.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ function CloneOrderedDictionary([System.Collections.Specialized.OrderedDictionar
490490
function SerializePipelineMatrix([Array]$matrix) {
491491
$pipelineMatrix = [Ordered]@{}
492492
foreach ($entry in $matrix) {
493-
if ($pipelineMatrix.Contains($entry.Name)) {
493+
if ($pipelineMatrix.Contains($entry.name)) {
494494
Write-Warning "Found duplicate configurations for job `"$($entry.name)`". Multiple values may have been replaced with the same value."
495495
continue
496496
}

0 commit comments

Comments
 (0)