-
Couldn't load subscription status.
- Fork 5.1k
implement Automation-Update-Metadata.ps1 for inner loop v1. #53458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Automation-Update-Metadata.ps1 | ||
| # This script is used to update metadata for the Azure SDK automation process | ||
|
|
||
| param( | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$sdkRepoPath, # Absolute path to the root folder of the local SDK repository. | ||
|
|
||
| [Parameter(Mandatory = $true)] | ||
| [string]$packagePath # Absolute path to the root folder of the local SDK project. | ||
| ) | ||
|
|
||
| # Step 1: Resolve both paths to absolute paths | ||
| try { | ||
| $resolvedPackage = Resolve-Path -Path $packagePath -ErrorAction Stop | ||
| $fullPackagePath = $resolvedPackage.ProviderPath | ||
| } catch { | ||
| # If it's not resolvable (e.g., path doesn't exist), fall back to raw input | ||
| $fullPackagePath = $packagePath | ||
| } | ||
|
|
||
| try { | ||
| $resolvedRepo = Resolve-Path -Path $sdkRepoPath -ErrorAction Stop | ||
| $fullRepoPath = $resolvedRepo.ProviderPath | ||
| } catch { | ||
| $fullRepoPath = $sdkRepoPath | ||
| } | ||
|
|
||
| # Step 2: Remove repo root from package path to get relative path | ||
| $fullRepoPath = $fullRepoPath.TrimEnd('\', '/') | ||
| if (-not $fullPackagePath.StartsWith($fullRepoPath, [System.StringComparison]::OrdinalIgnoreCase)) { | ||
| Write-Error "Package path '$fullPackagePath' does not start with repo path '$fullRepoPath'" | ||
| exit 1 | ||
| } | ||
|
|
||
| $relativePath = $fullPackagePath.Substring($fullRepoPath.Length).TrimStart('\', '/') | ||
|
|
||
| # Step 3: Split relative path and find 'sdk' segment | ||
| $parts = $relativePath -split '[\\/]+' | ||
|
|
||
| $sdkIndex = $parts.IndexOf('sdk') | ||
| if ($sdkIndex -lt 0 -or $sdkIndex -ge ($parts.Count - 1)) { | ||
| Write-Error "The relative path does not contain a valid 'sdk' segment: $relativePath" | ||
| exit 1 | ||
| } | ||
|
|
||
| # Extract everything after 'sdk' | ||
| $slugParts = $parts[($sdkIndex + 1)..($parts.Count - 1)] | ||
| $packagePath = ($slugParts -join '/') | ||
|
|
||
| Write-Host "Extracted package path: $packagePath" | ||
|
|
||
| # Call Export-API.ps1 script with the package path | ||
| $exportApiScript = Join-Path $sdkRepoPath "eng" "scripts" "Export-API.ps1" | ||
| Write-Host "Calling Export-API.ps1 with package path: $packagePath" | ||
|
|
||
| try { | ||
| & $exportApiScript $packagePath | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this script looking for the service directory? It is kind of hard to figure out what the parsing code is doing but if it is the service directory then we should update the variable. We should also explicitly list the script parameter name here, so it is clear what we are passing. |
||
| Write-Host "Export-API.ps1 completed successfully" | ||
| } catch { | ||
| Write-Error "Failed to execute Export-API.ps1: $($_.Exception.Message)" | ||
| exit 1 | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should try to use some of the existing helpers we have instead of parsing the paths independently. See https://github.com/Azure/azure-sdk-for-net/blob/main/eng/scripts/Language-Settings.ps1#L12 which depends on msbuild properties like https://github.com/Azure/azure-sdk-for-net/blob/main/eng/Directory.Build.Common.targets#L387, we could even call msbuild on the project path to get the service directory if we need it.