@@ -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
7374function 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