1414 workflow_dispatch :
1515jobs :
1616 test :
17- runs-on : macos-12
17+ runs-on : ubuntu-latest
1818 timeout-minutes : 60
1919 env :
2020 WORKING_DIRECTORY : paper-example
@@ -25,87 +25,89 @@ jobs:
2525 group : android-e2e-example-${{ github.ref }}
2626 cancel-in-progress : true
2727 steps :
28- - name : checkout
29- uses : actions/checkout@v3
30- with :
31- submodules : recursive
32- - uses : actions/setup-node@v3
28+ - name : Checkout
29+ uses : actions/checkout@v4
30+
31+ - name : Free Disk Space (Ubuntu)
32+ uses : jlumbroso/free-disk-space@main
3333 with :
34- node-version : 18
35- cache : ' yarn'
34+ tool-cache : true
35+ android : false
36+
3637 - name : Set up JDK 17
37- uses : actions/setup-java@v2
38+ uses : actions/setup-java@v4
3839 with :
3940 java-version : ' 17'
4041 distribution : ' zulu'
4142 cache : ' gradle'
42- - name : Install NDK
43- uses : nttld/setup-ndk@v1
44- id : setup-ndk
45- with :
46- ndk-version : r26d
47- local-cache : true
48- - name : Set ANDROID_NDK
49- run : echo "ANDROID_NDK=$ANDROID_HOME/ndk-bundle" >> $GITHUB_ENV
50- - name : Cache SDK image
51- id : cache-sdk-img
52- uses : actions/cache@v3
53- with :
54- path : $ANDROID_HOME/system-images/
55- key : ${{ runner.os }}-build-system-images-${{ env.SYSTEM_IMAGES }}
56- - name : SKDs - download required images
57- if : ${{ steps.cache-sdd-img.outputs.cache-hit != 'true' }}
58- run : $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager "system-images;android-34;google_apis;x86_64"
59- - name : Cache AVD
60- id : cache-avd
61- uses : actions/cache@v3
43+
44+ - name : Setup Node.js
45+ uses : actions/setup-node@v6
6246 with :
63- path : ~/.android/avd/${{ env.AVD_NAME }}.avd
64- key : ${{ runner.os }}-avd-images-${{ env.SYSTEM_IMAGES }}-${{ env.AVD_NAME }}
65- - name : Emulator - Create
66- if : ${{ steps.cache-avd.outputs.cache-hit != 'true' }}
67- run : $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n ${{ env.AVD_NAME }} --device 28 --package "${{ env.SYSTEM_IMAGES }}" --sdcard 512M
68- - name : Emulator - Set screen settings
69- if : ${{ steps.cache-avd.outputs.cache-hit != 'true' }}
47+ node-version : 22
48+ cache : ' yarn'
49+
50+ - name : Install AVD dependencies
51+ # libxkbfile1 is removed by "Free Disk Space (Ubuntu)" step first. Here we install it again
52+ # as it seems to be needed by the emulator.
7053 run : |
71- echo "AVD config path: $HOME/.android/avd/${{ env.AVD_NAME }}.avd/config.ini"
72- sed -i '' 's/.*hw\.lcd\.density.*/hw\.lcd\.density = 480/g' $HOME/.android/avd/${{ env.AVD_NAME }}.avd/config.ini
73- sed -i '' 's/.*hw\.lcd\.width.*/hw\.lcd\.width = 1344/g' $HOME/.android/avd/${{ env.AVD_NAME }}.avd/config.ini
74- sed -i '' 's/.*hw\.lcd\.height.*/hw\.lcd\.height = 2992/g' $HOME/.android/avd/${{ env.AVD_NAME }}.avd/config.ini
75- - name : Emulator - Boot
76- run : $ANDROID_HOME/emulator/emulator -memory 4096 -avd ${{ env.AVD_NAME }} -no-window -gpu swiftshader_indirect -no-snapshot -noaudio -no-boot-anim &
54+ sudo apt update
55+ sudo apt-get install -y libpulse0 libgl1 libxkbfile1
7756
78- - name : ADB Wait For Device
79- run : adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'
80- timeout-minutes : 10
57+ - name : Enable KVM
58+ run : |
59+ echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
60+ sudo udevadm control --reload-rules
61+ sudo udevadm trigger --name-match=kvm
8162
82- - name : Reverse TCP
83- working-directory : apps/${{ env.WORKING_DIRECTORY }}
84- run : adb devices | grep '\t' | awk '{print $1}' | sed 's/\\s//g' | xargs -I {} adb -s {} reverse tcp:8081 tcp:8081
63+ - name : AVD cache
64+ uses : actions/cache@v4
65+ id : avd-cache
66+ with :
67+ path : |
68+ ~/.android/avd/*
69+ ~/.android/adb*
70+ key : avd-${{ env.API_LEVEL }}
8571
86- - name : Install root node dependencies
87- run : yarn
72+ - name : Run emulator, Metro, and E2E
73+ uses : reactivecircus/android-emulator-runner@v2
74+ with :
75+ api-level : ${{ env.API_LEVEL }}
76+ target : default
77+ profile : pixel_7
78+ ram-size : ' 4096M'
79+ disk-size : ' 5G'
80+ disable-animations : false
81+ force-avd-creation : false
82+ emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
83+ avd-name : e2e_emulator
84+ arch : x86_64
85+ script : |
86+ # Install root node dependencies
87+ yarn install
88+ # Install example app node dependencies
89+ yarn --cwd apps/${{ env.WORKING_DIRECTORY }} install
90+
91+ # Set up ADB reverse for Metro
92+ $ANDROID_HOME/platform-tools/adb reverse tcp:8081 tcp:8081
8893
89- - name : Install example app node dependencies
90- run : yarn
91- working-directory : apps/${{ env.WORKING_DIRECTORY }}
94+ # Start Metro in the background
95+ E2E=true yarn --cwd apps/${{ env.WORKING_DIRECTORY }} start &> output.log &
9296
93- - name : Build Android app
94- working-directory : apps/${{ env.WORKING_DIRECTORY }}/android
95- run : ./gradlew assembleDebug
97+ # Build the Android app
98+ cd apps/${{ env.WORKING_DIRECTORY }}/android && ./gradlew assembleDebug
9699
97- - name : Start Metro server
98- working-directory : apps/${{ env.WORKING_DIRECTORY }}
99- run : E2E=true yarn start &> output.log &
100+ # Install the app APK
101+ $ANDROID_HOME/platform-tools/adb install -r apps/${{ env.WORKING_DIRECTORY }}/android/app/build/outputs/apk/debug/app-debug.apk
100102
101- - name : Install APK
102- run : adb install -r apps/${{ env.WORKING_DIRECTORY }}/android/app/build/outputs/apk/debug/app-debug.apk
103+ # Launch the app using bash
104+ bash -c 'until $ANDROID_HOME/platform-tools/adb shell monkey -p com.paperexample 1 | grep -q "Events injected: 1"; do sleep 1; echo "Retrying app launch..."; done'
103105
104- - name : Launch APK
105- run : ' while ! (adb shell monkey -p com.example 1 | grep -q "Events injected: 1"); do sleep 1; echo "Retrying due to errors in previous run..."; done '
106+ # Run E2E tests
107+ yarn e2e
106108
107- - name : Run e2e Tests
108- run : E2E=true yarn e2e
109+ # Kill Metro
110+ lsof -ti:8081 | xargs -r kill
109111
110112 - name : Upload test report
111113 uses : actions/upload-artifact@v4
@@ -114,6 +116,3 @@ jobs:
114116 path : |
115117 report.html
116118 jest-html-reporters-attach/
117-
118- - name : Kill emulator (so it can be cached safely)
119- run : adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done
0 commit comments