Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 1418 (Azure#14047)
Browse files Browse the repository at this point in the history
* Update Package Properties Logic, make prepare release require only 1 argument, make rerun of Get-PkgProperties in Update-Changelog not required

* Remove ServiceDirectory parameter from PrepareRelease.ps1

* changes to argument names

* pass service directory to Get-AllPackageInfoFromRepo

* Remove changes in Update-ChangeLog.ps1

* updates to Package-Properties.ps1

Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
  • Loading branch information
azure-sdk and chidozieononiwu authored Mar 16, 2021
1 parent 84ab472 commit 5f85ce2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 64 deletions.
104 changes: 45 additions & 59 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -78,41 +78,20 @@ function Get-PkgProperties
(
[Parameter(Mandatory = $true)]
[string]$PackageName,
[Parameter(Mandatory = $true)]
[string]$ServiceDirectory
)

$pkgDirectoryPath = $null
$serviceDirectoryPath = Join-Path $RepoRoot "sdk" $ServiceDirectory
if (!(Test-Path $serviceDirectoryPath))
{
LogError "Service Directory $ServiceDirectory does not exist"
return $null
}
$AllPkgProps = Get-AllPkgProperties -ServiceDirectory $ServiceDirectory

$directoriesPresent = Get-ChildItem $serviceDirectoryPath -Directory

foreach ($directory in $directoriesPresent)
foreach ($pkgProp in $AllPkgProps)
{
$pkgDirectoryPath = Join-Path $serviceDirectoryPath $directory.Name

if ($GetPackageInfoFromRepoFn -and (Test-Path "Function:$GetPackageInfoFromRepoFn"))
{
$pkgProps = &$GetPackageInfoFromRepoFn -pkgPath $pkgDirectoryPath -serviceDirectory $ServiceDirectory -pkgName $PackageName
}
else
if(($pkgProp.Name -eq $PackageName) -or ($pkgProp.ArtifactName -eq $PackageName))
{
LogError "The function for '$GetPackageInfoFromRepoFn' was not found.`
Make sure it is present in eng/scripts/Language-Settings.ps1 and referenced in eng/common/scripts/common.ps1.`
See https://github.com/Azure/azure-sdk-tools/blob/master/doc/common/common_engsys.md#code-structure"
}

if ($pkgProps -ne $null)
{
return $pkgProps
return $pkgProp
}
}
LogWarning "Failed to retrive Properties for $PackageName"

LogError "Failed to retrive Properties for [ $PackageName ]"
return $null
}

Expand All @@ -123,33 +102,22 @@ function Get-AllPkgProperties ([string]$ServiceDirectory = $null)
{
$pkgPropsResult = @()

if ([string]::IsNullOrEmpty($ServiceDirectory))
if (Test-Path "Function:Get-AllPackageInfoFromRepo")
{
$searchDir = Join-Path $RepoRoot "sdk"
foreach ($dir in (Get-ChildItem $searchDir -Directory))
{
$serviceDir = Join-Path $searchDir $dir.Name

if (Test-Path (Join-Path $serviceDir "ci.yml"))
{
$activePkgList = Get-PkgListFromYml -ciYmlPath (Join-Path $serviceDir "ci.yml")
if ($activePkgList -ne $null)
{
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -ServiceDirectory $dir.Name -pkgPropsResult $pkgPropsResult
}
}
}
}
$pkgPropsResult = Get-AllPackageInfoFromRepo -ServiceDirectory $serviceDirectory
}
else
{
$serviceDir = Join-Path $RepoRoot "sdk" $ServiceDirectory
if (Test-Path (Join-Path $serviceDir "ci.yml"))
if ([string]::IsNullOrEmpty($ServiceDirectory))
{
$activePkgList = Get-PkgListFromYml -ciYmlPath (Join-Path $serviceDir "ci.yml")
if ($activePkgList -ne $null)
foreach ($dir in (Get-ChildItem (Join-Path $RepoRoot "sdk") -Directory))
{
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -ServiceDirectory $ServiceDirectory -pkgPropsResult $pkgPropsResult
$pkgPropsResult += Get-PkgPropsForEntireService -serviceDirectoryPath $dir.FullName
}
}
else
{
$pkgPropsResult = Get-PkgPropsForEntireService -serviceDirectoryPath (Join-Path $RepoRoot "sdk" $ServiceDirectory)
}
}

Expand All @@ -164,21 +132,43 @@ function Get-CSVMetadata ([string]$MetadataUri=$MetadataUri)
return $metadataResponse
}

function Operate-OnPackages ($activePkgList, $ServiceDirectory, [Array]$pkgPropsResult)
function Get-PkgPropsForEntireService ($serviceDirectoryPath)
{
foreach ($pkg in $activePkgList)
$projectProps = @() # Properties from very project inthe service
$packageProps = @() # Properties for artifacts specified in ci.yml
$serviceDirectory = (Split-Path -Path $serviceDirectoryPath -Leaf)

if (!$GetPackageInfoFromRepoFn -or !(Test-Path "Function:$GetPackageInfoFromRepoFn"))
{
LogDebug "Operating on $($pkg["name"])"
$pkgProps = Get-PkgProperties -PackageName $pkg["name"] -ServiceDirectory $ServiceDirectory
LogError "The function for '$GetPackageInfoFromRepoFn' was not found.`
Make sure it is present in eng/scripts/Language-Settings.ps1 and referenced in eng/common/scripts/common.ps1.`
See https://github.com/Azure/azure-sdk-tools/blob/master/doc/common/common_engsys.md#code-structure"
}

foreach ($directory in (Get-ChildItem $serviceDirectoryPath -Directory))
{
$pkgDirectoryPath = Join-Path $serviceDirectoryPath $directory.Name
$pkgProps = &$GetPackageInfoFromRepoFn $pkgDirectoryPath $serviceDirectory
if ($null -ne $pkgProps)
{
$pkgPropsResult += $pkgProps
$projectProps += $pkgProps
}
}
return $pkgPropsResult

$ciYmlFiles = Get-ChildItem $serviceDirectoryPath -filter "ci.*yml"
foreach($ciYmlFile in $ciYmlFiles)
{
$activeArtifactList = Get-ArtifactListFromYml -ciYmlPath $ciYmlFile.FullName
foreach ($artifact in $activeArtifactList)
{
$packageProps += $projectProps | Where-Object { $_.ArtifactName -eq $artifact["name"] -and $_.Group -eq $artifact["groupId"] }
}
}

return $packageProps
}

function Get-PkgListFromYml ($ciYmlPath)
function Get-ArtifactListFromYml ($ciYmlPath)
{
$ProgressPreference = "SilentlyContinue"
if ((Get-PSRepository | ?{$_.Name -eq "PSGallery"}).Count -eq 0)
Expand All @@ -201,9 +191,5 @@ function Get-PkgListFromYml ($ciYmlPath)
{
$artifactsInCI = $ciYmlObj["extends"]["parameters"]["Artifacts"]
}
if ($artifactsInCI -eq $null)
{
LogError "Failed to retrive package names in ci $ciYmlPath"
}
return $artifactsInCI
}
8 changes: 4 additions & 4 deletions eng/common/scripts/Prepare-Release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function Get-ReleaseDay($baseDate)

$ErrorPreference = 'Stop'

$packageProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $serviceDirectory
$packageProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory

if (!$packageProperties)
{
Expand All @@ -36,7 +36,7 @@ if (!$packageProperties)
}

Write-Host "Package Name [ $($packageProperties.Name) ]"
Write-Host "Source directory [ $serviceDirectory ]"
Write-Host "Source directory [ $($packageProperties.ServiceDirectory) ]"

if (!$ReleaseDate)
{
Expand Down Expand Up @@ -89,7 +89,7 @@ if ($null -eq $newVersionParsed)

if (Test-Path "Function:SetPackageVersion")
{
SetPackageVersion -PackageName $packageProperties.Name -Version $newVersion -ServiceDirectory $serviceDirectory -ReleaseDate $releaseDateString `
SetPackageVersion -PackageName $packageProperties.Name -Version $newVersion -ServiceDirectory $packageProperties.ServiceDirectory -ReleaseDate $releaseDateString `
-PackageProperties $packageProperties
}
else
Expand All @@ -105,7 +105,7 @@ else
-packageName $packageProperties.Name `
-version $newVersion `
-plannedDate $releaseDateString `
-packageRepoPath $packageProperties.serviceDirectory `
-packageRepoPath $packageProperties.ServiceDirectory `
-packageType $packageProperties.SDKType `
-packageNewLibrary $packageProperties.IsNewSDK

Expand Down
1 change: 0 additions & 1 deletion eng/common/scripts/Update-ChangeLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ if ($null -eq [AzureEngSemanticVersion]::ParseVersionString($Version))
$PkgProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory
$ChangeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $PkgProperties.ChangeLogPath


if ($ChangeLogEntries.Contains($Version))
{
if ($ChangeLogEntries[$Version].ReleaseStatus -eq $ReleaseStatus)
Expand Down

0 comments on commit 5f85ce2

Please sign in to comment.