Skip to content

Commit e8dff5a

Browse files
fix: enhance Android harness workflow with AVD configuration and caching improvements
1 parent ab77829 commit e8dff5a

1 file changed

Lines changed: 44 additions & 23 deletions

File tree

.github/workflows/test-android-harness.yml

Lines changed: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ name: Test Android Harness
33
on:
44
workflow_call:
55

6+
env:
7+
DEVICE_API_LEVEL: '35'
8+
DEVICE_ARCH: 'x86_64'
9+
DEVICE_PROFILE: 'pixel_7'
10+
AVD_NAME: 'Pixel_8_API_35'
11+
612
jobs:
713
test-android-harness:
814
name: Test Android Harness
@@ -32,30 +38,45 @@ jobs:
3238
name: android-apk
3339
path: example/android/app/build/outputs/apk/debug/
3440

35-
# Use official React Native Harness action
36-
- name: Run React Native Harness Tests
37-
uses: callstackincubator/react-native-harness/actions/android@b5f855a048d085519a5faff60efa25aa70c3e32b
38-
with:
39-
app: android/app/build/outputs/apk/debug/app-debug.apk
40-
runner: android
41-
projectRoot: example
42-
packageManager: yarn
43-
44-
- name: Upload Android test results
45-
if: always()
46-
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874
41+
- name: AVD cache
42+
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830
43+
id: avd-cache
4744
with:
48-
name: android-harness-test-results
4945
path: |
50-
example/test-results/
51-
example/coverage/
52-
retention-days: 7
46+
~/.android/avd/*
47+
~/.android/adb*
48+
key: avd-${{ env.DEVICE_API_LEVEL }}-${{ env.DEVICE_ARCH }}
5349

54-
- name: Upload Android test logs
55-
if: failure()
56-
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874
50+
- name: Create AVD and generate snapshot for caching
51+
if: steps.avd-cache.outputs.cache-hit != 'true'
52+
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b
5753
with:
58-
name: android-test-logs
59-
path: |
60-
example/android/app/build/outputs/logs/
61-
retention-days: 7
54+
api-level: ${{ env.DEVICE_API_LEVEL }}
55+
arch: ${{ env.DEVICE_ARCH }}
56+
profile: ${{ env.DEVICE_PROFILE }}
57+
disk-size: 1G
58+
heap-size: 1G
59+
force-avd-creation: false
60+
avd-name: ${{ env.AVD_NAME }}
61+
disable-animations: true
62+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
63+
script: echo "Generated AVD snapshot for caching."
64+
65+
- name: Run Harness E2E tests
66+
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b
67+
with:
68+
working-directory: example
69+
api-level: ${{ env.DEVICE_API_LEVEL }}
70+
arch: ${{ env.DEVICE_ARCH }}
71+
force-avd-creation: false
72+
avd-name: ${{ env.AVD_NAME }}
73+
disable-animations: true
74+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
75+
script: |
76+
adb install -r "./android/app/build/outputs/apk/debug/app-debug.apk"
77+
bun run test:harness --harnessRunner android
78+
79+
# Gradle cache doesn't like daemons
80+
- name: Stop Gradle Daemon
81+
working-directory: example/android
82+
run: ./gradlew --stop

0 commit comments

Comments
 (0)