Sync eng/common directory with azure-sdk-tools for PR 1418 (#1759)

* 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>
Co-authored-by: Chidozie Ononiwu <31145988+chidozieononiwu@users.noreply.github.com>
This commit is contained in:
Azure SDK Bot 2021-03-15 23:23:26 -07:00 committed by GitHub
parent 86c908eeda
commit d08bebfb6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 66 deletions

View File

@ -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))
$AllPkgProps = Get-AllPkgProperties -ServiceDirectory $ServiceDirectory
foreach ($pkgProp in $AllPkgProps)
{
LogError "Service Directory $ServiceDirectory does not exist"
return $null
if(($pkgProp.Name -eq $PackageName) -or ($pkgProp.ArtifactName -eq $PackageName))
{
return $pkgProp
}
}
$directoriesPresent = Get-ChildItem $serviceDirectoryPath -Directory
foreach ($directory in $directoriesPresent)
{
$pkgDirectoryPath = Join-Path $serviceDirectoryPath $directory.Name
if ($GetPackageInfoFromRepoFn -and (Test-Path "Function:$GetPackageInfoFromRepoFn"))
{
$pkgProps = &$GetPackageInfoFromRepoFn -pkgPath $pkgDirectoryPath -serviceDirectory $ServiceDirectory -pkgName $PackageName
}
else
{
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
}
}
LogWarning "Failed to retrive Properties for $PackageName"
LogError "Failed to retrive Properties for [ $PackageName ]"
return $null
}
@ -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)
}
}
@ -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)
@ -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
}

View File

@ -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)
{
@ -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)
{
@ -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
@ -105,7 +105,7 @@ else
-packageName $packageProperties.Name `
-version $newVersion `
-plannedDate $releaseDateString `
-packageRepoPath $packageProperties.serviceDirectory `
-packageRepoPath $packageProperties.ServiceDirectory `
-packageType $packageProperties.SDKType `
-packageNewLibrary $packageProperties.IsNewSDK

View File

@ -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)