Skip to content
Merged
Show file tree
Hide file tree
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
Next Next commit
Restructure Changelog Logic
  • Loading branch information
chidozieononiwu committed Aug 28, 2020
commit d7bb967bbc639101ab046299fc7d52653999f8a1
6 changes: 2 additions & 4 deletions eng/common/pipelines/templates/steps/verify-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ parameters:
- name: PackageName
type: string
default: 'not-specified'
- name: ServiceName
- name: ServiceDirectory
type: string
default: 'not-specified'
- name: ForRelease
Expand All @@ -15,9 +15,7 @@ steps:
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Verify-ChangeLog.ps1
arguments: >
-PackageName ${{ parameters.PackageName }}
-ServiceName ${{ parameters.ServiceName }}
-RepoRoot $(Build.SourcesDirectory)
-RepoName $(Build.Repository.Name)
-ServiceDirectory ${{ parameters.ServiceDirectory }}
-ForRelease $${{ parameters.ForRelease }}
pwsh: true
workingDirectory: $(Pipeline.Workspace)
Expand Down
84 changes: 41 additions & 43 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
@@ -1,66 +1,65 @@
# 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

PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName)
[string]$Name
[string]$Version
[string]$DirectoryPath
[string]$ServiceDirectory
[string]$ReadMePath
[string]$ChangeLogPath
[string]$Group

PackageProps([string]$pkgName, [string]$pkgVersion, [string]$pkgDirectoryPath, [string]$pkgServiceDirectory)
{
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName)
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceDirectory)
}

PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName,[string]$pkgGroup="")
PackageProps([string]$pkgName, [string]$pkgVersion, [string]$pkgDirectoryPath, [string]$pkgServiceDirectory, [string]$pkgGroup = "")
{
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName, $pkgGroup)
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceDirectory, $pkgGroup)
}

hidden [void]Initialize(
[string]$pkgName,
[string]$pkgVersion,
[string]$pkgDirectoryPath,
[string]$pkgServiceName
[string]$pkgServiceDirectory
)
{
$this.pkgName = $pkgName
$this.pkgVersion = $pkgVersion
$this.pkgDirectoryPath = $pkgDirectoryPath
$this.pkgServiceName = $pkgServiceName
$this.Name = $pkgName
$this.Version = $pkgVersion
$this.DirectoryPath = $pkgDirectoryPath
$this.ServiceDirectory = $pkgServiceDirectory

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
}
}

hidden [void]Initialize(
[string]$pkgName,
[string]$pkgVersion,
[string]$pkgDirectoryPath,
[string]$pkgServiceName,
[string]$pkgServiceDirectory,
[string]$pkgGroup
)
{
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName)
$this.pkgGroup = $pkgGroup
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceDirectory)
$this.Group = $pkgGroup
}
}

