Skip to content

Commit 2ffb4bb

Browse files
scbeddazure-sdk
authored andcommitted
allow the sparse matrix to generate fully
1 parent ca2ae46 commit 2ffb4bb

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

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

Lines changed: 10 additions & 6 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 = $true)][bool] $FullSparseMatrix
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"] + "$batchPrefix$batchCounter"
159163
}
160164

161165
$OverallResult += $outputItem
@@ -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 !$SparseIndirect
240244
}
241245
$serialized = SerializePipelineMatrix $OverallResult
242246

0 commit comments

Comments
 (0)