Nh/fixes 740 (#743)

* Fix Android testing CI job, we don't use the packager since we build the Release bundle
* Test run on Docker-cph-01 or Docker-cph-02
This commit is contained in:
Nabil Hachicha 2016-12-20 19:01:45 +00:00 committed by GitHub
parent 43dabf5cbd
commit b9706b1e80
9 changed files with 40 additions and 28 deletions

6
Jenkinsfile vendored
View File

@ -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)
}
}
}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -12,4 +12,5 @@ public class MainActivity extends ReactActivity {
protected String getMainComponentName() {
return "ReactTests";
}
}

View File

@ -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;
}
}
}

View File

@ -82,17 +82,12 @@ async function runTests() {
class ReactTests extends React.Component {
render() {
runTests();
return (
<View style={styles.container}>
<Text style={styles.button} onPress={runTests}>
Running Tests...
Click To Run Tests Again.
</Text>
<Image
style={styles.icon}
source={require('image!ic_launcher')}
onLoad={() => runTests()}
/>
</View>
);
}

View File

@ -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