Skip to content

Commit 9fe3093

Browse files
committed
ci: make windows android sdk setup noninteractive
1 parent c8bbbc0 commit 9fe3093

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ jobs:
349349
- name: Create and boot Android emulator (Windows)
350350
if: runner.os == 'Windows'
351351
shell: pwsh
352+
timeout-minutes: 30
352353
run: |
353354
$ErrorActionPreference = "Stop"
354355
$sdk = $env:ANDROID_HOME
@@ -375,12 +376,26 @@ jobs:
375376
$adb = Join-Path $sdk "platform-tools\adb.exe"
376377
$emulator = Join-Path $sdk "emulator\emulator.exe"
377378
379+
$yesFile = Join-Path $env:RUNNER_TEMP "android-sdk-yes.txt"
380+
1..200 | ForEach-Object { "y" } | Set-Content -Path $yesFile -Encoding ascii
381+
$noFile = Join-Path $env:RUNNER_TEMP "android-avd-no.txt"
382+
"no" | Set-Content -Path $noFile -Encoding ascii
383+
384+
function Invoke-AndroidToolWithInput($tool, $arguments, $inputFile) {
385+
$line = "`"$tool`" $arguments < `"$inputFile`""
386+
Write-Host "cmd /c $line"
387+
cmd /c $line
388+
if ($LASTEXITCODE -ne 0) {
389+
throw "$tool $arguments failed with exit code $LASTEXITCODE."
390+
}
391+
}
392+
378393
Write-Host "Accepting Android SDK licenses"
379-
1..100 | ForEach-Object { "y" } | & $sdkmanager --licenses
394+
Invoke-AndroidToolWithInput $sdkmanager "--licenses" $yesFile
380395
Write-Host "Installing Android SDK emulator packages"
381-
1..100 | ForEach-Object { "y" } | & $sdkmanager --install "platform-tools" "emulator" "platforms;android-35" "system-images;android-35;google_apis;x86_64"
396+
Invoke-AndroidToolWithInput $sdkmanager "--install `"platform-tools`" `"emulator`" `"platforms;android-35`" `"system-images;android-35;google_apis;x86_64`"" $yesFile
382397
Write-Host "Creating Android AVD"
383-
"no" | & $avdmanager create avd --force --name SimDeck_Pixel_CI --package "system-images;android-35;google_apis;x86_64" --device "pixel_6"
398+
Invoke-AndroidToolWithInput $avdmanager "create avd --force --name SimDeck_Pixel_CI --package `"system-images;android-35;google_apis;x86_64`" --device `"pixel_6`"" $noFile
384399
385400
$args = @(
386401
"-avd", "SimDeck_Pixel_CI",

0 commit comments

Comments
 (0)