Skip to content

[flaky-ci] Recover MAUI R2R Helix device failures - #12715

Open
simonrozsival wants to merge 5 commits into
mainfrom
simonrozsival-maui-helix-device-recovery
Open

simonrozsival wants to merge 5 commits into
mainfrom
simonrozsival-maui-helix-device-recovery

Conversation

@simonrozsival

Copy link
Copy Markdown
Member

Summary

  • replace the embedded MAUI R2R work-item batch logic with a tested PowerShell device runner
  • require one authorized Android device, with one bounded ADB-server restart before a fast infrastructure failure
  • reduce Android AppId/UID churn by replacing and clearing the known test package instead of blindly uninstalling it before and after every run
  • reboot and retry installation once only for INSTALL_FAILED_INSUFFICIENT_STORAGE with could not be assigned a valid UID
  • preserve unknown APK/install failures without retry and upload device, storage, package-manager, install, and recovery diagnostics

Recovery boundaries

Failure Repository behavior
Missing, offline, or unauthorized device Restart the ADB server once, poll for a bounded interval, then fail with the device-lab action if the device is still unavailable.
Existing package has an incompatible signature Uninstall only the selected MAUI R2R package and retry installation once.
Package UID exhaustion Capture diagnostics, reboot the authorized device once, wait for boot and package-manager readiness, then retry installation once.
Any other install/APK failure Preserve the original output and fail without retry.

The runner allow-lists the four MAUI R2R package IDs and never uninstalls unrelated packages. The outer Helix work-item timeout remains unchanged; all internal command and recovery waits are bounded.

Service-owner boundary

The repository cannot authorize or physically attach a device, quarantine a Helix host, remove unrelated applications, or factory-reset/reprovision a device. Persistent unauthorized/no-device states and UID exhaustion that survives one reboot remain explicit failures for the Helix/device-lab owners tracked by dotnet/arcade#17483.

Validation

  • ran RunMauiR2RHelix.Tests.ps1, covering healthy devices, ADB restart recovery, missing/unauthorized/multiple devices, UID reboot recovery, persistent UID exhaustion, signature cleanup, unknown install failures, empty pidof output, and no-uninstall cleanup
  • ran ConfigureMauiR2RHelixEnvironment.Tests.ps1
  • parsed the PowerShell scripts and updated YAML template
  • inspected the generated Windows work-item wrapper
  • ran git diff --check

Addresses #12658.

Flaky-CI inventory: #12704

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival simonrozsival added the flaky-ci Intermittent CI failures and work to improve CI reliability label Sep 8, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12715

@github-actions github-actions Bot 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.

⚠️ Needs Changes — 0 errors, 1 warning, 1 suggestion.

The device selection, package allow-listing, bounded retries, and process-level regression coverage are well structured, and all 44 reported checks are green. The recovery path still needs an end-to-end budget below Helix’s 10-minute work-item timeout; otherwise the outer timeout can preempt the explicit diagnostics and cleanup this change is intended to provide. I also noted that repeated device polls overwrite their earlier snapshots.

Generated by Android PR Reviewer for #12715 · gpt56 · 123.4 AIC · ⌖ 8.58 AIC · ⊞ 26.3K
Comment /review to run again

Comment thread build-tools/automation/scripts/RunMauiR2RHelix.ps1
Comment thread build-tools/automation/scripts/RunMauiR2RHelix.ps1
Cap the complete MAUI R2R work item at nine minutes so repository recovery and final error handling finish before Helix's ten-minute timeout. Preserve every repeated ADB device snapshot and retain the command transcript that consumes the overall deadline.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12715

@github-actions github-actions Bot 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.

⚠️ Needs Changes

Found 1 warning: the new runner re-encodes ADB diagnostics as ASCII, which can corrupt non-ASCII crash and log output. The bounded recovery flow, package allow-list, targeted uninstall behavior, and fake-ADB coverage are otherwise well structured.

CI is currently red: the macOS and Linux build checks have failed, while the Windows build is still in progress. Those failures were not duplicated as review comments because their detailed cause was not available from the check results.

Generated by Android PR Reviewer for #12715 · gpt56 · 115.3 AIC · ⌖ 11.3 AIC · ⊞ 25.7K
Comment /review to run again

