Skip to content

Commit 59d160b

Browse files
author
Xiting Zhang
committed
Merge remote-tracking branch 'origin/main' into xitzhang/functioncallsample
2 parents 5a45a19 + 57c2f31 commit 59d160b

File tree

62 files changed

+635
-378
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+635
-378
lines changed

eng/automation/parameters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
SDK_ROOT = "../../" # related to file dir
1919
AUTOREST_CORE_VERSION = "3.9.7"
20-
AUTOREST_JAVA = "@autorest/[email protected].60"
20+
AUTOREST_JAVA = "@autorest/[email protected].62"
2121
DEFAULT_VERSION = "1.0.0-beta.1"
2222
GROUP_ID = "com.azure.resourcemanager"
2323
API_SPECS_FILE = "api-specs.yaml"

eng/common/pipelines/templates/steps/daily-dev-build-variable.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# is used when this pipeline is going to be generating and publishing daily dev builds.
33
parameters:
44
ServiceDirectory: ''
5+
Artifacts: []
56
Condition: succeeded()
67
steps:
78
- ${{if ne(parameters.ServiceDirectory, '')}}:
@@ -11,6 +12,7 @@ steps:
1112
arguments: >
1213
-ServiceDirectory ${{parameters.ServiceDirectory}}
1314
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
15+
-artifactList @('${{ replace(convertToJson(parameters.Artifacts), '''', '`''') }}' | ConvertFrom-Json | Select-Object -ExpandProperty name)
1416
pwsh: true
1517
workingDirectory: $(Pipeline.Workspace)
1618
displayName: Dump Package properties

eng/common/pipelines/templates/steps/set-test-pipeline-version.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ parameters:
1414
- name: TestPipeline
1515
type: boolean
1616
default: false
17-
- name: ArtifactsJson
18-
type: string
19-
default: ''
17+
- name: Artifacts
18+
type: object
19+
default: []
2020

2121
steps:
2222
- ${{ if eq(parameters.TestPipeline, true) }}:
@@ -31,5 +31,5 @@ steps:
3131
-PackageNames '${{ coalesce(parameters.PackageName, parameters.PackageNames) }}'
3232
-ServiceDirectory '${{ parameters.ServiceDirectory }}'
3333
-TagSeparator '${{ parameters.TagSeparator }}'
34-
-ArtifactsJson '${{ parameters.ArtifactsJson }}'
34+
-Artifacts @('${{ replace(convertToJson(parameters.Artifacts), '''', '`''') }}' | ConvertFrom-Json)
3535
pwsh: true

eng/common/scripts/Save-Package-Properties.ps1

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ package properties JSON file. If the package properties JSON file already
3030
exists, read the Version property from the existing package properties JSON file
3131
and set that as the Version property for the new output. This has the effect of
3232
"adding" a DevVersion property to the file which could be different from the
33-
Verison property in that file.
33+
Version property in that file.
34+
35+
.PARAMETER artifactList
36+
Optional array of artifact names to filter the package properties. Only packages
37+
with artifact names matching entries in this list will be processed.
3438
#>
3539

3640
[CmdletBinding()]
@@ -39,7 +43,8 @@ Param (
3943
[Parameter(Mandatory = $True)]
4044
[string] $outDirectory,
4145
[string] $prDiff,
42-
[switch] $addDevVersion
46+
[switch] $addDevVersion,
47+
[array] $artifactList
4348
)
4449

4550
. (Join-Path $PSScriptRoot common.ps1)
@@ -132,6 +137,38 @@ if (-not (Test-Path -Path $outDirectory))
132137
New-Item -ItemType Directory -Force -Path $outDirectory | Out-Null
133138
}
134139

