Sync eng/common directory with azure-sdk-tools for PR 9807 (#6417)

* replace PkgProps CIMatrixConfigs property in favor of a more generalized CIParameters property. Original CIMatrixConfigs will exist as an item of same key within CIParameters.
* update Create-PRJobMatrix to honor new CIMatrixConfigs property location

---------

Co-authored-by: Scott Beddall <scbedd@microsoft.com>
This commit is contained in:
Azure SDK Bot 2025-02-12 15:56:08 -08:00 committed by GitHub
parent 2f4c070473
commit 52797073f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 32 deletions

View File

@ -20,7 +20,7 @@ class PackageProps {
# additional packages required for validation of this one
[string[]]$AdditionalValidationPackages
[HashTable]$ArtifactDetails
[HashTable[]]$CIMatrixConfigs
[HashTable]$CIParameters
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory) {
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
@ -61,6 +61,7 @@ class PackageProps {
$this.ChangeLogPath = $null
}
$this.CIParameters = @{"CIMatrixConfigs" = @()}
$this.InitializeCIArtifacts()
}
@ -89,21 +90,7 @@ class PackageProps {
if ($artifactForCurrentPackage) {
$result = [PSCustomObject]@{
ArtifactConfig = [HashTable]$artifactForCurrentPackage
MatrixConfigs = @()
AdditionalMatrixConfigs = @()
}
# if we know this is the matrix for our file, we should now see if there is a custom matrix config for the package
$matrixConfigList = GetValueSafelyFrom-Yaml $content @("extends", "parameters", "MatrixConfigs")
if ($matrixConfigList) {
$result.MatrixConfigs += $matrixConfigList
}
$additionalMatrixConfigList = GetValueSafelyFrom-Yaml $content @("extends", "parameters", "AdditionalMatrixConfigs")
if ($additionalMatrixConfigList) {
$result.AdditionalMatrixConfigs += $additionalMatrixConfigList
ParsedYml = $content
}
return $result
@ -112,28 +99,45 @@ class PackageProps {
return $null
}
[PSCustomObject]GetCIYmlForArtifact() {
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot ".." ".." "..")
$ciFolderPath = Join-Path -Path $RepoRoot -ChildPath (Join-Path "sdk" $this.ServiceDirectory)
$ciFiles = Get-ChildItem -Path $ciFolderPath -Filter "ci*.yml" -File
$ciArtifactResult = $null
foreach ($ciFile in $ciFiles) {
$ciArtifactResult = $this.ParseYmlForArtifact($ciFile.FullName)
if ($ciArtifactResult) {
break
}
}
return $ciArtifactResult
}
[void]InitializeCIArtifacts() {
if (-not $env:SYSTEM_TEAMPROJECTID -and -not $env:GITHUB_ACTIONS) {
return
}
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot ".." ".." "..")
$ciFolderPath = Join-Path -Path $RepoRoot -ChildPath (Join-Path "sdk" $this.ServiceDirectory)
$ciFiles = Get-ChildItem -Path $ciFolderPath -Filter "ci*.yml" -File
if (-not $this.ArtifactDetails) {
foreach ($ciFile in $ciFiles) {
$ciArtifactResult = $this.ParseYmlForArtifact($ciFile.FullName)
if ($ciArtifactResult) {
$this.ArtifactDetails = [Hashtable]$ciArtifactResult.ArtifactConfig
$this.CIMatrixConfigs = $ciArtifactResult.MatrixConfigs
# if this package appeared in this ci file, then we should
# treat this CI file as the source of the Matrix for this package
if ($ciArtifactResult.PSObject.Properties.Name -contains "AdditionalMatrixConfigs" -and $ciArtifactResult.AdditionalMatrixConfigs) {
$this.CIMatrixConfigs += $ciArtifactResult.AdditionalMatrixConfigs
}
break
$ciArtifactResult = $this.GetCIYmlForArtifact()
if ($ciArtifactResult) {
$this.ArtifactDetails = [Hashtable]$ciArtifactResult.ArtifactConfig
# if we know this is the matrix for our file, we should now see if there is a custom matrix config for the package
$matrixConfigList = GetValueSafelyFrom-Yaml $ciArtifactResult.ParsedYml @("extends", "parameters", "MatrixConfigs")
if ($matrixConfigList) {
$this.CIParameters["CIMatrixConfigs"] += $matrixConfigList
}
$additionalMatrixConfigList = GetValueSafelyFrom-Yaml $ciArtifactResult.ParsedYml @("extends", "parameters", "AdditionalMatrixConfigs")
if ($additionalMatrixConfigList) {
$this.CIParameters["CIMatrixConfigs"] += $additionalMatrixConfigList
}
}
}

View File

@ -219,6 +219,7 @@ $configs = Get-Content -Raw $PRMatrixFile | ConvertFrom-Json
# get all the package property objects loaded
$packageProperties = Get-ChildItem -Recurse "$PackagePropertiesFolder" *.json `
| ForEach-Object { Get-Content -Path $_.FullName | ConvertFrom-Json }
| ForEach-Object { Add-Member -InputObject $_ -MemberType NoteProperty -Name CIMatrixConfigs -Value $_.CIParameters.CIMatrixConfigs -PassThru }
# enhance the package props with a default matrix config if one isn't present
$packageProperties | ForEach-Object {