Expand All @@ -72,18 +71,17 @@ function Get-PkgProperties
{
Param
(
[Parameter(Mandatory=$true)]
[Parameter(Mandatory = $true)]
[string]$PackageName,
[Parameter(Mandatory=$true)]
[string]$ServiceName
[Parameter(Mandatory = $true)]
[string]$ServiceDirectory
)

$pkgDirectoryName = $null
$pkgDirectoryPath = $null
$serviceDirectoryPath = Join-Path $RepoRoot "sdk" $ServiceName
$serviceDirectoryPath = Join-Path $RepoRoot "sdk" $ServiceDirectory
if (!(Test-Path $serviceDirectoryPath))
{
Write-Error "Service Directory $ServiceName does not exist"
Write-Error "Service Directory $ServiceDirectory does not exist"
exit 1
}

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 -ServiceDirectory $ServiceDirectory -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 All @@ -112,11 +110,11 @@ function Get-PkgProperties
# Takes ServiceName and Repo Root Directory
# Returns important properties for each package in the specified service, or entire repo if the serviceName is not specified
# Returns an Table of service key to array values of PS Object with properties @ { pkgName, pkgVersion, pkgDirectoryPath, pkgReadMePath, pkgChangeLogPath }
function Get-AllPkgProperties ([string]$ServiceName=$null)
function Get-AllPkgProperties ([string]$ServiceDirectory = $null)
{
$pkgPropsResult = @()

if ([string]::IsNullOrEmpty($ServiceName))
if ([string]::IsNullOrEmpty($ServiceDirectory))
{
$searchDir = Join-Path $RepoRoot "sdk"
foreach ($dir in (Get-ChildItem $searchDir -Directory))
Expand All @@ -128,32 +126,32 @@ function Get-AllPkgProperties ([string]$ServiceName=$null)
$activePkgList = Get-PkgListFromYml -ciYmlPath (Join-Path $serviceDir "ci.yml")
if ($activePkgList -ne $null)
{
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -serviceName $dir.Name -pkgPropsResult $pkgPropsResult
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -ServiceDirectory $dir.Name -pkgPropsResult $pkgPropsResult
}
}
}
}
else
{
$serviceDir = Join-Path $RepoRoot "sdk" $ServiceName
$serviceDir = Join-Path $RepoRoot "sdk" $ServiceDirectory
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 -serviceName $ServiceName -pkgPropsResult $pkgPropsResult
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -ServiceDirectory $ServiceDirectory -pkgPropsResult $pkgPropsResult
}
}
}

return $pkgPropsResult
}

