Repository navigation
[CI-Improvement]Retry only failing UI-test categories across all platforms - #39421
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). There may be pipelines that require an authorized user to comment /azp run to run. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟡 Changes recommended
Retry handling can lose unresolved fixture failures and overwrite first-attempt diagnostic reports.
3 open findings
What changed in this PR
Centralizes .NET MAUI UI-test retries across platforms, replacing whole-task retries with category-based retries.
Changes:
- Adds shared retry, NUnit reconciliation, and TRX merging logic.
- Adds bounded setup/build retries on iOS, MacCatalyst, and Windows.
- Documents retry behavior and result handling.
| File | Description |
|---|---|
| eng/pipelines/common/ui-tests-steps.yml | Removes pipeline-level task retries. |
| eng/devices/windows.cake | Uses shared setup and test retries. |
| eng/devices/uitests-shared.cake | Coordinates retries and result merging. |
| eng/devices/uitest-retry.cake | Adds category selection and report processing. |
| eng/devices/ios.cake | Adopts shared setup and test retries. |
| eng/devices/catalyst.cake | Adopts shared setup and test retries. |
| eng/devices/android.cake | Replaces the existing retry loop. |
| eng/cake/dotnet.cake | Supports custom TRX and NUnit output directories. |
| docs/UITesting-Guide.md | Documents retries and report retention. |
🧠 Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
MauiBot
left a comment
There was a problem hiding this comment.
Expert Review — 3 findings
See inline comments for details.
MauiBot
left a comment
There was a problem hiding this comment.
AI Review Summary
@Ahamed-Ali — new AI review results are available based on commit
95ab2f0.
🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix
Gate Result: ⚠️ SKIPPED
No tests were detected in this PR.
Recommendation: Add tests to verify the fix using the write-tests-agent.
📋 Pre-Flight — Context & Validation
Pre-Flight Context
Scope: Context-only read of #39421, its nine-file submitted patch, affected source at head 95ab2f0e008b168ea6ffae812a548d41081d3fdc, and accessible GitHub discussion. This is not an exhaustive review or recommendation.
Reported problem
The PR reports that UI-test retries rerun more work than necessary:
- Android previously retried the complete original test filter through an internal Cake loop.
- iOS, MacCatalyst, and Windows used an Azure Pipelines task retry, potentially restarting Cake preparation/build work and rerunning every category in a grouped lane.
- Fixture-level NUnit failures can reportedly be missed when VSTest exits successfully.
- The intended outcome is one CI-only retry containing only categories associated with failed tests or fixtures, while preserving a combined publishable TRX.
No linked issue was identified in the accessible PR body or discussion. Any external issue or design context is therefore unknown.
Submitted changes and mechanism
The PR is open, contains three commits, and changes nine files with 342 additions and 89 deletions. Its recorded base is inflight/candidate at 40a966c82c8aed0cf3cd41f5814b4475a3fcf59b, rather than main.
| Area | Submitted change |
|---|---|
eng/devices/uitest-retry.cake |
Adds XML helpers for one bounded setup retry, failed-category extraction from NUnit XML, fixture-failure projection into TRX RunInfos, and first/retry TRX merging. |
eng/devices/uitests-shared.cake |
Adds the shared CI-only test runner. It writes first-attempt NUnit output under a GUID directory, derives a narrower retry filter when possible, runs retries in a nested directory, copies retry attachments, and writes the merged result back to the top-level TRX. |
eng/cake/dotnet.cake |
Extends RunTestWithLocalDotNet with configurable TRX and NUnit output directories and passes NUnit.TestOutputXml after the test-runner -- separator. |
eng/devices/android.cake |
Replaces Android’s existing all-filter retry loop with RunUITestsWithRetry; test-project build, app preparation, and installation remain outside this retry. Final failure still invokes WriteLogCat. |
eng/devices/ios.cake |
Uses the shared test retry and adds bounded wrappers around device/simulator setup, app preparation/installation, and test-project build. |
eng/devices/catalyst.cake |
Uses the shared test retry and wraps app lookup/launch plus test-project build as one retryable setup phase. |
eng/devices/windows.cake |
Uses the shared test retry and wraps path setup and test-project build/environment setup. |
eng/pipelines/common/ui-tests-steps.yml |
Removes the non-Android Azure task-level retry. The pipeline continues converting comma-separated categories into exact OR expressions such as TestCategory=A|TestCategory=B; only top-level $(TestResultsDirectory)/*.trx files are published. |
docs/UITesting-Guide.md |
Documents category retries, setup retries, fixture handling, fallback behavior, and merged-result retention. |
Category narrowing accepts only exact ORed category filters matching TestCategory=<alphanumeric-or-underscore> terms. Custom filters, absent or malformed XML, incomplete NUnit runs, cancelled runs, or unmappable failures cause a warning and fallback to the original filter. Local executions do not retry because retries are gated by IsCIBuild().
Platform-sensitive paths
- Android is the requested validation platform. The changed runtime path is pipeline filter construction →
android.caketest-project build → sharedRunUITestsWithRetry→dotnet test --no-buildwith TRX and NUnit XML output. - Android setup/build retry boundaries intentionally differ from the other platforms: emulator/device setup, APK installation, and test-project compilation are not wrapped in
RunUITestSetupWithRetry. - iOS, MacCatalyst, and Windows now move recovery from an Azure task-level retry to selected in-process Cake phases. Those phases contain platform-specific, potentially stateful operations such as simulator reset, app installation/launch, directory cleanup, and environment mutation.
- Result merging is platform-shared and therefore affects all four UI-test lanes even when validation is performed only on Android.
- Device-test targets do not use the new automatic setup retry; setup retry requires CI and a target beginning with
uitest.
Validation requirements and available evidence
The supplied Gate result is uitest-retry.Tests.ps1 suite because it was not wired into CI.
For Android, later validation should establish:
- A grouped lane retries only categories containing failures, including inherited fixture categories and existing shard categories.
- Passing first-attempt categories remain in the final top-level TRX, while retry results replace only matching test IDs.
- Persistent failures remain failed; counters, outcome, finish time, run errors, and attachments remain coherent.
- Fixture-only
OneTimeTearDownfailures trigger a retry even when VSTest exits successfully. - Mixed ordinary test failures and fixture-level failures retain both forms of diagnostic evidence.
- Missing, malformed, incomplete, cancelled, or unmappable NUnit output safely retries the original filter without losing first-attempt TRX/XML diagnostics.
- Single-category and custom-filter lanes retain their intended selection.
- Local Android runs do not retry, while CI runs retry at most once.
- Android emits logcat only after the final failed attempt and does not repeat APK/device preparation or test-project build.
- The NUnit adapter accepts the generated
NUnit.TestOutputXmlargument and all affected Cake scripts load successfully.
The PR description links before/after Azure builds 1636090 and 1638061 and commit text claims extensive script-level testing, but those claims were not independently verified within this read-only context pass. GitHub comments show maui-pr-uitests and later full pipelines were triggered; a completed Android result was not established here.
Remaining uncertainties
-
Three unresolved automated review threads at the submitted head allege that:
- merging can discard an unresolved fixture-only run error when the retry omits that fixture;
- NUnit reconciliation is skipped when VSTest itself throws for an ordinary failed test;
- fallback retries can overwrite first-attempt reports before they are archived.
These are existing discussion claims, not adjudicated findings from this pre-flight pass.
-
Behavior with duplicate or parameterized test IDs, multiple NUnit report files, partial retry output, and deployment attachment-name collisions remains unverified.
-
Native Android execution and the cross-platform setup-retry paths remain unverified by evidence available here.
-
The rationale for targeting
inflight/candidate, and whether the PR should ultimately target another branch, is unknown. -
Performance/resource improvements are explicitly unmeasured in the PR description.
🔬 Code Review — Deep Analysis
Code Review — PR #39421
Independent Assessment
What this changes: The PR replaces per-platform retry behavior with a shared Cake retry engine (eng/devices/uitests-shared.cake) that (a) retries UI tests once in CI, (b) narrows retry scope to failed TestCategory groups parsed from NUnit XML (eng/devices/uitest-retry.cake), (c) merges first/retry TRX data, and (d) adds bounded setup/build retries for iOS/MacCatalyst/Windows. Android switches from an ad hoc full-filter retry loop to the shared helper.
Inferred motivation: Reduce wasted reruns and preserve actionable diagnostics by retrying only affected test categories while keeping a single publishable TRX.
Approach soundness: The direction is reasonable, but three correctness gaps in merge/reconciliation/archival paths currently violate the stated behavior contract and can hide unresolved failures.
Reconciliation with PR Narrative
Author claims: Category-targeted retries, fixture-failure handling even with successful VSTest exits, and retention of original+retry diagnostics in CI.
Agreement/disagreement:
- Agree that filter narrowing and setup retry scaffolding are implemented (e.g.,
RunUITestsWithRetry,GetFilter, setup wrappers in iOS/catalyst/windows scripts). - Disagree that fixture failure evidence is always preserved and that first-attempt diagnostics are always retained; current code loses these in specific ordinary failure/fallback paths.
Prior Review Reconciliation
| Prior ❌ Error Finding | Source | Status | Evidence |
|---|---|---|---|
| Merged TRX can lose unresolved fixture-only run error | Copilot inline comment (eng/devices/uitest-retry.cake:126) |
❌ Unresolved | MergeResults replaces ResultSummary with retry summary (new XElement(retrySummary)), dropping first-attempt RunInfos written by ApplyNUnitFailures (eng/devices/uitest-retry.cake:84-100,126,141). |
| NUnit reconciliation skipped when final attempt exits non-zero | Copilot inline comment (eng/devices/uitests-shared.cake:46) |
❌ Unresolved | Reconciliation (ApplyNUnitFailures) is after successful RunTestWithLocalDotNet; final non-zero exits jump to catch and rethrow on last attempt before reconciliation (eng/devices/uitests-shared.cake:41-59,63-69). |
| Fallback path can overwrite first-attempt reports before archive | Copilot inline comment (eng/devices/uitests-shared.cake:78) |
❌ Unresolved | Backup (CopyFile) occurs only after metadata parse/filter succeeds; fallback sets originalResults=null, causing next attempt to write top-level paths again (eng/devices/uitests-shared.cake:74-85). |
Blast Radius Assessment
- Runs for all instances: Yes for CI UI-test lanes on Android/iOS/MacCatalyst/Windows (
RunUITestsWithRetryis now shared path). - Startup impact: No app startup impact, but pipeline execution-path impact across all UI-test jobs.
- Static/shared state: Shared result-merging and retry state (
originalResults,retryFilter, directory conventions) affects all platform jobs.
CI Status
- Required-check result: undetermined (tool unavailable)
- Evidence:
gh pr checks 39421 --requiredfailed with authentication/tool error (gh auth loginprompt), so required-check rows could not be retrieved. - Classification: undetermined
- Action taken: confidence capped to low; no LGTM considered
Findings
❌ Error — Merged TRX can drop unresolved fixture-only failures
MergeResults clones retrySummary and replaces the original summary. If first attempt contained fixture-only NUnit failure promoted into RunInfos, and retry narrowed away that fixture, merged output can lose unresolved failure evidence while leaving passed test-case rows. Evidence: eng/devices/uitest-retry.cake:84-100 (injection), :126,141 (summary replacement).
❌ Error — Final failed attempt can bypass NUnit fixture reconciliation
NUnit reconciliation only runs in the success path after RunTestWithLocalDotNet. On the final attempt, ordinary VSTest failure throws and exits via catch/rethrow before ApplyNUnitFailures, suppressing fixture-only run-error promotion when both failure types coexist. Evidence: eng/devices/uitests-shared.cake:41-59,63-69.
❌ Error — Fallback retry path can overwrite first-attempt diagnostics
When narrowing metadata fails (custom filter, malformed/missing/unmappable NUnit XML), archive copy of first TRX occurs too late. Fallback sets originalResults = null, so retry writes to top-level paths and can overwrite first-attempt artifacts, contradicting documented retention. Evidence: eng/devices/uitests-shared.cake:74-85 and docs claim in docs/UITesting-Guide.md added section.
Failure-Mode Probing
- Non-feature users / unaffected categories: Narrowed retry can omit categories with latent fixture failures not mapped in current attempt; merged summary replacement then hides prior run-level error.
- Final-attempt ordinary failure + fixture-only failure: Ordinary non-zero exit prevents NUnit promotion path, so fixture diagnostics disappear from published TRX.
- Fallback metadata failure path: Custom/non-exact filter or malformed XML triggers full-filter fallback but without guaranteed pre-fallback archival, enabling overwrite of first-attempt TRX/XML outputs.
- Handler reconnect/static-state analogue: Not app handler lifecycle, but shared retry state (
originalResultsnull/non-null) behaves like a latch controlling merge path; state reset in fallback alters downstream artifact handling for subsequent attempt.
External Output Contract
| Consumer token/pattern | Producer location | Producer emission condition | Consumer assumption | Ordinary negative case | Downstream effect |
|---|---|---|---|---|---|
^TestCategory=[A-Za-z0-9_]+(|TestCategory=[A-Za-z0-9_]+)*$ |
eng/pipelines/common/ui-tests-steps.yml:142-154 builds OR filter |
Producer emits this exact shape for comma-separated categories; empty filter omitted | Safe to narrow only for exact category groups | Custom filter or non-standard expression passed to Cake | GetFilter throws; fallback path currently risks losing first-attempt artifacts before archive (eng/devices/uitests-shared.cake:74-85) |
NUnit run result="Failed", not label="Cancelled", total==test-case count |
NUnit XML emitted by dotnet test adapter, consumed at eng/devices/uitest-retry.cake:42-46 |
Failed completed run with complete case accounting | Complete failed run implies reliable category extraction | Failed run with malformed/partial XML (or no XML) | Throws and falls back to full filter; archive ordering bug can overwrite first attempt |
VSTest process success/failure (RunTestWithLocalDotNet throws on non-zero) |
eng/cake/dotnet.cake invocation in RunUITestsWithRetry |
Non-zero exit for ordinary test failures | NUnit reconciliation can still be enforced where needed | Final attempt has ordinary failed tests plus fixture-only NUnit failure | Catch/rethrow path bypasses ApplyNUnitFailures, so fixture failure not promoted to TRX run errors |
Trim/AOT Evidence Chain
Not applicable (this PR does not modify trimming/AOT annotations, suppressions, or feature guards).
CI/Gate Evidence Gap
- Gate context indicates SKIPPED because no tests were detected.
- Required checks could not be fetched via
gh pr checks --requireddue to auth/tool unavailability in this environment. - Therefore, no green CI evidence is available to offset the above correctness defects.
Verdict: NEEDS_CHANGES
Confidence: low
Summary: The retry framework refactor is directionally good, but current submitted HEAD still contains three concrete behavioral defects that can hide unresolved fixture failures and lose first-attempt diagnostics in ordinary fallback/failure scenarios. These defects are evidenced in modified lines and match unresolved prior inline findings. Given undetermined required-check status and skipped gate evidence, merge readiness is not established.
🛠️ Try-Fix — Analysis & Comparison
Alternative generation: not requested
Evidence-first mode intentionally omits routine Try-Fix attempts. This is not a failed
attempt, a completed alternative search, or evidence that alternatives have no value.
The expert review may still produce one evidence-backed PR refinement.
📝 PR Finalize — Recommended Title & Description
Assessment: ✏️ Recommend updating — the description is unusually thorough, but submitted HEAD overstates fixture reconciliation and report-retention guarantees that three source-backed review findings show are not yet implemented reliably.
Recommended title
[CI] UI tests: Retry only failing categories across all platforms
Recommended description
### Description of Change
Optimize UI-test retries across Android, iOS, MacCatalyst, and Windows by retrying only the categories containing failures, instead of rerunning every category in a grouped lane.
This applies dynamically to all configured category groups, regardless of which categories are grouped together. It reduces unnecessary test execution and is intended to reduce retry duration and resource consumption. Performance and memory improvements have not yet been measured.
#### Previous behavior
**iOS, MacCatalyst, and Windows** used an Azure Pipelines task-level retry:
```yaml
${{ if ne(parameters.platform, 'android')}}:
retryCountOnTaskFailure: 1
```
When the UI-test task failed, Azure Pipelines reran the entire PowerShell task, including the `build.ps1 ... --target=uitest` invocation. This restarted Cake and repeated its preparation and test-project build commands, even if those phases had already succeeded and only test execution had failed. MSBuild could still skip up-to-date compilation work.
For grouped lanes, the second attempt used the original filter, rerunning all categories—including categories whose tests had passed.
This retried the UI-test task, not the entire pipeline. Earlier, separate provisioning and sample-app build tasks were not restarted by this setting.
**Android** was excluded from the YAML retry because it already had an internal retry loop in `android.cake`. Device preparation, app installation, and the explicit test-project build happened before that loop. On a test failure, the loop reran the original category filter once using `--no-build`, without restarting Cake or repeating those pre-test phases.
#### New behavior
All four platforms now use a shared `RunUITestsWithRetry()` runner:
1. Execute the lane’s original test filter.
2. After a failed attempt, read NUnit XML to identify failed test cases and fixtures.
3. Resolve their categories from method and ancestor-fixture metadata, restricted to categories in the original filter.
4. Run one retry with the selected categories using the existing compiled assemblies and `--no-build`.
5. Replace matching first-attempt test IDs with retry results, recompute counters from the combined test-case rows, and write a top-level TRX for publication.
Example:
```text
Original lane: Editor | Effects | Essentials | FlyoutPage
Failures: Editor
Previously:
Retry Editor | Effects | Essentials | FlyoutPage
On non-Android platforms, restart the Cake task and repeat preparation/build.
Now:
Retry Editor only.
Do not restart Cake or repeat successful preparation/build phases.
```
### Reference Builds
Version | Build logs
-- | --
Before: Original retry behavior | [Build 1636090](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1636090&view=logs&j=9563833f-4c4d-52d1-181d-27c653362618&t=4139dfb2-12df-52a8-359a-30cefb3ee61f&s=e37d8aa8-459b-57e8-43e2-c37a79f6ca23)
After: Category-targeted retries | [Build 1638061](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1638061&view=logs&j=2e4e5d3e-10e5-5e00-93d5-57557f46284a&t=de23a71a-1f3c-5d5c-c6d0-9ca661b91b13)
The retry starts a new test process. NUnit fixture setup and any required app/session initialization still run for the selected tests.
This is category-level retry, not individual-test retry. All tests within a selected failing category run again, including tests that passed initially. A single-category lane such as `CarouselView` therefore retries the same category once.
#### Preparation and build recovery
Remove the non-Android whole-task YAML retry so that a failed internal test retry cannot trigger another complete category-group run.
To retain recovery from transient pre-test failures, add `RunUITestSetupWithRetry()` around selected preparation/build phases on iOS, MacCatalyst, and Windows:
- iOS: device/simulator preparation, app installation, and test-project build.
- MacCatalyst: app preparation/launch and test-project build.
- Windows: test-path preparation and test-project build.
Each wrapped phase receives one retry in CI only if that phase fails. Successful phases are not repeated because tests fail later. Errors outside these wrappers no longer receive a blanket whole-task restart.
Android’s setup/build retry boundaries remain unchanged. Separate pipeline tasks for installing .NET and Appium retain their existing retry settings.
#### Failure detection and fallback
- Use NUnit XML because it supplies the category metadata needed to map failures to their categories.
- Preserve CI shard selection, such as `CollectionView1`–`CollectionView7` and `Shell1`/`Shell2`, rather than expanding a shard to its umbrella category.
- If failure metadata is missing, incomplete, or cannot safely map a failure, log a warning and retry the original filter.
- Preserve custom filters rather than rewriting them.
- After a successful VSTest process, inspect NUnit XML so fixture-only errors such as `OneTimeTearDown` failures can trigger retries.
- Keep automatic retries limited to CI. Local test runs do not automatically retry.
#### Submitted-HEAD reporting limitations
- `MergeResults()` replaces the first-attempt `ResultSummary` with the retry summary. If a retry does not include a fixture represented only by a first-attempt TRX `RunInfo`, that diagnostic can be lost.
- When VSTest exits nonzero for an ordinary test failure, control reaches the retry catch path before `ApplyNUnitFailures()` runs. A concurrent fixture-only failure is therefore not promoted into the TRX on that attempt.
- First-attempt archival occurs after retry-filter metadata parsing. If parsing or category mapping falls back to the original filter, the retry can reuse top-level result paths and overwrite first-attempt reports.
These limitations need to be resolved before the submitted implementation can guarantee persistent fixture-error reporting and retention of first-attempt diagnostics.
#### Test results and reporting
- Update `RunTestWithLocalDotNet` to accept custom TRX and NUnit XML output directories, enabling separate result locations for a narrowed retry.
- Merge retry test-case rows with untouched first-attempt rows by test ID and recompute published counters.
#### Codebase simplification
- Centralize retry logic for test execution and setup/build phases across Android, iOS, MacCatalyst, and Windows.
- Remove the non-Android task-level retry to avoid an additional complete category-group run after the shared internal retry finishes.
### Validation
- Before behavior: [Build 1636090](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1636090&view=logs&j=9563833f-4c4d-52d1-181d-27c653362618&t=4139dfb2-12df-52a8-359a-30cefb3ee61f&s=e37d8aa8-459b-57e8-43e2-c37a79f6ca23)
- Submitted behavior: [Build 1638061](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1638061&view=logs&j=2e4e5d3e-10e5-5e00-93d5-57557f46284a&t=de23a71a-1f3c-5d5c-c6d0-9ca661b91b13)
- The submitted diff contains no automated regression-test suite for the retry, fallback, reconciliation, or TRX merge helpers.
### Issues Fixed
None linked; this is a CI infrastructure improvement.
🏁 Report — Final Recommendation
⚠️ Final Recommendation: REQUEST CHANGES
Phase Status
| Phase | Status | Notes |
|---|---|---|
| Pre-Flight | ✅ COMPLETE | Trusted evidence-first context consumed; submitted PR reviewed first |
| Code Review | NEEDS_CHANGES (low) | 3 errors, 0 warnings |
| Gate | No tests detected; approval is not permitted without Gate evidence | |
| Try-Fix | not requested | Intentional evidence-first omission; no try-fix-N candidates exist |
| Refinement | One consolidated pr-plus-reviewer patch implemented; one bounded pass exited nonzero on a validation-harness false positive |
|
| Report | ✅ COMPLETE |
Code Review and Candidate Comparison
| Candidate | Expert findings | Validation | Ranking |
|---|---|---|---|
pr |
Leaves all three blocking defects unresolved: fixture RunInfo loss, skipped reconciliation after a VSTest exception, and fallback report overwrite |
Gate skipped; no submitted regression tests; required checks undetermined | 2 |
pr-plus-reviewer |
Implements source-level corrections for all three findings | Android Cake dry-run and the substantive focused assertions ran successfully, but the single pass ultimately exited 1 because the final harness search also matched the variable declaration | 1 |
Selected Fix: pr-plus-reviewer. It is the stronger source candidate because it directly addresses every expert finding, whereas the submitted PR leaves verified failure mechanisms in place. It is not demonstrated merge-ready: the bounded validation pass did not finish successfully, and the execution contract forbids a retry.
Summary
Request changes. The raw submitted fix cannot be approved because the expert review found three blocking correctness errors and Gate supplied no test evidence. The consolidated refinement is the preferred candidate, but it must be incorporated into the submitted PR and validated successfully before merge readiness can be claimed.
Root Cause
The shared retry runner used originalResults both as merge state and as the output-directory selector, so metadata fallback could send a retry back to first-attempt paths. NUnit reconciliation lived only on the successful VSTest path, and summary merging treated the retry summary as authoritative without evidence that the retry actually covered the fixture failures represented only by first-attempt RunInfos.
Fix Quality
The refinement separates attempt isolation from merge availability, reconciles concurrent fixture failures before propagating VSTest exceptions, and makes removal of first-attempt run errors conditional on complete retry evidence. This is materially safer than the submitted implementation, but the failed overall validation exit and skipped Gate remain explicit blockers.
🧭 Next Steps — reviewer changes required
The reviewer-enhanced candidate identified changes that are not yet in the submitted PR.
Why: The refinement directly addresses all three blocking expert findings, while the submitted PR leaves verified diagnostic-loss and reconciliation defects. Its single validation pass was inconclusive because of a harness false positive, so it is preferred on source quality but is not demonstrated merge-ready.
Address the actionable findings in this review before merging.
|
Verified the core category-targeted retry behavior against actual CI logs for head Observed grouped-lane retries narrowed correctly on all four platforms:
One Android lane executed 270 tests initially and only 89 on retry: 181 fewer executions (67% fewer than repeating the full group). The retry command used Scope: this confirms the primary category-narrowing behavior, not complete validation of every recovery/reporting path. Setup-failure recovery, fixture-only failures, fallback behavior, and attachment preservation were not independently verified in this investigation. Wall-clock and memory savings were not measured. Build 1638061 failed overall; the automated test Gate was skipped, not passed. This evidence alone is not a merge-readiness verdict. |
kubaflo
left a comment
There was a problem hiding this comment.
Could you please check the ai's suggestions and target it to main?
9aaa126 to
6c996bd
Compare
Updated [Microsoft.AspNetCore.Authentication.Facebook](https://github.com/dotnet/dotnet) from 10.0.0 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.AspNetCore.Authentication.Facebook's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.AspNetCore.Authentication.Google](https://github.com/dotnet/dotnet) from 10.0.0 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.AspNetCore.Authentication.Google's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Updated [Microsoft.AspNetCore.Authentication.MicrosoftAccount](https://github.com/dotnet/dotnet) from 10.0.0 to 10.0.10. <details> <summary>Release notes</summary> _Sourced from [Microsoft.AspNetCore.Authentication.MicrosoftAccount's releases](https://github.com/dotnet/dotnet/releases)._ No release notes found for this version range. Commits viewable in [compare view](https://github.com/dotnet/dotnet/commits). </details> Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore <dependency name> major version` will close this group update PR and stop Dependabot creating any more for the specific dependency's major version (unless you unignore this specific dependency's major version or upgrade to it yourself) - `@dependabot ignore <dependency name> minor version` will close this group update PR and stop Dependabot creating any more for the specific dependency's minor version (unless you unignore this specific dependency's minor version or upgrade to it yourself) - `@dependabot ignore <dependency name>` will close this group update PR and stop Dependabot creating any more for the specific dependency (unless you unignore this specific dependency or upgrade to it yourself) - `@dependabot unignore <dependency name>` will remove all of the ignore conditions of the specified dependency - `@dependabot unignore <dependency name> <ignore condition>` will remove the ignore condition of the specified dependency and ignore conditions </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Share category-based retry selection across Android, iOS, MacCatalyst, and Windows. Preserve untouched test results and attachments when merging retry reports, and remove redundant whole-task retries. Known review gaps: pre-test setup/build recovery is not retried, and fixture-only teardown failures reported with a successful VSTest exit do not trigger retry selection. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Restore one CI retry for non-Android preparation/build phases without restarting test execution. Inspect NUnit XML after successful VSTest exits so fixture-only failures retry their categories and persistent errors fail the task and published TRX run. Verified 34 Pester tests, seven real NUnit execution scenarios with result and attachment preservation, eight production setup-wrapper cases, 76 category-isolation checks, and compilation of all four platform Cake scripts. Native platform CI runs remain unverified. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Remove eng/devices/uitest-retry.Tests.ps1 as requested. The suite was not wired into CI; leave the runtime retry implementation and pipeline configuration unchanged. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
95ab2f0 to
58091b6
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit 58091b6.
Source assessment incomplete (5/6 dimensions); finding count is partial.
Keep NUnit fixture run errors until complete retry results confirm successful completion of the same suite in the same assembly. Retain first-attempt results when category narrowing falls back to the original filter, and fail when merged errors remain unresolved. Reconcile readable NUnit reports before merging on both VSTest exit paths. Preserve the original test exception and stack when reports are missing or malformed, without discarding diagnostics from other readable reports. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Snapshot available TRX and NUnit XML before parsing, reconciliation, or filter selection so full-filter fallbacks and malformed reports retain the original diagnostic evidence. Isolate retry output by attempt number rather than merge eligibility. Publish the retry TRX and attachments when the first TRX cannot be read, reject missing retry reports, and stop on archive I/O failure without masking an existing test exception. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
PR Test Gate
|
There was a problem hiding this comment.
Expert Review — 0 findings
Reviewed commit d2c0be0.
Source assessment incomplete (5/6 dimensions); finding count is partial.
<!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! <!-- !!!!!!! MAIN IS THE ONLY ACTIVE BRANCH. MAKE SURE THIS PR IS TARGETING MAIN. !!!!!!! --> ### Description of Change <!-- Enter description of the fix in this section --> Add setup-only recovery with **at most five total attempts per operation**, without rerunning a test command or inferring setup failure from missing results. [UI-test build 1642459](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1642459) failed before executing tests while installing Android emulator/system-image packages (`Error on ZipFile unknown archive`, E2105/MSB3073). Material3 and several API 30 jobs encountered the same provisioning failure; manually retried jobs subsequently ran successfully. These are setup failures, distinct from flaky assertions. - Use `retryCountOnTaskFailure: 4` for shared setup-only .NET SDK/tool/workload, JDK, Xcode, Android environment/AVD, artifact-download, Node and Appium tasks. The shared paths serve applicable UI, device, unit/Helix and integration jobs, including legacy handler/template preparation. - Retry Android common, platform and emulator-image packages **individually** in Azure Pipelines. Each attempt has fresh Android user/temp caches; after a failure, discover the SDK and remove the failed package directory and SDK `.temp` staging before retrying. Stream attempt/exit-code diagnostics and fail explicitly after attempt five. Do not add an enclosing task retry that could multiply the package attempts. Non-CI MSBuild installs retain their original direct CLI invocation and do not acquire a PowerShell dependency. - Count the initial simulator-runtime download toward the five-attempt cap, retain existing CoreSimulator recovery and timeout limits, and fail explicitly on exhaustion or an unusable runtime. - Increase the existing separated Cake UI preparation/build helper to five attempts with backoff. Wire Android APK installation and test-project build into that helper, alongside existing iOS, MacCatalyst and Windows preparation. Test runner invocations, executed-test retry selection/counts, result reconciliation and publication remain unchanged. **Coverage limits:** this is not a whole-job retry. Android emulator boot, independent review-gate preparation, NUnit fixture setup/teardown, and provisioning inside Helix/XHarness workers retain their existing policies. Existing task/job timeouts can stop recovery before five attempts. Exact coverage is documented in `.github/docs/maui-ci-facts.md` and the UI-testing guide. **Upstream comparison:** #39421 already introduced category-based test retries, and open #39509 refines retries of executed tests. This change addresses the separate pre-test setup boundary, not either test-retry implementation. Reviewed recent provisioning fixes #38788 and #38806; they do not implement this bounded package recovery. **Local validation:** all passed without running native UI automation: - `dotnet cake eng/devices/android.cake --target=uitest --dryrun --verbosity=minimal` - `dotnet cake eng/devices/ios.cake --target=uitest --dryrun --verbosity=minimal` - `dotnet cake eng/devices/catalyst.cake --target=uitest --dryrun --verbosity=minimal` - `dotnet cake eng/devices/windows.cake --target=uitest --dryrun --verbosity=minimal` - PowerShell parser and `Invoke-ScriptAnalyzer -Path eng/scripts/Install-AndroidSdkPackage.ps1 -Severity Error,Warning -EnableExit`. - Modified YAML parsing with duplicate-key rejection, shared provisioning Bash syntax checks, and provisioning XML/MSBuild preprocessing for CI and non-CI configuration. - `dotnet format Microsoft.Maui.sln --no-restore --exclude Templates/src --exclude-diagnostics CA1822 --include eng/devices/android.cake eng/devices/uitest-retry.cake eng/devices/uitests-shared.cake src/Provisioning/Provisioning.csproj --verbosity quiet` - `git diff --check`. **Isolated real-installer runtime validation (macOS arm64):** Used the actual restored MAUI CLI, real Android command-line tools 19.0 and existing SDK licenses copied into a private SDK with no symlinks. `ANDROID_HOME` and `ANDROID_SDK_ROOT` both pointed to that copy; `dotnet maui android sdk check --ci --json` confirmed the private path and status `Ok` before provisioning. Android user/cache and temporary directories were private as well. The production script was invoked with this environment (`PRIVATE_ROOT` denotes that private validation directory): ```bash env TF_BUILD=True ANDROID_HOME="$PRIVATE_ROOT/sdk" ANDROID_SDK_ROOT="$PRIVATE_ROOT/sdk" \ ANDROID_USER_HOME="$PRIVATE_ROOT/android-user" TMPDIR="$PRIVATE_ROOT/tmp" \ pwsh -NoLogo -NoProfile -File eng/scripts/Install-AndroidSdkPackage.ps1 -Package platform-tools ``` - **Partial-install cleanup/recovery observed:** a regular file at the private SDK's `platform-tools/.installer` blocked the native install-properties directory. The command above failed on **attempt 1/5** with native exit code 1 and `Failed to read or create install properties file`. The production wrapper logged removal of the failed `platform-tools` directory, then the actual installer succeeded on **attempt 2/5**; wrapper exit code **0**. The installed `adb version` reported **37.0.1-15733141**. - **Exact exhaustion observed:** with the same environment, `/usr/bin/time -p pwsh -NoLogo -NoProfile -File eng/scripts/Install-AndroidSdkPackage.ps1 -Package 'platforms;android-0'` exercised a nonexistent package. The actual installer returned **E2105 / exit code 1** on exactly **attempts 1/5 through 5/5**. The wrapper also logged removal of the SDK `.temp` left by the preceding real install. It stopped with `failed after 5 total attempts (exit code 1)`, process exit code **1**, and **no sixth attempt**. Elapsed time was **43.08 seconds**. - **Successful-package preservation observed:** repeating the valid `-Package platform-tools` command after exhaustion succeeded on **attempt 1/5**, exit code **0**, and the previously installed `adb` remained usable at the same version. Failed-package cleanup did not remove that successful package. **Runtime evidence limit:** these were isolated **macOS arm64 CLI** executions, not literal reproduction of `ZipFile unknown archive` and not Windows/Linux recovery validation. Native installer failures were real; no substitute installer or test harness was used. The shared SDK was not targeted. Private SDK/cache copies were removed after checking for open files; raw `recovery.log`, `exhaustion.log` and `post-exhaustion.log` were retained in session artifacts. No code change, new commit/push or CI dispatch was needed for this validation. **Final hosted validation (unchanged head `9c7ca5bd9682cc8bf3c0fea0ec661c360459a477`):** All three builds are terminal. Overall CI is **not green**: main succeeded, UI has three post-test failures (two unmatched), and device tests have one confirmed main-baseline failure. No setup defect has been identified. | Pipeline | Final result | Observed completion | | --- | --- | --- | | [maui-pr 1645251](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1645251) | **Succeeded** | 26/26 jobs succeeded; 22 published test runs Completed | | [UI tests 1645252](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1645252) | **Failed** | 161 jobs: 158 succeeded, 3 failed; all 157 published test runs Completed | | [Device tests 1645253](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1645253) | **Failed** | All 7 build-log-correlated Helix jobs completed; only the Android CoreCLR assertion below failed | Main published **18,711 passed test executions / 140 skipped / 0 failed**; its final actual failed-result endpoint was empty. UI published **18,161 passed test executions / 342 skipped / 3 failed** and finished at **2026-10-22T14:37:38Z**. These are reported execution counts, not deduplicated unique tests or a count of first-attempt-only passes. The three final UI failures were identified from authoritative failed-run details and raw execution logs: - **Windows, confirmed pre-existing:** `Microsoft.Maui.TestCases.Tests.ShellSearchHandlerFeatureTests(Windows).VerifyShellSearch_TextTransformUppercase` (run **45735806**, result **100196**) failed the screenshot comparison at **0.70%**. [Main build 1641906](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1641906), run **45623126**, result **100198**, has the exact same fully qualified test, screenshot filename, **0.70%** difference and stack. This corrects the earlier unmatched assessment. [Current execution log 3577](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1645252/logs/3577) shows exactly the existing two test attempts, no new setup/build retry warning, and the genuine final test failure; [publisher log 3579](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1645252/logs/3579) correctly remains red. - **Android, unmatched / needs investigation:** `VerifyIsPasswordWhenCursorPositionValueSet` (run **45736456**, result **100129**) failed with an element timeout. No exact failed-result baseline match was found in the sampled five completed main UI builds; this is **not** classified as pre-existing. - **iOS, unmatched / needs investigation:** `DropEventCoordinates` (run **45736540**, result **100272**) failed its positive X/Y assertion. No exact failed-result baseline match was found in the same sample. Baseline run **45634910**, result **100259**, is a different `DragStartEventCoordinates` teardown failure, not a match. The sampled completed main UI builds were **1643718, 1642149, 1641906, 1640343 and 1633638**. Their compact `resultsbybuild` data returned incorrect test titles for some run/result IDs, including all three current failures. Classification above uses rechecked failed-run details, class/platform identity and raw logs, not those compact titles. Absence from this five-build sample does not establish that the two unmatched failures are PR-caused or pre-existing. The sole device-test failure was Android CoreCLR `ImageWithUndefinedSizeAndWithBackgroundSetRenders`, a red-color assertion. The same exact test/platform/reason is present on [main build 1641907](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1641907), run **45621312**, result **100999**. The other correlated Helix jobs passed. Existing test retries preserved the final UI and device failures; this PR does not rerun or hide them through the setup loop. **Setup evidence and completed archive audits:** - Azure Pipelines server-side preview succeeded for all three definitions: `maui-pr` (32 expanded jobs), `maui-pr-uitests` (28), and `maui-pr-devicetests` (8). These are expanded configuration counts, separate from actual final job/run counts above. - The new Android common-package installer ran successfully on Windows in [main build log 48](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1645251/logs/48), and on macOS in the Material3 sample-build job in [UI build log 24](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1645252/logs/24). Both show the new script installing `platform-tools`, `cmdline-tools;13.0` and `emulator` on attempt **1/5**, followed by `Build succeeded`. - Full archive audits read **971 individual task logs** for main, **145** for device validation and **5,522** for UI. They found respectively **104 + 8 + 308 = 420 actual Android package-install invocation lines**, all on attempt **1/5**, and **zero native Azure `RetryHelper` warnings**. All **157 UI test-execution task logs** were uniquely correlated with the **157 final published result runs**. The UI archive audit is complete; zero native retry warnings does not mean that inline simulator recovery or existing test retries did not occur. - **Real hosted pre-test simulator recovery observed:** scanning **67 simulator-runtime task logs** (25 main, 2 device, 40 UI) found **18 successful recoveries**: **14 main, 2 device, 2 UI**. Each log reports `Unable to connect to simulator`, `First attempt failed with exit code 70`, CoreSimulator cleanup/restart, then successful create-usable smoke-device validation `after 2 install attempt(s)` and final setup success. Examples: [main log 349](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1645251/logs/349) (lines 16-269), [device log 17](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1645253/logs/17) (lines 16-262), and [UI log 41](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1645252/logs/41) (lines 16-231) / [UI log 145](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1645252/logs/145) (lines 16-265). **The CoreSimulator cleanup/restart mechanism was pre-existing logic retained by this PR**, not a newly invented recovery mechanism. These logs demonstrate actual pre-test recovery with the revised attempt accounting, but not recovery beyond the second attempt or literal corrupt-ZIP recovery. - **Existing executed-test retries, audited separately:** **103 UI test-execution tasks ran once** and **54 ran twice**. Of those 54, **51 test-execution steps/jobs ultimately recovered** and **3 remained failed**, exactly the final failures above. These are recovered steps/jobs, **not 51 distinct flaky tests**. The **10** `Setup failed for test fixture` candidates occur **inside NUnit after runner start** and recovered through the existing executed-test retry path, not the new five-attempt pre-test loop. [Windows execution log 3577](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1645252/logs/3577) is an example of the unchanged two-attempt path preserving a final failure. - **Remaining limits:** no hosted Android package operation reached attempt 2. Successful first-attempt package installs do not certify corrupt-download recovery or exhaustion on hosted agents. The isolated macOS arm64 CLI observations above remain the direct Android cleanup/recovery/exhaustion proof; literal `ZipFile unknown archive` and Windows/Linux Android recovery remain unexercised. - Docs spellcheck passed. The existing [Pester scripts check](https://github.com/dotnet/maui/actions/runs/39766212470) reports **2,624 passed / 3 failed**. All three failures are stale GPT-5.6 model-policy assertions against the existing GPT-6 reviewer configuration. The failing tests and both configuration inputs are unchanged from the base commit; the base already sets `gpt-6-astra` in `Review-Tests.ps1` and imports `shared/gpt-6.1-sol.md` in `copilot-review-tests.md`. This PR does not change or suppress those checks. No pipeline Pester/regex/snapshot tests were added. No host macOS XCTest/UI automation was used. This evidence update made no code changes, push, rerun or CI dispatch. ### Issues Fixed <!-- Please make sure that there is a bug logged for the issue being fixed. The bug should describe the problem and how to reproduce it. --> No linked issue. Addresses the setup/provisioning failures in [build 1642459](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1642459), including [the Material3 provisioning log](https://dev.azure.com/dnceng-public/public/_apis/build/builds/1642459/logs/173). <!-- Are you targeting main? All PRs should target the main branch unless otherwise noted. -->


Description of Change
Optimize UI-test retries across Android, iOS, MacCatalyst, and Windows by retrying only the categories containing failures, instead of rerunning every category in a grouped lane.
This applies dynamically to all configured category groups, regardless of which categories are grouped together. It reduces unnecessary test execution and is intended to reduce retry duration and resource consumption. Performance and memory improvements have not yet been measured.
Previous behavior
iOS, MacCatalyst, and Windows used an Azure Pipelines task-level retry:
When the UI-test task failed, Azure Pipelines reran the entire PowerShell task, including the
build.ps1 ... --target=uitestinvocation. This restarted Cake and repeated its preparation and test-project build commands, even if those phases had already succeeded and only test execution had failed. MSBuild could still skip up-to-date compilation work.For grouped lanes, the second attempt used the original filter, rerunning all categories—including categories whose tests had passed.
This retried the UI-test task, not the entire pipeline. Earlier, separate provisioning and sample-app build tasks were not restarted by this setting.
Android was excluded from the YAML retry because it already had an internal retry loop in
android.cake. Device preparation, app installation, and the explicit test-project build happened before that loop. On a test failure, the loop reran the original category filter once using--no-build, without restarting Cake or repeating those pre-test phases.New behavior
All four platforms now use a shared
RunUITestsWithRetry()runner:--no-build.Example:
Reference Builds
The retry starts a new test process. NUnit fixture setup and any required app/session initialization still run for the selected tests.
This is category-level retry, not individual-test retry. All tests within a selected failing category run again, including tests that passed initially. A single-category lane such as
CarouselViewtherefore retries the same category once.Preparation and build recovery
Remove the non-Android whole-task YAML retry so that a failed internal test retry cannot trigger another complete category-group run.
To retain recovery from transient pre-test failures, add
RunUITestSetupWithRetry()around selected preparation/build phases on iOS, MacCatalyst, and Windows:Each wrapped phase receives one retry in CI only if that phase fails. Successful phases are not repeated because tests fail later. Errors outside these wrappers no longer receive a blanket whole-task restart.
Android’s setup/build retry boundaries remain unchanged. Separate pipeline tasks for installing .NET and Appium retain their existing retry settings.
Failure detection and fallback
CollectionView1–CollectionView7andShell1/Shell2, rather than expanding a shard to its umbrella category.OneTimeTearDownfailures can trigger retries. Persistent fixture errors fail the task and are recorded as TRX run errors.Test Results and Reporting
RunTestWithLocalDotNetmethod to accept custom results directories and support passing the NUnit XML output directory, enabling improved result management and diagnostics. [1] [2] [3]Codebase Simplification and Robustness
These changes collectively improve CI stability, make test failures easier to diagnose, and ensure more accurate reporting of UI test results.