From bdc3f1560f672e7c148a55d685bc0d15d6fc5abb Mon Sep 17 00:00:00 2001 From: Gergely Hegedus Date: Wed, 13 Apr 2022 13:07:18 +0300 Subject: [PATCH 1/3] Issue#74 Attempt to integrate testing on emulator Using [AndroidEmulator Runner Action](https://github.com/ReactiveCircus/android-emulator-runner) --- .github/workflows/pull-request-jobs.yml | 51 +++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/.github/workflows/pull-request-jobs.yml b/.github/workflows/pull-request-jobs.yml index 82508f3..0e888e9 100644 --- a/.github/workflows/pull-request-jobs.yml +++ b/.github/workflows/pull-request-jobs.yml @@ -73,3 +73,54 @@ jobs: name: JVM Test Results path: ./**/build/reports/tests/**/index.html retention-days: 1 + + run-tests-on-emulator: + runs-on: macos-latest + strategy: + matrix: + api-level: [ 21, 30 ] + fail-fast: false + steps: + - name: checkout + uses: actions/checkout@v3 + - name: Setup Java + uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: '11' + - name: Gradle cache + uses: gradle/gradle-build-action@v2 + - name: AVD cache + uses: actions/cache@v3 + 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: + arch: 'x86_64' + api-level: ${{ matrix.api-level }} + 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 Android Tests + uses: reactivecircus/android-emulator-runner@v2 + with: + arch: 'x86_64' + api-level: ${{ matrix.api-level }} + 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 connectedDebugAndroidTest + - name: Upload Test Results + uses: actions/upload-artifact@v2 + if: always() + with: + name: Emulator-Test-Results-${{ matrix.api-level }} + path: ./**/build/reports/androidTests/**/*.html + retention-days: 1 From 78e88b541831cb533fc01ed4bced7afc9e019294 Mon Sep 17 00:00:00 2001 From: Gergely Hegedus Date: Wed, 13 Apr 2022 20:06:06 +0300 Subject: [PATCH 2/3] Fix Resource loading above API 25 on SplashScreen Compose --- .../test/showcase/compose/screen/splash/SplashScreen.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/fnives/test/showcase/compose/screen/splash/SplashScreen.kt b/app/src/main/java/org/fnives/test/showcase/compose/screen/splash/SplashScreen.kt index 7030d4d..65cec1f 100644 --- a/app/src/main/java/org/fnives/test/showcase/compose/screen/splash/SplashScreen.kt +++ b/app/src/main/java/org/fnives/test/showcase/compose/screen/splash/SplashScreen.kt @@ -1,5 +1,7 @@ package org.fnives.test.showcase.compose.screen.splash +import android.os.Build.VERSION +import android.os.Build.VERSION_CODES import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.layout.Box @@ -16,8 +18,13 @@ import org.fnives.test.showcase.R @Composable fun SplashScreen() { Box(Modifier.fillMaxSize().background(colorResource(R.color.purple_700)), contentAlignment = Alignment.Center) { + val resourceId = if (VERSION.SDK_INT >= VERSION_CODES.N) { + R.drawable.ic_launcher_foreground + } else { + R.mipmap.ic_launcher_round + } Image( - painter = painterResource(R.mipmap.ic_launcher_round), + painter = painterResource(resourceId), contentDescription = null, modifier = Modifier.size(120.dp) ) From 757da9da557c27b5eea6e2397773d7f3b18fd657 Mon Sep 17 00:00:00 2001 From: Gergely Hegedus Date: Wed, 13 Apr 2022 20:06:19 +0300 Subject: [PATCH 3/3] Fix detekt report path on CI --- .github/workflows/pull-request-jobs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull-request-jobs.yml b/.github/workflows/pull-request-jobs.yml index 0e888e9..35a74f1 100644 --- a/.github/workflows/pull-request-jobs.yml +++ b/.github/workflows/pull-request-jobs.yml @@ -31,7 +31,7 @@ jobs: if: always() with: name: Detekt Results - path: build/reports/detekt.html + path: ./build/reports/detekt/detekt.html retention-days: 1 - name: Run ktlint run: ./gradlew ktlintCheck