Skip to content

Commit 496c7ea

Browse files
committed
ci: use windows emulator acceleration when available
1 parent 19214fa commit 496c7ea

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,8 @@ jobs:
399399
Invoke-AndroidToolWithInput $sdkmanager "--install `"platform-tools`" `"emulator`" `"$windowsPlatform`" `"$windowsSystemImage`"" $yesFile
400400
Write-Host "Checking Android emulator acceleration"
401401
& $emulator -accel-check
402-
if ($LASTEXITCODE -ne 0) {
402+
$accelSupported = $LASTEXITCODE -eq 0
403+
if (-not $accelSupported) {
403404
Write-Host "Hosted Windows runner did not report VM acceleration; forcing software acceleration for the CI smoke emulator."
404405
}
405406
Write-Host "Creating Android AVD"
@@ -416,10 +417,14 @@ jobs:
416417
"-gpu", "swiftshader_indirect",
417418
"-grpc", "8554",
418419
"-port", "5554",
419-
"-accel", "off",
420420
"-no-metrics",
421421
"-skip-adb-auth"
422422
)
423+
if ($accelSupported) {
424+
$args += @("-accel", "on")
425+
} else {
426+
$args += @("-accel", "off")
427+
}
423428
function Write-EmulatorDiagnostics {
424429
Write-Host "adb devices:"
425430
& $adb devices -l
@@ -435,7 +440,7 @@ jobs:
435440
Write-Host "Starting Android emulator"
436441
$process = Start-Process -FilePath $emulator -ArgumentList $args -PassThru -RedirectStandardOutput $stdout -RedirectStandardError $stderr
437442
$process.Id | Out-File -FilePath emulator.pid -Encoding ascii
438-
$deviceDeadline = (Get-Date).AddMinutes(8)
443+
$deviceDeadline = (Get-Date).AddMinutes(10)
439444
$deviceSeen = $false
440445
do {
441446
if ($process.HasExited) {

scripts/github-actions.test.mjs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,14 @@ test("Windows Android CI boot path is bounded and diagnostic", () => {
8080
"Android emulator integration tests (Windows)",
8181
);
8282

83-
assert.match(windowsBootStep, /-accel", "off"/);
83+
assert.match(windowsBootStep, /\$accelSupported = \$LASTEXITCODE -eq 0/);
84+
assert.match(windowsBootStep, /"-accel", "on"/);
85+
assert.match(windowsBootStep, /"-accel", "off"/);
8486
assert.match(windowsBootStep, /-RedirectStandardOutput \$stdout/);
8587
assert.match(windowsBootStep, /Write-EmulatorDiagnostics/);
8688
assert.match(
8789
windowsBootStep,
88-
/deviceDeadline = \(Get-Date\)\.AddMinutes\(8\)/,
90+
/deviceDeadline = \(Get-Date\)\.AddMinutes\(10\)/,
8991
);
9092
assert.doesNotMatch(windowsBootStep, /wait-for-device/);
9193
});

0 commit comments

Comments
 (0)