diff --git a/Jenkinsfile b/Jenkinsfile index b9425b5f..1bb6472f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -163,10 +163,8 @@ def doDockerInside(script, target, postStep = null) { def doAndroidBuild(target, postStep = null) { return { - node('docker && android && nexus-5x') { - timeout(time: 20, unit: 'MINUTES') { - doDockerInside("./scripts/docker-android-wrapper.sh ./scripts/test.sh", target, postStep) - } + node('docker && android') { + doDockerInside("./scripts/docker-android-wrapper.sh ./scripts/test.sh", target, postStep) } } } diff --git a/scripts/prepublish.sh b/scripts/prepublish.sh index 0fe81249..56ef6206 100755 --- a/scripts/prepublish.sh +++ b/scripts/prepublish.sh @@ -3,10 +3,9 @@ set -e set -o pipefail export REALM_CORE_VERSION=$(./scripts/download-core.sh --version) -echo "Core Version: $REALM_CORE_VERSION" +echo "Core Version: $REALM_CORE_VERSION" cd "$(dirname "$0")/.." if [ -n "$REALM_BUILD_ANDROID" ]; then - rm -rf android (cd react-native/android && ./gradlew publishAndroid -PbuildWithSync=true) fi diff --git a/scripts/test.sh b/scripts/test.sh index 2303adc3..106a67a7 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -169,14 +169,16 @@ case "$TARGET" in pushd tests/react-test-app npm install - open_chrome - start_packager - ./run-android.sh + echo "Resetting logcat" # Despite the docs claiming -c to work, it doesn't, so `-T 1` alleviates that. adb logcat -c adb logcat -T 1 | tee "$LOGCAT_OUT" & + ./run-android.sh + + echo "Start listening for Test completion" + while :; do if grep -q "__REALM_REACT_ANDROID_TESTS_COMPLETED__" "$LOGCAT_OUT"; then break diff --git a/tests/react-test-app/android/app/build.gradle b/tests/react-test-app/android/app/build.gradle index 38416890..fce3217c 100644 --- a/tests/react-test-app/android/app/build.gradle +++ b/tests/react-test-app/android/app/build.gradle @@ -90,6 +90,16 @@ android { abiFilters "armeabi-v7a", "x86" } } + + signingConfigs { + release { + storeFile file("my-release-key.keystore") + storePassword "android" + keyAlias "my-key-alias" + keyPassword "android" + } + } + splits { abi { reset() @@ -102,6 +112,7 @@ android { release { minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" + signingConfig signingConfigs.release } } // applicationVariants are e.g. debug, release diff --git a/tests/react-test-app/android/app/my-release-key.keystore b/tests/react-test-app/android/app/my-release-key.keystore new file mode 100644 index 00000000..e3eca062 Binary files /dev/null and b/tests/react-test-app/android/app/my-release-key.keystore differ diff --git a/tests/react-test-app/android/app/src/main/java/MainActivity.java b/tests/react-test-app/android/app/src/main/java/io/realm/react/testapp/MainActivity.java similarity index 99% rename from tests/react-test-app/android/app/src/main/java/MainActivity.java rename to tests/react-test-app/android/app/src/main/java/io/realm/react/testapp/MainActivity.java index 801b2a43..0120858d 100644 --- a/tests/react-test-app/android/app/src/main/java/MainActivity.java +++ b/tests/react-test-app/android/app/src/main/java/io/realm/react/testapp/MainActivity.java @@ -12,4 +12,5 @@ public class MainActivity extends ReactActivity { protected String getMainComponentName() { return "ReactTests"; } + } diff --git a/tests/react-test-app/android/app/src/main/java/MainApplication.java b/tests/react-test-app/android/app/src/main/java/io/realm/react/testapp/MainApplication.java similarity index 92% rename from tests/react-test-app/android/app/src/main/java/MainApplication.java rename to tests/react-test-app/android/app/src/main/java/io/realm/react/testapp/MainApplication.java index d1760386..216ee8a5 100644 --- a/tests/react-test-app/android/app/src/main/java/MainApplication.java +++ b/tests/react-test-app/android/app/src/main/java/io/realm/react/testapp/MainApplication.java @@ -1,18 +1,16 @@ package io.realm.react.testapp; import android.app.Application; -import android.util.Log; import com.facebook.react.ReactApplication; -import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactNativeHost; import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; +import com.rnfs.RNFSPackage; import java.util.Arrays; import java.util.List; -import com.rnfs.RNFSPackage; import io.realm.react.RealmReactPackage; public class MainApplication extends Application implements ReactApplication { @@ -37,4 +35,5 @@ public class MainApplication extends Application implements ReactApplication { public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } -} \ No newline at end of file + +} diff --git a/tests/react-test-app/index.android.js b/tests/react-test-app/index.android.js index bd27a8e3..2b22be59 100644 --- a/tests/react-test-app/index.android.js +++ b/tests/react-test-app/index.android.js @@ -82,17 +82,12 @@ async function runTests() { class ReactTests extends React.Component { render() { + runTests(); return ( - Running Tests... + Click To Run Tests Again. - - runTests()} - /> ); } diff --git a/tests/react-test-app/run-android.sh b/tests/react-test-app/run-android.sh index 63b77ed7..a292e9c5 100755 --- a/tests/react-test-app/run-android.sh +++ b/tests/react-test-app/run-android.sh @@ -5,23 +5,30 @@ set -e PATH="/opt/android-sdk-linux/platform-tools:$PATH" -# Inform the prepublish script to build Android modules. -REALM_BUILD_ANDROID=1 npm install realm realm-tests +if [ -n "$REALM_BUILD_ANDROID" ]; then + echo "Realm is already installed" # by inoking test.sh previously for example + +else + # Inform the prepublish script to build Android modules. + REALM_BUILD_ANDROID=1 npm install realm realm-tests +fi + cp ../../src/object-store/tests/query.json node_modules/realm-tests/query-tests.json +echo "Uninstalling old apk" adb uninstall io.realm.react.testapp || true echo "Reversing port for physical device" adb reverse tcp:8081 tcp:8081 -react-native run-android +echo "Building Release APK" +pushd android && ./gradlew assembleRelease -echo "Unlocking device" -# sometimes on CI the application is not on the foreground -adb shell input keyevent 82 -adb shell input text 1234 && adb shell input keyevent 66 +echo "Installing APK" +adb install app/build/outputs/apk/app-release.apk -sleep 1 echo "Starting the Main Activity" adb shell am start -n io.realm.react.testapp/.MainActivity + +popd