Sync eng/common directory with azure-sdk-tools for PR 9290 (#23676)

* identify and resolve missing function GenerateMatrixForConfig 
* identify and resolve miss-used null-coalesce operator

---------

Co-authored-by: Scott Beddall <scbedd@microsoft.com>
This commit is contained in:
Azure SDK Bot 2024-10-30 22:19:14 -07:00 коммит произвёл GitHub
Родитель 84097f5834
Коммит a6f7621bba
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
2 изменённых файлов: 28 добавлений и 1 удалений

Просмотреть файл

@ -64,7 +64,9 @@ $packageProperties = Get-ChildItem -Recurse "$PackagePropertiesFolder" *.json `
# set default matrix config for each package if there isn't an override
$packageProperties | ForEach-Object {
$_.CIMatrixConfigs = $_.CIMatrixConfigs ?? $configs
if (-not $_.CIMatrixConfigs) {
$_.CIMatrixConfigs = $configs
}
}
# The key here is that after we group the packages by the matrix config objects, we can use the first item's MatrixConfig

Просмотреть файл

@ -740,3 +740,28 @@ function Get4dMatrixIndex([int]$index, [Array]$dimensions) {
return @($page3, $page2, $page1, $remainder)
}
function GenerateMatrixForConfig {
param (
[Parameter(Mandatory = $true)][string] $ConfigPath,
[Parameter(Mandatory = $True)][string] $Selection,
[Parameter(Mandatory = $false)][string] $DisplayNameFilter,
[Parameter(Mandatory = $false)][array] $Filters,
[Parameter(Mandatory = $false)][array] $Replace
)
$matrixFile = Join-Path $PSScriptRoot ".." ".." ".." ".." $ConfigPath
$resolvedMatrixFile = Resolve-Path $matrixFile
$config = GetMatrixConfigFromFile (Get-Content $resolvedMatrixFile -Raw)
# Strip empty string filters in order to be able to use azure pipelines yaml join()
$Filters = $Filters | Where-Object { $_ }
[array]$matrix = GenerateMatrix `
-config $config `
-selectFromMatrixType $Selection `
-displayNameFilter $DisplayNameFilter `
-filters $Filters `
-replace $Replace
return , $matrix
}