Merge pull request #666 from realm/ajl/jenkinsfile
Jenkinsfile to replace js_pr
This commit is contained in:
commit
a4e0ddb76a
74
Dockerfile
74
Dockerfile
|
@ -1,8 +1,76 @@
|
||||||
FROM ubuntu:xenial
|
FROM ubuntu:xenial
|
||||||
|
|
||||||
RUN apt-get update && \
|
# Install the JDK
|
||||||
apt-get install -y curl && \
|
# We are going to need some 32 bit binaries because aapt (Android Asset
|
||||||
|
# Packaging Tool) requires it
|
||||||
|
# file is need by the script that creates NDK toolchains
|
||||||
|
ENV DEBIAN_FRONTEND noninteractive
|
||||||
|
RUN dpkg --add-architecture i386 && \
|
||||||
|
apt-get update -qq && \
|
||||||
|
apt-get install -y \
|
||||||
|
autoconf \
|
||||||
|
automake \
|
||||||
|
build-essential \
|
||||||
|
bsdmainutils \
|
||||||
|
curl \
|
||||||
|
file \
|
||||||
|
git \
|
||||||
|
lsof \
|
||||||
|
libc6:i386 \
|
||||||
|
libconfig++9v5 \
|
||||||
|
libgcc1:i386 \
|
||||||
|
libncurses5:i386 \
|
||||||
|
libstdc++6:i386 \
|
||||||
|
libz1:i386 \
|
||||||
|
python \
|
||||||
|
python-dev \
|
||||||
|
s3cmd \
|
||||||
|
software-properties-common \
|
||||||
|
strace \
|
||||||
|
unzip \
|
||||||
|
wget \
|
||||||
|
zip && \
|
||||||
curl -sL https://deb.nodesource.com/setup_4.x | bash - && \
|
curl -sL https://deb.nodesource.com/setup_4.x | bash - && \
|
||||||
apt-get install -y nodejs gcc-4.9 python build-essential
|
apt-get install -y nodejs && \
|
||||||
|
echo oracle-java6-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \
|
||||||
|
add-apt-repository -y ppa:webupd8team/java && \
|
||||||
|
apt-get update -qq && \
|
||||||
|
apt-get install -y oracle-java8-installer && \
|
||||||
|
rm -rf /var/cache/oracle-jdk8-installer && \
|
||||||
|
apt-get clean
|
||||||
|
|
||||||
ENV NPM_CONFIG_UNSAFE_PERM true
|
ENV NPM_CONFIG_UNSAFE_PERM true
|
||||||
|
|
||||||
|
# Locales
|
||||||
|
RUN locale-gen en_US.UTF-8
|
||||||
|
ENV LANG "en_US.UTF-8"
|
||||||
|
ENV LANGUAGE "en_US.UTF-8"
|
||||||
|
ENV LC_ALL "en_US.UTF-8"
|
||||||
|
|
||||||
|
# Install the Android SDK
|
||||||
|
ENV ANDROID_SDK_VERSION r24.4.1
|
||||||
|
RUN cd /opt && curl -s https://dl.google.com/android/android-sdk_${ANDROID_SDK_VERSION}-linux.tgz | tar -xz
|
||||||
|
ENV ANDROID_HOME /opt/android-sdk-linux
|
||||||
|
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
|
||||||
|
RUN echo y | android update sdk --no-ui --all --filter tools > /dev/null && \
|
||||||
|
echo y | android update sdk --no-ui --all --filter platform-tools | grep 'package installed' && \
|
||||||
|
echo y | android update sdk --no-ui --all --filter build-tools-23.0.1 | grep 'package installed' && \
|
||||||
|
echo y | android update sdk --no-ui --all --filter extra-android-m2repository | grep 'package installed' && \
|
||||||
|
echo y | android update sdk --no-ui --all --filter android-23 | grep 'package installed'
|
||||||
|
|
||||||
|
# Install the Android NDK
|
||||||
|
ENV ANDROID_NDK_VERSION r10e
|
||||||
|
RUN cd /opt && \
|
||||||
|
curl -sO http://dl.google.com/android/repository/android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && \
|
||||||
|
unzip -q android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip && \
|
||||||
|
rm android-ndk-${ANDROID_NDK_VERSION}-linux-x86_64.zip
|
||||||
|
ENV ANDROID_NDK /opt/android-ndk-${ANDROID_NDK_VERSION}
|
||||||
|
|
||||||
|
RUN cd /opt && \
|
||||||
|
git clone https://github.com/facebook/watchman.git && \
|
||||||
|
cd watchman && \
|
||||||
|
git checkout v4.7.0 && \
|
||||||
|
./autogen.sh && ./configure && \
|
||||||
|
make && make install
|
||||||
|
|
||||||
|
RUN npm install -g react-native-cli
|
||||||
|
|
|
@ -0,0 +1,161 @@
|
||||||
|
#!groovy
|
||||||
|
import groovy.json.JsonOutput
|
||||||
|
|
||||||
|
repoName = 'realm-js' // This is a global variable
|
||||||
|
|
||||||
|
def getSourceArchive() {
|
||||||
|
checkout scm
|
||||||
|
sh 'git clean -ffdx -e .????????'
|
||||||
|
sshagent(['realm-ci-ssh']) {
|
||||||
|
sh 'git submodule update --init --recursive'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def readGitTag() {
|
||||||
|
sh "git describe --exact-match --tags HEAD | tail -n 1 > tag.txt 2>&1 || true"
|
||||||
|
def tag = readFile('tag.txt').trim()
|
||||||
|
return tag
|
||||||
|
}
|
||||||
|
|
||||||
|
def readGitSha() {
|
||||||
|
sh "git rev-parse HEAD | cut -b1-8 > sha.txt"
|
||||||
|
def sha = readFile('sha.txt').readLines().last().trim()
|
||||||
|
return sha
|
||||||
|
}
|
||||||
|
|
||||||
|
def getVersion(){
|
||||||
|
def dependencies = readProperties file: 'dependencies.list'
|
||||||
|
def gitTag = readGitTag()
|
||||||
|
def gitSha = readGitSha()
|
||||||
|
if (gitTag == "") {
|
||||||
|
return "${dependencies.VERSION}-g${gitSha}"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return dependencies.VERSION
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def setBuildName(newBuildName) {
|
||||||
|
currentBuild.displayName = "${currentBuild.displayName} - ${newBuildName}"
|
||||||
|
}
|
||||||
|
|
||||||
|
def gitTag
|
||||||
|
def gitSha
|
||||||
|
def dependencies
|
||||||
|
def version
|
||||||
|
|
||||||
|
stage('check') {
|
||||||
|
node('docker') {
|
||||||
|
getSourceArchive()
|
||||||
|
|
||||||
|
dependencies = readProperties file: 'dependencies.list'
|
||||||
|
|
||||||
|
gitTag = readGitTag()
|
||||||
|
gitSha = readGitSha()
|
||||||
|
version = getVersion()
|
||||||
|
echo "tag: ${gitTag}"
|
||||||
|
if (gitTag == "") {
|
||||||
|
echo "No tag given for this build"
|
||||||
|
setBuildName("${gitSha}")
|
||||||
|
} else {
|
||||||
|
if (gitTag != "v${dependencies.VERSION}") {
|
||||||
|
echo "Git tag '${gitTag}' does not match v${dependencies.VERSION}"
|
||||||
|
} else {
|
||||||
|
echo "Building release: '${gitTag}'"
|
||||||
|
setBuildName("Tag ${gitTag}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
echo "version: ${version}"
|
||||||
|
|
||||||
|
if (['master'].contains(env.BRANCH_NAME)) {
|
||||||
|
// If we're on master, instruct the docker image builds to push to the
|
||||||
|
// cache registry
|
||||||
|
env.DOCKER_PUSH = "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def reportStatus(target, state, message) {
|
||||||
|
step([
|
||||||
|
$class: 'GitHubCommitStatusSetter',
|
||||||
|
contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: target],
|
||||||
|
statusResultSource: [$class: 'ConditionalStatusResultSource', results: [[
|
||||||
|
$class: 'AnyBuildResult', message: message, state: state]]
|
||||||
|
],
|
||||||
|
reposSource: [$class: 'ManuallyEnteredRepositorySource', url: 'https://github.com/realm/realm-js']
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
def doInside(script, target, postStep = null) {
|
||||||
|
try {
|
||||||
|
reportStatus(target, 'PENDING', 'Build has started')
|
||||||
|
getSourceArchive()
|
||||||
|
sh "bash ${script} ${target}"
|
||||||
|
if(postStep) {
|
||||||
|
postStep.call()
|
||||||
|
}
|
||||||
|
|
||||||
|
reportStatus(target, 'SUCCESS', 'Success!')
|
||||||
|
} catch(Exception e) {
|
||||||
|
reportStatus(target, 'FAILURE', e.toString())
|
||||||
|
currentBuild.rawBuild.setResult(Result.FAILURE)
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def doDockerInside(script, target, postStep = null) {
|
||||||
|
docker.withRegistry("https://${env.DOCKER_REGISTRY}", "ecr:eu-west-1:aws-ci-user") {
|
||||||
|
doInside(script, target, postStep)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def doAndroidBuild(target, postStep = null) {
|
||||||
|
return {
|
||||||
|
node('docker && android') {
|
||||||
|
lock("${env.NODE_NAME}-android") {
|
||||||
|
doDockerInside("./scripts/docker-android-wrapper.sh ./scripts/test.sh", target, postStep)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def doDockerBuild(target, postStep = null) {
|
||||||
|
return {
|
||||||
|
node('docker') {
|
||||||
|
doDockerInside("./scripts/docker-wrapper.sh ./scripts/test.sh", target, postStep)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def doMacBuild(target, postStep = null) {
|
||||||
|
return {
|
||||||
|
node('osx_vegas') {
|
||||||
|
doInside("./scripts/test.sh", target, postStep)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('build') {
|
||||||
|
parallel(
|
||||||
|
eslint: doDockerBuild('eslint-ci', {
|
||||||
|
step([$class: 'CheckStylePublisher', canComputeNew: false, canRunOnFailed: true, defaultEncoding: '', healthy: '', pattern: 'eslint.xml', unHealthy: ''])
|
||||||
|
}),
|
||||||
|
jsdoc: doDockerBuild('jsdoc', {
|
||||||
|
publishHTML([allowMissing: false, alwaysLinkToLastBuild: false, keepAll: false, reportDir: 'docs/output', reportFiles: 'index.html', reportName: 'Docs'])
|
||||||
|
}),
|
||||||
|
linux_node_debug: doDockerBuild('node Debug'),
|
||||||
|
linux_node_release: doDockerBuild('node Release'),
|
||||||
|
linux_test_runners: doDockerBuild('test-runners'),
|
||||||
|
macos_node_debug: doMacBuild('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'),
|
||||||
|
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'
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
|
@ -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 \
|
||||||
|
-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 \
|
||||||
|
"${@}"
|
|
@ -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 $@
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# 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
|
||||||
|
|
||||||
|
cmd=${@:-/bin/bash}
|
||||||
|
|
||||||
|
./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 \
|
||||||
|
${cmd}
|
|
@ -120,6 +120,11 @@ case "$TARGET" in
|
||||||
npm install
|
npm install
|
||||||
npm run lint .
|
npm run lint .
|
||||||
;;
|
;;
|
||||||
|
"eslint-ci")
|
||||||
|
[[ $CONFIGURATION == 'Debug' ]] && exit 0
|
||||||
|
npm install
|
||||||
|
./node_modules/.bin/eslint -f checkstyle . > eslint.xml || true
|
||||||
|
;;
|
||||||
"jsdoc")
|
"jsdoc")
|
||||||
[[ $CONFIGURATION == 'Debug' ]] && exit 0
|
[[ $CONFIGURATION == 'Debug' ]] && exit 0
|
||||||
npm install
|
npm install
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
package="io.realm.react.testapp">
|
package="io.realm.react.testapp">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".MainApplication"
|
android:name=".MainApplication"
|
||||||
|
|
|
@ -5,7 +5,7 @@ buildscript {
|
||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
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
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|
|
@ -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
|
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"
|
echo "Reversing port for physical device"
|
||||||
adb reverse tcp:8081 tcp:8081
|
adb reverse tcp:8081 tcp:8081
|
||||||
|
|
||||||
react-native run-android
|
react-native run-android
|
||||||
|
|
||||||
echo "Unlocking device"
|
echo "Unlocking device"
|
||||||
|
# sometimes on CI the application is not on the foreground
|
||||||
adb shell input keyevent 82
|
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
|
||||||
|
|
Loading…
Reference in New Issue