@@ -24,7 +24,9 @@ defaults:
2424jobs :
2525 run :
2626 name : ${{ inputs.unity-version }} ${{ inputs.api-level }} ${{ inputs.init-type }}
27- runs-on : ubuntu-latest
27+ # Unity 6000.x builds ARM64 so we run Redroid (containerized arm64 Android) on an
28+ # arm64 Linux runner.
29+ runs-on : ${{ fromJSON(inputs.unity-version) >= 6000 && 'ubuntu-24.04-arm' || 'ubuntu-latest' }}
2830 env :
2931 ARTIFACTS_PATH : samples/IntegrationTest/test-artifacts/
3032 HOMEBREW_NO_INSTALL_CLEANUP : 1
@@ -48,28 +50,45 @@ jobs:
4850 name : testapp-android-compiled-${{ inputs.unity-version }}-${{ inputs.init-type }}
4951 path : samples/IntegrationTest/Build
5052
53+ - name : Determine device
54+ id : device
55+ run : |
56+ if ([double]"${{ inputs.unity-version }}" -ge 6000) {
57+ $device = "redroid"; $arch = "arm64-v8a"
58+ } else {
59+ $device = "emulator"; $arch = "x86_64"
60+ }
61+ "device=$device" >> $env:GITHUB_OUTPUT
62+ "arch=$arch" >> $env:GITHUB_OUTPUT
63+ Write-Host "Using device: $device ($arch)"
64+
65+ # --- x86_64 path: hardware-accelerated emulator on the x86 Linux runner ---
66+
67+ - name : Add Android build-tools to PATH
68+ if : ${{ steps.device.outputs.device == 'emulator' }}
69+ run : |
70+ $buildToolsDir = (Get-ChildItem "$env:ANDROID_HOME/build-tools" -Directory | Sort-Object Name | Select-Object -Last 1).FullName
71+ Write-Host "Found build-tools at: $buildToolsDir"
72+ $buildToolsDir >> $env:GITHUB_PATH
73+
5174 # See https://github.blog/changelog/2023-02-23-hardware-accelerated-android-virtualization-on-actions-windows-and-linux-larger-hosted-runners/
5275 - name : Enable KVM group perms
76+ if : ${{ steps.device.outputs.device == 'emulator' }}
5377 run : |
5478 echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
5579 sudo udevadm control --reload-rules
5680 sudo udevadm trigger --name-match=kvm
5781
5882 # Make sure that the required directories and .cfg do exists. Workaround to keep ADV happy on `ubuntu-latest`.
5983 - name : Setup Android directories
84+ if : ${{ steps.device.outputs.device == 'emulator' }}
6085 run : |
6186 mkdir -p $HOME/.android
6287 mkdir -p $HOME/.android/avd
6388 touch $HOME/.android/repositories.cfg
6489
65- - name : Add Android build-tools to PATH
66- run : |
67- BUILD_TOOLS_DIR=$(ls -d $ANDROID_HOME/build-tools/*/ | sort -V | tail -1)
68- echo "Found build-tools at: $BUILD_TOOLS_DIR"
69- echo "$BUILD_TOOLS_DIR" >> $GITHUB_PATH
70- shell : bash
71-
72- - name : Run Android Integration Tests
90+ - name : Run Android Integration Tests (emulator)
91+ if : ${{ steps.device.outputs.device == 'emulator' }}
7392 uses : reactivecircus/android-emulator-runner@0a638108440efd5c7f980e6ba145dbcdd8f32009 # v2.37.0
7493 id : integration-test
7594 timeout-minutes : 30
@@ -90,13 +109,71 @@ jobs:
90109 -camera-front none
91110 -timezone US/Pacific
92111 -no-metrics
93- arch : x86_64
112+ arch : ${{ steps.device.outputs.arch }}
94113 script : |
95114 adb wait-for-device
96115 adb shell input keyevent 82
97116 adb devices -l
98117 pwsh -Command '$env:SENTRY_TEST_PLATFORM = "Android"; $env:SENTRY_TEST_APP = "samples/IntegrationTest/Build/test.apk"; Invoke-Pester -Path test/IntegrationTest/Integration.Tests.ps1 -CI'
99118
119+ # --- arm64 path: Redroid container on the arm64 runner (no hypervisor needed) ---
120+
121+ - name : Start Redroid container
122+ if : ${{ steps.device.outputs.device == 'redroid' }}
123+ run : |
124+ $ErrorActionPreference = "Stop"
125+ $PSNativeCommandUseErrorActionPreference = $true
126+ $kernel = uname -r
127+ sudo apt-get update
128+ sudo apt-get install -y adb aapt "linux-modules-extra-$kernel"
129+ sudo modprobe binder_linux devices="binder,hwbinder,vndbinder"
130+ $PSNativeCommandUseErrorActionPreference = $false
131+ sudo modprobe ashmem_linux # built into the kernel on newer releases; ignore if absent
132+ $hasBinder = (Test-Path /dev/binderfs) -or
133+ (Select-String -Path /proc/filesystems -Pattern '\bbinder\b' -Quiet) -or
134+ (Test-Path /dev/binder)
135+ if (-not $hasBinder) {
136+ Write-Error "binder is unavailable on this kernel ($kernel); Redroid cannot run."
137+ exit 1
138+ }
139+ docker run -d --rm --privileged `
140+ --name redroid `
141+ -p 5555:5555 `
142+ redroid/redroid:13.0.0_64only-latest `
143+ androidboot.redroid_gpu_mode=guest
144+
145+ - name : Run Android Integration Tests (redroid)
146+ if : ${{ steps.device.outputs.device == 'redroid' }}
147+ id : integration-test-redroid
148+ timeout-minutes : 30
149+ env :
150+ # adb auto-detects Redroid both on the emulator console port (emulator-5554) and via our
151+ # `adb connect` (localhost:5555). Pin a single serial so bare `adb` commands in the test
152+ # (e.g. the launcher-activity dumpsys) don't fail/misfire with "more than one device".
153+ ANDROID_SERIAL : localhost:5555
154+ run : |
155+ $ErrorActionPreference = "Stop"
156+ # adbd inside Redroid takes a while to come up. `adb connect` reports success even when the
157+ # port isn't serving yet and the transport stays 'offline', so poll connect + boot state
158+ # together instead of relying on `adb wait-for-device`.
159+ for ($i = 1; $i -le 60; $i++) {
160+ adb connect localhost:5555 *> $null
161+ $booted = (adb -s localhost:5555 shell getprop sys.boot_completed 2>$null | Out-String).Trim()
162+ if ($booted -eq "1") { Write-Host "Redroid booted after $($i * 5)s"; break }
163+ if ($i -eq 60) {
164+ Write-Host "Redroid did not boot in time"
165+ adb devices -l
166+ docker logs redroid 2>&1 | Select-Object -Last 80
167+ adb -s localhost:5555 logcat -d 2>&1 | Select-Object -Last 100
168+ exit 1
169+ }
170+ Start-Sleep -Seconds 5
171+ }
172+ adb devices -l
173+ $env:SENTRY_TEST_PLATFORM = "Android"
174+ $env:SENTRY_TEST_APP = "samples/IntegrationTest/Build/test.apk"
175+ Invoke-Pester -Path test/IntegrationTest/Integration.Tests.ps1 -CI
176+
100177 - name : Upload test results on failure
101178 if : ${{ failure() }}
102179 uses : actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
0 commit comments