140+
if ($artifactList)
141+
{
142+
# Filter out null, empty, or whitespace-only entries
143+
$filteredArtifacts = @($artifactList | Where-Object { -not [string]::IsNullOrWhiteSpace($_) })
144+
145+
if ($filteredArtifacts.Count -eq 0)
146+
{
147+
Write-Warning "Artifact list contains no valid entries"
148+
}
149+
else
150+
{
151+
Write-Host "Filtering package properties to match artifact list: $($filteredArtifacts -join ', ')"
152+
$artifactSet = New-Object 'System.Collections.Generic.HashSet[string]' ([System.StringComparer]::OrdinalIgnoreCase)
153+
foreach ($artifact in $filteredArtifacts) {
154+
$artifactSet.Add($artifact) | Out-Null
155+
}
156+
157+
# Warn about packages missing ArtifactName property
158+
$missingArtifactName = $allPackageProperties | Where-Object { $_.PSObject.Properties.Name -notcontains 'ArtifactName' }
159+
foreach ($pkg in $missingArtifactName) {
160+
Write-Warning "Package '$($pkg.PackageName)' does not have an 'ArtifactName' property and will be excluded from artifact filtering."
161+
}
162+
$allPackageProperties = $allPackageProperties | Where-Object { $_.ArtifactName -and $artifactSet.Contains($_.ArtifactName) }
163+
164+
if (!$allPackageProperties)
165+
{
166+
Write-Error "No packages found matching the provided artifact list"
167+
exit 1
168+
}
169+
}
170+
}
171+
135172
foreach ($pkg in $allPackageProperties)
136173
{
137174
if ($pkg.Name)

eng/common/scripts/SetTestPipelineVersion.ps1

Lines changed: 63 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,63 +5,83 @@ param (
55
[string]$BuildID,
66
[Parameter(mandatory = $false)]
77
[string]$PackageNames = "",
8-
[Parameter(mandatory = $true)]
8+
[Parameter(mandatory = $false)]
9+
# ServiceDirectory is required when using PackageNames,
10+
# or when Artifacts do not include their own ServiceDirectory property.
911
[string]$ServiceDirectory,
1012
[Parameter(mandatory = $false)]
1113
[string]$TagSeparator = "_",
1214
[Parameter(mandatory = $false)]
13-
[string]$ArtifactsJson = ""
15+
[object[]]$Artifacts = @()
1416
)
1517

1618
. (Join-Path $PSScriptRoot common.ps1)
1719

20+
# Ensure Artifacts is always an array
21+
$Artifacts = @($Artifacts)
22+
1823
Write-Host "PackageNames: $PackageNames"
1924
Write-Host "ServiceDirectory: $ServiceDirectory"
2025
Write-Host "BuildID: $BuildID"
21-
Write-Host "ArtifactsJson: $ArtifactsJson"
26+
Write-Host "Artifacts count: $($Artifacts.Count)"
2227

23-
$packageNamesArray = @()
24-
$artifacts = $null
25-
26-
# If ArtifactsJson is provided, extract package names from it
27-
if (![String]::IsNullOrWhiteSpace($ArtifactsJson)) {
28-
Write-Host "Using ArtifactsJson to determine package names"
28+
if ($Artifacts -and $Artifacts.Count -gt 0) {
29+
# When using Artifacts, process each artifact with its name and groupId (if applicable)
2930
try {
30-
$artifacts = $ArtifactsJson | ConvertFrom-Json
31-
$packageNamesArray = $artifacts | ForEach-Object { $_.name }
32-
Write-Host "Extracted package names from ArtifactsJson: $($packageNamesArray -join ', ')"
33-
}
34-
catch {
35-
LogError "Failed to parse ArtifactsJson: $($_.Exception.Message)"
36-
exit 1
37-
}
38-
}
39-
elseif (![String]::IsNullOrWhiteSpace($PackageNames)) {
40-
$packageNamesArray = $PackageNames.Split(',')
41-
}
42-
else {
43-
LogError "Either PackageNames or ArtifactsJson must be provided."
44-
exit 1
45-
}
31+
foreach ($artifact in $Artifacts) {
32+
# Validate required properties
33+
if (-not (Get-Member -InputObject $artifact -Name 'name' -MemberType Properties)) {
34+
LogError "Artifact is missing required 'name' property."
35+
exit 1
36+
}
4637

47-
if ($artifacts) {
48-
# When using ArtifactsJson, process each artifact with its name and groupId (if applicable)
49-
try {
50-
foreach ($artifact in $artifacts) {
5138
$packageName = $artifact.name
39+
if ([String]::IsNullOrWhiteSpace($packageName)) {
40+
LogError "Artifact 'name' property is null or empty."
41+
exit 1
42+
}
43+
44+
$artifactServiceDirectory = $null
45+
# Check for ServiceDirectory property
46+
if (Get-Member -InputObject $artifact -Name 'ServiceDirectory' -MemberType Properties) {
47+
if (![String]::IsNullOrWhiteSpace($artifact.ServiceDirectory)) {
48+
$artifactServiceDirectory = $artifact.ServiceDirectory
49+
}
50+
}
51+
52+
if ([String]::IsNullOrWhiteSpace($artifactServiceDirectory)) {
53+
$artifactServiceDirectory = $ServiceDirectory
54+
}
55+
56+
# Validate ServiceDirectory is available
57+
if ([String]::IsNullOrWhiteSpace($artifactServiceDirectory)) {
58+
LogError "ServiceDirectory is required but not provided for artifact '$packageName'. Provide it via script parameter or artifact property."
59+
exit 1
60+
}
61+
5262
$newVersion = [AzureEngSemanticVersion]::new("1.0.0")
5363
$prefix = "$packageName$TagSeparator"
5464

5565
if ($Language -eq "java") {
66+
# Check for groupId property
67+
if (-not (Get-Member -InputObject $artifact -Name 'groupId' -MemberType Properties)) {
68+
LogError "Artifact '$packageName' is missing required 'groupId' property for Java language."
69+
exit 1
70+
}
71+
5672
$groupId = $artifact.groupId
57-
Write-Host "Processing $packageName with groupId $groupId"
5873
if ([String]::IsNullOrWhiteSpace($groupId)) {
5974
LogError "GroupId is missing for package $packageName."
6075
exit 1
6176
}
77+
78+
Write-Host "Processing $packageName with groupId $groupId"
6279
# Use groupId+artifactName format for tag prefix (e.g., "com.azure.v2+azure-sdk-template_")
6380
$prefix = "$groupId+$packageName$TagSeparator"
6481
}
82+
else {
83+
Write-Host "Processing $packageName"
84+
}
6585

6686
Write-Host "Get Latest Tag : git tag -l $prefix*"
6787
$latestTags = git tag -l "$prefix*"
@@ -87,21 +107,27 @@ if ($artifacts) {
87107
if ($Language -ne "java") {
88108
SetPackageVersion -PackageName $packageName `
89109
-Version $newVersion.ToString() `
90-
-ServiceDirectory $ServiceDirectory
110+
-ServiceDirectory $artifactServiceDirectory
91111
} else {
92112
SetPackageVersion -PackageName $packageName `
93113
-Version $newVersion.ToString() `
94-
-ServiceDirectory $ServiceDirectory `
114+
-ServiceDirectory $artifactServiceDirectory `
95115
-GroupId $groupId
96116
}
97117
}
98118
}
99119
catch {
100-
LogError "Failed to process ArtifactsJson: $ArtifactsJson, exception: $($_.Exception.Message)"
120+
LogError "Failed to process Artifacts: exception: $($_.Exception.Message)"
101121
exit 1
102122
}
103-
} else {
123+
} elseif (![String]::IsNullOrWhiteSpace($PackageNames)) {
104124
# Fallback to original logic when using PackageNames string
125+
if ([String]::IsNullOrWhiteSpace($ServiceDirectory)) {
126+
LogError "ServiceDirectory is required when using PackageNames."
127+
exit 1
128+
}
129+
130+
$packageNamesArray = $PackageNames.Split(',')
105131
foreach ($packageName in $packageNamesArray) {
106132
Write-Host "Processing $packageName"
107133
$newVersion = [AzureEngSemanticVersion]::new("1.0.0")
@@ -131,4 +157,7 @@ if ($artifacts) {
131157
-Version $newVersion.ToString() `
132158
-ServiceDirectory $ServiceDirectory
133159
}
160+
} else {
161+
LogError "Either PackageNames or Artifacts must be provided."
162+
exit 1
134163
}

eng/common/scripts/logging.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ function LogGroupStart() {
9494
elseif (Test-SupportsGitHubLogging) {
9595
Write-Host "::group::$args"
9696
}
97+
else {
98+
Write-Host "> $args"
99+
}
97100
}
98101

99102
function LogGroupEnd() {

0 commit comments

Comments
 (0)