Repository navigation
fix(ci): Harden + fail-fast the nuget.org publish gate for Uno.* deps - #2181
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the NuGet publish gate (build/Verify-NuGetDependenciesOnNuGetOrg.ps1) so that stable Uno.* transitive dependencies are still verified against nuget.org, closing a blind spot where an unreleased stable Uno-family dependency could slip through and later break restore for consumers.
Changes:
- Add
StableTransitiveIncludePrefixes(default@('Uno.')) to force-check stable transitive dependencies matching configured prefixes. - Introduce
Test-StableTransitiveShouldCheckhelper to apply the prefix-based inclusion rule (case-insensitive). - Update the transitive expansion skip logic to continue skipping stable third-party/BCL dependencies unless explicitly included or
-IncludeStableTransitiveVersionsis set.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (3)
build/Verify-NuGetDependenciesOnNuGetOrg.ps1:331
returnin a dot-sourced script runs in the caller’s scope and can prematurely exit the caller scriptblock (e.g. PesterBeforeAll). In this PR, dot-sourcing this script fromVerify-NuGetDependenciesOnNuGetOrg.Tests.ps1would skip any lines after the dot-source and can cause test setup to be incomplete. Prefer guarding the entry point withif ($MyInvocation.InvocationName -ne '.') { ... }(wrapping the main body) rather than usingreturnto bail out.
if ($MyInvocation.InvocationName -eq '.') {
# Dot-sourced (e.g. from the Pester tests): load the functions only and skip the
# artifact-scanning / nuget.org entry point below so unit tests run offline.
return
}
build/Verify-NuGetDependenciesOnNuGetOrg.ps1:476
- PR description frames the change as only verifying stable Uno.* transitive dependencies, but the implementation also changes traversal semantics: tracked packages (matching the prefixes) now have their dependency graph expanded beyond
TransitiveDependencyDepthto (bounded) full closure viaTest-ShouldExpandCoordinate. If this deeper walk is intentional (it may increase nuget.org requests/time), it should be called out explicitly in the PR description; otherwise, consider keeping expansion capped atTransitiveDependencyDepthand only changing the stable-skip decision.
# Seed the frontier with the directly-referenced coordinates at depth 0, then walk
# breadth-first. Non-tracked packages are expanded up to TransitiveDependencyDepth
# hops; tracked (Uno.*) packages are walked to their full closure so an unpublished
# tracked package at ANY depth is caught. Coordinate de-duplication ($expandedKeys)
# keeps the walk finite; TrackedTransitiveDependencyMaxDepth is a runaway guard.
$frontier = New-Object System.Collections.Generic.List[object]
foreach ($seed in $uniqueChecks) {
$frontier.Add([PSCustomObject]@{ Id = $seed.Id; Version = $seed.Version; Source = $seed.Source; Depth = 0 })
}
build/Verify-NuGetDependenciesOnNuGetOrg.ps1:10
- The new
StableTransitiveIncludePrefixesparameter is used for more than “stable transitive” verification: it also defines which package IDs are treated as “tracked” for full-closure expansion (Test-ShouldExpandCoordinate). This makes the parameter name/API misleading for callers. Consider renaming to something likeTrackedPackageIdPrefixes(or splitting into separate parameters if you want independent control over stable-verification vs deep-expansion).
[int]$TransitiveDependencyDepth = 1,
[switch]$IncludeStableTransitiveVersions,
[string[]]$StableTransitiveIncludePrefixes = @('Uno.'),
[int]$TrackedTransitiveDependencyMaxDepth = 16
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
.github/workflows/ci.yml:60
- The PR description says the pre-build “fail-fast before the build” job is a follow-up (not in this PR) and recommends making it advisory on PRs, but this workflow change introduces
verify_dependenciesand makesbuild/generate-test-matrixdepend on it (blocking PR builds if nuget.org doesn’t yet have the referenced versions). If the intent is to keep this in the PR, consider making the job non-blocking onpull_requestruns to match the described behavior.
# Verify every referenced Uno.* package exists on nuget.org BEFORE the build and the
# template test matrix run, so a package-availability problem fails the pipeline in
# seconds instead of after build + sign + the full test matrix have consumed runners.
# Reads the source Uno.Sdk manifest (no build output needed) and runs on push and PRs.
verify_dependencies:
name: Verify Dependencies
runs-on: ubuntu-latest
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
build/Verify-NuGetDependenciesOnNuGetOrg.ps1:589
- During transitive-closure expansion, availability is probed with
MaxAttempts 1and missing coordinates are simply deferred to the final verification pass. If a root/trackable package is temporarily unavailable due to nuget.org propagation/indexing delay but becomes available during the final retries, its nuspec is never fetched here, so its transitive dependencies are never discovered/verified and the gate can incorrectly pass without checking the full closure.
$coordinateAvailable = Test-NuGetVersionAvailability -PackageId $coordinate.Id -Version $coordinate.Version -MaxAttempts 1 -RetryDelaySeconds 0 -HttpTimeoutSeconds $HttpTimeoutSeconds
if ($coordinateAvailable) {
$availabilityCache[$coordinateKey] = $true
}
}
|
Tick the box to add this pull request to the merge queue (same as
|
ec3cd35 to
aaa06f8
Compare
aaa06f8 to
2fabae7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
.github/workflows/ci.yml:66
- This new job uses
actions/checkout@v2while later jobs in the same workflow already useactions/checkout@v4(e.g.linux-template-tests). Using@v4here avoids older checkout versions and keeps the workflow consistent.
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ env.CheckoutRef }}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (4)
build/Verify-NuGetDependenciesOnNuGetOrg.ps1:14
MaxAttemptscan currently be set to 0 (or negative), which will cause the final verification loop (for ($round = 1; $round -le $MaxAttempts; ...)) to run zero times and incorrectly succeed without checking any coordinates. Add input validation so at least one sweep always runs.
# Availability is verified in set-based rounds: MaxAttempts total sweeps (1 initial + up to
# MaxAttempts-1 retries of only the still-missing set), RetryDelaySeconds between rounds.
# Total wait on failure is bounded by (MaxAttempts - 1) * RetryDelaySeconds regardless of how
# many packages are missing, so a genuinely absent version fails fast. Default: 2 retries max.
[int]$MaxAttempts = 3,
[int]$RetryDelaySeconds = 20,
build/Verify-NuGetDependenciesOnNuGetOrg.ps1:654
- The retry log message uses the nonstandard/pluralization hack
dependency/ies, which reads oddly in CI logs. Prefer a normal plural form ("dependencies" works fine even for 1) or "dependency(ies)".
Write-Host "$($stillMissing.Count) dependency/ies not available on nuget.org yet; retrying in $RetryDelaySeconds second(s) (round $round/$MaxAttempts)..."
.github/workflows/ci.yml:66
- This new job uses
actions/checkout@v2, but later in the same workflow other jobs already useactions/checkout@v4(e.g. ci.yml:217+). Consider using v4 here as well to avoid mixing major versions and to pick up the latest security/bug fixes.
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ env.CheckoutRef }}
.github/workflows/ci.yml:58
- PR description references “uno.toolkit.ui (#1616)” as the root-cause fix, but the linked issue in this repo (#1616) is about MSAL templates/obsolete AddMsal overload and appears unrelated to NuGet dependency gating. Please update the PR description to link the correct issue (full URL) or add an explicit note that there is no related issue for this repo.
# Verify every referenced Uno.* package exists on nuget.org BEFORE the build and the
# template test matrix run, so a package-availability problem fails the pipeline in
# seconds instead of after build + sign + the full test matrix have consumed runners.
# Reads the source Uno.Sdk manifest (no build output needed) and runs on push and PRs.
verify_dependencies:
2fabae7 to
7e15e96
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
.github/workflows/ci.yml:66
verify_dependenciesusesactions/checkout@v2, while other jobs in this workflow already useactions/checkout@v4(e.g., template test matrix).v2is deprecated and lacks the latest security/performance fixes; the new job should usev4as well.
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ env.CheckoutRef }}
build/Verify-NuGetDependenciesOnNuGetOrg.ps1:25
StableTransitiveIncludePrefixesis used not only to decide which stable transitive dependencies are verified, but also to decide which package IDs are treated as "tracked" for full transitive-closure expansion (see uses inTest-ShouldExpandCoordinate/Test-ShouldVerifyTransitiveDependency). The parameter name/comment currently suggests it only affects stable verification, which can mislead future callers.
[switch]$IncludeStableTransitiveVersions,
[string[]]$StableTransitiveIncludePrefixes = @('Uno.'),
[ValidateRange(0, [int]::MaxValue)]
Problem
The publish gate (
build/Verify-NuGetDependenciesOnNuGetOrg.ps1) verifies that every package/version referenced by a produced.nupkg— including itspackages.jsoncatalog entries and transitive nuspec dependencies — is available on nuget.org, and blocks the nuget.org publish if any is missing. It runs before both nuget.org publish paths (dev on push tomainviapublish_dev, and prod onrelease/**viapublish_release_nuget_org).It had weaknesses for the Uno family, which — unlike third-party / BCL packages — follows our own release cadence and can legitimately reference a version not published yet:
System.*/Microsoft.*, false forUno.*.TransitiveDependencyDepth = 1). An unpublishedUno.*package reachable only at depth ≥ 2 wasn't checked.build,sign, and the whole template test matrix. A package-availability failure wasted all those runners before being caught.7.0.1) took 12+ minutes before the gate failed.Real occurrence
Uno.Toolkit.WinUI.Material/.Cupertino/.Simple9.1.0-dev.1were published depending onUno.Material.WinUI/Uno.Cupertino.WinUI/Uno.Simple.WinUI7.0.1— a stable version that was never published (only7.0.0-dev.*and7.1.0-dev.1exist). The SDK-update PR that bumpedUnoToolkitVersionto9.1.0-dev.1passed the gate and published, because the manifest's directly-listed versions are on nuget.org and the phantom stable7.0.1was skipped by weakness #1. It broke restore for direct consumers of the flavored toolkit packages. Root cause fixed inuno.toolkit.ui(#1616); this PR closes the gate weaknesses so the same class of failure is caught here.Change
Uno.*transitive deps.StableTransitiveIncludePrefixes(default@('Uno.')): stable transitive deps whose id matches a prefix are still checked; third-party stable deps remain skipped for speed.-IncludeStableTransitiveVersionsstill forces all. Case-insensitive.Uno.*transitive closure. The one-hopforloop is now a breadth-first walk with per-coordinate depth. Non-tracked packages stop atTransitiveDependencyDepth; tracked (Uno.*) packages are walked to their full closure, bounded byTrackedTransitiveDependencyMaxDepth(default16; coordinate de-dup already makes it finite). UnpublishedUno.*at any depth is caught.verify_dependenciesruns the check in a new-ManifestPathmode that reads the sourcesrc/Uno.Sdk/packages.json(no build output needed).buildandgenerate-test-matrixnowneeds: verify_dependencies, so the whole pipeline short-circuits in seconds on a package problem — on push and on PRs — instead of after build + sign + the full test matrix. The existing artifact-based gate still runs before each nuget.org push as the authoritative final check.(MaxAttempts - 1) × RetryDelaySecondsregardless of how many are missing. DefaultMaxAttemptsis now 3 (2 retries max); theverify_dependenciesjob runs3×10s, the publish gate3×20s. Also fixed the abort message that rendered the missing list asSystem.Object[].Add-ChecksFromPackageGroups/Add-ChecksFromManifest/Add-ChecksFromArtifacts; decision logic intoTest-IsTrackedPackageId/Test-ShouldVerifyTransitiveDependency/Test-ShouldExpandCoordinate. The script's main body is guarded so it can be dot-sourced for offline unit tests.CI job graph (after)
verify_dependenciesfails →build+generate-test-matrixskip → tests, sign, and publish all skip.Tests
New
build/Verify-NuGetDependenciesOnNuGetOrg.Tests.ps1(Pester v5+, fully offline). 22/22 passing locally (Pester 6.0.1): tracked-id detection, verify/skip decision, closure-expansion depth logic, version-range parsing, and manifest/group parsing.End-to-end (executed against real nuget.org):
Uno.Material.WinUI 7.1.0-dev.1→ walk expanded 4 hops deep, discovered the fullUno.*closure (12 coordinates:Uno.Themes.WinUI,Uno.WinUI,Uno.Foundation,Uno.WinRT,Uno.Core.Extensions.*,Uno.Fonts.*,Uno.WinUI.Lottie), all verified → success. Proves the multi-hop closure the old depth-1 gate would have missed.throw"Aborting publish… not available on nuget.org" → blocks (message now formats one item per line).9.1.0-dev.1→ phantomUno.Material/Cupertino/Simple.WinUI 7.0.1) now fails in ~25s locally (≈40s in CI at3×10s), reporting all three missing at once — vs 12+ minutes with the old per-coordinate 12×20s retry.Note
verify_dependencieson this PR is expected to stay red until the toolkit fix lands: it is correctly catching the realUno.Toolkit.WinUI.* 9.1.0-dev.1 → Uno.*.WinUI 7.0.1phantom dependency in the manifest. It will go green onceuno.toolkit.ui#1616merges, a corrected toolkit dev build republishes, and the manifest bumps to it.Example of the validation