Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache AVD to improve instrumented tests time #786

Merged
merged 3 commits into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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