Skip to content

Commit 6a92dd3

Browse files
committed
Sync eng/common directory with azure-sdk-tools repository for Tools PR 823
1 parent a994c45 commit 6a92dd3

File tree

4 files changed

+75
-92
lines changed

4 files changed

+75
-92
lines changed

eng/common/pipelines/templates/steps/verify-changelog.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ parameters:
55
- name: ServiceName
66
type: string
77
default: 'not-specified'
8+
- name: ServiceDirectory
9+
type: string
10+
default: ''
811
- name: ForRelease
912
type: boolean
1013
default: false
@@ -15,9 +18,7 @@ steps:
1518
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Verify-ChangeLog.ps1
1619
arguments: >
1720
-PackageName ${{ parameters.PackageName }}
18-
-ServiceName ${{ parameters.ServiceName }}
19-
-RepoRoot $(Build.SourcesDirectory)
20-
-RepoName $(Build.Repository.Name)
21+
-ServiceDirectory ${{ coalesce(parameters.ServiceDirectory, parameters.ServiceName) }}
2122
-ForRelease $${{ parameters.ForRelease }}
2223
pwsh: true
2324
workingDirectory: $(Pipeline.Workspace)

eng/common/scripts/Package-Properties.ps1

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,65 @@
11
# Helper functions for retireving useful information from azure-sdk-for-* repo
2-
# Example Use : Import-Module .\eng\common\scripts\modules
32
class PackageProps
43
{
5-
[string]$pkgName
6-
[string]$pkgVersion
7-
[string]$pkgDirectoryPath
8-
[string]$pkgServiceName
9-
[string]$pkgReadMePath
10-
[string]$pkgChangeLogPath
11-
[string]$pkgGroup
12-
13-
PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName)
4+
[string]$Name
5+
[string]$Version
6+
[string]$DirectoryPath
7+
[string]$ServiceDirectory
8+
[string]$ReadMePath
9+
[string]$ChangeLogPath
10+
[string]$Group
11+
12+
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory)
1413
{
15-
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName)
14+
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
1615
}
1716

18-
PackageProps([string]$pkgName,[string]$pkgVersion,[string]$pkgDirectoryPath,[string]$pkgServiceName,[string]$pkgGroup="")
17+
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory, [string]$group = "")
1918
{
20-
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName, $pkgGroup)
19+
$this.Initialize($name, $version, $directoryPath, $serviceDirectory, $group)
2120
}
2221

2322
hidden [void]Initialize(
24-
[string]$pkgName,
25-
[string]$pkgVersion,
26-
[string]$pkgDirectoryPath,
27-
[string]$pkgServiceName
23+
[string]$name,
24+
[string]$version,
25+
[string]$directoryPath,
26+
[string]$serviceDirectory
2827
)
2928
{
30-
$this.pkgName = $pkgName
31-
$this.pkgVersion = $pkgVersion
32-
$this.pkgDirectoryPath = $pkgDirectoryPath
33-
$this.pkgServiceName = $pkgServiceName
29+
$this.Name = $name
30+
$this.Version = $version
31+
$this.DirectoryPath = $directoryPath
32+
$this.ServiceDirectory = $serviceDirectory
3433

35-
if (Test-Path (Join-Path $pkgDirectoryPath "README.md"))
34+
if (Test-Path (Join-Path $directoryPath "README.md"))
3635
{
37-
$this.pkgReadMePath = Join-Path $pkgDirectoryPath "README.md"
36+
$this.ReadMePath = Join-Path $directoryPath "README.md"
3837
}
3938
else
4039
{
41-
$this.pkgReadMePath = $null
40+
$this.ReadMePath = $null
4241
}
4342

44-
if (Test-Path (Join-Path $pkgDirectoryPath "CHANGELOG.md"))
43+
if (Test-Path (Join-Path $directoryPath "CHANGELOG.md"))
4544
{
46-
$this.pkgChangeLogPath = Join-Path $pkgDirectoryPath "CHANGELOG.md"
45+
$this.ChangeLogPath = Join-Path $directoryPath "CHANGELOG.md"
4746
}
4847
else
4948
{
50-
$this.pkgChangeLogPath = $null
49+
$this.ChangeLogPath = $null
5150
}
5251
}
5352

5453
hidden [void]Initialize(
55-
[string]$pkgName,
56-
[string]$pkgVersion,
57-
[string]$pkgDirectoryPath,
58-
[string]$pkgServiceName,
59-
[string]$pkgGroup
54+
[string]$name,
55+
[string]$version,
56+
[string]$directoryPath,
57+
[string]$serviceDirectory,
58+
[string]$group
6059
)
6160
{
62-
$this.Initialize($pkgName, $pkgVersion, $pkgDirectoryPath, $pkgServiceName)
63-
$this.pkgGroup = $pkgGroup
61+
$this.Initialize($name, $version, $directoryPath, $serviceDirectory)
62+
$this.Group = $group
6463
}
6564
}
6665

