Added support for React tests on android in docker (phew)

This commit is contained in:
Adam Lebsack 2016-11-24 14:29:19 +01:00
parent bccec2cb3f
commit 5ac6d97833
7 changed files with 65 additions and 37 deletions

41
Jenkinsfile vendored
View File

@ -97,18 +97,28 @@ def doInside(script, target, postStep = null) {
}
}
def doDockerBuild(target, postStep = null) {
def doAndroidBuild(target, postStep = null) {
return {
node('docker') {
doInside('scripts/docker-test.sh', target, postStep)
node('docker && android') {
lock("${env.NODE_NAME}-android") {
doInside("./scripts/docker-wrapper.sh ./scripts/test.sh", target, postStep)
}
}
}
}
def doBuild(nodeSpec, target, postStep = null) {
def doDockerBuild(target, postStep = null) {
return {
node(nodeSpec) {
doInside('scripts/test.sh', target, postStep)
node('docker') {
doInside("./scripts/docker-wrapper.sh ./scripts/test.sh", target, postStep)
}
}
}
def doMacBuild(target, postStep = null) {
return {
node('osx_vegas') {
doInside("./scripts/test.sh", target, postStep)
}
}
}
@ -124,18 +134,17 @@ stage('build') {
linux_node_debug: doDockerBuild('node Debug'),
linux_node_release: doDockerBuild('node Release'),
linux_test_runners: doDockerBuild('test-runners'),
macos_node_debug: doBuild('osx_vegas', 'node Debug'),
macos_node_release: doBuild('osx_vegas', 'node Release'),
macos_realmjs_debug: doBuild('osx_vegas', 'realmjs Debug'),
macos_realmjs_release: doBuild('osx_vegas', 'realmjs Release'),
macos_react_tests_debug: doBuild('osx_vegas', 'react-tests Debug'),
macos_react_tests_release: doBuild('osx_vegas', 'react-tests Release', {
macos_node_debug: doMacBuild('osx_vegas', 'node Debug'),
macos_node_release: doMacBuild('node Release'),
macos_realmjs_debug: doMacBuild('realmjs Debug'),
macos_realmjs_release: doMacBuild('realmjs Release'),
macos_react_tests_debug: doMacBuild('react-tests Debug'),
macos_react_tests_release: doMacBuild('react-tests Release', {
junit 'build/reports/junit.xml'
}),
macos_react_example_debug: doBuild('osx_vegas', 'react-example Debug'),
macos_react_example_release: doBuild('osx_vegas', 'react-example Release'),
android_react_tests: doBuild('FastLinux', 'react-tests-android', {
sh "cat tests/react-test-app/tests.xml"
macos_react_example_debug: doMacBuild('react-example Debug'),
macos_react_example_release: doMacBuild('react-example Release'),
android_react_tests: doAndroidBuild('react-tests-android', {
junit 'tests/react-test-app/tests.xml'
})
)

View File

@ -0,0 +1,25 @@
#!/bin/sh
# This is a wrapper script which uses docker. It is used in CI, but can also
# be used locally if you have your ~/.android directory setup and access to
# /dev/bus/usb.
#
# ./scripts/docker-android-wrapper.sh ./scripts/test.sh react-tests-android
#
set -e
./scripts/docker_build_wrapper.sh ci/realm-js:build .
exec docker run --rm -it \
-u $(id -u) \
--privileged \
--net=host \
-e HOME=/tmp \
-e _JAVA_OPTIONS=-Duser.home=/tmp \
-v /etc/passwd:/etc/passwd:ro \
-v /dev/bus/usb:/dev/bus/usb \
-v $HOME/.android:/tmp/.android \
-v $(pwd):/source \
-w /source \
ci/realm-js:build \
"${@}"

View File

@ -1,18 +0,0 @@
#!/bin/sh
# This is a wrapper script around ./scripts/test.sh which uses docker. The
# arguments are the same, as they are passed directly to test.sh.
# It can be used to locally check and debug the linux build process
# outside of CI.
set -e
./scripts/docker_build_wrapper.sh ci/realm-js:build .
exec docker run --rm \
-u $(id -u) \
-e HOME=/tmp \
-v $(pwd):/source \
-w /source \
ci/realm-js:build \
./scripts/test.sh $@

View File

@ -1,6 +1,9 @@
#!/bin/sh
# This is a wrapper script which uses docker. It allows you to run commands
# in a docker environment.
# This is a wrapper script which uses docker. It is used in CI, but can also
# be used locally.
#
# ./scripts/docker-wrapper.sh ./scripts/test.sh node
#
set -e

View File

@ -2,6 +2,7 @@
package="io.realm.react.testapp">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:name=".MainApplication"

View File

@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
classpath 'com.android.tools.build:gradle:1.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files

View File

@ -10,10 +10,18 @@ REALM_BUILD_ANDROID=1 npm install realm realm-tests
cp ../../src/object-store/tests/query.json node_modules/realm-tests/query-tests.json
adb uninstall io.realm.react.testapp || true
echo "Reversing port for physical device"
adb reverse tcp:8081 tcp:8081
react-native run-android
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
sleep 1
echo "Starting the Main Activity"
adb shell am start -n io.realm.react.testapp/.MainActivity