Skip to content

Commit

Permalink
chore(e2e): Move emulator setup back to CI
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Niedermann <info@niedermann.it>
Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
  • Loading branch information
stefan-niedermann authored and AndyScherzinger committed Jan 19, 2024
1 parent 1121816 commit 33c0ff7
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 35 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ jobs:
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: |
adb shell pm uninstall -k --user 0 com.nextcloud.android.beta || true
wget -q https://download.nextcloud.com/android/dev/latest.apk
adb install latest.apk
adb shell pm grant com.nextcloud.android.beta android.permission.READ_EXTERNAL_STORAGE
adb logcat -c || true
adb logcat -s "E2E" -v color &
adb logcat *:I -v color &
./gradlew :sample:connectedDebugAndroidTest
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ buildscript {
}
}

plugins {
id "de.undercouch.download" version "5.4.0"
}
//plugins {
// id "de.undercouch.download" version "5.4.0"
//}

allprojects {
repositories {
Expand Down
59 changes: 27 additions & 32 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
import com.android.ddmlib.AndroidDebugBridge
import com.android.ddmlib.NullOutputReceiver

import java.util.concurrent.TimeUnit

apply plugin: 'com.android.application'

android {
Expand Down Expand Up @@ -33,33 +28,33 @@ android {
}
}

task downloadNextcloudApk(type: Download) {
src 'https://download.nextcloud.com/android/dev/latest.apk'
dest new File(buildDir, 'latest.apk')
overwrite true
}

task setupNextcloudEnvironment(dependsOn: downloadNextcloudApk) {
def bridge = AndroidDebugBridge.createBridge(android.adbExecutable.path, false, 10, TimeUnit.SECONDS)
doLast {
bridge.devices.each { device ->
println "Uninstall Nextcloud apk from ${device.name}"
device.uninstallPackage("com.nextcloud.android.beta")

println "Install Nextcloud apk on ${device.name}"
device.installPackage(new File(buildDir, 'latest.apk').getAbsolutePath(), true)

println "Grant permissions to Nextcloud"
device.executeShellCommand("pm grant com.nextcloud.android.beta android.permission.READ_EXTERNAL_STORAGE", NullOutputReceiver.receiver, 3, TimeUnit.SECONDS)
}
}
}

tasks.whenTaskAdded { taskItem ->
if (taskItem.name.contains("connected") && taskItem.name.endsWith("AndroidTest")) {
taskItem.dependsOn setupNextcloudEnvironment
}
}
//task downloadNextcloudApk(type: Download) {
// src 'https://download.nextcloud.com/android/dev/latest.apk'
// dest new File(buildDir, 'latest.apk')
// overwrite true
//}
//
//task setupNextcloudEnvironment(dependsOn: downloadNextcloudApk) {
// def bridge = AndroidDebugBridge.createBridge(android.adbExecutable.path, false, 10, TimeUnit.SECONDS)
// doLast {
// bridge.devices.each { device ->
// println "Uninstall Nextcloud apk from ${device.name}"
// device.uninstallPackage("com.nextcloud.android.beta")
//
// println "Install Nextcloud apk on ${device.name}"
// device.installPackage(new File(buildDir, 'latest.apk').getAbsolutePath(), true)
//
// println "Grant permissions to Nextcloud"
// device.executeShellCommand("pm grant com.nextcloud.android.beta android.permission.READ_EXTERNAL_STORAGE", NullOutputReceiver.receiver, 3, TimeUnit.SECONDS)
// }
// }
//}
//
//tasks.whenTaskAdded { taskItem ->
// if (taskItem.name.contains("connected") && taskItem.name.endsWith("AndroidTest")) {
// taskItem.dependsOn setupNextcloudEnvironment
// }
//}

dependencies {
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.0.4'
Expand Down

0 comments on commit 33c0ff7

Please sign in to comment.