@@ -290,19 +290,11 @@ jobs:
290290 # runs-on: "macos-12" # macOS-latest
291291 runs-on : ubicloud-standard-8
292292 env :
293- MATRIX_E_SDK : ${{ matrix.android_emu_version }}
294- MATRIX_AVD : ${{ matrix.android_avd }}
293+ MATRIX_E_SDK : ${{ matrix.api-level }}
295294 strategy :
296295 fail-fast : false
297- max-parallel : 1
298296 matrix :
299- android_avd : [Pixel_API_32_AOSP]
300- include :
301- # - android_avd: Pixel_API_27_AOSP
302- # android_emu_version: 27
303- # # # Cannot run > 27-emuLevel -_- https://github.com/actions/runner-images/issues/6527
304- - android_avd : Pixel_API_32_AOSP
305- android_emu_version : 32
297+ api-level : [29]
306298 steps :
307299
308300 - uses : actions/checkout@v4
@@ -325,145 +317,45 @@ jobs:
325317 fail-on-cache-miss : false
326318
327319 - name : Display structure of downloaded files
320+ if : steps.cache-jniLibs.outputs.cache-hit == 'true'
328321 run : |
329322 pushd mobile/src/main/jniLibs && ls -R && popd
330323
331- - name : Install intel-haxm
332- if : runner.os == 'macOS'
333- run : brew install intel-haxm
334-
335- # # # Below code is majorly from https://github.com/actions/runner-images/issues/6152#issuecomment-1243718140
336324 - name : Set up JDK
337325 uses : actions/setup-java@v4
338326 with :
339327 distribution : ' temurin'
340328 java-version : ${{ env.JAVA_VERSION }}
341329
342- # Android SDK & NDK (set up once before both emulator creation and tests)
343- - name : Set up Android SDK
344- uses : android-actions/setup-android@v3
345- - name : Set up Android NDK
346- run : |
347- sdkmanager "ndk;${{ env.NDK_VERSION }}"
348- ANDROID_NDK_HOME="$ANDROID_SDK_ROOT/ndk/${{ env.NDK_VERSION }}"
349- ls $ANDROID_NDK_HOME
350- echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
351- - name : Create Android emulator
352- run : |
353- # Install system image
354- echo "y" | sdkmanager --install "system-images;android-${MATRIX_E_SDK};default;x86_64"
355- echo "y" | sdkmanager --licenses || true
356-
357- # Create emulator
358- echo "no" | avdmanager --noui create avd -n "$MATRIX_AVD" -d pixel \
359- --package "system-images;android-${MATRIX_E_SDK};default;x86_64" --force
360- echo "Created AVDs:"
361- $ANDROID_HOME/emulator/emulator -list-avds
362-
363- - name : Start Android emulator
364- timeout-minutes : 30 # ~4min normal - 3x DOSafety
365- env :
366- SUFFIX : ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}
367- HOMEBREW_NO_INSTALL_CLEANUP : 1
368- run : |
369- echo "Starting emulator and waiting for boot to complete...."
370- ls -la $ANDROID_HOME/emulator
371- nohup $ANDROID_HOME/emulator/emulator -avd $MATRIX_AVD -gpu swiftshader_indirect -no-audio -no-boot-anim -camera-back none -camera-front none -qemu -m 2048 2>&1 &
372- $ANDROID_HOME/platform-tools/adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed | tr -d '\r') ]]; do echo "wait..."; sleep 1; done; input keyevent 82'
373- echo "Emulator has finished booting"
374- $ANDROID_HOME/platform-tools/adb devices
375- sleep 30
376- mkdir -p screenshots
377- screencapture screenshots/screenshot-$SUFFIX.jpg
378- $ANDROID_HOME/platform-tools/adb exec-out screencap -p > screenshots/emulator-$SUFFIX.png
379-
380- # # # Have to re-setup everything since we need to run emulator for faster performance on masOS ? Other os'es emulator will not startup ?
381- # TODO: Optimize the steps taking into consideration all software present by default on macOS runner image
382-
383- # # # Test # # reactiveCircus is giving a black screenshot not working
384- # # # TODO: Take a screenshot of OS to confirm if its Emulator issue or testcode/androidsdk issue - or maybe the emulator is screen off ?
385- # # # https://github.com/ReactiveCircus/android-emulator-runner
386- # - name: Test Cache
387- # uses: reactivecircus/android-emulator-runner@v2
388- # with:
389- # api-level: ${{ matrix.android_emu_version }}
390- # arch: x86_64
391- # profile: Nexus 6
392- # target: google_apis
393- # emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
394- # script: echo Meoooow !
395- # - name: Test
396- # id: test
397- # uses: reactivecircus/android-emulator-runner@v2
398- # with:
399- # api-level: ${{ matrix.android_emu_version }}
400- # arch: x86_64
401- # profile: Nexus 6
402- # target: google_apis
403- # emulator-options: -gpu swiftshader_indirect -noaudio -no-boot-anim -no-snapshot-save
404- # # Only running specific Instrumentation tests cause others are failing right now. TODO: Fix others
405- # script: ./gradlew connectedCheck -Pandroid.testInstrumentationRunnerArguments.class=net.activitywatch.android.ScreenshotTest --stacktrace
406-
407- # - name: Install recorder and record session
408- # env:
409- # SUFFIX: ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}-${{ matrix.os }}
410- # run: |
411- # brew install ffmpeg
412- # $ANDROID_HOME/tools/emulator -help-all
413- # # -logcat *:v
414- # # $ANDROID_HOME/tools/emulator -port 18725 -verbose -no-audio -gpu swiftshader_indirect -logcat *:v @$MATRIX_AVD &
415- # ffmpeg -f avfoundation -i 0 -t 120 out$SUFFIX.mov &
416-
417-
418- - name : Run E2E tests
419- timeout-minutes : 20
330+ - name : Run Emulator and E2E tests
331+ uses : reactivecircus/android-emulator-runner@v2
332+ timeout-minutes : 30
420333 id : test
421- run : |
422- make test-e2e
423-
424- - name : Output and save logcat to file
425- if : ${{ success() || steps.test.conclusion == 'failure'}}
426- run : |
427- mkdir -p mobile/build
428- adb logcat -d > mobile/build/logcat.log
429- adb logcat -v color &
430-
431- - name : Screenshot
432- if : ${{ success() || steps.test.conclusion == 'failure'}}
433- env :
434- SUFFIX : ${{ matrix.android_avd }}-eAPI-${{ matrix.android_emu_version }}
435- run : |
436- adb shell monkey -p net.activitywatch.android.debug 1
437- sleep 10
438- screencapture screenshots/pscreenshot-$SUFFIX.jpg
439- $ANDROID_HOME/platform-tools/adb exec-out screencap -p > screenshots/pemulator-$SUFFIX.png
440- ls -alh screenshots/
334+ with :
335+ api-level : ${{ matrix.api-level }}
336+ target : google_apis
337+ arch : x86_64
338+ ndk : ${{ env.NDK_VERSION }}
339+ emulator-options : -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -no-snapshot-save
340+ disable-animations : true
341+ script : |
342+ make test-e2e || true
343+ adb shell screencap -p /sdcard/screenshot.png
344+ adb pull /sdcard/screenshot.png .
345+
346+ - name : Upload screenshot
347+ uses : actions/upload-artifact@v4
348+ if : ${{ success() || steps.test.conclusion == 'failure' }}
349+ with :
350+ name : emulator-screenshot
351+ path : screenshot.png
441352
442353 - name : Upload logcat
443- if : ${{ success() || steps.test.conclusion == 'failure'}}
354+ if : ${{ success() || steps.test.conclusion == 'failure' }}
444355 uses : actions/upload-artifact@v4
445356 with :
446357 name : logcat
447- # mobile\build\outputs\connected_android_test_additional_output\debugAndroidTest\connected\Pixel_XL_API_32(AVD) - 12\ScreenshotTest_saveDeviceScreenBitmap.png
448- path : |
449- mobile/build/logcat.log
450- # mobile/build/reports/*
451-
452- # - name: Upload video
453- # if: ${{ success() || steps.test.conclusion == 'failure'}}
454- # uses: actions/upload-artifact@master
455- # with:
456- # name: video
457- # path: ./*.mov # out.mov
458-
459- - name : Upload screenshots
460- uses : actions/upload-artifact@v4
461- if : ${{ success() || steps.test.conclusion == 'failure'}}
462- with :
463- name : screenshots
464- path : |
465- screenshots/*
466- **/mobile/build/outputs/connected_android_test_additional_output/debugAndroidTest/connected/*
358+ path : mobile/build/logcat.log
467359
468360 # - name: Publish Test Report
469361 # # # uses: mikepenz/action-junit-report@v3
0 commit comments