Skip to content

Commit

Permalink
ci: change to ubuntu kvm and set gradle cache/avd
Browse files Browse the repository at this point in the history
  • Loading branch information
ujizin committed Sep 9, 2024
1 parent 8ea3f4d commit 3dc813e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 8 deletions.
48 changes: 42 additions & 6 deletions .github/workflows/android_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,26 @@ on:

jobs:
test:
runs-on: macos-latest
runs-on: ubuntu-latest
strategy:
matrix:
api-level: [21, 26, 31]
api-level: [21, 26, 31, 34]
include:
- api-level: 21
arch: 'x86'
target: default
- api-level: 26
arch: 'x86_64'
target: default
- api-level: 31
arch: 'x86_64'
target: google_apis
- api-level: 34
arch: 'x86_64'
target: google_apis
steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: set up JDK 17
uses: actions/setup-java@v3
Expand All @@ -31,15 +37,45 @@ jobs:
- name: make gradlew executable
run: chmod +x ./gradlew

- name: gradle cache
uses: gradle/gradle-build-action@v2
- name: Enable KVM group perms
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
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 }}

- 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 }}
arch: ${{ matrix.arch }}
target: ${{ matrix.target }}
force-avd-creation: false
emulator-options: -no-window -no-boot-anim -camera-back emulated -camera-front emulated -gpu swiftshader_indirect
disable-animations: false
script: echo "Generated AVD snapshot for caching."

- name: run android tests
uses: reactivecircus/android-emulator-runner@v2
env:
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 60
with:
api-level: ${{ matrix.api-level }}
target: ${{ matrix.target }}
arch: ${{ matrix.arch }}
disable-animations: true
force-avd-creation: false
emulator-options: -no-snapshot -no-window -no-boot-anim -camera-back emulated -camera-front emulated -gpu swiftshader_indirect
emulator-options: -no-snapshot-save -no-window -no-boot-anim -no-metrics -camera-back emulated -camera-front emulated -gpu swiftshader_indirect
script: ./gradlew connectedAndroidTest --stacktrace
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ internal class ExposureCompensationTest: CameraTest() {
exposureCompensation.value = cameraState.minExposure

runOnIdle {
if (!cameraState.isExposureSupported) return@runOnIdle

assertEquals(cameraState.minExposure, currentExposure)
assertEquals(exposureCompensation.value, currentExposure)
}
Expand All @@ -39,6 +41,8 @@ internal class ExposureCompensationTest: CameraTest() {
exposureCompensation.value = cameraState.maxExposure

runOnIdle {
if (!cameraState.isExposureSupported) return@runOnIdle

assertEquals(cameraState.maxExposure, currentExposure)
assertEquals(exposureCompensation.value, currentExposure)
}
Expand All @@ -52,6 +56,8 @@ internal class ExposureCompensationTest: CameraTest() {
exposureCompensation.value = Int.MAX_VALUE

runOnIdle {
if (!cameraState.isExposureSupported) return@runOnIdle

assertNotEquals(cameraState.maxExposure, currentExposure)
assertNotEquals(exposureCompensation.value, currentExposure)
assertEquals(cameraState.initialExposure, currentExposure)
Expand All @@ -67,4 +73,4 @@ internal class ExposureCompensationTest: CameraTest() {
exposureCompensation = exposureCompensation.value
)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,9 @@ public class CameraState(context: Context) {
}

private fun setExposureCompensation(exposureCompensation: Int) {
controller.cameraControl?.setExposureCompensationIndex(exposureCompensation)
if (exposureCompensation in minExposure..maxExposure) {
controller.cameraControl?.setExposureCompensationIndex(exposureCompensation)
}
}

/**
Expand Down

0 comments on commit 3dc813e

Please sign in to comment.