From 506ff6ab4535277799f681f3c8350b6169d55934 Mon Sep 17 00:00:00 2001 From: ray chen Date: Mon, 13 Oct 2025 23:05:33 +0000 Subject: [PATCH 01/11] Updated validate pkg template to use packageInfo --- .../templates/steps/validate-all-packages.yml | 18 +- .../Helpers/DevOps-WorkItem-Helpers.ps1 | 148 ++++++++- eng/common/scripts/Prepare-Release.ps1 | 25 +- eng/common/scripts/Validate-All-Packages.ps1 | 292 ++++++++++++++++-- 4 files changed, 434 insertions(+), 49 deletions(-) diff --git a/eng/common/pipelines/templates/steps/validate-all-packages.yml b/eng/common/pipelines/templates/steps/validate-all-packages.yml index 03a5f84cc29a..9666e88b8ee3 100644 --- a/eng/common/pipelines/templates/steps/validate-all-packages.yml +++ b/eng/common/pipelines/templates/steps/validate-all-packages.yml @@ -1,7 +1,16 @@ parameters: - ArtifactPath: $(Build.ArtifactStagingDirectory) - Artifacts: [] - ConfigFileDir: $(Build.ArtifactStagingDirectory)/PackageInfo + - name: ArtifactPath + type: string + default: $(Build.ArtifactStagingDirectory) + - name: Artifacts + type: object + default: [] + - name: ConfigFileDir + type: string + default: $(Build.ArtifactStagingDirectory)/PackageInfo + - name: PackageInfoFiles + type: object + default: [] steps: - ${{ if and(ne(variables['Skip.PackageValidation'], 'true'), and(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['System.TeamProject'], 'internal'))) }}: @@ -24,7 +33,8 @@ steps: -ConfigFileDir '${{ parameters.ConfigFileDir }}' ` -BuildDefinition $(System.CollectionUri)$(System.TeamProject)/_build?definitionId=$(System.DefinitionId) ` -PipelineUrl $(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId) ` - -IsReleaseBuild $$(SetAsReleaseBuild) + -IsReleaseBuild $$(SetAsReleaseBuild) ` + -PackageInfoFiles ('${{ convertToJson(parameters.PackageInfoFiles) }}' | ConvertFrom-Json -NoEnumerate) workingDirectory: $(Pipeline.Workspace) displayName: Validate packages and update work items continueOnError: true diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index e87b2c8a91b3..7d258620ff2b 100644 --- a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 +++ b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 @@ -1,8 +1,15 @@ +. ${PSScriptRoot}\..\SemVer.ps1 + $ReleaseDevOpsOrgParameters = @("--organization", "https://dev.azure.com/azure-sdk") $ReleaseDevOpsCommonParameters = $ReleaseDevOpsOrgParameters + @("--output", "json") $ReleaseDevOpsCommonParametersWithProject = $ReleaseDevOpsCommonParameters + @("--project", "Release") +# This is used to determine whether or not the az login and azure-devops extension +# install have already been completed. +$global:AzLoginAndDevOpsExtensionInstallComplete = $false +$global:HasDevOpsAccess = $false + function Get-DevOpsRestHeaders() { # Get a temp access token from the logged in az cli user for azure devops resource @@ -17,17 +24,44 @@ function Get-DevOpsRestHeaders() return $headers } +# Function was created from the same code being in Update-DevOps-Release-WorkItem.ps1 +# and Validate-Package.ps1. The global variable is used to prevent az commands from +# being rerun multiple times +function CheckAzLoginAndDevOpsExtensionInstall() +{ + if (-not $global:AzLoginAndDevOpsExtensionInstallComplete) { + az account show *> $null + if (!$?) { + Write-Host 'Running az login...' + az login *> $null + } + + az extension show -n azure-devops *> $null + if (!$?){ + az extension add --name azure-devops + } else { + # Force update the extension to the latest version if it was already installed + # this is needed to ensure we have the authentication issue fixed from earlier versions + az extension update -n azure-devops *> $null + } + $global:AzLoginAndDevOpsExtensionInstallComplete = $true + } +} + function CheckDevOpsAccess() { - # Dummy test query to validate permissions - $query = "SELECT [System.ID] FROM WorkItems WHERE [Work Item Type] = 'Package' AND [Package] = 'azure-sdk-template'" + if (-not $global:HasDevOpsAccess) { + # Dummy test query to validate permissions + $query = "SELECT [System.ID] FROM WorkItems WHERE [Work Item Type] = 'Package' AND [Package] = 'azure-sdk-template'" - $response = Invoke-RestMethod -Method POST ` - -Uri "https://dev.azure.com/azure-sdk/Release/_apis/wit/wiql/?api-version=6.0" ` - -Headers (Get-DevOpsRestHeaders) -Body "{ ""query"": ""$query"" }" -ContentType "application/json" | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashTable + $response = Invoke-RestMethod -Method POST ` + -Uri "https://dev.azure.com/azure-sdk/Release/_apis/wit/wiql/?api-version=6.0" ` + -Headers (Get-DevOpsRestHeaders) -Body "{ ""query"": ""$query"" }" -ContentType "application/json" | ConvertTo-Json -Depth 10 | ConvertFrom-Json -AsHashTable - if ($response -isnot [HashTable] -or !$response.ContainsKey("workItems")) { - throw "Failed to run test query against Azure DevOps. Please ensure you are logged into the public azure cloud. Consider running 'az logout' and then 'az login'." + if ($response -isnot [HashTable] -or !$response.ContainsKey("workItems")) { + throw "Failed to run test query against Azure DevOps. Please ensure you are logged into the public azure cloud. Consider running 'az logout' and then 'az login'." + } + $global:HasDevOpsAccess = $true } } @@ -1018,7 +1052,7 @@ function UpdateValidationStatus($pkgvalidationDetails, $BuildDefinition, $Pipeli function Get-LanguageDevOpsName($LanguageShort) { - switch ($LanguageShort.ToLower()) + switch ($LanguageShort.ToLower()) { "net" { return "Dotnet" } "js" { return "JavaScript" } @@ -1057,7 +1091,7 @@ function Get-ReleasePlanForPackage($packageName) } function Update-ReleaseStatusInReleasePlan($releasePlanWorkItemId, $status, $version) -{ +{ $devopsFieldLanguage = Get-LanguageDevOpsName -LanguageShort $LanguageShort if (!$devopsFieldLanguage) { @@ -1170,7 +1204,7 @@ function Get-TriagesForCPEXAttestation() $query += " AND [Custom.ProductType] IN ('Feature', 'Offering', 'Sku')" $workItems = Invoke-Query $fields $query - return $workItems + return $workItems } function Update-AttestationStatusInWorkItem($workItemId, $fieldName, $status) @@ -1181,4 +1215,96 @@ function Update-AttestationStatusInWorkItem($workItemId, $fieldName, $status) $workItem = UpdateWorkItem -id $workItemId -fields $fields Write-Host "Updated attestation status for [$fieldName] in Work Item [$workItemId]" return $true -} \ No newline at end of file +} + +# This function was originally the entirety of what was in Update-DevOps-Release-WorkItem.ps1 +# and has been converted to a function. +function Update-DevOpsReleaseWorkItem { + param( + [Parameter(Mandatory=$true)] + [string]$language, + [Parameter(Mandatory=$true)] + [string]$packageName, + [Parameter(Mandatory=$true)] + [string]$version, + [string]$plannedDate, + [string]$serviceName = $null, + [string]$packageDisplayName = $null, + [string]$packageRepoPath = "NA", + [string]$packageType = "client", + [string]$packageNewLibrary = "true", + [string]$relatedWorkItemId = $null, + [string]$tag = $null, + [bool]$inRelease = $true + ) + + if (!(Get-Command az -ErrorAction SilentlyContinue)) { + Write-Error 'You must have the Azure CLI installed: https://aka.ms/azure-cli' + return $false + } + + CheckAzLoginAndDevOpsExtensionInstall + + CheckDevOpsAccess + + $parsedNewVersion = [AzureEngSemanticVersion]::new($version) + $state = "In Release" + $releaseType = $parsedNewVersion.VersionType + $versionMajorMinor = "" + $parsedNewVersion.Major + "." + $parsedNewVersion.Minor + + $packageInfo = [PSCustomObject][ordered]@{ + Package = $packageName + DisplayName = $packageDisplayName + ServiceName = $serviceName + RepoPath = $packageRepoPath + Type = $packageType + New = $packageNewLibrary + }; + + if (!$plannedDate) { + $plannedDate = Get-Date -Format "MM/dd/yyyy" + } + + $plannedVersions = @( + [PSCustomObject][ordered]@{ + Type = $releaseType + Version = $version + Date = $plannedDate + } + ) + $ignoreReleasePlannerTests = $true + if ($tag -and $tag.Contains("Release Planner App Test")) { + $ignoreReleasePlannerTests = $false + } + + $workItem = FindOrCreateClonePackageWorkItem $language $packageInfo $versionMajorMinor -allowPrompt $true -outputCommand $false -relatedId $relatedWorkItemId -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests + + if (!$workItem) { + Write-Host "Something failed as we don't have a work-item so exiting." + return $false + } + + Write-Host "Updated or created a release work item for a package release with the following properties:" + Write-Host " Lanuage: $($workItem.fields['Custom.Language'])" + Write-Host " Version: $($workItem.fields['Custom.PackageVersionMajorMinor'])" + Write-Host " Package: $($workItem.fields['Custom.Package'])" + if ($workItem.fields['System.AssignedTo']) { + Write-Host " AssignedTo: $($workItem.fields['System.AssignedTo']["uniqueName"])" + } + else { + Write-Host " AssignedTo: unassigned" + } + Write-Host " PackageDisplayName: $($workItem.fields['Custom.PackageDisplayName'])" + Write-Host " ServiceName: $($workItem.fields['Custom.ServiceName'])" + Write-Host " PackageType: $($workItem.fields['Custom.PackageType'])" + Write-Host "" + if ($inRelease) + { + Write-Host "Marking item [$($workItem.id)]$($workItem.fields['System.Title']) as '$state' for '$releaseType'" + $updatedWI = UpdatePackageWorkItemReleaseState -id $workItem.id -state "In Release" -releaseType $releaseType -outputCommand $false + } + $updatedWI = UpdatePackageVersions $workItem -plannedVersions $plannedVersions + + Write-Host "Release tracking item is at https://dev.azure.com/azure-sdk/Release/_workitems/edit/$($updatedWI.id)/" + return $true +} diff --git a/eng/common/scripts/Prepare-Release.ps1 b/eng/common/scripts/Prepare-Release.ps1 index b3990671deea..415831e32300 100755 --- a/eng/common/scripts/Prepare-Release.ps1 +++ b/eng/common/scripts/Prepare-Release.ps1 @@ -55,6 +55,7 @@ Set-StrictMode -Version 3 . ${PSScriptRoot}\common.ps1 . ${PSScriptRoot}\Helpers\ApiView-Helpers.ps1 +. ${PSScriptRoot}\Helpers\DevOps-WorkItem-Helpers.ps1 function Get-ReleaseDay($baseDate) { @@ -141,18 +142,18 @@ if ($null -eq $newVersionParsed) exit 1 } -&$EngCommonScriptsDir/Update-DevOps-Release-WorkItem.ps1 ` - -language $LanguageDisplayName ` - -packageName $packageProperties.Name ` - -version $newVersion ` - -plannedDate $releaseDateString ` - -packageRepoPath $packageProperties.serviceDirectory ` - -packageType $packageProperties.SDKType ` - -packageNewLibrary $packageProperties.IsNewSDK - -if ($LASTEXITCODE -ne 0) { - Write-Error "Updating of the Devops Release WorkItem failed." - exit 1 +$result = Update-DevOpsReleaseWorkItem -language $LanguageDisplayName ` + -packageName $packageProperties.Name ` + -version $newVersion ` + -plannedDate $releaseDateString ` + -packageRepoPath $packageProperties.serviceDirectory ` + -packageType $packageProperties.SDKType ` + -packageNewLibrary $packageProperties.IsNewSDK + +if (-not $result) +{ + Write-Error "Update of the Devops Release WorkItem failed." + exit 1 } # Check API status diff --git a/eng/common/scripts/Validate-All-Packages.ps1 b/eng/common/scripts/Validate-All-Packages.ps1 index f327c455291e..f3bee41aa605 100644 --- a/eng/common/scripts/Validate-All-Packages.ps1 +++ b/eng/common/scripts/Validate-All-Packages.ps1 @@ -1,6 +1,6 @@ [CmdletBinding()] Param ( - [Parameter(Mandatory=$True)] + [Parameter(Mandatory=$False)] [array]$ArtifactList, [Parameter(Mandatory=$True)] [string]$ArtifactPath, @@ -12,39 +12,287 @@ Param ( [string]$BuildDefinition, [string]$PipelineUrl, [string]$APIViewUri = "https://apiview.dev/AutoReview/GetReviewStatus", - [bool] $IsReleaseBuild = $false + [bool] $IsReleaseBuild = $false, + [Parameter(Mandatory=$False)] + [array] $PackageInfoFiles ) +# Validate-All-Packages.ps1 folds in the code that was originally in Validate-Package.ps1 +# since Validate-Package.ps1 was only called from Validate-All-Packages.ps1. This replaces +# script calls with function calls and also allows calling CheckAzLoginAndDevOpsExtensionInstall +# and CheckDevOpsAccess once for all of the PackageInfo files being processed instead of once +# per artifact in Validate-Package.ps1 and then again in Update-DevOps-Release-WorkItem.ps1 + Set-StrictMode -Version 3 . (Join-Path $PSScriptRoot common.ps1) +. ${PSScriptRoot}\Helpers\ApiView-Helpers.ps1 +. ${PSScriptRoot}\Helpers\DevOps-WorkItem-Helpers.ps1 + +# Function to validate change log +function ValidateChangeLog($changeLogPath, $versionString, $validationStatus) +{ + try + { + $ChangeLogStatus = [PSCustomObject]@{ + IsValid = $false + Message = "" + } + $changeLogFullPath = Join-Path $RepoRoot $changeLogPath + Write-Host "Path to change log: [$changeLogFullPath]" + if (Test-Path $changeLogFullPath) + { + Confirm-ChangeLogEntry -ChangeLogLocation $changeLogFullPath -VersionString $versionString -ForRelease $true -ChangeLogStatus $ChangeLogStatus -SuppressErrors $true + $validationStatus.Status = if ($ChangeLogStatus.IsValid) { "Success" } else { "Failed" } + $validationStatus.Message = $ChangeLogStatus.Message + } + else { + $validationStatus.Status = "Failed" + $validationStatus.Message = "Change log is not found in [$changeLogPath]. Change log file must be present in package root directory." + } + } + catch + { + Write-Host "Current directory: $(Get-Location)" + $validationStatus.Status = "Failed" + $validationStatus.Message = $_.Exception.Message + } +} + +# Function to verify API review status +function VerifyAPIReview($packageName, $packageVersion, $language) +{ + $APIReviewValidation = [PSCustomObject]@{ + Name = "API Review Approval" + Status = "Pending" + Message = "" + } + $PackageNameValidation = [PSCustomObject]@{ + Name = "Package Name Approval" + Status = "Pending" + Message = "" + } + + try + { + $apiStatus = [PSCustomObject]@{ + IsApproved = $false + Details = "" + } + $packageNameStatus = [PSCustomObject]@{ + IsApproved = $false + Details = "" + } + Write-Host "Checking API review status for package $packageName with version $packageVersion. language [$language]." + Check-ApiReviewStatus $packageName $packageVersion $language $APIViewUri $APIKey $apiStatus $packageNameStatus + + Write-Host "API review approval details: $($apiStatus.Details)" + Write-Host "Package name approval details: $($packageNameStatus.Details)" + #API review approval status + $APIReviewValidation.Message = $apiStatus.Details + $APIReviewValidation.Status = if ($apiStatus.IsApproved) { "Approved" } else { "Pending" } + + # Package name approval status + $PackageNameValidation.Status = if ($packageNameStatus.IsApproved) { "Approved" } else { "Pending" } + $PackageNameValidation.Message = $packageNameStatus.Details + } + catch + { + Write-Warning "Failed to get API review status. Error: $_" + $PackageNameValidation.Status = "Failed" + $PackageNameValidation.Message = $_.Exception.Message + $APIReviewValidation.Status = "Failed" + $APIReviewValidation.Message = $_.Exception.Message + } -function ProcessPackage($PackageName, $ConfigFileDir) + return [PSCustomObject]@{ + ApiviewApproval = $APIReviewValidation + PackageNameApproval = $PackageNameValidation + } +} + + +function IsVersionShipped($packageName, $packageVersion) +{ + # This function will decide if a package version is already shipped or not + Write-Host "Checking if a version is already shipped for package $packageName with version $packageVersion." + $parsedNewVersion = [AzureEngSemanticVersion]::new($packageVersion) + $versionMajorMinor = "" + $parsedNewVersion.Major + "." + $parsedNewVersion.Minor + $workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $packageName -version $versionMajorMinor -includeClosed $true -outputCommand $false + if ($workItem) + { + # Check if the package version is already shipped + $shippedVersionSet = ParseVersionSetFromMDField $workItem.fields["Custom.ShippedPackages"] + if ($shippedVersionSet.ContainsKey($packageVersion)) { + return $true + } + } + else { + Write-Host "No work item found for package [$packageName]. Creating new work item for package." + } + return $false +} + +function CreateUpdatePackageWorkItem($pkgInfo) { - Write-Host "Artifact path: $($ArtifactPath)" - Write-Host "Package Name: $($PackageName)" - Write-Host "Config File directory: $($ConfigFileDir)" + # This function will create or update package work item in Azure DevOps + $versionString = $pkgInfo.Version + $packageName = $pkgInfo.Name + $plannedDate = $pkgInfo.ReleaseStatus + $setReleaseState = $true + if (!$plannedDate -or $plannedDate -eq "Unreleased") + { + $setReleaseState = $false + $plannedDate = "unknown" + } - &$EngCommonScriptsDir/Validate-Package.ps1 ` - -PackageName $PackageName ` - -ArtifactPath $ArtifactPath ` - -RepoRoot $RepoRoot ` - -APIViewUri $APIViewUri ` - -APIKey $APIKey ` - -BuildDefinition $BuildDefinition ` - -PipelineUrl $PipelineUrl ` - -ConfigFileDir $ConfigFileDir - if ($LASTEXITCODE -ne 0) { - Write-Error "Failed to validate package $PackageName" - exit 1 + # Create or update package work item + $result = Update-DevOpsReleaseWorkItem -language $LanguageDisplayName ` + -packageName $packageName ` + -version $versionString ` + -plannedDate $plannedDate ` + -packageRepoPath $pkgInfo.serviceDirectory ` + -packageType $pkgInfo.SDKType ` + -packageNewLibrary $pkgInfo.IsNewSDK ` + -serviceName "unknown" ` + -packageDisplayName "unknown" ` + -inRelease $IsReleaseBuild + + if (-not $result) + { + Write-Host "Update of the Devops Release WorkItem failed." } + return [bool]$result } +function ProcessPackage($packageInfo) +{ + # Read package property file and identify all packages to process + Write-Host "Processing artifact: $($packageInfo.Name)" + Write-Host "Is Release Build: $IsReleaseBuild" + $pkgName = $packageInfo.Name + $changeLogPath = $packageInfo.ChangeLogPath + $versionString = $packageInfo.Version + Write-Host "Checking if we need to create or update work item for package $pkgName with version $versionString." + $isShipped = IsVersionShipped $pkgName $versionString + if ($isShipped) { + Write-Host "Package work item already exists for version [$versionString] that is marked as shipped. Skipping the update of package work item." + exit 0 + } + + Write-Host "Validating package $pkgName with version $versionString." + + # Change log validation + $changeLogStatus = [PSCustomObject]@{ + Name = "Change Log Validation" + Status = "Success" + Message = "" + } + ValidateChangeLog $changeLogPath $versionString $changeLogStatus + + # API review and package name validation + $fullPackageName = $pkgName + + # If there's a groupId that means this is Java and pkgName = GroupId+ArtifactName + # but the VerifyAPIReview requires GroupId:ArtifactName + if ($packageInfo.PSObject.Members.Name -contains "Group") { + $groupId = $packageInfo.Group + if ($groupId){ + $fullPackageName = "${$groupId}:${$packageInfo.ArtifactName}" + } + } + + Write-Host "Checking API review status for package $fullPackageName" + $apireviewDetails = VerifyAPIReview $fullPackageName $packageInfo.Version $Language + + $pkgValidationDetails= [PSCustomObject]@{ + Name = $pkgName + Version = $packageInfo.Version + ChangeLogValidation = $changeLogStatus + APIReviewValidation = $apireviewDetails.ApiviewApproval + PackageNameValidation = $apireviewDetails.PackageNameApproval + } + + $output = ConvertTo-Json $pkgValidationDetails + Write-Host "Output: $($output)" + + # Create json token file in artifact path + $tokenFile = Join-Path $ArtifactPath "$pkgName-Validation.json" + $output | Out-File -FilePath $tokenFile -Encoding utf8 + + # Create DevOps work item + $updatedWi = CreateUpdatePackageWorkItem $packageInfo + + # Update validation status in package work item + if ($updatedWi) { + Write-Host "Updating validation status in package work item." + $updatedWi = UpdateValidationStatus $pkgValidationDetails $BuildDefinition $PipelineUrl + } + + # Fail the build if any validation is not successful for a release build + Write-Host "Change log status:" $changeLogStatus.Status + Write-Host "API Review status:" $apireviewDetails.ApiviewApproval.Status + Write-Host "Package Name status:" $apireviewDetails.PackageNameApproval.Status + + if ($IsReleaseBuild) + { + if (!$updatedWi -or $changeLogStatus.Status -ne "Success" -or $apireviewDetails.ApiviewApproval.Status -ne "Approved" -or $apireviewDetails.PackageNameApproval.Status -ne "Approved") { + Write-Error "At least one of the Validations above failed for package $pkgName with version $versionString." + exit 1 + } + } +} + +CheckAzLoginAndDevOpsExtensionInstall + +CheckDevOpsAccess + +Write-Host "Artifact path: $($ArtifactPath)" +Write-Host "Artifact List: $($ArtifactList -join ', ')" +Write-Host "Package Info Files: $($PackageInfoFiles -join ', ')" +Write-Host "IsReleaseBuild: $IsReleaseBuild" + # Check if package config file is present. This file has package version, SDK type etc info. if (-not $ConfigFileDir) { $ConfigFileDir = Join-Path -Path $ArtifactPath "PackageInfo" } -foreach ($artifact in $ArtifactList) + +Write-Host "Config file path: $($ConfigFileDir)" +# Initialize working variable +$ProcessedPackageInfoFiles = @() + +if ($ArtifactList -and $ArtifactList.Count -gt 0) +{ + # Multiple artifacts mode (existing usage) + Write-Host "Using ArtifactList parameter with $($ArtifactList.Count) artifacts" + foreach ($artifact in $ArtifactList) + { + $pkgPropPath = Join-Path -Path $ConfigFileDir "$($artifact.name).json" + if (Test-Path $pkgPropPath) { + $ProcessedPackageInfoFiles += $pkgPropPath + } + else { + Write-Warning "Package property file path $pkgPropPath is invalid." + } + } +} +elseif ($PackageInfoFiles -and $PackageInfoFiles.Count -gt 0) { - Write-Host "Processing $($artifact.name)" - ProcessPackage -PackageName $artifact.name -ConfigFileDir $ConfigFileDir -} \ No newline at end of file + # Direct PackageInfoFiles (new method) + Write-Host "Using PackageInfoFiles parameter with $($PackageInfoFiles.Count) files" + $ProcessedPackageInfoFiles = $PackageInfoFiles +} + +# Validate that we have package info files to process +if (-not $ProcessedPackageInfoFiles -or $ProcessedPackageInfoFiles.Count -eq 0) { + Write-Error "No package info files found after processing parameters." + exit 1 +} + +Write-Host "Processed Package Info Files: $($ProcessedPackageInfoFiles -join ', ')" + +# Process all packages using the processed PackageInfoFiles array +foreach ($packageInfoFile in $ProcessedPackageInfoFiles) +{ + $packageInfo = Get-Content $packageInfoFile | ConvertFrom-Json + ProcessPackage -packageInfo $packageInfo +} From deade4745a4dd2b7404b61ea3fae0e55e10a8d1b Mon Sep 17 00:00:00 2001 From: ray chen Date: Mon, 13 Oct 2025 23:21:37 +0000 Subject: [PATCH 02/11] Fixed typo --- eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 | 2 +- eng/common/scripts/Validate-All-Packages.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index 7d258620ff2b..32dcd1e6406f 100644 --- a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 +++ b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 @@ -1285,7 +1285,7 @@ function Update-DevOpsReleaseWorkItem { } Write-Host "Updated or created a release work item for a package release with the following properties:" - Write-Host " Lanuage: $($workItem.fields['Custom.Language'])" + Write-Host " Language: $($workItem.fields['Custom.Language'])" Write-Host " Version: $($workItem.fields['Custom.PackageVersionMajorMinor'])" Write-Host " Package: $($workItem.fields['Custom.Package'])" if ($workItem.fields['System.AssignedTo']) { diff --git a/eng/common/scripts/Validate-All-Packages.ps1 b/eng/common/scripts/Validate-All-Packages.ps1 index f3bee41aa605..ced913a852ee 100644 --- a/eng/common/scripts/Validate-All-Packages.ps1 +++ b/eng/common/scripts/Validate-All-Packages.ps1 @@ -197,7 +197,7 @@ function ProcessPackage($packageInfo) if ($packageInfo.PSObject.Members.Name -contains "Group") { $groupId = $packageInfo.Group if ($groupId){ - $fullPackageName = "${$groupId}:${$packageInfo.ArtifactName}" + $fullPackageName = "${groupId}:${$packageInfo.ArtifactName}" } } From accbf841d886c6ff1612361ab61fc489825b69e6 Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 16 Oct 2025 00:49:05 +0000 Subject: [PATCH 03/11] Fixed the right variable to use --- eng/common/scripts/Validate-All-Packages.ps1 | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/eng/common/scripts/Validate-All-Packages.ps1 b/eng/common/scripts/Validate-All-Packages.ps1 index ced913a852ee..bb4a280ae1a1 100644 --- a/eng/common/scripts/Validate-All-Packages.ps1 +++ b/eng/common/scripts/Validate-All-Packages.ps1 @@ -167,7 +167,9 @@ function CreateUpdatePackageWorkItem($pkgInfo) function ProcessPackage($packageInfo) { # Read package property file and identify all packages to process - Write-Host "Processing artifact: $($packageInfo.Name)" + # $packageInfo.Name is the package name published to package managers, e.g. @azure/azure-template + # $packageInfo.ArtifactName is the name can be used in path and file names, e.g. azure-template + Write-Host "Processing artifact: $($packageInfo.ArtifactName)" Write-Host "Is Release Build: $IsReleaseBuild" $pkgName = $packageInfo.Name $changeLogPath = $packageInfo.ChangeLogPath @@ -197,7 +199,7 @@ function ProcessPackage($packageInfo) if ($packageInfo.PSObject.Members.Name -contains "Group") { $groupId = $packageInfo.Group if ($groupId){ - $fullPackageName = "${groupId}:${$packageInfo.ArtifactName}" + $fullPackageName = "${groupId}:${packageInfo.ArtifactName}" } } @@ -216,7 +218,7 @@ function ProcessPackage($packageInfo) Write-Host "Output: $($output)" # Create json token file in artifact path - $tokenFile = Join-Path $ArtifactPath "$pkgName-Validation.json" + $tokenFile = Join-Path $ArtifactPath "$($packageInfo.ArtifactName)-Validation.json" $output | Out-File -FilePath $tokenFile -Encoding utf8 # Create DevOps work item From 1fe6c04be8a5f01d16fb9562852555c1c30b9872 Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 16 Oct 2025 17:56:49 +0000 Subject: [PATCH 04/11] output debug log --- eng/common/scripts/Validate-All-Packages.ps1 | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Validate-All-Packages.ps1 b/eng/common/scripts/Validate-All-Packages.ps1 index bb4a280ae1a1..1d39a1b0ec26 100644 --- a/eng/common/scripts/Validate-All-Packages.ps1 +++ b/eng/common/scripts/Validate-All-Packages.ps1 @@ -197,9 +197,11 @@ function ProcessPackage($packageInfo) # If there's a groupId that means this is Java and pkgName = GroupId+ArtifactName # but the VerifyAPIReview requires GroupId:ArtifactName if ($packageInfo.PSObject.Members.Name -contains "Group") { - $groupId = $packageInfo.Group + $groupId = $packageInfo.Group + Write-Debug "groupId: $groupId" + Write-Debug "artifactname: $($packageInfo.ArtifactName)" if ($groupId){ - $fullPackageName = "${groupId}:${packageInfo.ArtifactName}" + $fullPackageName = "${groupId}:${$packageInfo.ArtifactName}" } } From 6ae4eb175ce9ab429d6263ff63738165e8f90fe6 Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 16 Oct 2025 18:37:29 +0000 Subject: [PATCH 05/11] Fixed errors in expression evaluation --- eng/common/scripts/Validate-All-Packages.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/eng/common/scripts/Validate-All-Packages.ps1 b/eng/common/scripts/Validate-All-Packages.ps1 index 1d39a1b0ec26..aebb1f4735a0 100644 --- a/eng/common/scripts/Validate-All-Packages.ps1 +++ b/eng/common/scripts/Validate-All-Packages.ps1 @@ -196,12 +196,13 @@ function ProcessPackage($packageInfo) # If there's a groupId that means this is Java and pkgName = GroupId+ArtifactName # but the VerifyAPIReview requires GroupId:ArtifactName + Write-Host "Package name before checking groupId: $fullPackageName" if ($packageInfo.PSObject.Members.Name -contains "Group") { - $groupId = $packageInfo.Group - Write-Debug "groupId: $groupId" - Write-Debug "artifactname: $($packageInfo.ArtifactName)" + $groupId = $packageInfo.Group + Write-Host "groupId: $groupId" + Write-Host "artifactname: $($packageInfo.ArtifactName)" if ($groupId){ - $fullPackageName = "${groupId}:${$packageInfo.ArtifactName}" + $fullPackageName = "${groupId}:$($packageInfo.ArtifactName)" } } From 87da29fc6fc23b77d931eb7e6c7337916d628725 Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 16 Oct 2025 19:36:30 +0000 Subject: [PATCH 06/11] removed debug code --- eng/common/scripts/Validate-All-Packages.ps1 | 2 -- 1 file changed, 2 deletions(-) diff --git a/eng/common/scripts/Validate-All-Packages.ps1 b/eng/common/scripts/Validate-All-Packages.ps1 index aebb1f4735a0..a92b7ff190b8 100644 --- a/eng/common/scripts/Validate-All-Packages.ps1 +++ b/eng/common/scripts/Validate-All-Packages.ps1 @@ -199,8 +199,6 @@ function ProcessPackage($packageInfo) Write-Host "Package name before checking groupId: $fullPackageName" if ($packageInfo.PSObject.Members.Name -contains "Group") { $groupId = $packageInfo.Group - Write-Host "groupId: $groupId" - Write-Host "artifactname: $($packageInfo.ArtifactName)" if ($groupId){ $fullPackageName = "${groupId}:$($packageInfo.ArtifactName)" } From abd368bc760ffb34fe097bee04f2b1290bb01c91 Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 16 Oct 2025 20:48:59 +0000 Subject: [PATCH 07/11] Fixed an issue in pipeline --- eng/common/pipelines/templates/steps/validate-all-packages.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/validate-all-packages.yml b/eng/common/pipelines/templates/steps/validate-all-packages.yml index 9666e88b8ee3..1d60cd9e3c84 100644 --- a/eng/common/pipelines/templates/steps/validate-all-packages.yml +++ b/eng/common/pipelines/templates/steps/validate-all-packages.yml @@ -33,7 +33,7 @@ steps: -ConfigFileDir '${{ parameters.ConfigFileDir }}' ` -BuildDefinition $(System.CollectionUri)$(System.TeamProject)/_build?definitionId=$(System.DefinitionId) ` -PipelineUrl $(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId) ` - -IsReleaseBuild $$(SetAsReleaseBuild) ` + -IsReleaseBuild $(SetAsReleaseBuild) ` -PackageInfoFiles ('${{ convertToJson(parameters.PackageInfoFiles) }}' | ConvertFrom-Json -NoEnumerate) workingDirectory: $(Pipeline.Workspace) displayName: Validate packages and update work items From 5a1ef707ec1a7a5b29983f4da77a0009755e08ad Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 16 Oct 2025 21:43:30 +0000 Subject: [PATCH 08/11] Updated condition for variable setting step --- .../pipelines/templates/steps/validate-all-packages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/pipelines/templates/steps/validate-all-packages.yml b/eng/common/pipelines/templates/steps/validate-all-packages.yml index 1d60cd9e3c84..ab75877a02da 100644 --- a/eng/common/pipelines/templates/steps/validate-all-packages.yml +++ b/eng/common/pipelines/templates/steps/validate-all-packages.yml @@ -17,7 +17,7 @@ steps: - pwsh: | echo "##vso[task.setvariable variable=SetAsReleaseBuild]false" displayName: "Set as release build" - condition: and(succeeded(), eq(variables['SetAsReleaseBuild'], '')) + condition: and(succeededOrFailed(), eq(variables['SetAsReleaseBuild'], '')) - task: AzureCLI@2 inputs: @@ -33,7 +33,7 @@ steps: -ConfigFileDir '${{ parameters.ConfigFileDir }}' ` -BuildDefinition $(System.CollectionUri)$(System.TeamProject)/_build?definitionId=$(System.DefinitionId) ` -PipelineUrl $(System.CollectionUri)$(System.TeamProject)/_build/results?buildId=$(Build.BuildId) ` - -IsReleaseBuild $(SetAsReleaseBuild) ` + -IsReleaseBuild $$(SetAsReleaseBuild) ` -PackageInfoFiles ('${{ convertToJson(parameters.PackageInfoFiles) }}' | ConvertFrom-Json -NoEnumerate) workingDirectory: $(Pipeline.Workspace) displayName: Validate packages and update work items From 4fd17cf73bbbfed503b0f9cc9a5d4437c01b8b9f Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 16 Oct 2025 22:32:54 +0000 Subject: [PATCH 09/11] Join paths of the script path --- eng/common/scripts/Validate-All-Packages.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Validate-All-Packages.ps1 b/eng/common/scripts/Validate-All-Packages.ps1 index a92b7ff190b8..8de88181cba7 100644 --- a/eng/common/scripts/Validate-All-Packages.ps1 +++ b/eng/common/scripts/Validate-All-Packages.ps1 @@ -25,8 +25,8 @@ Param ( Set-StrictMode -Version 3 . (Join-Path $PSScriptRoot common.ps1) -. ${PSScriptRoot}\Helpers\ApiView-Helpers.ps1 -. ${PSScriptRoot}\Helpers\DevOps-WorkItem-Helpers.ps1 +. (Join-Path $PSScriptRoot Helpers\ApiView-Helpers.ps1) +. (Join-Path $PSScriptRoot Helpers\DevOps-WorkItem-Helpers.ps1) # Function to validate change log function ValidateChangeLog($changeLogPath, $versionString, $validationStatus) From 3f586c87ac1c1b82ecc01821e563f22f548ed35e Mon Sep 17 00:00:00 2001 From: ray chen Date: Thu, 16 Oct 2025 22:35:55 +0000 Subject: [PATCH 10/11] Use join-path --- eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 index 32dcd1e6406f..04f6e31e1aa2 100644 --- a/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 +++ b/eng/common/scripts/Helpers/DevOps-WorkItem-Helpers.ps1 @@ -1,5 +1,5 @@ -. ${PSScriptRoot}\..\SemVer.ps1 +. (Join-Path $PSScriptRoot .. SemVer.ps1) $ReleaseDevOpsOrgParameters = @("--organization", "https://dev.azure.com/azure-sdk") $ReleaseDevOpsCommonParameters = $ReleaseDevOpsOrgParameters + @("--output", "json") From b25d6365f61f658577f5a6c7ec743c1454351faf Mon Sep 17 00:00:00 2001 From: ray chen Date: Fri, 17 Oct 2025 16:40:40 +0000 Subject: [PATCH 11/11] return from the function rather than exit --- eng/common/scripts/Validate-All-Packages.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/scripts/Validate-All-Packages.ps1 b/eng/common/scripts/Validate-All-Packages.ps1 index 8de88181cba7..a27fd4652d93 100644 --- a/eng/common/scripts/Validate-All-Packages.ps1 +++ b/eng/common/scripts/Validate-All-Packages.ps1 @@ -178,7 +178,7 @@ function ProcessPackage($packageInfo) $isShipped = IsVersionShipped $pkgName $versionString if ($isShipped) { Write-Host "Package work item already exists for version [$versionString] that is marked as shipped. Skipping the update of package work item." - exit 0 + return } Write-Host "Validating package $pkgName with version $versionString."