Skip to content

Commit

Permalink
ci: Implement more redudency for AVD tests (#327)
Browse files Browse the repository at this point in the history
* Update build.yml

* fix DELETE_FAILED_INTERNAL_ERROR on adb uninstall

* cleanup and save cache on failure too

* Update build.yml
  • Loading branch information
ShootingKing-AM authored Apr 14, 2024
1 parent a853534 commit c930868
Showing 1 changed file with 53 additions and 137 deletions.
190 changes: 53 additions & 137 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,61 +234,28 @@ jobs:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ env.EMU_TARGET }}-${{ env.EMU_PROFILE }}-${{ env.EMU_AVD_NAME }}
key: avd-${{ matrix.api-level }}-${{ env.EMU_TARGET }}-${{ env.EMU_PROFILE }}-${{ env.EMU_AVD_NAME }} # Make sure you have the same key while saving in below step

# Create AVD with some redundancy - 3 Checks
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
id: avd_create_1
continue-on-error: true
with:
working-directory: ${{env.GRADLE_DIR}}
api-level: ${{ matrix.api-level }}
target: ${{ env.EMU_TARGET }}
force-avd-creation: false
emulator-options: ${{ env.EMU_OPTS }}
disable-animations: false
profile: ${{ env.EMU_PROFILE }}
avd-name: ${{ env.EMU_AVD_NAME }}
emulator-boot-timeout: ${{ env.EMU_TIMEOUT }}
script: echo "Generated AVD snapshot for caching."

- name: create AVD and generate snapshot for caching try#2
if: steps.avd-cache.outputs.cache-hit != 'true' && steps.avd_create_1.outcome == 'failure'
uses: reactivecircus/android-emulator-runner@v2
id: avd_create_2
continue-on-error: true
with:
working-directory: ${{env.GRADLE_DIR}}
api-level: ${{ matrix.api-level }}
target: ${{ env.EMU_TARGET }}
force-avd-creation: false
emulator-options: ${{ env.EMU_OPTS }}
disable-animations: false
profile: ${{ env.EMU_PROFILE }}
avd-name: ${{ env.EMU_AVD_NAME }}
emulator-boot-timeout: ${{ env.EMU_TIMEOUT }}
script: echo "Generated AVD snapshot for caching."
id: avd_create
uses: Wandalen/[email protected]
with:
action: reactivecircus/android-emulator-runner@v2
attempt_limit: 5
attempt_delay: 1000 # ms
with: |
working-directory: ${{env.GRADLE_DIR}}
api-level: ${{ matrix.api-level }}
target: ${{ env.EMU_TARGET }}
force-avd-creation: false
emulator-options: ${{ env.EMU_OPTS }}
disable-animations: false
profile: ${{ env.EMU_PROFILE }}
avd-name: ${{ env.EMU_AVD_NAME }}
emulator-boot-timeout: ${{ env.EMU_TIMEOUT }}
script: echo "Generated AVD snapshot for caching."
- name: create AVD and generate snapshot for caching try#3
if: steps.avd-cache.outputs.cache-hit != 'true' && steps.avd_create_2.outcome == 'failure'
uses: reactivecircus/android-emulator-runner@v2
id: avd_create_3
# continue-on-error: true # Fail, if failed in the 3rd try
with:
working-directory: ${{env.GRADLE_DIR}}
api-level: ${{ matrix.api-level }}
target: ${{ env.EMU_TARGET }}
force-avd-creation: false
emulator-options: ${{ env.EMU_OPTS }}
disable-animations: false
profile: ${{ env.EMU_PROFILE }}
avd-name: ${{ env.EMU_AVD_NAME }}
emulator-boot-timeout: ${{ env.EMU_TIMEOUT }}
script: echo "Generated AVD snapshot for caching."
# Redundancy End

- name: Prepare deps
shell: bash
run: |
Expand Down Expand Up @@ -334,85 +301,33 @@ jobs:
# brew install ffmpeg
# ffmpeg -f avfoundation -i 0 -t 840 out_API$SUFFIX.mov &

