Sync eng/common directory with azure-sdk-tools repository for Tools PR 823 (#553)
This commit is contained in:
parent
e75d8e1775
commit
30112e3fcd
@ -5,6 +5,9 @@ parameters:
|
||||
- name: ServiceName
|
||||
type: string
|
||||
default: 'not-specified'
|
||||
- name: ServiceDirectory
|
||||
type: string
|
||||
default: ''
|
||||
- name: ForRelease
|
||||
type: boolean
|
||||
default: false
|
||||
@ -15,9 +18,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 ${{ coalesce(parameters.ServiceDirectory, parameters.ServiceName) }}
|
||||
-ForRelease $${{ parameters.ForRelease }}
|
||||
pwsh: true
|
||||
workingDirectory: $(Pipeline.Workspace)
|
||||
|
||||
@ -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
|
||||
[string]$Name
|
||||
[string]$Version
|
||||
[string]$DirectoryPath
|
||||
[string]$ServiceDirectory
|
||||
[string]$ReadMePath
|
||||
[string]$ChangeLogPath
|
||||
[string]$Group
|
||||
|
||||
PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName)
|
||||
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory)
|
||||
{
|
||||
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName)
|
||||
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
|
||||
}
|
||||
|
||||
PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName,[string]$pkgGroup="")
|
||||
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory, [string]$group = "")
|
||||
{
|
||||
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName, $pkgGroup)
|
||||
$this.Initialize($name, $version, $directoryPath, $serviceDirectory, $group)
|
||||
}
|
||||
|
||||
hidden [void]Initialize(
|
||||
[string]$pkgName,
|
||||
[string]$pkgVersion,
|
||||
[string]$pkgDirectoryPath,
|
||||
[string]$pkgServiceName
|
||||
[string]$name,
|
||||
[string]$version,
|
||||
[string]$directoryPath,
|
||||
[string]$serviceDirectory
|
||||
)
|
||||
{
|
||||
$this.pkgName = $pkgName
|
||||
$this.pkgVersion = $pkgVersion
|
||||
$this.pkgDirectoryPath = $pkgDirectoryPath
|
||||
$this.pkgServiceName = $pkgServiceName
|
||||
$this.Name = $name
|
||||
$this.Version = $version
|
||||
$this.DirectoryPath = $directoryPath
|
||||
$this.ServiceDirectory = $serviceDirectory
|
||||
|
||||
if (Test-Path (Join-Path $pkgDirectoryPath "README.md"))
|
||||
if (Test-Path (Join-Path $directoryPath "README.md"))
|
||||
{
|
||||
$this.pkgReadMePath = Join-Path $pkgDirectoryPath "README.md"
|
||||
$this.ReadMePath = Join-Path $directoryPath "README.md"
|
||||
}
|
||||
else
|
||||
{
|
||||
$this.pkgReadMePath = $null
|
||||
$this.ReadMePath = $null
|
||||
}
|
||||
|
||||
if (Test-Path (Join-Path $pkgDirectoryPath "CHANGELOG.md"))
|
||||
if (Test-Path (Join-Path $directoryPath "CHANGELOG.md"))
|
||||
{
|
||||
$this.pkgChangeLogPath = Join-Path $pkgDirectoryPath "CHANGELOG.md"
|
||||
$this.ChangeLogPath = Join-Path $directoryPath "CHANGELOG.md"
|
||||
}
|
||||
else
|
||||
{
|
||||
$this.pkgChangeLogPath = $null
|
||||
$this.ChangeLogPath = $null
|
||||
}
|
||||
}
|
||||
|
||||
hidden [void]Initialize(
|
||||
[string]$pkgName,
|
||||
[string]$pkgVersion,
|
||||
[string]$pkgDirectoryPath,
|
||||
[string]$pkgServiceName,
|
||||
[string]$pkgGroup
|
||||
[string]$name,
|
||||
[string]$version,
|
||||
[string]$directoryPath,
|
||||
[string]$serviceDirectory,
|
||||
[string]$group
|
||||
)
|
||||
{
|
||||
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName)
|
||||
$this.pkgGroup = $pkgGroup
|
||||
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
|
||||
$this.Group = $group
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
@ -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)
|
||||
@ -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))
|
||||
@ -128,20 +126,20 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -149,11 +147,11 @@ function Get-AllPkgProperties ([string]$ServiceName=$null)
|
||||
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
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
@ -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)
|
||||
|
||||
@ -1,25 +1,29 @@
|
||||
$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
|
||||
}
|
||||
If ($LanguageShort -eq $null)
|
||||
{
|
||||
$LangaugeShort = $Language
|
||||
}
|
||||
|
||||
# Transformed Functions
|
||||
$GetPackageInfoFromRepoFn = "Get-${Language}-PackageInfoFromRepo"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user