Skip to content

Commit a7a5d0d

Browse files
azure-sdkscbedd
andauthored
Sync eng/common directory with azure-sdk-tools for PR 9807 (Azure#2138)
* 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 <[email protected]>
1 parent 63250c2 commit a7a5d0d

File tree

2 files changed

+35
-30
lines changed

2 files changed

+35
-30
lines changed

eng/common/scripts/Package-Properties.ps1

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class PackageProps {
2020
# additional packages required for validation of this one
2121
[string[]]$AdditionalValidationPackages
2222
[HashTable]$ArtifactDetails
23-
[HashTable[]]$CIMatrixConfigs
23+
[HashTable]$CIParameters
2424

2525
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory) {
2626
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
@@ -61,6 +61,7 @@ class PackageProps {
6161
$this.ChangeLogPath = $null
6262
}
6363

64+
$this.CIParameters = @{"CIMatrixConfigs" = @()}
6465
$this.InitializeCIArtifacts()
6566
}
6667

@@ -89,51 +90,54 @@ class PackageProps {
8990
if ($artifactForCurrentPackage) {
9091
$result = [PSCustomObject]@{
9192
ArtifactConfig = [HashTable]$artifactForCurrentPackage
92-
MatrixConfigs = @()
93-
AdditionalMatrixConfigs = @()
93+
ParsedYml = $content
9494
}
9595

96-
# if we know this is the matrix for our file, we should now see if there is a custom matrix config for the package
97-
$matrixConfigList = GetValueSafelyFrom-Yaml $content @("extends", "parameters", "MatrixConfigs")
98-
99-
if ($matrixConfigList) {
100-
$result.MatrixConfigs += $matrixConfigList
101-
}
96+
return $result
97+
}
98+
}
99+
return $null
100+
}
102101

103-
$additionalMatrixConfigList = GetValueSafelyFrom-Yaml $content @("extends", "parameters", "AdditionalMatrixConfigs")
102+
[PSCustomObject]GetCIYmlForArtifact() {
103+
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot ".." ".." "..")
104104

105-
if ($additionalMatrixConfigList) {
106-
$result.AdditionalMatrixConfigs += $additionalMatrixConfigList
107-
}
105+
$ciFolderPath = Join-Path -Path $RepoRoot -ChildPath (Join-Path "sdk" $this.ServiceDirectory)
106+
$ciFiles = Get-ChildItem -Path $ciFolderPath -Filter "ci*.yml" -File
107+
$ciArtifactResult = $null
108108

109-
return $result
109+
foreach ($ciFile in $ciFiles) {
110+
$ciArtifactResult = $this.ParseYmlForArtifact($ciFile.FullName)
111+
if ($ciArtifactResult) {
112+
break
110113
}
111114
}
112-
return $null
115+
116+
return $ciArtifactResult
113117
}
114118

115119
[void]InitializeCIArtifacts() {
116120
if (-not $env:SYSTEM_TEAMPROJECTID -and -not $env:GITHUB_ACTIONS) {
117121
return
118122
}
119123

120-
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot ".." ".." "..")
124+
if (-not $this.ArtifactDetails) {
125+
$ciArtifactResult = $this.GetCIYmlForArtifact()
121126

122-
$ciFolderPath = Join-Path -Path $RepoRoot -ChildPath (Join-Path "sdk" $this.ServiceDirectory)
123-
$ciFiles = Get-ChildItem -Path $ciFolderPath -Filter "ci*.yml" -File
127+
if ($ciArtifactResult) {
128+
$this.ArtifactDetails = [Hashtable]$ciArtifactResult.ArtifactConfig
124129

125-
if (-not $this.ArtifactDetails) {
126-
foreach ($ciFile in $ciFiles) {
127-
$ciArtifactResult = $this.ParseYmlForArtifact($ciFile.FullName)
128-
if ($ciArtifactResult) {
129-
$this.ArtifactDetails = [Hashtable]$ciArtifactResult.ArtifactConfig
130-
$this.CIMatrixConfigs = $ciArtifactResult.MatrixConfigs
131-
# if this package appeared in this ci file, then we should
132-
# treat this CI file as the source of the Matrix for this package
133-
if ($ciArtifactResult.PSObject.Properties.Name -contains "AdditionalMatrixConfigs" -and $ciArtifactResult.AdditionalMatrixConfigs) {
134-
$this.CIMatrixConfigs += $ciArtifactResult.AdditionalMatrixConfigs
135-
}
136-
break
130+
# if we know this is the matrix for our file, we should now see if there is a custom matrix config for the package
131+
$matrixConfigList = GetValueSafelyFrom-Yaml $ciArtifactResult.ParsedYml @("extends", "parameters", "MatrixConfigs")
132+
133+
if ($matrixConfigList) {
134+
$this.CIParameters["CIMatrixConfigs"] += $matrixConfigList
135+
}
136+
137+
$additionalMatrixConfigList = GetValueSafelyFrom-Yaml $ciArtifactResult.ParsedYml @("extends", "parameters", "AdditionalMatrixConfigs")
138+
139+
if ($additionalMatrixConfigList) {
140+
$this.CIParameters["CIMatrixConfigs"] += $additionalMatrixConfigList
137141
}
138142
}
139143
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ $configs = Get-Content -Raw $PRMatrixFile | ConvertFrom-Json
219219
# get all the package property objects loaded
220220
$packageProperties = Get-ChildItem -Recurse "$PackagePropertiesFolder" *.json `
221221
| ForEach-Object { Get-Content -Path $_.FullName | ConvertFrom-Json }
222+
| ForEach-Object { Add-Member -InputObject $_ -MemberType NoteProperty -Name CIMatrixConfigs -Value $_.CIParameters.CIMatrixConfigs -PassThru }
222223

223224
# enhance the package props with a default matrix config if one isn't present
224225
$packageProperties | ForEach-Object {

0 commit comments

Comments
 (0)