Skip to content

Commit

Permalink
Cache AVD to improve instrumented tests time (#786)
Browse files Browse the repository at this point in the history
## Proposed Changes

- Apply cache suggestions from
https://github.com/ReactiveCircus/android-emulator-runner to improve the
instrumented tests time. It's currently taking 9-10 minutes.
- Added more `setup-gradle` steps to further use gradle cache too. Those
need to be merged to `master` to work.
  • Loading branch information
sdsantos committed Jul 26, 2024
1 parent 453191b commit 90544b5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ jobs:
- name: checkout
uses: actions/checkout@v4

- name: Gradle cache
uses: gradle/actions/setup-gradle@v3

- name: Build `StableFullRelease` and `StableFdroidRelease` variants
run: ./gradlew build${{ matrix.version }} && ./gradlew clean

Expand All @@ -54,6 +57,9 @@ jobs:
- name: checkout
uses: actions/checkout@v4

- name: Gradle cache
uses: gradle/actions/setup-gradle@v3

- name: Run unit tests
run: ./gradlew testOoniStableFullRelease

Expand Down Expand Up @@ -90,6 +96,32 @@ jobs:
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Gradle cache
uses: gradle/actions/setup-gradle@v3

- name: AVD cache
uses: actions/cache@v4
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}-${{ matrix.target }}

- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: x86_64
profile: Nexus 6
ram-size: 4096M
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: Run instrumented tests
uses: reactivecircus/android-emulator-runner@v2
with:
Expand All @@ -98,6 +130,9 @@ jobs:
arch: x86_64
profile: Nexus 6
ram-size: 4096M
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew connectedOoniStableFullDebugAndroidTest

- name: uploads test reports
Expand Down Expand Up @@ -153,6 +188,9 @@ jobs:
java-version: '17'
distribution: 'temurin'

- name: Gradle cache
uses: gradle/actions/setup-gradle@v3

- name: Assemble APKs
if: success() && steps.get_issue_number.outputs.result
run: ./gradlew assemble${{ matrix.version }}
Expand Down

0 comments on commit 90544b5

Please sign in to comment.