-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add daily pipeline to register unregistered azure-mgmt-* package names #45485
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
Open
msyyc
wants to merge
10
commits into
main
Choose a base branch
from
register-package-name-pipeline
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
e78f4bb
Add daily pipeline to register unregistered azure-mgmt-* package names
msyyc 3468a8e
Disable step 3 (pipeline trigger) for testing, log results only
msyyc 5cd20ff
Annotate step 3 with early return for testing, keep original code intact
msyyc 4f5e661
Fix Get-ChildItem glob pattern for _version.py discovery
msyyc 82fe6fd
Re-enable step 3: trigger name reservation pipeline
msyyc d280c9c
Merge branch 'main' into register-package-name-pipeline
msyyc 00412a1
Merge branch 'main' into register-package-name-pipeline
msyyc e5f7bf9
Update eng/pipelines/register-package-name.yml
msyyc ac0db4c
Update eng/pipelines/register-package-name.yml
msyyc c6f27fd
Merge branch 'main' into register-package-name-pipeline
msyyc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| trigger: none | ||
| pr: none | ||
|
|
||
| schedules: | ||
| - cron: "0 8 * * *" | ||
| displayName: Daily Package Name Registration | ||
| branches: | ||
| include: | ||
| - main | ||
| always: true | ||
|
|
||
| pool: | ||
| name: azsdk-pool | ||
| image: ubuntu-24.04 | ||
|
Member
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. We should use our 1ES hosted pool |
||
| os: linux | ||
|
|
||
| steps: | ||
| - checkout: self | ||
|
|
||
| - pwsh: | | ||
| # Step 1: Find azure-mgmt-* packages with version 1.0.0b1 | ||
| Write-Host "=== Step 1: Scanning for azure-mgmt-* packages with version 1.0.0b1 ===" | ||
| $versionFiles = Get-ChildItem -Path "sdk/*/azure-mgmt-*" -Directory | ForEach-Object { Get-ChildItem -Path $_.FullName -Recurse -Filter "_version.py" } | ||
msyyc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $candidatePackages = @() | ||
|
|
||
| foreach ($file in $versionFiles) { | ||
| $content = Get-Content $file.FullName -Raw | ||
| if ($content -match 'VERSION\s*=\s*"1\.0\.0b1"') { | ||
| # Extract the azure-mgmt-* folder name from the path | ||
msyyc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| $parts = $file.FullName -replace '\\', '/' -split '/' | ||
| $pkgName = $null | ||
| foreach ($part in $parts) { | ||
| if ($part -like 'azure-mgmt-*') { | ||
| $pkgName = $part | ||
| break | ||
| } | ||
| } | ||
| if ($pkgName -and $candidatePackages -notcontains $pkgName) { | ||
| $candidatePackages += $pkgName | ||
| Write-Host " Found: $pkgName ($($file.FullName))" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Write-Host "`nTotal candidates with version 1.0.0b1: $($candidatePackages.Count)" | ||
|
|
||
| if ($candidatePackages.Count -eq 0) { | ||
| Write-Host "No packages to process. Exiting." | ||
| return | ||
| } | ||
|
|
||
| # Step 2: Check PyPI for each candidate package | ||
| Write-Host "`n=== Step 2: Checking PyPI for unregistered packages ===" | ||
| $unregisteredPackages = @() | ||
|
|
||
| foreach ($pkg in $candidatePackages) { | ||
| $pypiUrl = "https://pypi.org/pypi/$pkg/json" | ||
| $maxAttempts = 3 | ||
| $attempt = 0 | ||
| $checked = $false | ||
|
|
||
| while (-not $checked -and $attempt -lt $maxAttempts) { | ||
| $attempt += 1 | ||
| try { | ||
| $response = Invoke-WebRequest -Uri $pypiUrl -Method Head -SkipHttpErrorCheck | ||
| if ($response.StatusCode -eq 404) { | ||
| $unregisteredPackages += $pkg | ||
| Write-Host " NOT on PyPI: $pkg" | ||
| } else { | ||
| Write-Host " Already on PyPI: $pkg (skipping, status code: $($response.StatusCode))" | ||
| } | ||
| $checked = $true | ||
| } catch { | ||
| if ($attempt -lt $maxAttempts) { | ||
| Write-Host " PyPI check attempt $attempt for $pkg failed (`"$($_.Exception.Message)`"). Retrying..." | ||
| Start-Sleep -Seconds 5 | ||
| } else { | ||
| Write-Host " PyPI check failed for $pkg after $maxAttempts attempts (`"$($_.Exception.Message)`"). Skipping reservation for this package." | ||
| $checked = $true | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Write-Host "`nPackages to register: $($unregisteredPackages.Count)" | ||
|
|
||
| if ($unregisteredPackages.Count -eq 0) { | ||
| Write-Host "All packages are already registered on PyPI. Exiting." | ||
| return | ||
| } | ||
|
|
||
| # Step 3: Trigger pipeline 8013 for each unregistered package | ||
| Write-Host "`n=== Step 3: Triggering name reservation pipeline ===" | ||
| $pipelineUrl = "https://dev.azure.com/azure-sdk/internal/_apis/pipelines/8013/runs?api-version=7.1" | ||
| $headers = @{ | ||
| "Authorization" = "Bearer $env:SYSTEM_ACCESSTOKEN" | ||
| "Content-Type" = "application/json" | ||
| } | ||
|
|
||
| $failures = @() | ||
| $successes = @() | ||
|
|
||
| foreach ($pkg in $unregisteredPackages) { | ||
| $body = @{ | ||
| templateParameters = @{ | ||
| NameForReservation = $pkg | ||
| } | ||
| } | ConvertTo-Json -Depth 5 | ||
|
|
||
| Write-Host " Triggering pipeline for: $pkg" | ||
| try { | ||
| $result = Invoke-RestMethod -Uri $pipelineUrl -Method Post -Headers $headers -Body $body | ||
| $successes += $pkg | ||
| Write-Host " Success: Run ID $($result.id)" | ||
| } catch { | ||
| $failures += @{ Package = $pkg; Error = $_.Exception.Message } | ||
| Write-Host " FAILED: $($_.Exception.Message)" | ||
| } | ||
| } | ||
|
|
||
| # Summary | ||
| Write-Host "`n=== Summary ===" | ||
| Write-Host "Successfully triggered: $($successes.Count)" | ||
| Write-Host "Failed: $($failures.Count)" | ||
|
|
||
| if ($failures.Count -gt 0) { | ||
| Write-Host "`nFailed packages:" | ||
| foreach ($f in $failures) { | ||
| Write-Host " - $($f.Package): $($f.Error)" | ||
| } | ||
| Write-Error "Some pipeline triggers failed. See details above." | ||
| } | ||
| displayName: Register unregistered azure-mgmt-* package names | ||
| env: | ||
| SYSTEM_ACCESSTOKEN: $(System.AccessToken) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I see what you're going for here, but I think this is overly complex.
autofor the package name, which should trigger an additional grep for package name step). Doing it this way means you don't need to worry about access token to queue another build or anything like that. You can just add a schedule to thereserve-namespace-buildas it is.I'll approve a stop gap that just adds a scheduled run to the existing build.