-
Notifications
You must be signed in to change notification settings - Fork 868
fix(sdk): correct broken AndroidX package entries and add CI validation guard #23175
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6073f53
fix(sdk): correct broken AndroidX package entries and add CI validati…
agneszitte 45bf12a
fix: address PR review - add sparse checkout path and handle null HTT…
agneszitte e7e3aab
fix: add WarningOnly mode for release branches in packages validation
agneszitte ea1eacd
fix: align AndroidX.Car.App.App ID in implicit targets and harden val…
agneszitte aa1d6d1
fix(docs): update android-auto.md to correct Car.App.App package name
agneszitte 76d6ae6
fix(ci): narrow sparse checkout and detect release PRs via target branch
agneszitte 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
Some comments aren't visible on the classic Files Changed page.
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
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,154 @@ | ||
| #!/usr/bin/env pwsh | ||
| <# | ||
| .SYNOPSIS | ||
| Validates that all package IDs and versions in src/Uno.Sdk/packages.json exist on NuGet.org. | ||
|
|
||
| .DESCRIPTION | ||
| Parses packages.json, skips groups with placeholder versions (e.g. "DefaultUnoVersion"), | ||
| and verifies each package ID + version (including versionOverride entries) against NuGet.org. | ||
| Exits with code 1 if any package/version is missing. | ||
|
|
||
| .PARAMETER PackagesJsonPath | ||
| Path to the packages.json file. Defaults to src/Uno.Sdk/packages.json relative to repo root. | ||
| #> | ||
| param( | ||
| [string]$PackagesJsonPath, | ||
| [switch]$WarningOnly | ||
| ) | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| # Auto-detect: on release/* branches, switch to warning-only mode | ||
| # (stable builds test with versions not yet public on NuGet.org) | ||
| if (-not $WarningOnly) { | ||
| $branch = $env:BUILD_SOURCEBRANCH | ||
| $targetBranch = $env:SYSTEM_PULLREQUEST_TARGETBRANCH | ||
| if (($branch -and $branch -like 'refs/heads/release/*') -or | ||
| ($targetBranch -and $targetBranch -like 'refs/heads/release/*')) { | ||
| $detected = if ($targetBranch -like 'refs/heads/release/*') { $targetBranch } else { $branch } | ||
| Write-Host "Detected release branch ($detected) - running in warning-only mode." -ForegroundColor Yellow | ||
| $WarningOnly = $true | ||
| } | ||
| } | ||
|
|
||
| # Resolve path | ||
| if (-not $PackagesJsonPath) { | ||
| $repoRoot = Split-Path -Parent (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) | ||
| $PackagesJsonPath = Join-Path $repoRoot 'src/Uno.Sdk/packages.json' | ||
| } | ||
|
|
||
| if (-not (Test-Path $PackagesJsonPath)) { | ||
| Write-Error "packages.json not found at: $PackagesJsonPath" | ||
| exit 1 | ||
| } | ||
|
|
||
| Write-Host "Validating packages.json: $PackagesJsonPath" -ForegroundColor Cyan | ||
|
|
||
| $json = Get-Content $PackagesJsonPath -Raw | ConvertFrom-Json | ||
| $errors = @() | ||
| $checked = 0 | ||
| $validatedPairs = @{} # De-duplicate package+version pairs across groups | ||
|
|
||
| # Placeholder versions that should not be validated against NuGet | ||
| $placeholderVersions = @('DefaultUnoVersion') | ||
|
|
||
| foreach ($group in $json) { | ||
| $groupName = $group.group | ||
| $baseVersion = $group.version | ||
| $packages = $group.packages | ||
|
|
||
| # Skip groups with placeholder versions | ||
| if ($placeholderVersions -contains $baseVersion) { | ||
| Write-Host " [SKIP] $groupName (placeholder version: $baseVersion)" -ForegroundColor DarkGray | ||
| continue | ||
| } | ||
|
|
||
| # Collect all version+package combinations to check | ||
| $versionsToCheck = @() | ||
|
|
||
| # Base version | ||
| $versionsToCheck += @{ Version = $baseVersion; Label = 'base' } | ||
|
|
||
| # Version overrides (TFM-specific) | ||
| if ($group.PSObject.Properties['versionOverride'] -and $null -ne $group.versionOverride) { | ||
| $overrides = $group.versionOverride | ||
| foreach ($prop in $overrides.PSObject.Properties) { | ||
| $versionsToCheck += @{ Version = $prop.Value; Label = "override($($prop.Name))" } | ||
| } | ||
| } | ||
|
|
||
| foreach ($pkg in $packages) { | ||
| foreach ($vEntry in $versionsToCheck) { | ||
| $version = $vEntry.Version | ||
| $label = $vEntry.Label | ||
|
|
||
| # Also skip overrides that reference a placeholder | ||
| if ($placeholderVersions -contains $version) { | ||
| continue | ||
| } | ||
|
|
||
| # De-duplicate: skip if we already validated this package+version | ||
| $pairKey = "$($pkg.ToLowerInvariant())|$($version.ToLowerInvariant())" | ||
| if ($validatedPairs.ContainsKey($pairKey)) { | ||
| Write-Host " [OK] $pkg $version ($label) - already validated" -ForegroundColor DarkGreen | ||
| continue | ||
| } | ||
| $validatedPairs[$pairKey] = $true | ||
|
|
||
| $checked++ | ||
| $url = "https://api.nuget.org/v3-flatcontainer/$($pkg.ToLowerInvariant())/$($version.ToLowerInvariant())/$($pkg.ToLowerInvariant()).nuspec" | ||
|
|
||
| try { | ||
| $response = Invoke-WebRequest -Uri $url -Method Head -UseBasicParsing ` | ||
| -TimeoutSec 30 -MaximumRetryCount 3 -RetryIntervalSec 2 -ErrorAction Stop | ||
| if ($response.StatusCode -eq 200) { | ||
| Write-Host " [OK] $pkg $version ($label)" -ForegroundColor Green | ||
| } | ||
|
agneszitte marked this conversation as resolved.
|
||
| } | ||
| catch { | ||
| $httpResponse = $_.Exception.Response | ||
| if ($null -ne $httpResponse) { | ||
| $statusCode = $httpResponse.StatusCode.value__ | ||
| if ($statusCode -eq 404) { | ||
| Write-Host " [MISSING] $pkg $version ($label) - NOT FOUND on NuGet" -ForegroundColor Red | ||
| $errors += "Group '$groupName': $pkg $version ($label) does not exist on NuGet.org" | ||
| } | ||
| else { | ||
| Write-Host " [ERROR] $pkg $version ($label) - HTTP $statusCode" -ForegroundColor Yellow | ||
| $errors += "Group '$groupName': $pkg $version ($label) - HTTP error $statusCode" | ||
| } | ||
| } | ||
| else { | ||
| Write-Host " [ERROR] $pkg $version ($label) - $($_.Exception.Message)" -ForegroundColor Yellow | ||
| $errors += "Group '$groupName': $pkg $version ($label) - network error: $($_.Exception.Message)" | ||
| } | ||
|
agneszitte marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Write-Host "" | ||
| Write-Host "Checked $checked package/version combinations." -ForegroundColor Cyan | ||
|
|
||
| if ($errors.Count -gt 0) { | ||
| Write-Host "" | ||
| if ($WarningOnly) { | ||
| Write-Host "VALIDATION WARNINGS - $($errors.Count) package(s) not found on NuGet.org (non-fatal):" -ForegroundColor Yellow | ||
| } | ||
| else { | ||
| Write-Host "VALIDATION FAILED - $($errors.Count) error(s):" -ForegroundColor Red | ||
| } | ||
| foreach ($err in $errors) { | ||
| Write-Host " - $err" -ForegroundColor $(if ($WarningOnly) { 'Yellow' } else { 'Red' }) | ||
| } | ||
| if ($WarningOnly) { | ||
| Write-Host "" | ||
| Write-Host "Running in warning-only mode (stable branch) - not failing the build." -ForegroundColor Yellow | ||
| exit 0 | ||
| } | ||
| exit 1 | ||
| } | ||
| else { | ||
| Write-Host "All packages validated successfully." -ForegroundColor Green | ||
| exit 0 | ||
| } | ||
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,9 @@ | ||
| steps: | ||
| - task: PowerShell@2 | ||
| displayName: Validate packages.json (NuGet existence check) | ||
| inputs: | ||
| pwsh: true | ||
| filePath: build/ci/scripts/validate-packages-json.ps1 | ||
| arguments: '-PackagesJsonPath "$(Build.SourcesDirectory)/src/Uno.Sdk/packages.json"' | ||
| env: | ||
| BUILD_SOURCEBRANCH: $(Build.SourceBranch) |
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.