Skip to content

Commit

Permalink
tweak video recording and emulator version #639
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
thoutbeckers committed Mar 27, 2023
1 parent 00a9315 commit 0a44387
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
39 changes: 28 additions & 11 deletions .github/workflows/emulator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -65,42 +65,59 @@ 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
with:
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
4 changes: 4 additions & 0 deletions record_emulator.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0a44387

Please sign in to comment.