From f1238977d0ea4250eb90c43af3914a6bbaabfdfb Mon Sep 17 00:00:00 2001 From: Steve Soltys Date: Tue, 12 Sep 2023 22:17:39 +0000 Subject: [PATCH 1/5] Add end-to-end emulator test running on CI --- .cirrus.yml | 53 +++++++ .idea/runConfigurations/app_emulator.xml | 6 +- app/build.gradle | 23 ++- app/development/scripts/clear_app_data.sh | 22 +++ app/development/scripts/provision_emulator.sh | 1 - .../seedvault/KoinInstrumentationTestApp.kt | 35 +++++ .../KoinInstrumentationTestRunner.kt | 20 +++ .../com/stevesoltys/seedvault/PluginTest.kt | 2 + .../seedvault/e2e/BackupRestoreTest.kt | 139 ++++++++++++++++++ .../seedvault/e2e/LargeTestBase.kt | 110 ++++++++++++++ .../seedvault/e2e/screen/UiDeviceScreen.kt | 20 +++ .../seedvault/e2e/screen/impl/BackupScreen.kt | 12 ++ .../e2e/screen/impl/DocumentPickerScreen.kt | 17 +++ .../e2e/screen/impl/RecoveryCodeScreen.kt | 15 ++ .../e2e/screen/impl/RestoreScreen.kt | 12 ++ .../plugins/saf/DocumentsStorageTest.kt | 2 + .../transport/backup/PackageServiceTest.kt | 2 + .../java/com/stevesoltys/seedvault/App.kt | 26 ++-- gradle.properties | 5 +- gradle/dependencies.gradle | 2 +- settings.gradle | 15 ++ 21 files changed, 519 insertions(+), 20 deletions(-) create mode 100644 .cirrus.yml create mode 100755 app/development/scripts/clear_app_data.sh create mode 100644 app/src/androidTest/java/com/stevesoltys/seedvault/KoinInstrumentationTestApp.kt create mode 100644 app/src/androidTest/java/com/stevesoltys/seedvault/KoinInstrumentationTestRunner.kt create mode 100644 app/src/androidTest/java/com/stevesoltys/seedvault/e2e/BackupRestoreTest.kt create mode 100644 app/src/androidTest/java/com/stevesoltys/seedvault/e2e/LargeTestBase.kt create mode 100644 app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/UiDeviceScreen.kt create mode 100644 app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/impl/BackupScreen.kt create mode 100644 app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/impl/DocumentPickerScreen.kt create mode 100644 app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/impl/RecoveryCodeScreen.kt create mode 100644 app/src/androidTest/java/com/stevesoltys/seedvault/e2e/screen/impl/RestoreScreen.kt diff --git a/.cirrus.yml b/.cirrus.yml new file mode 100644 index 00000000..d2f6c6c1 --- /dev/null +++ b/.cirrus.yml @@ -0,0 +1,53 @@ +container: + image: ghcr.io/cirruslabs/android-sdk:33 + kvm: true + cpu: 8 + memory: 16G + +check_android_task: + skip: "!changesInclude('.cirrus.yml', '*.gradle', '*.gradle.kts', '**/*.gradle', '**/*.gradle.kts', '*.properties', '**/*.properties', '**/*.kt', '**/*.xml')" + create_avd_script: + start_avd_background_script: + sdkmanager --install "system-images;android-33;google_apis;x86_64"; + echo no | avdmanager create avd -n seedvault -k "system-images;android-33;google_apis;x86_64"; + $ANDROID_HOME/emulator/emulator + -avd seedvault + -no-audio + -no-boot-anim + -gpu swiftshader_indirect + -no-snapshot + -no-window + -writable-system; + provision_avd_background_script: + adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'; + wget --output-document etar.apk https://f-droid.org/repo/ws.xsoh.etar_35.apk; + adb install etar.apk + + adb root; + sleep 5; + adb remount; + adb reboot; + adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'; + adb root; + sleep 5; + adb remount; + assemble_release_script: + ./gradlew :app:assembleRelease :app:assembleAndroidTest + install_app_script: + timeout 180s bash -c 'while [[ -z $(adb shell mount | grep "/system " | grep "(rw,") ]]; do sleep 1; done;'; + adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'; + adb shell mkdir -p /system/priv-app/Seedvault; + adb push app/build/outputs/apk/release/app-release.apk /system/priv-app/Seedvault/Seedvault.apk; + adb push permissions_com.stevesoltys.seedvault.xml /system/etc/permissions/privapp-permissions-seedvault.xml; + adb push allowlist_com.stevesoltys.seedvault.xml /system/etc/sysconfig/allowlist-seedvault.xml; + adb shell bmgr enable true; + adb shell bmgr transport com.stevesoltys.seedvault.transport.ConfigurableBackupTransport; + adb reboot; + adb wait-for-device shell 'while [[ -z $(getprop sys.boot_completed) ]]; do sleep 1; done;'; + run_large_tests_script: ./gradlew -Pinstrumented_test_size=large :app:connectedAndroidTest + run_medium_tests_script: ./gradlew -Pinstrumented_test_size=medium :app:connectedAndroidTest + always: + pull_screenshots_script: + adb pull /sdcard/Documents/screenshots + screenshots_artifacts: + path: "screenshots/**/*.png" diff --git a/.idea/runConfigurations/app_emulator.xml b/.idea/runConfigurations/app_emulator.xml index 0579cb25..60f48b57 100644 --- a/.idea/runConfigurations/app_emulator.xml +++ b/.idea/runConfigurations/app_emulator.xml @@ -17,7 +17,7 @@