From 345101e9a541029d5feeadb5664b68d58de81fb8 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 9 Oct 2025 15:56:21 -0700 Subject: [PATCH] Sync eng/common directory with azure-sdk-tools for PR 12416 (#6775) * Pass packageInfo parameter conditionally to Find-Language-Artifacts-For-Apireview * Use new parameter --------- Co-authored-by: ray chen --- eng/common/scripts/Detect-Api-Changes.ps1 | 49 ++++++++++++++--------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/eng/common/scripts/Detect-Api-Changes.ps1 b/eng/common/scripts/Detect-Api-Changes.ps1 index 25f3101a8..1e9bfc4a0 100644 --- a/eng/common/scripts/Detect-Api-Changes.ps1 +++ b/eng/common/scripts/Detect-Api-Changes.ps1 @@ -80,22 +80,13 @@ function Submit-Request($filePath, $packageName) return $StatusCode } -function Should-Process-Package($pkgPath, $packageName) +function Should-Process-Package($packageInfo) { - $pkg = Split-Path -Leaf $pkgPath - $pkgPropPath = Join-Path -Path $configFileDir "$packageName.json" - if (!(Test-Path $pkgPropPath)) - { - LogWarning "Package property file path $($pkgPropPath) is invalid." - return $False - } - # Get package info from json file created before updating version to daily dev - $pkgInfo = Get-Content $pkgPropPath | ConvertFrom-Json - $packagePath = $pkgInfo.DirectoryPath + $packagePath = $packageInfo.DirectoryPath $modifiedFiles = @(Get-ChangedFiles -DiffPath "$packagePath/*" -DiffFilterType '') $filteredFileCount = $modifiedFiles.Count LogInfo "Number of modified files for package: $filteredFileCount" - return ($filteredFileCount -gt 0 -and $pkgInfo.IsNewSdk) + return ($filteredFileCount -gt 0 -and $packageInfo.IsNewSdk) } function Log-Input-Params() @@ -126,24 +117,42 @@ $responses = @{} LogInfo "Processing PackageInfo at $configFileDir" -$packageProperties = Get-ChildItem -Recurse -Force "$configFileDir" ` - | Where-Object { +$packageInfoFiles = Get-ChildItem -Recurse -Force "$configFileDir" ` + | Where-Object { $_.Extension -eq '.json' -and ($_.FullName.Substring($configFileDir.Length + 1) -notmatch '^_.*?[\\\/]') } -foreach ($packagePropFile in $packageProperties) +foreach ($packageInfoFile in $packageInfoFiles) { - $packageMetadata = Get-Content $packagePropFile | ConvertFrom-Json - $pkgArtifactName = $packageMetadata.ArtifactName ?? $packageMetadata.Name + $packageInfo = Get-Content $packageInfoFile | ConvertFrom-Json + $pkgArtifactName = $packageInfo.ArtifactName ?? $packageInfo.Name LogInfo "Processing $($pkgArtifactName)" - $packages = &$FindArtifactForApiReviewFn $ArtifactPath $pkgArtifactName + # Check if the function supports the packageInfo parameter + $functionInfo = Get-Command $FindArtifactForApiReviewFn -ErrorAction SilentlyContinue + $supportsPackageInfoParam = $false + + if ($functionInfo -and $functionInfo.Parameters) { + # Check if function specifically supports packageInfo parameter + $parameterNames = $functionInfo.Parameters.Keys + $supportsPackageInfoParam = $parameterNames -contains 'packageInfo' + } + + # Call function with appropriate parameters + if ($supportsPackageInfoParam) { + LogInfo "Calling $FindArtifactForApiReviewFn with packageInfo parameter" + $packages = &$FindArtifactForApiReviewFn $ArtifactPath $pkgArtifactName $packageInfo + } + else { + LogInfo "Calling $FindArtifactForApiReviewFn with legacy parameters" + $packages = &$FindArtifactForApiReviewFn $ArtifactPath $pkgArtifactName + } if ($packages) { $pkgPath = $packages.Values[0] - $isRequired = Should-Process-Package -pkgPath $pkgPath -packageName $pkgArtifactName + $isRequired = Should-Process-Package $packageInfo LogInfo "Is API change detect required for $($pkgArtifactName):$($isRequired)" if ($isRequired -eq $True) { @@ -156,7 +165,7 @@ foreach ($packagePropFile in $packageProperties) } else { - LogInfo "Pull request does not have any change for $($pkgArtifactName)). Skipping API change detect." + LogInfo "Pull request does not have any change for $($pkgArtifactName). Skipping API change detect." } } else