Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync eng/common directory with azure-sdk-tools for PR 9393 #47221

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions eng/common/scripts/job-matrix/Create-PrJobMatrix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -90,31 +90,33 @@ foreach ($matrixBatchKey in $matrixBatchesByConfig.Keys) {

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

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

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

if ($matrixSuffixNecessary) {
$matrixOutputItem["name"] = $matrixOutputItem["name"] + $matrixConfig.Name
$outputItem["name"] = $outputItem["name"] + "_" + $matrixConfig.Name
}

if ($batchSuffixNecessary) {
$matrixOutputItem["name"] = $matrixOutputItem["name"] + "b$batchCounter"
$outputItem["name"] = $outputItem["name"] + "_b$batchCounter"
}

$OverallResult += $matrixOutputItem
$OverallResult += $outputItem
}
$batchCounter += 1
}
Expand Down
2 changes: 1 addition & 1 deletion eng/common/scripts/job-matrix/job-matrix-functions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ function CloneOrderedDictionary([System.Collections.Specialized.OrderedDictionar
function SerializePipelineMatrix([Array]$matrix) {
$pipelineMatrix = [Ordered]@{}
foreach ($entry in $matrix) {
if ($pipelineMatrix.Contains($entry.Name)) {
if ($pipelineMatrix.Contains($entry.name)) {
Write-Warning "Found duplicate configurations for job `"$($entry.name)`". Multiple values may have been replaced with the same value."
continue
}
Expand Down