Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 34 additions & 30 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -61,6 +61,7 @@ class PackageProps {
$this.ChangeLogPath = $null
}

$this.CIParameters = @{"CIMatrixConfigs" = @()}
$this.InitializeCIArtifacts()
}

Expand Down Expand Up @@ -89,51 +90,54 @@ class PackageProps {
if ($artifactForCurrentPackage) {
$result = [PSCustomObject]@{
ArtifactConfig = [HashTable]$artifactForCurrentPackage
MatrixConfigs = @()
AdditionalMatrixConfigs = @()
ParsedYml = $content
}

# 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
}
return $result
}
}
return $null
}

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

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

return $result
foreach ($ciFile in $ciFiles) {
$ciArtifactResult = $this.ParseYmlForArtifact($ciFile.FullName)
if ($ciArtifactResult) {
break
}
}
return $null

return $ciArtifactResult
}

[void]InitializeCIArtifacts() {
if (-not $env:SYSTEM_TEAMPROJECTID -and -not $env:GITHUB_ACTIONS) {
return
}

$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot ".." ".." "..")
if (-not $this.ArtifactDetails) {
$ciArtifactResult = $this.GetCIYmlForArtifact()

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

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
# 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
}
}
}
Expand Down
1 change: 1 addition & 0 deletions eng/common/scripts/job-matrix/Create-PrJobMatrix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading