Skip to content

fix(ci): Harden + fail-fast the nuget.org publish gate for Uno.* deps - #2181

Merged
agneszitte merged 1 commit into
mainfrom
dev/agzi/harden-nuget-gate-uno-transitive
Jul 28, 2026
Merged

agneszitte merged 1 commit into
mainfrom
dev/agzi/harden-nuget-gate-uno-transitive

Conversation

@agneszitte

@agneszitte agneszitte commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Problem

The publish gate (build/Verify-NuGetDependenciesOnNuGetOrg.ps1) verifies that every package/version referenced by a produced .nupkg — including its packages.json catalog 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 to main via publish_dev, and prod on release/** via publish_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:

  1. Stable transitive deps were skipped. The transitive expansion skipped stable (non-prerelease) dependencies on the assumption they're always published. True for System.* / Microsoft.*, false for Uno.*.
  2. Only one transitive hop was walked (TransitiveDependencyDepth = 1). An unpublished Uno.* package reachable only at depth ≥ 2 wasn't checked.
  3. It ran only at publish time — after build, sign, and the whole template test matrix. A package-availability failure wasted all those runners before being caught.
  4. It failed slowly. Each missing coordinate retried serially with a 12×20s budget during transitive expansion, so a genuinely-absent version (the phantom 7.0.1) took 12+ minutes before the gate failed.

Real occurrence

Uno.Toolkit.WinUI.Material / .Cupertino / .Simple 9.1.0-dev.1 were published depending on Uno.Material.WinUI / Uno.Cupertino.WinUI / Uno.Simple.WinUI 7.0.1 — a stable version that was never published (only 7.0.0-dev.* and 7.1.0-dev.1 exist). The SDK-update PR that bumped UnoToolkitVersion to 9.1.0-dev.1 passed the gate and published, because the manifest's directly-listed versions are on nuget.org and the phantom stable 7.0.1 was skipped by weakness #1. It broke restore for direct consumers of the flavored toolkit packages. Root cause fixed in uno.toolkit.ui (#1616); this PR closes the gate weaknesses so the same class of failure is caught here.

Change

  • Verify stable 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. -IncludeStableTransitiveVersions still forces all. Case-insensitive.
  • Walk the full Uno.* transitive closure. The one-hop for loop is now a breadth-first walk with per-coordinate depth. Non-tracked packages stop at TransitiveDependencyDepth; tracked (Uno.*) packages are walked to their full closure, bounded by TrackedTransitiveDependencyMaxDepth (default 16; coordinate de-dup already makes it finite). Unpublished Uno.* at any depth is caught.
  • Fail fast, before the build. New first CI job verify_dependencies runs the check in a new -ManifestPath mode that reads the source src/Uno.Sdk/packages.json (no build output needed). build and generate-test-matrix now needs: 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.
  • Fail fast, fewer retries. During expansion, availability is probed with a single attempt (no retry storm; a not-found coordinate is deferred to the final pass). The final verification uses a set-based retry — sweep all once, then retry only the still-missing set between rounds — so total wait is bounded by (MaxAttempts - 1) × RetryDelaySeconds regardless of how many are missing. Default MaxAttempts is now 3 (2 retries max); the verify_dependencies job runs 3×10s, the publish gate 3×20s. Also fixed the abort message that rendered the missing list as System.Object[].
  • Refactor + testability. Gathering logic split into Add-ChecksFromPackageGroups / Add-ChecksFromManifest / Add-ChecksFromArtifacts; decision logic into Test-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_dependencies  (new root — runs on push + PR)
  ├─ build ─ sign ─ publish_dev / publish_release_uno ─ publish_release_nuget_org
  └─ generate-test-matrix ─ {linux,windows,macos}-template-tests ─ test-validation

verify_dependencies fails → build + generate-test-matrix skip → 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.

Invoke-Pester -Path build/Verify-NuGetDependenciesOnNuGetOrg.Tests.ps1

End-to-end (executed against real nuget.org):

  • Manifest listing Uno.Material.WinUI 7.1.0-dev.1 → walk expanded 4 hops deep, discovered the full Uno.* 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.
  • Manifest listing an unpublished package → throw "Aborting publish… not available on nuget.org" → blocks (message now formats one item per line).
  • Fail-fast timing: the exact incident repro (manifest → toolkit 9.1.0-dev.1 → phantom Uno.Material/Cupertino/Simple.WinUI 7.0.1) now fails in ~25s locally (≈40s in CI at 3×10s), reporting all three missing at once — vs 12+ minutes with the old per-coordinate 12×20s retry.

Note

verify_dependencies on this PR is expected to stay red until the toolkit fix lands: it is correctly catching the real Uno.Toolkit.WinUI.* 9.1.0-dev.1 → Uno.*.WinUI 7.0.1 phantom dependency in the manifest. It will go green once uno.toolkit.ui#1616 merges, a corrected toolkit dev build republishes, and the manifest bumps to it.

Example of the validation

image

Copilot AI review requested due to automatic review settings July 28, 2026 15:50
@agneszitte
agneszitte requested review from kazo0 and nickrandolph July 28, 2026 15:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-StableTransitiveShouldCheck helper 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 -IncludeStableTransitiveVersions is set.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings July 28, 2026 16:11
@agneszitte agneszitte changed the title fix(ci): Verify stable Uno.* transitive deps against nuget.org fix(ci): Harden nuget.org publish gate for Uno.* transitive deps Jul 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • return in a dot-sourced script runs in the caller’s scope and can prematurely exit the caller scriptblock (e.g. Pester BeforeAll). In this PR, dot-sourcing this script from Verify-NuGetDependenciesOnNuGetOrg.Tests.ps1 would skip any lines after the dot-source and can cause test setup to be incomplete. Prefer guarding the entry point with if ($MyInvocation.InvocationName -ne '.') { ... } (wrapping the main body) rather than using return to 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 TransitiveDependencyDepth to (bounded) full closure via Test-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 at TransitiveDependencyDepth and 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 StableTransitiveIncludePrefixes parameter 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 like TrackedPackageIdPrefixes (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

Copilot AI review requested due to automatic review settings July 28, 2026 16:27
@agneszitte agneszitte changed the title fix(ci): Harden nuget.org publish gate for Uno.* transitive deps fix(ci): Harden + fail-fast the nuget.org publish gate for Uno.* deps Jul 28, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dependencies and makes build/generate-test-matrix depend 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 on pull_request runs 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

Copilot AI review requested due to automatic review settings July 28, 2026 16:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 1 and 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
				}
			}

@mergify

mergify Bot commented Jul 28, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Copilot AI review requested due to automatic review settings July 28, 2026 17:43
@agneszitte
agneszitte force-pushed the dev/agzi/harden-nuget-gate-uno-transitive branch from ec3cd35 to aaa06f8 Compare July 28, 2026 17:43
@agneszitte
agneszitte force-pushed the dev/agzi/harden-nuget-gate-uno-transitive branch from aaa06f8 to 2fabae7 Compare July 28, 2026 17:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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@v2 while later jobs in the same workflow already use actions/checkout@v4 (e.g. linux-template-tests). Using @v4 here avoids older checkout versions and keeps the workflow consistent.
    - name: Checkout
      uses: actions/checkout@v2
      with:
        ref: ${{ env.CheckoutRef }}

Copilot AI review requested due to automatic review settings July 28, 2026 17:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  • MaxAttempts can 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 use actions/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:

Copilot AI review requested due to automatic review settings July 28, 2026 17:51
@agneszitte
agneszitte force-pushed the dev/agzi/harden-nuget-gate-uno-transitive branch from 2fabae7 to 7e15e96 Compare July 28, 2026 17:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_dependencies uses actions/checkout@v2, while other jobs in this workflow already use actions/checkout@v4 (e.g., template test matrix). v2 is deprecated and lacks the latest security/performance fixes; the new job should use v4 as well.
    - name: Checkout
      uses: actions/checkout@v2
      with:
        ref: ${{ env.CheckoutRef }}

build/Verify-NuGetDependenciesOnNuGetOrg.ps1:25

  • StableTransitiveIncludePrefixes is 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 in Test-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)]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants