Skip to content

Enable Android dependency install test retries#12059

Open
simonrozsival with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-install-android-dependencies-test
Open

Enable Android dependency install test retries#12059
simonrozsival with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-install-android-dependencies-test

Conversation

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

InstallAndroidDependenciesTest retries transient SDK/JDK download failures, but ProjectBuilder throws on the first failed build, preventing later attempts.

  • Retry behavior
    • Disable ThrowOnBuildFailure for this test’s builder.
    • Preserve the existing three-attempt loop, cleanup, delay, and final assertion.
b.CleanupAfterSuccessfulBuild = false;
b.ThrowOnBuildFailure = false;

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix flaky test for InstallAndroidDependenciesTest Enable Android dependency install test retries Jul 13, 2026
Copilot AI requested a review from simonrozsival July 13, 2026 20:35
@simonrozsival simonrozsival marked this pull request as ready for review July 14, 2026 15:34
Copilot AI review requested due to automatic review settings July 14, 2026 15:34
@simonrozsival

Copy link
Copy Markdown
Member

/review

@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

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 fixes the retry behavior of InstallAndroidDependenciesTest by ensuring the test can observe build failures as false return values (instead of exceptions), allowing its existing retry loop to function as intended when SDK/JDK downloads fail transiently in CI.

Changes:

  • Disable ProjectBuilder.ThrowOnBuildFailure for InstallAndroidDependenciesTest so the three-attempt retry loop can continue after a failed build.
Show a summary per file
File Description
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AndroidDependenciesTests.cs Sets ThrowOnBuildFailure = false so transient dependency install failures don’t abort the retry loop via exceptions.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@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.

✅ LGTM

Verdict: ✅ LGTM — Clean, minimal, correct fix.

Summary

The one-line change (b.ThrowOnBuildFailure = false;) is exactly what the retry loop needs. Previously, ProjectBuilder.Build throws FailedBuildException on the first failed build (Builder.cs:414), which aborted the three-attempt loop before it could retry transient SDK/JDK download failures. Disabling ThrowOnBuildFailure lets b.Build(...) return false, so the loop's cleanup + delay + retry logic works as intended, and the final Assert.IsTrue (installSucceeded, ...) still fails the test if all attempts fail.

Issue counts: ❌ 0 · ⚠️ 0 · 💡 1

Verification

  • ✅ Retry loop (lines 76–92) now functions correctly across all 3 attempts.
  • ✅ Final assertion still enforces success.
  • ✅ The final default-target build (line 121) remains guarded by Assert.IsTrue, so disabling throw-on-failure for the whole builder doesn't mask a real failure there.
  • ✅ Change is scoped to a single test; no production code affected.

Positive callouts

  • Good use of a clear code comment referencing the tracking issue (#11973).
  • Cleanup-per-attempt (deleting/recreating sdkPath/jdkPath) correctly avoids partial-download contamination between retries.

Nice, focused change.

Generated by Android PR Reviewer for #12059 · 65.1 AIC · ⌖ 18.5 AIC · ⊞ 6.8K
Comment /review to run again

using (var b = CreateApkBuilder ()) {
b.Verbosity = LoggerVerbosity.Detailed;
b.CleanupAfterSuccessfulBuild = false;
b.ThrowOnBuildFailure = false;

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 — This is the correct fix: without it, Builder.Build throws FailedBuildException on the first failed attempt (Builder.cs:414), so the retry loop below could never reach attempts 2–3. One thing to be aware of: this disables throwing for the entire builder, including the final default-target build at line 121. That's still safe because that build is guarded by Assert.IsTrue (b.Build (...), "build should have succeeded."), so a real failure there is still surfaced. No change needed — just confirming the behavior is intentional.

(Rule: Verify retry/error-handling semantics)

@jonathanpeppers jonathanpeppers left a comment

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 should re-enable the ignored test in main, if this is really the fix.

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.

[Flaky test] InstallAndroidDependenciesTest (GoogleV2/Xamarin, CoreCLR) fails intermittently across PRs

4 participants