diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 43f8f1a39a..3cafab140c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -86,56 +86,60 @@ jobs: - uses: gradle/gradle-build-action@v2 with: cache-read-only: ${{ env.MAIN_BRANCH != 'true' }} - - name: Pre build sources before launching emulator - run: ./gradlew compileDebugAndroidTestSources - - name: AVD cache - uses: actions/cache@v3 - id: avd-cache + - name: Setup Android SDK + uses: android-actions/setup-android@v2 + - name: Instrumentation tests + # Flags from https://github.com/android/nowinandroid/blob/main/.github/workflows/Build.yaml + run: > + adb logcat > logcat.out & + ./gradlew packageDebugAndroidTest && + ./gradlew cleanManagedDevices --unused-only && + ./gradlew uiTestsDeviceDebugAndroidTest + -Dorg.gradle.workers.max=1 + -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" + -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true + - name: Upload failed instrumentation artifacts + if: failure() + uses: actions/upload-artifact@v2 with: + name: instrumentation-failures path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-29 - - name: Create AVD and generate snapshot for caching - if: steps.avd-cache.outputs.cache-hit != 'true' - uses: reactivecircus/android-emulator-runner@v2 + **/build/reports + logcat.out + + screenshot-tests: + name: Screenshot tests + runs-on: macOS-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 with: - # Use API 29 https://github.com/ReactiveCircus/android-emulator-runner/issues/222 - api-level: 29 - arch: x86_64 - 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: Instrumentation tests - uses: reactivecircus/android-emulator-runner@v2 + distribution: 'zulu' + java-version: '17' + - uses: gradle/wrapper-validation-action@v1 + - uses: gradle/gradle-build-action@v2 with: - # Use API 29 https://github.com/ReactiveCircus/android-emulator-runner/issues/222 - api-level: 29 - arch: x86_64 - 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: | - adb logcat > logcat.out & - ./gradlew connectedCheck - - name: Managed device clean-up - run: > - ./gradlew cleanManagedDevices --unused-only + cache-read-only: ${{ env.MAIN_BRANCH != 'true' }} + - name: Setup Android SDK + uses: android-actions/setup-android@v2 - name: Screenshot tests - # Flags from https://github.com/android/nowinandroid/blob/main/.github/workflows/AndroidCIWithGmd.yaml + # Flags from https://github.com/android/nowinandroid/blob/main/.github/workflows/Build.yaml run: > + adb logcat > logcat.out & + ./gradlew cleanManagedDevices --unused-only && ./gradlew screenshotTestsCompareBaseline -Dorg.gradle.workers.max=1 -Pandroid.testoptions.manageddevices.emulator.gpu="swiftshader_indirect" -Pandroid.experimental.testOptions.managedDevices.emulator.showKernelLogging=true - - name: Upload failed instrumentation artifacts + - name: Upload failed screenshot artifacts if: failure() uses: actions/upload-artifact@v2 with: - name: instrumentation-failures + name: screenshot-failures path: | **/build/reports + **/build/outputs/managed_device_android_test_additional_output logcat.out check-documentation: diff --git a/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidCommonConfiguration.kt b/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidCommonConfiguration.kt index 6428abbdc6..8ec6d40e71 100644 --- a/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidCommonConfiguration.kt +++ b/plugins/convention/src/main/kotlin/com/bumble/appyx/android/AndroidCommonConfiguration.kt @@ -2,6 +2,7 @@ package com.bumble.appyx.android import com.android.build.api.dsl.CommonExtension import com.android.build.api.dsl.DefaultConfig +import com.android.build.api.dsl.ManagedVirtualDevice import com.android.build.api.variant.AndroidComponentsExtension import com.bumble.appyx.versionCatalog import org.gradle.api.JavaVersion @@ -9,6 +10,7 @@ import org.gradle.api.Project import org.gradle.api.artifacts.VersionCatalog import org.gradle.api.artifacts.VersionCatalogsExtension import org.gradle.kotlin.dsl.getByType +import org.gradle.kotlin.dsl.register internal inline fun < reified ConfigT : DefaultConfig, @@ -77,6 +79,12 @@ private fun CommonExtension<*, *, DefaultConfig unitTests.all { it.useJUnitPlatform() } + managedDevices.devices.register("uiTestsDevice") { + device = "Pixel" + @Suppress("MagicNumber") + apiLevel = 30 + systemImageSource = "aosp-atd" // headless mode, do not use for screenshots. + } } packagingOptions {