From 99a2f9f87f98793e255612f1c79ee1e39c35e691 Mon Sep 17 00:00:00 2001 From: Tijl Houtbeckers Date: Fri, 24 Mar 2023 13:35:04 +0100 Subject: [PATCH] tweak video recording and emulator version #639 [skip ci] --- .github/workflows/emulator.yaml | 46 ++++++++++++++++++++++--------- date-time-picker/build.gradle.kts | 8 ++++++ record_emulator.sh | 4 +++ 3 files changed, 45 insertions(+), 13 deletions(-) create mode 100755 record_emulator.sh diff --git a/.github/workflows/emulator.yaml b/.github/workflows/emulator.yaml index d065b29c8..adc62ee4f 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.v9-${{ 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 - script: echo "Generated AVD snapshot for caching." + channel: canary + script: ./check_emulator.sh - - 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 --no-configuration-cache :${{ 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,39 @@ 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 --no-configuration-cache :${{ matrix.project }}:recordVideo :${{ matrix.project }}:connectedDebugAndroidTest - 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: rename video + if: always() && inputs.video + run: mv video.mp4 recording-${{ matrix.project }}-${{ matrix.api-level }}.mp4 - 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 }} - path: recording-${{ matrix.project }}-${{ matrix.api-level }}.mov + name: recording-${{ matrix.project }}-${{ matrix.api-level }} + path: recording-${{ matrix.project }}-${{ matrix.api-level }}.mp4 diff --git a/date-time-picker/build.gradle.kts b/date-time-picker/build.gradle.kts index f2f010af7..863ab02a7 100644 --- a/date-time-picker/build.gradle.kts +++ b/date-time-picker/build.gradle.kts @@ -5,6 +5,7 @@ plugins { id("com.android.library") id("org.jetbrains.dokka") id("org.jlleitschuh.gradle.ktlint") + id("com.github.psxpaul.execfork") version "0.2.2" } publishableComponent() @@ -13,6 +14,13 @@ dependencies { androidTestImplementationDependency(Dependencies.AndroidX.Activity.Ktx) } +task("recordVideo") { + executable = "./record_emulator.sh" + args.add("video.mp4") + workingDir = project.rootProject.rootDir + waitForOutput = "FFmpeg developers" +} + kotlin { sourceSets { getByName("commonMain") { 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