Skip to content

Commit 9c1525c

Browse files
azure-sdkscbedd
andauthored
Sync eng/common directory with azure-sdk-tools for PR 9290 (Azure#1885)
* identify and resolve missing function GenerateMatrixForConfig * identify and resolve miss-used null-coalesce operator --------- Co-authored-by: Scott Beddall <[email protected]>
1 parent 46faf38 commit 9c1525c

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ $packageProperties = Get-ChildItem -Recurse "$PackagePropertiesFolder" *.json `
6464

6565
# set default matrix config for each package if there isn't an override
6666
$packageProperties | ForEach-Object {
67-
$_.CIMatrixConfigs = $_.CIMatrixConfigs ?? $configs
67+
if (-not $_.CIMatrixConfigs) {
68+
$_.CIMatrixConfigs = $configs
69+
}
6870
}
6971

7072
# The key here is that after we group the packages by the matrix config objects, we can use the first item's MatrixConfig

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,3 +740,28 @@ function Get4dMatrixIndex([int]$index, [Array]$dimensions) {
740740
return @($page3, $page2, $page1, $remainder)
741741
}
742742

743+
function GenerateMatrixForConfig {
744+
param (
745+
[Parameter(Mandatory = $true)][string] $ConfigPath,
746+
[Parameter(Mandatory = $True)][string] $Selection,
747+
[Parameter(Mandatory = $false)][string] $DisplayNameFilter,
748+
[Parameter(Mandatory = $false)][array] $Filters,
749+
[Parameter(Mandatory = $false)][array] $Replace
750+
)
751+
$matrixFile = Join-Path $PSScriptRoot ".." ".." ".." ".." $ConfigPath
752+
753+
$resolvedMatrixFile = Resolve-Path $matrixFile
754+
755+
$config = GetMatrixConfigFromFile (Get-Content $resolvedMatrixFile -Raw)
756+
# Strip empty string filters in order to be able to use azure pipelines yaml join()
757+
$Filters = $Filters | Where-Object { $_ }
758+
759+
[array]$matrix = GenerateMatrix `
760+
-config $config `
761+
-selectFromMatrixType $Selection `
762+
-displayNameFilter $DisplayNameFilter `
763+
-filters $Filters `
764+
-replace $Replace
765+
766+
return , $matrix
767+
}

0 commit comments

Comments
 (0)