## Create AVD with some redundancy - 3 Checks
## Run tests with some redundancy - 5 Checks
- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
id: avd_run_1
continue-on-error: true
with:
working-directory: ${{env.GRADLE_DIR}}
api-level: ${{ matrix.api-level }}
target: ${{ env.EMU_TARGET }}
force-avd-creation: false
emulator-options: ${{ env.EMU_OPTS }}
disable-animations: true
profile: ${{ env.EMU_PROFILE }}
avd-name: ${{ env.EMU_AVD_NAME }}
emulator-boot-timeout: ${{ env.EMU_TIMEOUT }}
script: |
adb shell settings put secure immersive_mode_confirmations confirmed
adb uninstall viritualisres.phonevr.test
adb uninstall viritualisres.phonevr
adb shell "logcat -b all -v color" &
./gradlew connectedCheck --warning-mode=all --stacktrace -Dorg.gradle.java.home=${{env.JAVA_HOME}}
# adb logcat -b all > logcat.log
jobs -p | xargs kill
# adb bugreport bugreport.zip # hangs indef here
- name: Run tests try#2
uses: reactivecircus/android-emulator-runner@v2
if: steps.avd_run_1.outcome == 'failure'
id: avd_run_2
continue-on-error: true
with:
working-directory: ${{env.GRADLE_DIR}}
api-level: ${{ matrix.api-level }}
target: ${{ env.EMU_TARGET }}
force-avd-creation: false
emulator-options: ${{ env.EMU_OPTS }}
disable-animations: true
profile: ${{ env.EMU_PROFILE }}
avd-name: ${{ env.EMU_AVD_NAME }}
emulator-boot-timeout: ${{ env.EMU_TIMEOUT }}
script: |
adb shell settings put secure immersive_mode_confirmations confirmed
adb uninstall viritualisres.phonevr.test
adb uninstall viritualisres.phonevr
adb shell "logcat -b all -v color" &
./gradlew connectedCheck --warning-mode=all --stacktrace -Dorg.gradle.java.home=${{env.JAVA_HOME}}
# adb logcat -b all > logcat.log
jobs -p | xargs kill
# adb bugreport bugreport.zip # hangs indef here
- name: Run tests try#3
uses: reactivecircus/android-emulator-runner@v2
if: steps.avd_run_2.outcome == 'failure'
id: avd_run_3
# continue-on-error: true # Fail if even fail the 3rd try
with:
working-directory: ${{env.GRADLE_DIR}}
api-level: ${{ matrix.api-level }}
target: ${{ env.EMU_TARGET }}
force-avd-creation: false
emulator-options: ${{ env.EMU_OPTS }}
disable-animations: true
profile: ${{ env.EMU_PROFILE }}
avd-name: ${{ env.EMU_AVD_NAME }}
emulator-boot-timeout: ${{ env.EMU_TIMEOUT }}
script: |
adb shell settings put secure immersive_mode_confirmations confirmed
adb uninstall viritualisres.phonevr.test
adb uninstall viritualisres.phonevr
adb shell "logcat -b all -v color" &
./gradlew connectedCheck --warning-mode=all --stacktrace -Dorg.gradle.java.home=${{env.JAVA_HOME}}
# adb logcat -b all > logcat.log
jobs -p | xargs kill
# adb bugreport bugreport.zip # hangs indef here
## Redundancy End

uses: Wandalen/[email protected]
with:
action: reactivecircus/android-emulator-runner@v2
attempt_limit: 5
attempt_delay: 1000 # ms
with: |
working-directory: ${{env.GRADLE_DIR}}
api-level: ${{ matrix.api-level }}
target: ${{ env.EMU_TARGET }}
force-avd-creation: false
emulator-options: ${{ env.EMU_OPTS }}
disable-animations: true
profile: ${{ env.EMU_PROFILE }}
avd-name: ${{ env.EMU_AVD_NAME }}
emulator-boot-timeout: ${{ env.EMU_TIMEOUT }}
script: |
adb shell settings put secure immersive_mode_confirmations confirmed
./gradlew :app:uninstallAll
adb shell "logcat -b all -v color" &
./gradlew connectedCheck --warning-mode=all --stacktrace -Dorg.gradle.java.home=${{env.JAVA_HOME}}
# adb logcat -b all > logcat.log
jobs -p | xargs kill
# adb bugreport bugreport.zip # hangs indef here
- name: Shutdown PVR ADB-Telnet Server and log
working-directory: ${{env.GRADLE_DIR}}/app/src/androidTest/java/viritualisres/phonevr/utils/
if: always()
Expand Down Expand Up @@ -529,14 +444,15 @@ jobs:
edit-mode: replace
issue-number: ${{ github.event.number }}

# - name: Save AVD Cache
# uses: actions/cache/save@v3
# if: always() && !steps.avd-cache.outputs.cache-hit
# with:
# path: |
# ~/.android/avd/*
# ~/.android/adb*
# key: avd-${{ matrix.api-level }}
- name: Save AVD Cache
uses: actions/cache/save@v4
if: always() && !steps.avd-cache.outputs.cache-hit && steps.avd_create.outcome == 'success'
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ env.EMU_TARGET }}-${{ env.EMU_PROFILE }}-${{ env.EMU_AVD_NAME }} # key has to be same as in restore in previous step

# Test_APK_Linux:
# name: Test APK Linux
# runs-on: ubuntu-latest
Expand Down

0 comments on commit c930868

Please sign in to comment.