diff --git a/.github/workflows/emulator.yaml b/.github/workflows/emulator.yaml index d065b29c8..ed4b26edd 100644 --- a/.github/workflows/emulator.yaml +++ b/.github/workflows/emulator.yaml @@ -49,7 +49,7 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* - key: avd.v5-${{ matrix.api-level }} + key: avd.v8-${{ matrix.api-level }} - name: create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' @@ -65,14 +65,22 @@ jobs: ram-size: 3G heap-size: 1500M profile: 3.4in WQVGA + channel: canary script: echo "Generated AVD snapshot for caching." - - name: run ffmpeg screen capture + - name: install ffmpeg if: inputs.video - run: | - brew install ffmpeg - ffmpeg -nostdin -f avfoundation -i 0 recording-${{ matrix.project }}-${{ matrix.api-level }}.mov & - sleep 5 + uses: FedericoCarboni/setup-ffmpeg@v2 + + - name: pregenerate test package + if: inputs.video + run: ./gradlew :${{ matrix.project }}:packageDebugAndroidTest + +# - name: run ffmpeg screen capture +# if: inputs.video +# run: | +# ./record_emulator.sh recording-${{ matrix.project }}-${{ matrix.api-level }}.mp4 & +# sleep 5 - name: run tests uses: reactivecircus/android-emulator-runner@v2 @@ -80,27 +88,36 @@ jobs: api-level: ${{ matrix.api-level }} target: google_apis force-avd-creation: false - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot-save -noaudio -no-boot-anim -camera-back none disable-animations: true arch: x86_64 disk-size: 3G ram-size: 3G heap-size: 1500M profile: 3.4in WQVGA - script: ./gradlew :${{ matrix.project }}:connectedDebugAndroidTest + channel: canary + script: ./gradlew :${{ matrix.project }}:connectedDebugAndroidTest && ./record_emulator.sh recording-${{ matrix.project }}-${{ matrix.api-level }}.mp4 & - name: stop screen capture - if: inputs.video + if: always() && inputs.video continue-on-error: true shell: bash run: | + ps aux | grep -m 1 ffmpeg + ps aux | grep -m 1 screenrecord + PID=$(ps aux | grep -m 1 ffmpeg | awk '{print $2}') python -c "import os, signal; os.kill($PID, signal.SIGINT)" + sleep 2 + + PID=$(ps aux | grep -m 1 screenrecord | awk '{print $2}') + python -c "import os, signal; os.kill($PID, signal.SIGINT)" + sleep 5 - name: upload video - if: inputs.video + if: always() && inputs.video continue-on-error: true uses: actions/upload-artifact@master with: - name: Recording-${{ matrix.project }}-${{ matrix.api-level }} + name: recording-${{ matrix.project }}-${{ matrix.api-level }} path: recording-${{ matrix.project }}-${{ matrix.api-level }}.mov diff --git a/record_emulator.sh b/record_emulator.sh new file mode 100755 index 000000000..21c2beda2 --- /dev/null +++ b/record_emulator.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -x +echo "Record to $1" +adb shell "while true; do screenrecord --output-format=h264 -; done" | ffmpeg -i - $1