diff --git a/.github/scripts/run_tests.sh b/.github/scripts/run_tests.sh index b74705450..e091cbad1 100755 --- a/.github/scripts/run_tests.sh +++ b/.github/scripts/run_tests.sh @@ -1,3 +1,6 @@ +adb reboot +adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;' + adb root sleep 5 adb remount @@ -14,20 +17,22 @@ echo "Setting Seedvault transport..." sleep 10 adb shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport -wget --quiet https://github.com/seedvault-app/seedvault-test-data/releases/download/1/backup.tar.gz -adb shell mkdir -p /sdcard/seedvault_baseline -adb push backup.tar.gz /sdcard/seedvault_baseline -adb wait-for-device -adb shell tar -xzf /sdcard/seedvault_baseline/backup.tar.gz --directory=/sdcard/seedvault_baseline -adb shell rm /sdcard/seedvault_baseline/backup.tar.gz - large_test_exit_code=0 ./gradlew --stacktrace -Pinstrumented_test_size=large :app:connectedAndroidTest || large_test_exit_code=$? +adb pull /sdcard/seedvault_test_results + +if [ "$large_test_exit_code" -ne 0 ]; then + echo 'Large tests failed.' + exit 1 +fi + medium_test_exit_code=0 ./gradlew --stacktrace -Pinstrumented_test_size=medium :app:connectedAndroidTest || medium_test_exit_code=$? -adb pull /sdcard/seedvault_test_results +if [ "$medium_test_exit_code" -ne 0 ]; then + echo 'Medium tests failed.' + exit 1 +fi -[ -n "$large_test_exit_code" ] && [ "$large_test_exit_code" -ne 0 ] && { echo 'Large test failed.'; exit 1; } -[ -n "$medium_test_exit_code" ] && [ "$medium_test_exit_code" -ne 0 ] && { echo 'Medium test failed.'; exit 1; } +exit 0 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 82ca5c423..52dd750b7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,10 @@ name: Build on: [push, pull_request] +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + jobs: build: name: Build diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 700f45eb8..c31f3174d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,8 @@ concurrency: jobs: instrumentation_tests: runs-on: macos-11 + if: github.repository == 'seedvault-app/seedvault' + timeout-minutes: 80 strategy: fail-fast: false matrix: @@ -35,51 +37,29 @@ jobs: java-version: '17' cache: 'gradle' - - name: AVD cache - uses: actions/cache@v3 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-${{ matrix.emulator_type }}-${{ matrix.android_target }} - - name: Build Release APK run: ./gradlew :app:assembleRelease - - name: Create AVD snapshot - if: steps.avd-cache.outputs.cache-hit != 'true' - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: ${{ matrix.android_target }} - target: ${{ matrix.emulator_type }} - arch: x86_64 - force-avd-creation: false - emulator-options: -writable-system -no-snapshot-load -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: true - script: | - ./app/development/scripts/provision_emulator.sh "test" "system-images;android-${{ matrix.android_target }};${{ matrix.emulator_type }};x86_64" - echo "Generated AVD snapshot for caching." - - name: Assemble tests run: ./gradlew :app:assembleAndroidTest - name: Run tests - uses: reactivecircus/android-emulator-runner@v2 + uses: Wandalen/wretry.action@v1.3.0 with: - api-level: ${{ matrix.android_target }} - target: ${{ matrix.emulator_type }} - arch: x86_64 - force-avd-creation: false - emulator-options: -writable-system -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - profile: pixel_6a - heap-size: '512M' - ram-size: '4096M' - disk-size: '14G' - sdcard-path-or-size: '4096M' - cores: 3 - disable-animations: false - script: ./.github/scripts/run_tests.sh + attempt_limit: 3 + action: reactivecircus/android-emulator-runner@v2 + with: | + api-level: ${{ matrix.android_target }} + target: ${{ matrix.emulator_type }} + arch: x86_64 + force-avd-creation: true + emulator-options: -cores 3 -writable-system -no-snapshot-load -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disk-size: '14G' + sdcard-path-or-size: '4096M' + disable-animations: true + script: | + ./app/development/scripts/provision_emulator.sh "test" "system-images;android-${{ matrix.android_target }};${{ matrix.emulator_type }};x86_64" + ./.github/scripts/run_tests.sh - name: Upload test results if: always() diff --git a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/UiDeviceScreen.kt b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/UiDeviceScreen.kt index fdcdd67b9..2b1d9aac0 100644 --- a/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/UiDeviceScreen.kt +++ b/app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/UiDeviceScreen.kt @@ -11,6 +11,10 @@ import java.lang.Thread.sleep abstract class UiDeviceScreen { + companion object { + private const val SELECTOR_TIMEOUT = 180000L + } + operator fun invoke(function: T.() -> Unit) { function.invoke(this as T) } @@ -18,8 +22,12 @@ abstract class UiDeviceScreen { fun UiObject.scrollTo( scrollSelector: UiSelector = UiSelector().className(ScrollView::class.java), ): UiObject { - UiScrollable(scrollSelector).scrollIntoView(this) - waitForExists(15000) + waitForExists(SELECTOR_TIMEOUT) + + val uiScrollable = UiScrollable(scrollSelector) + uiScrollable.waitForExists(SELECTOR_TIMEOUT) + uiScrollable.scrollIntoView(this) + sleep(2000) return this } @@ -32,6 +40,6 @@ abstract class UiDeviceScreen { private fun device() = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) .also { - Configurator.getInstance().waitForSelectorTimeout = 60000 + Configurator.getInstance().waitForSelectorTimeout = SELECTOR_TIMEOUT } }