Comment thread build-tools/automation/scripts/RunMauiR2RHelix.ps1 Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival
simonrozsival marked this pull request as ready for review September 9, 2026 21:57
Copilot AI lite review requested due to automatic review settings September 9, 2026 21:58

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.

Copilot review overview

🟡 Changes recommended

The new adb device parsing can mis-handle real-world adb devices output noise and should be made robust before relying on it for CI recovery decisions.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 Medium severity · 1 Low severity

New issues introduced by this change (2)
Severity Finding
Medium severity build-tools/​automation/​scripts/​RunMauiR2RHelix.ps1 — ❌ bug: Get-AdbDeviceSnapshot currently treats any non-empty line as a device row, so adb daemon…
Low severity build-tools/​automation/​scripts/​RunMauiR2RHelix.ps1⚠️ operational_implications: The per-command logs written by Write-CommandResult use ASCII…
What changed in this PR

This PR hardens the MAUI R2R Helix device work-item execution by replacing the previous inline batch logic with a dedicated, tested PowerShell runner that performs bounded device recovery (ADB restart, UID-exhaustion reboot/install retry), reduces package churn, and uploads diagnostics for infrastructure failures.

Changes:

  • Replace embedded adb batch workflow in the Helix payload with RunMauiR2RHelix.ps1 and ship it in the work-item payload.
  • Add a PowerShell test suite (including process exit-code validation) and wire it into the YAML template.
  • Implement bounded recovery paths (single ADB restart; single reboot+install retry for UID exhaustion; single uninstall+retry for update-incompatible).
File Description
build-tools/​automation/​yaml-templates/​run-maui-r2r-helix-matrix.yaml Copies the new runner into the Helix payload and adds test execution steps in the pipeline template.
build-tools/​automation/​scripts/​RunMauiR2RHelix.ps1 New Helix-side device runner implementing bounded recovery + diagnostics capture.
build-tools/​automation/​scripts/​RunMauiR2RHelix.Tests.ps1 New unit-style PowerShell tests using a fake adb to validate recovery boundaries and no-uninstall behavior.
build-tools/​automation/​scripts/​RunMauiR2RHelix.Tests.Process.ps1 New process-level wrapper to validate exit-code behavior when running the test suite under pwsh.

Comment thread build-tools/automation/scripts/RunMauiR2RHelix.ps1
Comment thread build-tools/automation/scripts/RunMauiR2RHelix.ps1 Outdated
Ignore ADB daemon startup banners when selecting the attached device and keep ADB output UTF-8 through capture and uploaded diagnostics.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@simonrozsival

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12715

@github-actions github-actions Bot 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.

⚠️ Needs Changes

Found 1 error: the new no-uninstall flow can false-pass by launching an allowed package left from a previous work item when the newly built APK installs under an unexpected application ID. The inline comment describes how to bind validation to the APK under test.

The bounded ADB recovery, allow-listed cleanup, diagnostic preservation, and focused fake-ADB coverage are otherwise well structured. All 44 reported checks, including the Azure DevOps dotnet-android build, are green.

Generated by Android PR Reviewer for #12715 · copilot · gpt56 · 99.8 AIC · ⌖ 11.2 AIC · ⊞ 21K
Comment /review to run again

$result = Invoke-Adb $arguments -TimeoutSeconds 180
Write-CommandResult "install-$ConfigurationName-attempt-$attempt" $arguments $result
if ($result.ExitCode -eq 0) {
return

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.

🤖 ❌ Testing — A successful adb install -r does not prove that this APK updated $PackageName: if the built APK unexpectedly has a different application ID, Android installs it as a second package, and the allowed package retained from a previous work item still makes Verify-MauiR2RPackage and the launch check pass against stale code. Please verify the APK application ID before installation or otherwise prove that the selected package was replaced, and cover the stale-package case in the fake-ADB suite.

Rule: Do not validate stale artifacts.

[switch] $SkipExtendedDiagnostics
)

$ErrorActionPreference = 'Stop'

@jonathanpeppers jonathanpeppers Sep 14, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We are using both bash and yaml for CI, and this introduces powershell (which we might already have a small amount of).

Is there a way this could be done without introducing more scripts (more code)? I'm wondering if inline bash in yaml is what we should standardize on.

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

Labels

flaky-ci Intermittent CI failures and work to improve CI reliability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants