Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
whole bunch of debugging still present. why is this not working?
  • Loading branch information
scbedd authored and azure-sdk committed Oct 10, 2024
commit 63d61e08ea1293a19b8e9d90d0105e41ac0504b7
61 changes: 45 additions & 16 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PackageProps
$this.Group = $group
}

hidden [object]Get-ValueSafely($hashtable, [string[]]$keys) {
hidden [object]GetValueSafely($hashtable, [string[]]$keys) {
$current = $hashtable
foreach ($key in $keys) {
if ($current.ContainsKey($key) -or $current[$key]) {
Expand All @@ -93,20 +93,38 @@ class PackageProps
return $null
}
}

return $current
}

hidden [string]ParseYmlForArtifact([string]$ymlPath) {
hidden [HashTable]ParseYmlForArtifact([string]$ymlPath) {
if (Test-Path -Path $ymlPath) {
try {
$content = Get-Content -Raw -Path $ymlPath | CompatibleConvertFrom-Yaml
if ($content) {

Write-Host "Calling CI Artifacts for $($this.Name) using artifact name $($this.ArtifactName)"
$artifacts = $this.GetValueSafely($content, @("extends", "parameters", "Artifacts"))

$artifactForCurrentPackage = $artifacts | Where-Object { $_.name -eq $this.ArtifactName }

return $artifactForCurrentPackage
$artifactForCurrentPackage = $artifacts | Where-Object { $_["name"] -eq $this.ArtifactName -or $_["name"] -eq $this.Name } | Select-Object -First 1

# adapt this for a warning
# if ($pkgProps.Count -ge 1)
# {
# if ($pkgProps.Count -gt 1)
# {
# Write-Host "Found more than one project with the name [$PackageName], choosing the first one under $($pkgProps[0].DirectoryPath)"
# }
# return $pkgProps[0]
# }
if ($artifactForCurrentPackage) {
Write-Host "Got $artifactForCurrentPackage with type $($artifactForCurrentPackage.GetType())"
return [HashTable]$artifactForCurrentPackage
}
else {
Write-Host "No artifact found for $($this.Name)"
return $null
}
return @{}
}
}
catch {
Expand All @@ -117,23 +135,34 @@ class PackageProps
return $null
}

hidden [void]InitializeCIArtifacts(){
[void]InitializeCIArtifacts(){
$RepoRoot = Resolve-Path (Join-Path $PSScriptRoot ".." ".." "..")
$ciFilePath = Join-Path -Path $RepoRoot -ChildPath (Join-Path "sdk" $this.ServiceDirectory "ci.yml")
$ciMgmtYmlFilePath = Join-Path -Path $RepoRoot -ChildPath (Join-Path "sdk" $this.ServiceDirectory "ci.mgmt.yml")

Write-Host "Calling InitializeCIArtifacts against $($this.Name)"

$ciArtifactResult = $this.ParseYmlForArtifact($ciFilePath)

if ($ciArtifactResult) {
Write-Host "Is CI"
$this.ArtifactDetails = $ciArtifactResult
}
return
if (-not $this.ArtifactDetails) {
Write-Host "No assigned ArtifactDetails, so using the artifact result if it exists"
if ($ciArtifactResult) {
Write-Host "We have a ciArtifactResult"
$this.ArtifactDetails = [Hashtable]$ciArtifactResult
Write-Host $this.ArtifactDetails | Format-Table
}
else {
Write-Host "We lost ciArtifactResult somehowfor $($this.ArtifactName)"
}

$ciMgmtResult = $this.ParseYmlForArtifact($ciMgmtYmlFilePath)
if (-not $this.ArtifactDetails) {
$ciMgmtResult = $this.ParseYmlForArtifact($ciMgmtYmlFilePath)

if ($ciMgmtResult) {
$this.ArtifactDetails = $ciArtifactResult
if ($ciMgmtResult) {
$ciMgmtResult.GetEnumerator() | Format-List -Force
$this.ArtifactDetails = [Hashtable]$ciMgmtResult
}
}
}
}
}
Expand Down Expand Up @@ -170,7 +199,7 @@ function Get-PkgProperties
function Get-PrPkgProperties([string]$InputDiffJson) {
$packagesWithChanges = @()

$allPackageProperties = Get-AllPkgProperties
$allPackageProperties = Get-AllPkgProperties "appconfiguration"
$diff = Get-Content $InputDiffJson | ConvertFrom-Json
$targetedFiles = $diff.ChangedFiles

Expand Down