Skip to content

Commit 5afa2da

Browse files
azure-sdkraych1
andauthored
Sync eng/common directory with azure-sdk-tools for PR 13076 (#25756)
* Used full pkg name in release work items * Used full pkg name for dev ops work item * Added test * Pass in package info file path * Reverted changes to verify-changelog.yml and script * Updated script to process groupId in work items * Renamed new property to GroupId * Removed the condition check for Group * Build hash key with non-null arguments * Used the original BuildHashKey to return hash from non-null args --------- Co-authored-by: ray chen <[email protected]>
1 parent ded8fb6 commit 5afa2da

File tree

5 files changed

+110
-34
lines changed

5 files changed

+110
-34
lines changed

eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,17 @@ function FindParentWorkItem($serviceName, $packageDisplayName, $outputCommand =
215215
$packageWorkItems = @{}
216216
$packageWorkItemWithoutKeyFields = @{}
217217

218-
function FindLatestPackageWorkItem($lang, $packageName, $outputCommand = $true, $ignoreReleasePlannerTests = $true, $tag = $null)
218+
function FindLatestPackageWorkItem($lang, $packageName, $groupId = $null, $outputCommand = $true, $ignoreReleasePlannerTests = $true, $tag = $null)
219219
{
220220
# Cache all the versions of this package and language work items
221-
$null = FindPackageWorkItem $lang $packageName -includeClosed $true -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests -tag $tag
221+
$null = FindPackageWorkItem $lang $packageName -includeClosed $true -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests -tag $tag -groupId $groupId
222222

223223
$latestWI = $null
224224
foreach ($wi in $packageWorkItems.Values)
225225
{
226226
if ($wi.fields["Custom.Language"] -ne $lang) { continue }
227227
if ($wi.fields["Custom.Package"] -ne $packageName) { continue }
228+
if ($groupId -and $wi.fields["Custom.GroupId"] -ne $groupId) { continue }
228229

229230
if (!$latestWI) {
230231
$latestWI = $wi
@@ -238,9 +239,9 @@ function FindLatestPackageWorkItem($lang, $packageName, $outputCommand = $true,
238239
return $latestWI
239240
}
240241

241-
function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $true, $includeClosed = $false, $ignoreReleasePlannerTests = $true, $tag = $null)
242+
function FindPackageWorkItem($lang, $packageName, $version, $groupId = $null, $outputCommand = $true, $includeClosed = $false, $ignoreReleasePlannerTests = $true, $tag = $null)
242243
{
243-
$key = BuildHashKeyNoNull $lang $packageName $version
244+
$key = BuildHashKey $lang $packageName $version $groupId
244245
if ($key -and $packageWorkItems.ContainsKey($key)) {
245246
return $packageWorkItems[$key]
246247
}
@@ -253,6 +254,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr
253254
$fields += "System.Tags"
254255
$fields += "Custom.Language"
255256
$fields += "Custom.Package"
257+
$fields += "Custom.GroupId"
256258
$fields += "Custom.PackageDisplayName"
257259
$fields += "System.Title"
258260
$fields += "Custom.PackageType"
@@ -282,6 +284,9 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr
282284
if ($packageName) {
283285
$query += " AND [Package] = '${packageName}'"
284286
}
287+
if ($groupId) {
288+
$query += " AND [GroupId] = '${groupId}'"
289+
}
285290
if ($version) {
286291
$query += " AND [PackageVersionMajorMinor] = '${version}'"
287292
}
@@ -295,7 +300,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr
295300

296301
foreach ($wi in $workItems)
297302
{
298-
$localKey = BuildHashKeyNoNull $wi.fields["Custom.Language"] $wi.fields["Custom.Package"] $wi.fields["Custom.PackageVersionMajorMinor"]
303+
$localKey = BuildHashKey $wi.fields["Custom.Language"] $wi.fields["Custom.Package"] $wi.fields["Custom.PackageVersionMajorMinor"] $wi.fields["Custom.GroupId"]
299304
if (!$localKey) {
300305
$packageWorkItemWithoutKeyFields[$wi.id] = $wi
301306
Write-Host "Skipping package [$($wi.id)]$($wi.fields['System.Title']) which is missing required fields language, package, or version."
@@ -461,10 +466,10 @@ function UpdatePackageWorkItemReleaseState($id, $state, $releaseType, $outputCom
461466

462467
function FindOrCreateClonePackageWorkItem($lang, $pkg, $verMajorMinor, $allowPrompt = $false, $outputCommand = $false, $relatedId = $null, $tag= $null, $ignoreReleasePlannerTests = $true)
463468
{
464-
$workItem = FindPackageWorkItem -lang $lang -packageName $pkg.Package -version $verMajorMinor -includeClosed $true -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests
469+
$workItem = FindPackageWorkItem -lang $lang -packageName $pkg.Package -version $verMajorMinor -includeClosed $true -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests -groupId $pkg.GroupId
465470

466471
if (!$workItem) {
467-
$latestVersionItem = FindLatestPackageWorkItem -lang $lang -packageName $pkg.Package -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests
472+
$latestVersionItem = FindLatestPackageWorkItem -lang $lang -packageName $pkg.Package -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests -groupId $pkg.GroupId
468473
$assignedTo = "me"
469474
$extraFields = @()
470475
if ($latestVersionItem) {
@@ -512,6 +517,13 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
512517
Write-Host "Cannot create or update because one of lang, pkg or verMajorMinor aren't set. [$lang|$($pkg.Package)|$verMajorMinor]"
513518
return
514519
}
520+
521+
# PackageProp object uses Group, while other places use GroupId, such as in work item fields and package csv files.
522+
$pkgGroupId = if ($pkg.PSObject.Properties.Name -contains "GroupId") {
523+
$pkg.GroupId
524+
} else {
525+
$null
526+
}
515527
$pkgName = $pkg.Package
516528
$pkgDisplayName = $pkg.DisplayName
517529
$pkgType = $pkg.Type
@@ -523,6 +535,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
523535
$fields = @()
524536
$fields += "`"Language=${lang}`""
525537
$fields += "`"Package=${pkgName}`""
538+
$fields += "`"GroupId=${pkgGroupId}`""
526539
$fields += "`"PackageDisplayName=${pkgDisplayName}`""
527540
$fields += "`"PackageType=${pkgType}`""
528541
$fields += "`"PackageTypeNewLibrary=${pkgNewLibrary}`""
@@ -540,6 +553,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
540553

541554
if ($lang -ne $existingItem.fields["Custom.Language"]) { $changedField = "Custom.Language" }
542555
if ($pkgName -ne $existingItem.fields["Custom.Package"]) { $changedField = "Custom.Package" }
556+
if ($pkgGroupId -ne $existingItem.fields["Custom.GroupId"]) { $changedField = "Custom.GroupId" }
543557
if ($verMajorMinor -ne $existingItem.fields["Custom.PackageVersionMajorMinor"]) { $changedField = "Custom.PackageVersionMajorMinor" }
544558
if ($pkgDisplayName -ne $existingItem.fields["Custom.PackageDisplayName"]) { $changedField = "Custom.PackageDisplayName" }
545559
if ($pkgType -ne [string]$existingItem.fields["Custom.PackageType"]) { $changedField = "Custom.PackageType" }
@@ -1029,15 +1043,16 @@ function UpdatePackageVersions($pkgWorkItem, $plannedVersions, $shippedVersions)
10291043
function UpdateValidationStatus($pkgvalidationDetails, $BuildDefinition, $PipelineUrl)
10301044
{
10311045
$pkgName = $pkgValidationDetails.Name
1046+
$groupId = $pkgValidationDetails.GroupId
10321047
$versionString = $pkgValidationDetails.Version
10331048

10341049
$parsedNewVersion = [AzureEngSemanticVersion]::new($versionString)
10351050
$versionMajorMinor = "" + $parsedNewVersion.Major + "." + $parsedNewVersion.Minor
1036-
$workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $pkgName -version $versionMajorMinor -includeClosed $true -outputCommand $false
1051+
$workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $pkgName -groupId $groupId -version $versionMajorMinor -includeClosed $true -outputCommand $false
10371052

10381053
if (!$workItem)
10391054
{
1040-
Write-Host"No work item found for package [$pkgName]."
1055+
Write-Host "No work item found for package [$pkgName] with groupId [$groupId]."
10411056
return $false
10421057
}
10431058

@@ -1250,6 +1265,7 @@ function Update-DevOpsReleaseWorkItem {
12501265
[Parameter(Mandatory=$true)]
12511266
[string]$version,
12521267
[string]$plannedDate,
1268+
[string]$groupId = $null,
12531269
[string]$serviceName = $null,
12541270
[string]$packageDisplayName = $null,
12551271
[string]$packageRepoPath = "NA",
@@ -1277,6 +1293,7 @@ function Update-DevOpsReleaseWorkItem {
12771293

12781294
$packageInfo = [PSCustomObject][ordered]@{
12791295
Package = $packageName
1296+
GroupId = $groupId
12801297
DisplayName = $packageDisplayName
12811298
ServiceName = $serviceName
12821299
RepoPath = $packageRepoPath

eng/common/scripts/Package-Properties.ps1

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,30 @@ class PackageProps {
230230
# Returns important properties of the package relative to the language repo
231231
# Returns a PS Object with properties @ { pkgName, pkgVersion, pkgDirectoryPath, pkgReadMePath, pkgChangeLogPath }
232232
# Note: python is required for parsing python package properties.
233+
# GroupId is optional and is used to filter packages for languages that support group identifiers (e.g., Java).
234+
# When GroupId is provided, the function will match both the package name and the group ID.
233235
function Get-PkgProperties {
234236
Param
235237
(
236238
[Parameter(Mandatory = $true)]
237239
[string]$PackageName,
238-
[string]$ServiceDirectory
240+
[string]$ServiceDirectory,
241+
[string]$GroupId
239242
)
240243

244+
Write-Host "Get-PkgProperties called with PackageName: [$PackageName], ServiceDirectory: [$ServiceDirectory], GroupId: [$GroupId]"
245+
241246
$allPkgProps = Get-AllPkgProperties -ServiceDirectory $ServiceDirectory
242-
$pkgProps = $allPkgProps.Where({ $_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName });
247+
248+
if ([string]::IsNullOrEmpty($GroupId)) {
249+
$pkgProps = $allPkgProps.Where({ $_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName });
250+
}
251+
else {
252+
$pkgProps = $allPkgProps.Where({
253+
($_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName) -and
254+
($_.PSObject.Properties.Name -contains "Group" -and $_.Group -eq $GroupId)
255+
});
256+
}
243257

244258
if ($pkgProps.Count -ge 1) {
245259
if ($pkgProps.Count -gt 1) {
@@ -248,7 +262,12 @@ function Get-PkgProperties {
248262
return $pkgProps[0]
249263
}
250264

251-
LogError "Failed to retrieve Properties for [$PackageName]"
265+
if ([string]::IsNullOrEmpty($GroupId)) {
266+
LogError "Failed to retrieve Properties for [$PackageName]"
267+
}
268+
else {
269+
LogError "Failed to retrieve Properties for [$PackageName] with GroupId [$GroupId]. Ensure the package has a Group property matching the specified GroupId."
270+
}
252271
return $null
253272
}
254273

@@ -568,3 +587,25 @@ function Get-PkgPropsForEntireService ($serviceDirectoryPath) {
568587

569588
return $projectProps
570589
}
590+
591+
# Get the full package name based on packageInfo properties
592+
# Returns Group+ArtifactName if Group exists and has a value, otherwise returns Name
593+
# If UseColonSeparator switch is enabled, returns Group:ArtifactName format (colon separator)
594+
function Get-FullPackageName {
595+
param (
596+
[Parameter(Mandatory=$true)]
597+
[PSCustomObject]$PackageInfo,
598+
[switch]$UseColonSeparator
599+
)
600+
601+
if ($PackageInfo.PSObject.Members.Name -contains "Group") {
602+
$groupId = $PackageInfo.Group
603+
if ($groupId) {
604+
if ($UseColonSeparator) {
605+
return "${groupId}:$($PackageInfo.Name)"
606+
}
607+
return "${groupId}+$($PackageInfo.Name)"
608+
}
609+
}
610+
return $PackageInfo.Name
611+
}

eng/common/scripts/Prepare-Release.ps1

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ If one isn't provided, then it will compute the next ship date or today's date i
3030
.PARAMETER ReleaseTrackingOnly
3131
Optional: If this switch is passed then the script will only update the release work items and not update the versions in the local repo or validate the changelog.
3232
33+
.PARAMETER GroupId
34+
Optional: The group ID for the package. For Java packages, if not provided, the script will prompt for input with 'com.azure' as the default.
35+
3336
.EXAMPLE
3437
PS> ./eng/common/scripts/Prepare-Release.ps1 <PackageName>
3538
@@ -49,14 +52,27 @@ param(
4952
[string]$PackageName,
5053
[string]$ServiceDirectory,
5154
[string]$ReleaseDate, # Pass Date in the form MM/dd/yyyy"
52-
[switch]$ReleaseTrackingOnly = $false
55+
[switch]$ReleaseTrackingOnly = $false,
56+
[string]$GroupId
5357
)
5458
Set-StrictMode -Version 3
5559

5660
. ${PSScriptRoot}\common.ps1
5761
. ${PSScriptRoot}\Helpers\ApiView-Helpers.ps1
5862
. ${PSScriptRoot}\Helpers\DevOps-WorkItem-Helpers.ps1
5963

64+
# Prompt for GroupId if language is Java and GroupId is not provided
65+
if ($Language -eq 'java' -and [string]::IsNullOrEmpty($GroupId)) {
66+
$userInput = Read-Host "Input the group id, or press Enter to use 'com.azure' as the group id"
67+
if ([string]::IsNullOrWhiteSpace($userInput)) {
68+
$GroupId = "com.azure"
69+
}
70+
else {
71+
$GroupId = $userInput.Trim()
72+
}
73+
Write-Host "Using GroupId: $GroupId" -ForegroundColor Green
74+
}
75+
6076
function Get-ReleaseDay($baseDate)
6177
{
6278
# Find first friday
@@ -74,7 +90,7 @@ function Get-ReleaseDay($baseDate)
7490
$ErrorPreference = 'Stop'
7591

7692
$packageProperties = $null
77-
$packageProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory
93+
$packageProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory -GroupId $GroupId
7894

7995
if (!$packageProperties)
8096
{
@@ -128,7 +144,7 @@ if (Test-Path "Function:GetExistingPackageVersions")
128144
}
129145

130146
$currentProjectVersion = $packageProperties.Version
131-
$newVersion = Read-Host -Prompt "Input the new version, or press Enter to use use current project version '$currentProjectVersion'"
147+
$newVersion = Read-Host -Prompt "Input the new version, or press Enter to use current project version '$currentProjectVersion'"
132148

133149
if (!$newVersion)
134150
{
@@ -144,6 +160,7 @@ if ($null -eq $newVersionParsed)
144160

145161
$result = Update-DevOpsReleaseWorkItem -language $LanguageDisplayName `
146162
-packageName $packageProperties.Name `
163+
-groupId $packageProperties.Group `
147164
-version $newVersion `
148165
-plannedDate $releaseDateString `
149166
-packageRepoPath $packageProperties.serviceDirectory `
@@ -166,7 +183,8 @@ try
166183
}
167184
$url = az keyvault secret show --name "APIURL" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
168185
$apiKey = az keyvault secret show --name "APIKEY" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
169-
Check-ApiReviewStatus -PackageName $packageProperties.Name -packageVersion $newVersion -Language $LanguageDisplayName -url $url -apiKey $apiKey
186+
$fullPackageNameInApiView = Get-FullPackageName -PackageInfo $packageProperties -UseColonSeparator
187+
Check-ApiReviewStatus -PackageName $fullPackageNameInApiView -packageVersion $newVersion -Language $LanguageDisplayName -url $url -apiKey $apiKey
170188
}
171189
catch
172190
{
@@ -194,7 +212,7 @@ if (Test-Path "Function:SetPackageVersion")
194212
}
195213
SetPackageVersion -PackageName $packageProperties.Name -Version $newVersion `
196214
-ServiceDirectory $packageProperties.ServiceDirectory -ReleaseDate $releaseDateString `
197-
-PackageProperties $packageProperties -ReplaceLatestEntryTitle $replaceLatestEntryTitle
215+
-PackageProperties $packageProperties -ReplaceLatestEntryTitle $replaceLatestEntryTitle -GroupId $packageProperties.Group
198216
}
199217
else
200218
{

eng/common/scripts/Update-ChangeLog.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# Version : Version to add or replace in change log
55
# Unreleased: Default is true. If it is set to false, then today's date will be set in verion title. If it is True then title will show "Unreleased"
66
# ReplaceLatestEntryTitle: Replaces the latest changelog entry title.
7+
# GroupId: Optional. The group ID for the package. Used for filtering packages in languages that support group identifiers (e.g., Java).
78

89
[CmdletBinding()]
910
param (
@@ -14,7 +15,8 @@ param (
1415
[Boolean]$Unreleased = $true,
1516
[Boolean]$ReplaceLatestEntryTitle = $false,
1617
[String]$ChangelogPath,
17-
[String]$ReleaseDate
18+
[String]$ReleaseDate,
19+
[String]$GroupId
1820
)
1921
Set-StrictMode -Version 3
2022

@@ -59,7 +61,7 @@ if ($null -eq [AzureEngSemanticVersion]::ParseVersionString($Version))
5961

6062
if ([string]::IsNullOrEmpty($ChangelogPath))
6163
{
62-
$pkgProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory
64+
$pkgProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory -GroupId $GroupId
6365
$ChangelogPath = $pkgProperties.ChangeLogPath
6466
}
6567

0 commit comments

Comments
 (0)