function Operate-OnPackages ($activePkgList, $serviceName, [Array]$pkgPropsResult)
function Operate-OnPackages ($activePkgList, $ServiceDirectory, [Array]$pkgPropsResult)
{
foreach ($pkg in $activePkgList)
{
$pkgProps = Get-PkgProperties -PackageName $pkg["name"] -ServiceName $serviceName
$pkgProps = Get-PkgProperties -PackageName $pkg["name"] -ServiceDirectory $ServiceDirectory
$pkgPropsResult += $pkgProps
}
return $pkgPropsResult
Expand All @@ -168,11 +166,11 @@ function Get-PkgListFromYml ($ciYmlPath)
$ciYmlObj = ConvertFrom-Yaml $ciYmlContent -Ordered
if ($ciYmlObj.Contains("stages"))
{
$artifactsInCI = $ciYmlObj["stages"][0]["parameters"]["Artifacts"]
$artifactsInCI = $ciYmlObj["stages"][0]["parameters"]["Artifacts"]
}
elseif ($ciYmlObj.Contains("extends"))
{
$artifactsInCI = $ciYmlObj["extends"]["parameters"]["Artifacts"]
$artifactsInCI = $ciYmlObj["extends"]["parameters"]["Artifacts"]
}
if ($artifactsInCI -eq $null)
{
Expand Down
28 changes: 4 additions & 24 deletions eng/common/scripts/Verify-ChangeLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@ param (
[String]$ChangeLogLocation,
[String]$VersionString,
[string]$PackageName,
[string]$ServiceName,
[string]$RepoRoot,
[ValidateSet("net", "java", "js", "python")]
[string]$Language,
[string]$RepoName,
[string]$ServiceDirectory,
[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 -ServiceDirectory $ServiceDirectory
$validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $PackageProp.ChangeLogPath -VersionString $PackageProp.Version -ForRelease $ForRelease
}

if (!$validChangeLog)
Expand Down
26 changes: 13 additions & 13 deletions eng/common/scripts/common.ps1
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
$global:RepoRoot = Resolve-Path "${PSScriptRoot}..\..\..\.."
$global:EngDir = Join-Path $global:RepoRoot "eng"
$global:EngCommonDir = Join-Path $global:EngDir "common"
$global:EngCommonScriptsDir = Join-Path $global:EngCommonDir "scripts"
$global:EngScriptsDir = Join-Path $global:EngDir "scripts"
$RepoRoot = Resolve-Path "${PSScriptRoot}..\..\..\.."
$EngDir = Join-Path $RepoRoot "eng"
$EngCommonDir = Join-Path $EngDir "common"
$EngCommonScriptsDir = Join-Path $EngCommonDir "scripts"
$EngScriptsDir = Join-Path $EngDir "scripts"

# Import required scripts
. (Join-Path $global:EngCommonScriptsDir SemVer.ps1)
. (Join-Path $global:EngCommonScriptsDir Changelog-Operations.ps1)
. (Join-Path $global:EngCommonScriptsDir Package-Properties.ps1)
. (Join-Path $EngCommonScriptsDir SemVer.ps1)
. (Join-Path $EngCommonScriptsDir ChangeLog-Operations.ps1)
. (Join-Path $EngCommonScriptsDir Package-Properties.ps1)

# Setting expected from common languages settings
$global:Language = "Unknown"
$global:PackageRepository = "Unknown"
$global:packagePattern = "Unknown"
$global:MetadataUri = "Unknown"
$Language = "Unknown"
$PackageRepository = "Unknown"
$packagePattern = "Unknown"
$MetadataUri = "Unknown"

# Import common language settings
$EngScriptsLanguageSettings = Join-path $global:EngScriptsDir "Language-Settings.ps1"
$EngScriptsLanguageSettings = Join-path $EngScriptsDir "Language-Settings.ps1"
if (Test-Path $EngScriptsLanguageSettings) {
. $EngScriptsLanguageSettings
}
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/templates/stages/archetype-net-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ stages:
- template: /eng/common/pipelines/templates/steps/verify-changelog.yml
parameters:
PackageName: ${{artifact.name}}
ServiceName: ${{parameters.ServiceDirectory}}
ServiceDirectory: ${{parameters.ServiceDirectory}}
ForRelease: true
- template: /eng/pipelines/templates/steps/stage-artifacts.yml
parameters:
Expand Down
8 changes: 4 additions & 4 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $PackageRepository = "Nuget"
$packagePattern = "*.nupkg"
$MetadataUri = "https://raw.githubusercontent.com/Azure/azure-sdk/master/_data/releases/latest/dotnet-packages.csv"

function Extract-dotnet-PkgProperties ($pkgPath, $serviceName, $pkgName)
function Get-dotnet-PackageInfoFromRepo ($pkgPath, $serviceName, $pkgName)
{
$projectPath = Join-Path $pkgPath "src" "$pkgName.csproj"
if (Test-Path $projectPath)
Expand All @@ -21,7 +21,7 @@ function Extract-dotnet-PkgProperties ($pkgPath, $serviceName, $pkgName)
}

# Returns the nuget publish status of a package id and version.
function IsNugetPackageVersionPublished($pkgId, $pkgVersion)
function IsNugetPackageVersionPublished ($pkgId, $pkgVersion)
{
$nugetUri = "https://api.nuget.org/v3-flatcontainer/$($pkgId.ToLowerInvariant())/index.json"

Expand All @@ -48,7 +48,7 @@ function IsNugetPackageVersionPublished($pkgId, $pkgVersion)
}

# Parse out package publishing information given a nupkg ZIP format.
function Parse-dotnet-Package($pkg, $workingDirectory)
function Get-dotnet-PackageInfoFromPackageFile ($pkg, $workingDirectory)
{
$workFolder = "$workingDirectory$($pkg.Basename)"
$origFolder = Get-Location
Expand Down Expand Up @@ -88,7 +88,7 @@ function Parse-dotnet-Package($pkg, $workingDirectory)
}

# Stage and Upload Docs to blob Storage
function StageAndUpload-dotnet-Docs ()
function Publish-dotnet-GithubIODocs ()
{
$PublishedPkgs = Get-ChildItem "$($DocLocation)/packages" | Where-Object -FilterScript {$_.Name.EndsWith(".nupkg") -and -not $_.Name.EndsWith(".symbols.nupkg")}
$PublishedDocs = Get-ChildItem "$($DocLocation)" | Where-Object -FilterScript {$_.Name.StartsWith("Docs.")}
Expand Down