Sync eng/common directory with azure-sdk-tools for PR 13202 (#6861)

* Added optional artifact list to filter the package info to be returned

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* return full package info if the input artifact list is empty

* Fixed hashset issue

* Added artifacts parameter

---------

Co-authored-by: ray chen <raychen@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Azure SDK Bot 2025-12-05 10:42:15 -08:00 committed by GitHub
parent 0055aa5f95
commit b5ae8c9d8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 41 additions and 2 deletions

View File

@ -2,6 +2,7 @@
# is used when this pipeline is going to be generating and publishing daily dev builds.
parameters:
ServiceDirectory: ''
Artifacts: []
Condition: succeeded()
steps:
- ${{if ne(parameters.ServiceDirectory, '')}}:
@ -11,6 +12,7 @@ steps:
arguments: >
-ServiceDirectory ${{parameters.ServiceDirectory}}
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
-artifactList @('${{ replace(convertToJson(parameters.Artifacts), '''', '`''') }}' | ConvertFrom-Json | Select-Object -ExpandProperty name)
pwsh: true
workingDirectory: $(Pipeline.Workspace)
displayName: Dump Package properties

View File

@ -30,7 +30,11 @@ package properties JSON file. If the package properties JSON file already
exists, read the Version property from the existing package properties JSON file
and set that as the Version property for the new output. This has the effect of
"adding" a DevVersion property to the file which could be different from the
Verison property in that file.
Version property in that file.
.PARAMETER artifactList
Optional array of artifact names to filter the package properties. Only packages
with artifact names matching entries in this list will be processed.
#>
[CmdletBinding()]
@ -39,7 +43,8 @@ Param (
[Parameter(Mandatory = $True)]
[string] $outDirectory,
[string] $prDiff,
[switch] $addDevVersion
[switch] $addDevVersion,
[array] $artifactList
)
. (Join-Path $PSScriptRoot common.ps1)
@ -132,6 +137,38 @@ if (-not (Test-Path -Path $outDirectory))
New-Item -ItemType Directory -Force -Path $outDirectory | Out-Null
}
if ($artifactList)
{
# Filter out null, empty, or whitespace-only entries
$filteredArtifacts = @($artifactList | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
if ($filteredArtifacts.Count -eq 0)
{
Write-Warning "Artifact list contains no valid entries"
}
else
{
Write-Host "Filtering package properties to match artifact list: $($filteredArtifacts -join ', ')"
$artifactSet = New-Object 'System.Collections.Generic.HashSet[string]' ([System.StringComparer]::OrdinalIgnoreCase)
foreach ($artifact in $filteredArtifacts) {
$artifactSet.Add($artifact) | Out-Null
}
# Warn about packages missing ArtifactName property
$missingArtifactName = $allPackageProperties | Where-Object { $_.PSObject.Properties.Name -notcontains 'ArtifactName' }
foreach ($pkg in $missingArtifactName) {
Write-Warning "Package '$($pkg.PackageName)' does not have an 'ArtifactName' property and will be excluded from artifact filtering."
}
$allPackageProperties = $allPackageProperties | Where-Object { $_.ArtifactName -and $artifactSet.Contains($_.ArtifactName) }
if (!$allPackageProperties)
{
Write-Error "No packages found matching the provided artifact list"
exit 1
}
}
}
foreach ($pkg in $allPackageProperties)
{
if ($pkg.Name)