@@ -72,18 +71,17 @@ function Get-PkgProperties
7271
{
7372
Param
7473
(
75-
[Parameter(Mandatory=$true)]
74+
[Parameter(Mandatory = $true)]
7675
[string]$PackageName,
77-
[Parameter(Mandatory=$true)]
78-
[string]$ServiceName
76+
[Parameter(Mandatory = $true)]
77+
[string]$ServiceDirectory
7978
)
8079

81-
$pkgDirectoryName = $null
8280
$pkgDirectoryPath = $null
83-
$serviceDirectoryPath = Join-Path $RepoRoot "sdk" $ServiceName
81+
$serviceDirectoryPath = Join-Path $RepoRoot "sdk" $ServiceDirectory
8482
if (!(Test-Path $serviceDirectoryPath))
8583
{
86-
Write-Error "Service Directory $ServiceName does not exist"
84+
Write-Error "Service Directory $ServiceDirectory does not exist"
8785
exit 1
8886
}
8987

@@ -92,13 +90,13 @@ function Get-PkgProperties
9290
foreach ($directory in $directoriesPresent)
9391
{
9492
$pkgDirectoryPath = Join-Path $serviceDirectoryPath $directory.Name
95-
if ($ExtractPkgProps)
93+
if ($GetPackageInfoFromRepoFn)
9694
{
97-
$pkgProps = &$ExtractPkgProps -pkgPath $pkgDirectoryPath -serviceName $ServiceName -pkgName $PackageName
95+
$pkgProps = &$GetPackageInfoFromRepoFn -pkgPath $pkgDirectoryPath -serviceDirectory $ServiceDirectory -pkgName $PackageName
9896
}
9997
else
10098
{
101-
Write-Error "The function '${ExtractPkgProps}' was not found."
99+
Write-Error "The function 'Get-${Language}-PackageInfoFromRepo' was not found."
102100
}
103101

104102
if ($pkgProps -ne $null)
@@ -112,11 +110,11 @@ function Get-PkgProperties
112110
# Takes ServiceName and Repo Root Directory
113111
# Returns important properties for each package in the specified service, or entire repo if the serviceName is not specified
114112
# Returns an Table of service key to array values of PS Object with properties @ { pkgName, pkgVersion, pkgDirectoryPath, pkgReadMePath, pkgChangeLogPath }
115-
function Get-AllPkgProperties ([string]$ServiceName=$null)
113+
function Get-AllPkgProperties ([string]$ServiceDirectory = $null)
116114
{
117115
$pkgPropsResult = @()
118116

119-
if ([string]::IsNullOrEmpty($ServiceName))
117+
if ([string]::IsNullOrEmpty($ServiceDirectory))
120118
{
121119
$searchDir = Join-Path $RepoRoot "sdk"
122120
foreach ($dir in (Get-ChildItem $searchDir -Directory))
@@ -128,32 +126,32 @@ function Get-AllPkgProperties ([string]$ServiceName=$null)
128126
$activePkgList = Get-PkgListFromYml -ciYmlPath (Join-Path $serviceDir "ci.yml")
129127
if ($activePkgList -ne $null)
130128
{
131-
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -serviceName $dir.Name -pkgPropsResult $pkgPropsResult
129+
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -ServiceDirectory $dir.Name -pkgPropsResult $pkgPropsResult
132130
}
133131
}
134132
}
135133
}
136134
else
137135
{
138-
$serviceDir = Join-Path $RepoRoot "sdk" $ServiceName
136+
$serviceDir = Join-Path $RepoRoot "sdk" $ServiceDirectory
139137
if (Test-Path (Join-Path $serviceDir "ci.yml"))
140138
{
141139
$activePkgList = Get-PkgListFromYml -ciYmlPath (Join-Path $serviceDir "ci.yml")
142140
if ($activePkgList -ne $null)
143141
{
144-
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -serviceName $ServiceName -pkgPropsResult $pkgPropsResult
142+
$pkgPropsResult = Operate-OnPackages -activePkgList $activePkgList -ServiceDirectory $ServiceDirectory -pkgPropsResult $pkgPropsResult
145143
}
146144
}
147145
}
148146

149147
return $pkgPropsResult
150148
}
151149

