Skip to content

Commit 25c1140

Browse files
scbeddazure-sdk
authored andcommitted
handle additional matrix config list
1 parent 901bfa3 commit 25c1140

File tree

1 file changed

+32
-59
lines changed

1 file changed

+32
-59
lines changed

eng/common/scripts/Package-Properties.ps1

+32-59
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
# Helper functions for retrieving useful information from azure-sdk-for-* repo
22
. "${PSScriptRoot}\logging.ps1"
33
. "${PSScriptRoot}\Helpers\Package-Helpers.ps1"
4-
class PackageProps
5-
{
4+
class PackageProps {
65
[string]$Name
76
[string]$Version
87
[string]$DevVersion
@@ -23,13 +22,11 @@ class PackageProps
2322
[HashTable]$ArtifactDetails
2423
[HashTable[]]$CIMatrixConfigs
2524

26-
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory)
27-
{
25+
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory) {
2826
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
2927
}
3028

31-
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory, [string]$group = "")
32-
{
29+
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory, [string]$group = "") {
3330
$this.Initialize($name, $version, $directoryPath, $serviceDirectory, $group)
3431
}
3532

@@ -38,35 +35,29 @@ class PackageProps
3835
[string]$version,
3936
[string]$directoryPath,
4037
[string]$serviceDirectory
41-
)
42-
{
38+
) {
4339
$this.Name = $name
4440
$this.Version = $version
4541
$this.DirectoryPath = $directoryPath
4642
$this.ServiceDirectory = $serviceDirectory
4743
$this.IncludedForValidation = $false
4844

49-
if (Test-Path (Join-Path $directoryPath "README.md"))
50-
{
45+
if (Test-Path (Join-Path $directoryPath "README.md")) {
5146
$this.ReadMePath = Join-Path $directoryPath "README.md"
5247
}
53-
else
54-
{
48+
else {
5549
$this.ReadMePath = $null
5650
}
5751

58-
if (Test-Path (Join-Path $directoryPath "CHANGELOG.md"))
59-
{
52+
if (Test-Path (Join-Path $directoryPath "CHANGELOG.md")) {
6053
$this.ChangeLogPath = Join-Path $directoryPath "CHANGELOG.md"
6154
# Get release date for current version and set in package property
6255
$changeLogEntry = Get-ChangeLogEntry -ChangeLogLocation $this.ChangeLogPath -VersionString $this.Version
63-
if ($changeLogEntry -and $changeLogEntry.ReleaseStatus)
64-
{
65-
$this.ReleaseStatus = $changeLogEntry.ReleaseStatus.Trim().Trim("()")
56+
if ($changeLogEntry -and $changeLogEntry.ReleaseStatus) {
57+
$this.ReleaseStatus = $changeLogEntry.ReleaseStatus.Trim().Trim("()")
6658
}
6759
}
68-
else
69-
{
60+
else {
7061
$this.ChangeLogPath = $null
7162
}
7263

@@ -79,8 +70,7 @@ class PackageProps
7970
[string]$directoryPath,
8071
[string]$serviceDirectory,
8172
[string]$group
82-
)
83-
{
73+
) {
8474
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
8575
$this.Group = $group
8676
}
@@ -99,14 +89,14 @@ class PackageProps
9989
if ($artifactForCurrentPackage) {
10090
$result = [PSCustomObject]@{
10191
ArtifactConfig = [HashTable]$artifactForCurrentPackage
102-
MatrixConfigs = @()
92+
MatrixConfigs = @()
10393
}
10494

10595
# if we know this is the matrix for our file, we should now see if there is a custom matrix config for the package
10696
$matrixConfigList = GetValueSafelyFrom-Yaml $content @("extends", "parameters", "MatrixConfigs")
10797

10898
if ($matrixConfigList) {
109-
$result.MatrixConfigs = matrixConfigList
99+
$result.MatrixConfigs = $matrixConfigList
110100
}
111101

112102
return $result
@@ -115,14 +105,14 @@ class PackageProps
115105
return $null
116106
}
117107

118-
[void]InitializeCIArtifacts(){
108+
[void]InitializeCIArtifacts() {
119109
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot ".." ".." "..")
120110

121111
$ciFolderPath = Join-Path -Path $RepoRoot -ChildPath (Join-Path "sdk" $this.ServiceDirectory)
122112
$ciFiles = Get-ChildItem -Path $ciFolderPath -Filter "ci*.yml" -File
123113

124114
if (-not $this.ArtifactDetails) {
125-
foreach($ciFile in $ciFiles) {
115+
foreach ($ciFile in $ciFiles) {
126116
$ciArtifactResult = $this.ParseYmlForArtifact($ciFile.FullName)
127117
if ($ciArtifactResult) {
128118
$this.ArtifactDetails = [Hashtable]$ciArtifactResult.ArtifactConfig
@@ -140,8 +130,7 @@ class PackageProps
140130
# Returns important properties of the package relative to the language repo
141131
# Returns a PS Object with properties @ { pkgName, pkgVersion, pkgDirectoryPath, pkgReadMePath, pkgChangeLogPath }
142132
# Note: python is required for parsing python package properties.
143-
function Get-PkgProperties
144-
{
133+
function Get-PkgProperties {
145134
Param
146135
(
147136
[Parameter(Mandatory = $true)]
@@ -152,10 +141,8 @@ function Get-PkgProperties
152141
$allPkgProps = Get-AllPkgProperties -ServiceDirectory $ServiceDirectory
153142
$pkgProps = $allPkgProps.Where({ $_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName });
154143

155-
if ($pkgProps.Count -ge 1)
156-
{
157-
if ($pkgProps.Count -gt 1)
158-
{
144+
if ($pkgProps.Count -ge 1) {
145+
if ($pkgProps.Count -gt 1) {
159146
Write-Host "Found more than one project with the name [$PackageName], choosing the first one under $($pkgProps[0].DirectoryPath)"
160147
}
161148
return $pkgProps[0]
@@ -175,14 +162,12 @@ function Get-PrPkgProperties([string]$InputDiffJson) {
175162
$additionalValidationPackages = @()
176163
$lookup = @{}
177164

178-
foreach ($pkg in $allPackageProperties)
179-
{
165+
foreach ($pkg in $allPackageProperties) {
180166
$pkgDirectory = Resolve-Path "$($pkg.DirectoryPath)"
181167
$lookupKey = ($pkg.DirectoryPath).Replace($RepoRoot, "").TrimStart('\/')
182168
$lookup[$lookupKey] = $pkg
183169

184-
foreach ($file in $targetedFiles)
185-
{
170+
foreach ($file in $targetedFiles) {
186171
$filePath = Resolve-Path (Join-Path $RepoRoot $file)
187172
$shouldInclude = $filePath -like "$pkgDirectory*"
188173
if ($shouldInclude) {
@@ -207,8 +192,7 @@ function Get-PrPkgProperties([string]$InputDiffJson) {
207192
}
208193
}
209194

210-
if ($AdditionalValidationPackagesFromPackageSetFn -and (Test-Path "Function:$AdditionalValidationPackagesFromPackageSetFn"))
211-
{
195+
if ($AdditionalValidationPackagesFromPackageSetFn -and (Test-Path "Function:$AdditionalValidationPackagesFromPackageSetFn")) {
212196
$packagesWithChanges += &$AdditionalValidationPackagesFromPackageSetFn $packagesWithChanges $diff $allPackageProperties
213197
}
214198

@@ -218,25 +202,19 @@ function Get-PrPkgProperties([string]$InputDiffJson) {
218202
# Takes ServiceName and Repo Root Directory
219203
# Returns important properties for each package in the specified service, or entire repo if the serviceName is not specified
220204
# Returns a Table of service key to array values of PS Object with properties @ { pkgName, pkgVersion, pkgDirectoryPath, pkgReadMePath, pkgChangeLogPath }
221-
function Get-AllPkgProperties ([string]$ServiceDirectory = $null)
222-
{
205+
function Get-AllPkgProperties ([string]$ServiceDirectory = $null) {
223206
$pkgPropsResult = @()
224207

225-
if (Test-Path "Function:Get-AllPackageInfoFromRepo")
226-
{
208+
if (Test-Path "Function:Get-AllPackageInfoFromRepo") {
227209
$pkgPropsResult = Get-AllPackageInfoFromRepo -ServiceDirectory $serviceDirectory
228210
}
229-
else
230-
{
231-
if ([string]::IsNullOrEmpty($ServiceDirectory))
232-
{
233-
foreach ($dir in (Get-ChildItem (Join-Path $RepoRoot "sdk") -Directory))
234-
{
211+
else {
212+
if ([string]::IsNullOrEmpty($ServiceDirectory)) {
213+
foreach ($dir in (Get-ChildItem (Join-Path $RepoRoot "sdk") -Directory)) {
235214
$pkgPropsResult += Get-PkgPropsForEntireService -serviceDirectoryPath $dir.FullName
236215
}
237216
}
238-
else
239-
{
217+
else {
240218
$pkgPropsResult = Get-PkgPropsForEntireService -serviceDirectoryPath (Join-Path $RepoRoot "sdk" $ServiceDirectory)
241219
}
242220
}
@@ -246,29 +224,24 @@ function Get-AllPkgProperties ([string]$ServiceDirectory = $null)
246224

247225
# Given the metadata url under https://github.com/Azure/azure-sdk/tree/main/_data/releases/latest,
248226
# the function will return the csv metadata back as part of the response.
249-
function Get-CSVMetadata ([string]$MetadataUri=$MetadataUri)
250-
{
227+
function Get-CSVMetadata ([string]$MetadataUri = $MetadataUri) {
251228
$metadataResponse = Invoke-RestMethod -Uri $MetadataUri -method "GET" -MaximumRetryCount 3 -RetryIntervalSec 10 | ConvertFrom-Csv
252229
return $metadataResponse
253230
}
254231

255-
function Get-PkgPropsForEntireService ($serviceDirectoryPath)
256-
{
232+
function Get-PkgPropsForEntireService ($serviceDirectoryPath) {
257233
$projectProps = @() # Properties from every project in the service
258234
$serviceDirectory = $serviceDirectoryPath -replace '^.*[\\/]+sdk[\\/]+([^\\/]+).*$', '$1'
259235

260-
if (!$GetPackageInfoFromRepoFn -or !(Test-Path "Function:$GetPackageInfoFromRepoFn"))
261-
{
236+
if (!$GetPackageInfoFromRepoFn -or !(Test-Path "Function:$GetPackageInfoFromRepoFn")) {
262237
LogError "The function for '$GetPackageInfoFromRepoFn' was not found.`
263238
Make sure it is present in eng/scripts/Language-Settings.ps1 and referenced in eng/common/scripts/common.ps1.`
264239
See https://github.com/Azure/azure-sdk-tools/blob/main/doc/common/common_engsys.md#code-structure"
265240
}
266241

267-
foreach ($directory in (Get-ChildItem $serviceDirectoryPath -Directory))
268-
{
242+
foreach ($directory in (Get-ChildItem $serviceDirectoryPath -Directory)) {
269243
$pkgProps = &$GetPackageInfoFromRepoFn $directory.FullName $serviceDirectory
270-
if ($null -ne $pkgProps)
271-
{
244+
if ($null -ne $pkgProps) {
272245
$projectProps += $pkgProps
273246
}
274247
}

0 commit comments

Comments
 (0)