Skip to content

Commit

Permalink
Restructure Changelog Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
chidozieononiwu committed Jul 29, 2020
1 parent 911a328 commit 3e87c44
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 46 deletions.
2 changes: 0 additions & 2 deletions eng/common/pipelines/templates/steps/verify-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ steps:
arguments: >
-PackageName ${{ parameters.PackageName }}
-ServiceName ${{ parameters.ServiceName }}
-RepoRoot $(Build.SourcesDirectory)
-RepoName $(Build.Repository.Name)
-ForRelease $${{ parameters.ForRelease }}
pwsh: true
workingDirectory: $(Pipeline.Workspace)
Expand Down
File renamed without changes.
40 changes: 19 additions & 21 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# Helper functions for retireving useful information from azure-sdk-for-* repo
# Example Use : Import-Module .\eng\common\scripts\modules
class PackageProps
{
[string]$pkgName
[string]$pkgVersion
[string]$pkgDirectoryPath
[string]$pkgServiceName
[string]$pkgReadMePath
[string]$pkgChangeLogPath
[string]$pkgGroup
[string]$Name
[string]$Version
[string]$DirectoryPath
[string]$ServiceName
[string]$ReadMePath
[string]$ChangeLogPath
[string]$Group

PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName)
{
Expand All @@ -27,27 +26,27 @@ class PackageProps
[string]$pkgServiceName
)
{
$this.pkgName = $pkgName
$this.pkgVersion = $pkgVersion
$this.pkgDirectoryPath = $pkgDirectoryPath
$this.pkgServiceName = $pkgServiceName
$this.Name = $pkgName
$this.Version = $pkgVersion
$this.DirectoryPath = $pkgDirectoryPath
$this.ServiceName = $pkgServiceName

if (Test-Path (Join-Path $pkgDirectoryPath "README.md"))
{
$this.pkgReadMePath = Join-Path $pkgDirectoryPath "README.md"
$this.ReadMePath = Join-Path $pkgDirectoryPath "README.md"
}
else
{
$this.pkgReadMePath = $null
$this.ReadMePath = $null
}

if (Test-Path (Join-Path $pkgDirectoryPath "CHANGELOG.md"))
{
$this.pkgChangeLogPath = Join-Path $pkgDirectoryPath "CHANGELOG.md"
$this.ChangeLogPath = Join-Path $pkgDirectoryPath "CHANGELOG.md"
}
else
{
$this.pkgChangeLogPath = $null
$this.ChangeLogPath = $null
}
}

Expand All @@ -60,7 +59,7 @@ class PackageProps
)
{
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName)
$this.pkgGroup = $pkgGroup
$this.Group = $pkgGroup
}
}

Expand All @@ -78,7 +77,6 @@ function Get-PkgProperties
[string]$ServiceName
)

$pkgDirectoryName = $null
$pkgDirectoryPath = $null
$serviceDirectoryPath = Join-Path $RepoRoot "sdk" $ServiceName
if (!(Test-Path $serviceDirectoryPath))
Expand All @@ -92,13 +90,13 @@ function Get-PkgProperties
foreach ($directory in $directoriesPresent)
{
$pkgDirectoryPath = Join-Path $serviceDirectoryPath $directory.Name
if ($ExtractPkgProps)
if ($GetPackageInfoFromRepoFn)
{
$pkgProps = &$ExtractPkgProps -pkgPath $pkgDirectoryPath -serviceName $ServiceName -pkgName $PackageName
$pkgProps = &$GetPackageInfoFromRepoFn -pkgPath $pkgDirectoryPath -serviceName $ServiceName -pkgName $PackageName
}
else
{
Write-Error "The function '${ExtractPkgProps}' was not found."
Write-Error "The function 'Get-${Language}-PackageInfoFromRepo' was not found."
}

if ($pkgProps -ne $null)
Expand Down
26 changes: 3 additions & 23 deletions eng/common/scripts/Verify-ChangeLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ param (
[String]$VersionString,
[string]$PackageName,
[string]$ServiceName,
[string]$RepoRoot,
[ValidateSet("net", "java", "js", "python")]
[string]$Language,
[string]$RepoName,
[boolean]$ForRelease = $False
)

$ProgressPreference = "SilentlyContinue"
. (Join-Path $PSScriptRoot SemVer.ps1)
Import-Module (Join-Path $PSScriptRoot modules ChangeLog-Operations.psm1)
. (Join-Path $PSScriptRoot common.ps1)

$validChangeLog = $false
if ($ChangeLogLocation -and $VersionString)
Expand All @@ -22,22 +16,8 @@ if ($ChangeLogLocation -and $VersionString)
}
else
{
Import-Module (Join-Path $PSScriptRoot modules Package-Properties.psm1)
if ([System.String]::IsNullOrEmpty($Language))
{
if ($RepoName -match "azure-sdk-for-(?<lang>[^-]+)")
{
$Language = $matches["lang"]
}
else
{
Write-Error "Failed to set Language automatically. Please pass the appropriate Language as a parameter."
exit 1
}
}

$PackageProp = Get-PkgProperties -PackageName $PackageName -ServiceName $ServiceName -Language $Language -RepoRoot $RepoRoot
$validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $PackageProp.pkgChangeLogPath -VersionString $PackageProp.pkgVersion -ForRelease $ForRelease
$PackageProp = Get-PkgProperties -PackageName $PackageName -ServiceName $ServiceName
$validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $PackageProp.ChangeLogPath -VersionString $PackageProp.Version -ForRelease $ForRelease
}

if (!$validChangeLog)
Expand Down

0 comments on commit 3e87c44

Please sign in to comment.