152-
function Operate-OnPackages ($activePkgList, $serviceName, [Array]$pkgPropsResult)
150+
function Operate-OnPackages ($activePkgList, $ServiceDirectory, [Array]$pkgPropsResult)
153151
{
154152
foreach ($pkg in $activePkgList)
155153
{
156-
$pkgProps = Get-PkgProperties -PackageName $pkg["name"] -ServiceName $serviceName
154+
$pkgProps = Get-PkgProperties -PackageName $pkg["name"] -ServiceDirectory $ServiceDirectory
157155
$pkgPropsResult += $pkgProps
158156
}
159157
return $pkgPropsResult
@@ -168,11 +166,11 @@ function Get-PkgListFromYml ($ciYmlPath)
168166
$ciYmlObj = ConvertFrom-Yaml $ciYmlContent -Ordered
169167
if ($ciYmlObj.Contains("stages"))
170168
{
171-
$artifactsInCI = $ciYmlObj["stages"][0]["parameters"]["Artifacts"]
169+
$artifactsInCI = $ciYmlObj["stages"][0]["parameters"]["Artifacts"]
172170
}
173171
elseif ($ciYmlObj.Contains("extends"))
174172
{
175-
$artifactsInCI = $ciYmlObj["extends"]["parameters"]["Artifacts"]
173+
$artifactsInCI = $ciYmlObj["extends"]["parameters"]["Artifacts"]
176174
}
177175
if ($artifactsInCI -eq $null)
178176
{

eng/common/scripts/Verify-ChangeLog.ps1

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,11 @@ param (
33
[String]$ChangeLogLocation,
44
[String]$VersionString,
55
[string]$PackageName,
6-
[string]$ServiceName,
7-
[string]$RepoRoot,
8-
[ValidateSet("net", "java", "js", "python")]
9-
[string]$Language,
10-
[string]$RepoName,
6+
[string]$ServiceDirectory,
117
[boolean]$ForRelease = $False
128
)
139

14-
$ProgressPreference = "SilentlyContinue"
15-
. (Join-Path $PSScriptRoot SemVer.ps1)
16-
Import-Module (Join-Path $PSScriptRoot modules ChangeLog-Operations.psm1)
10+
. (Join-Path $PSScriptRoot common.ps1)
1711

1812
$validChangeLog = $false
1913
if ($ChangeLogLocation -and $VersionString)
@@ -22,22 +16,8 @@ if ($ChangeLogLocation -and $VersionString)
2216
}
2317
else
2418
{
25-
Import-Module (Join-Path $PSScriptRoot modules Package-Properties.psm1)
26-
if ([System.String]::IsNullOrEmpty($Language))
27-
{
28-
if ($RepoName -match "azure-sdk-for-(?<lang>[^-]+)")
29-
{
30-
$Language = $matches["lang"]
31-
}
32-
else
33-
{
34-
Write-Error "Failed to set Language automatically. Please pass the appropriate Language as a parameter."
35-
exit 1
36-
}
37-
}
38-
39-
$PackageProp = Get-PkgProperties -PackageName $PackageName -ServiceName $ServiceName -Language $Language -RepoRoot $RepoRoot
40-
$validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $PackageProp.pkgChangeLogPath -VersionString $PackageProp.pkgVersion -ForRelease $ForRelease
19+
$PackageProp = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory
20+
$validChangeLog = Confirm-ChangeLogEntry -ChangeLogLocation $PackageProp.ChangeLogPath -VersionString $PackageProp.Version -ForRelease $ForRelease
4121
}
4222

4323
if (!$validChangeLog)

eng/common/scripts/common.ps1

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
1-
$global:RepoRoot = Resolve-Path "${PSScriptRoot}..\..\..\.."
2-
$global:EngDir = Join-Path $global:RepoRoot "eng"
3-
$global:EngCommonDir = Join-Path $global:EngDir "common"
4-
$global:EngCommonScriptsDir = Join-Path $global:EngCommonDir "scripts"
5-
$global:EngScriptsDir = Join-Path $global:EngDir "scripts"
1+
$RepoRoot = Resolve-Path "${PSScriptRoot}..\..\..\.."
2+
$EngDir = Join-Path $RepoRoot "eng"
3+
$EngCommonDir = Join-Path $EngDir "common"
4+
$EngCommonScriptsDir = Join-Path $EngCommonDir "scripts"
5+
$EngScriptsDir = Join-Path $EngDir "scripts"
66

77
# Import required scripts
8-
. (Join-Path $global:EngCommonScriptsDir SemVer.ps1)
9-
. (Join-Path $global:EngCommonScriptsDir Changelog-Operations.ps1)
10-
. (Join-Path $global:EngCommonScriptsDir Package-Properties.ps1)
8+
. (Join-Path $EngCommonScriptsDir SemVer.ps1)
9+
. (Join-Path $EngCommonScriptsDir ChangeLog-Operations.ps1)
10+
. (Join-Path $EngCommonScriptsDir Package-Properties.ps1)
1111

1212
# Setting expected from common languages settings
13-
$global:Language = "Unknown"
14-
$global:PackageRepository = "Unknown"
15-
$global:packagePattern = "Unknown"
16-
$global:MetadataUri = "Unknown"
13+
$Language = "Unknown"
14+
$PackageRepository = "Unknown"
15+
$packagePattern = "Unknown"
16+
$MetadataUri = "Unknown"
1717

1818
# Import common language settings
19-
$EngScriptsLanguageSettings = Join-path $global:EngScriptsDir "Language-Settings.ps1"
19+
$EngScriptsLanguageSettings = Join-path $EngScriptsDir "Language-Settings.ps1"
2020
if (Test-Path $EngScriptsLanguageSettings) {
2121
. $EngScriptsLanguageSettings
2222
}
23+
If ($LanguageShort -eq $null)
24+
{
25+
$LangaugeShort = $Language
26+
}
2327

2428
# Transformed Functions
2529
$GetPackageInfoFromRepoFn = "Get-${Language}-PackageInfoFromRepo"

0 commit comments

Comments
 (0)