From 014191a6636f0805da1b5f17d95dd2b5b5e4c742 Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Thu, 17 Nov 2016 16:55:02 +0100 Subject: [PATCH 01/13] Added jenkinsfile --- Dockerfile | 32 +++++++++- Jenkinsfile | 126 ++++++++++++++++++++++++++++++++++++++ scripts/docker-wrapper.sh | 17 +++++ scripts/test.sh | 5 ++ 4 files changed, 177 insertions(+), 3 deletions(-) create mode 100644 Jenkinsfile create mode 100755 scripts/docker-wrapper.sh diff --git a/Dockerfile b/Dockerfile index fe46cd45..338e96dd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,34 @@ FROM ubuntu:xenial -RUN apt-get update && \ - apt-get install -y curl && \ +# Install the JDK +# We are going to need some 32 bit binaries because aapt 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 file git curl wget zip unzip bsdmainutils strace lsof \ + build-essential libc6:i386 software-properties-common \ + libstdc++6:i386 libgcc1:i386 libncurses5:i386 libz1:i386 \ + s3cmd libconfig++9v5 python build-essential && \ 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 + +# 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" + +# ENV PATH ${PATH}:${NDK_HOME} + +# Install writable dir +RUN mkdir /tmp/opt && chmod 777 /tmp/opt + diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 00000000..4c3ab071 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,126 @@ +#!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}" + } +} + +def doDockerBuild(target, postStep = null) { + return { + timeout(50) { // minutes + node('docker') { + getSourceArchive() + sh "bash scripts/docker-test.sh ${target}" + if(postStep) { + postStep.call() + } + } + } + } +} + +def doBuild(nodeSpec, target, postStep = null) { + return { + timeout(50) { // minutes + node(nodeSpec) { + getSourceArchive() + sh "bash scripts/test.sh ${target}" + if(postStep) { + postStep.call() + } + } + } + } +} + +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: 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', { + 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" + junit 'tests/react-test-app/tests.xml' + }) + ) +} \ No newline at end of file diff --git a/scripts/docker-wrapper.sh b/scripts/docker-wrapper.sh new file mode 100755 index 00000000..22bdfee3 --- /dev/null +++ b/scripts/docker-wrapper.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# This is a wrapper script which uses docker. It allows you to run commands +# in a docker environment. + +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} diff --git a/scripts/test.sh b/scripts/test.sh index f931ff32..814a6365 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -112,6 +112,11 @@ case "$TARGET" in npm install npm run lint . ;; +"eslint-ci") + [[ $CONFIGURATION == 'Debug' ]] && exit 0 + npm install + ./node_modules/.bin/eslint -f checkstyle . > eslint.xml || true + ;; "jsdoc") [[ $CONFIGURATION == 'Debug' ]] && exit 0 npm install From 01a46c3275feb02ad2d34a2682b75855535e16b4 Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Tue, 22 Nov 2016 11:02:50 +0100 Subject: [PATCH 02/13] Report status of each step to github --- Jenkinsfile | 47 +++++++++++++++++++++++++++++++---------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 4c3ab071..3f1c7f3f 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -69,30 +69,45 @@ stage('check') { } } +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) + } +} + def doDockerBuild(target, postStep = null) { return { - timeout(50) { // minutes - node('docker') { - getSourceArchive() - sh "bash scripts/docker-test.sh ${target}" - if(postStep) { - postStep.call() - } - } + node('docker') { + doInside('scripts/docker-test.sh', target, postStep) } } } def doBuild(nodeSpec, target, postStep = null) { return { - timeout(50) { // minutes - node(nodeSpec) { - getSourceArchive() - sh "bash scripts/test.sh ${target}" - if(postStep) { - postStep.call() - } - } + node(nodeSpec) { + doInside('scripts/test.sh', target, postStep) } } } From 67193d097501dbccbc659070e14ad0927ca6dd87 Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Tue, 22 Nov 2016 11:50:55 +0100 Subject: [PATCH 03/13] Rethrow the error in a parellel job --- Jenkinsfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3f1c7f3f..e1533c35 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -82,7 +82,6 @@ def reportStatus(target, state, message) { def doInside(script, target, postStep = null) { try { - reportStatus(target, 'PENDING', 'Build has started') getSourceArchive() sh "bash ${script} ${target}" if(postStep) { @@ -93,10 +92,12 @@ def doInside(script, target, postStep = null) { } catch(Exception e) { reportStatus(target, 'FAILURE', e.toString()) currentBuild.rawBuild.setResult(Result.FAILURE) + throw e } } def doDockerBuild(target, postStep = null) { + reportStatus(target, 'PENDING', 'Build has started') return { node('docker') { doInside('scripts/docker-test.sh', target, postStep) @@ -105,6 +106,7 @@ def doDockerBuild(target, postStep = null) { } def doBuild(nodeSpec, target, postStep = null) { + reportStatus(target, 'PENDING', 'Build has started') return { node(nodeSpec) { doInside('scripts/test.sh', target, postStep) From 61dd300f29d12f266849d20a980eac60dd5e3a1c Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Tue, 22 Nov 2016 11:52:32 +0100 Subject: [PATCH 04/13] Moving pending back to node --- Jenkinsfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index e1533c35..69f5a186 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -82,6 +82,7 @@ def reportStatus(target, state, message) { def doInside(script, target, postStep = null) { try { + reportStatus(target, 'PENDING', 'Build has started') getSourceArchive() sh "bash ${script} ${target}" if(postStep) { @@ -97,7 +98,6 @@ def doInside(script, target, postStep = null) { } def doDockerBuild(target, postStep = null) { - reportStatus(target, 'PENDING', 'Build has started') return { node('docker') { doInside('scripts/docker-test.sh', target, postStep) @@ -106,7 +106,6 @@ def doDockerBuild(target, postStep = null) { } def doBuild(nodeSpec, target, postStep = null) { - reportStatus(target, 'PENDING', 'Build has started') return { node(nodeSpec) { doInside('scripts/test.sh', target, postStep) From f670d0cdbeb53f6116502feb1068c3a7a1fa4dd7 Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Thu, 24 Nov 2016 10:55:46 +0100 Subject: [PATCH 05/13] Added android SDK and NDK to dockerfile --- Dockerfile | 57 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 338e96dd..92c6bc92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,34 @@ FROM ubuntu:xenial # Install the JDK -# We are going to need some 32 bit binaries because aapt requires it +# We are going to need some 32 bit binaries because apt 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 file git curl wget zip unzip bsdmainutils strace lsof \ - build-essential libc6:i386 software-properties-common \ - libstdc++6:i386 libgcc1:i386 libncurses5:i386 libz1:i386 \ - s3cmd libconfig++9v5 python build-essential && \ + 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 - && \ apt-get install -y nodejs && \ echo oracle-java6-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \ @@ -27,8 +46,30 @@ ENV LANG "en_US.UTF-8" ENV LANGUAGE "en_US.UTF-8" ENV LC_ALL "en_US.UTF-8" -# ENV PATH ${PATH}:${NDK_HOME} +# 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-24.0.0 | 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-24 | grep 'package installed' -# Install writable dir -RUN mkdir /tmp/opt && chmod 777 /tmp/opt +# 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 From f2cea40c6c5979c4e96d9a7ef410103742c81e0e Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Thu, 24 Nov 2016 11:07:45 +0100 Subject: [PATCH 06/13] Fixed comment about aapt --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 92c6bc92..c58e6fb9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,8 @@ FROM ubuntu:xenial # Install the JDK -# We are going to need some 32 bit binaries because apt requires it +# 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 && \ From bccec2cb3fd836199240efca766eb37c5b92a89c Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Thu, 24 Nov 2016 13:13:15 +0100 Subject: [PATCH 07/13] Use android-23 --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index c58e6fb9..05162f77 100644 --- a/Dockerfile +++ b/Dockerfile @@ -54,9 +54,9 @@ 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-24.0.0 | 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-24 | 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 From 5ac6d97833e00f2d8183e4bf5122078af0b50488 Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Thu, 24 Nov 2016 14:29:19 +0100 Subject: [PATCH 08/13] Added support for React tests on android in docker (phew) --- Jenkinsfile | 41 +++++++++++-------- scripts/docker-android-wrapper.sh | 25 +++++++++++ scripts/docker-test.sh | 18 -------- scripts/docker-wrapper.sh | 7 +++- .../android/app/src/main/AndroidManifest.xml | 1 + tests/react-test-app/android/build.gradle | 2 +- tests/react-test-app/run-android.sh | 8 ++++ 7 files changed, 65 insertions(+), 37 deletions(-) create mode 100755 scripts/docker-android-wrapper.sh delete mode 100755 scripts/docker-test.sh diff --git a/Jenkinsfile b/Jenkinsfile index 69f5a186..365e3ad5 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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' }) ) diff --git a/scripts/docker-android-wrapper.sh b/scripts/docker-android-wrapper.sh new file mode 100755 index 00000000..c163539e --- /dev/null +++ b/scripts/docker-android-wrapper.sh @@ -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 \ + "${@}" diff --git a/scripts/docker-test.sh b/scripts/docker-test.sh deleted file mode 100755 index 0a5f6f9d..00000000 --- a/scripts/docker-test.sh +++ /dev/null @@ -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 $@ - diff --git a/scripts/docker-wrapper.sh b/scripts/docker-wrapper.sh index 22bdfee3..778351c8 100755 --- a/scripts/docker-wrapper.sh +++ b/scripts/docker-wrapper.sh @@ -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 diff --git a/tests/react-test-app/android/app/src/main/AndroidManifest.xml b/tests/react-test-app/android/app/src/main/AndroidManifest.xml index 4bfced4c..59a58005 100644 --- a/tests/react-test-app/android/app/src/main/AndroidManifest.xml +++ b/tests/react-test-app/android/app/src/main/AndroidManifest.xml @@ -2,6 +2,7 @@ package="io.realm.react.testapp"> + Date: Thu, 24 Nov 2016 17:02:49 +0100 Subject: [PATCH 09/13] Fixed arguments do doMacBuild() --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 365e3ad5..2179db27 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -134,7 +134,7 @@ stage('build') { linux_node_debug: doDockerBuild('node Debug'), linux_node_release: doDockerBuild('node Release'), linux_test_runners: doDockerBuild('test-runners'), - macos_node_debug: doMacBuild('osx_vegas', 'node Debug'), + macos_node_debug: doMacBuild('node Debug'), macos_node_release: doMacBuild('node Release'), macos_realmjs_debug: doMacBuild('realmjs Debug'), macos_realmjs_release: doMacBuild('realmjs Release'), From 4eaa8eae9165f6127d6f47f8bef25e64879bf9eb Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Thu, 24 Nov 2016 17:16:15 +0100 Subject: [PATCH 10/13] Added docker cache support --- Jenkinsfile | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 2179db27..96b4cf70 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -66,6 +66,12 @@ stage('check') { } } echo "version: ${version}" + + if (['ajl/jenkinsfile', '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" + } } } @@ -97,11 +103,17 @@ def doInside(script, target, postStep = null) { } } +def doDockerInside(script, target, postStep = null) { + docker.withRegistry("https://${env.DOCKER_REGISTRY}", "ecr:eu-west-1:aws-ci-user") { + doInside("./scripts/docker-wrapper.sh ${script}", target, postStep) + } +} + def doAndroidBuild(target, postStep = null) { return { node('docker && android') { lock("${env.NODE_NAME}-android") { - doInside("./scripts/docker-wrapper.sh ./scripts/test.sh", target, postStep) + doDockerInside("./scripts/test.sh", target, postStep) } } } @@ -110,7 +122,7 @@ def doAndroidBuild(target, postStep = null) { def doDockerBuild(target, postStep = null) { return { node('docker') { - doInside("./scripts/docker-wrapper.sh ./scripts/test.sh", target, postStep) + doDockerInside("./scripts/test.sh", target, postStep) } } } From 7d100a79a1b7bf1c495c6ce9581a0a8747868c32 Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Thu, 24 Nov 2016 17:34:09 +0100 Subject: [PATCH 11/13] Fix for android wrapper --- Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 96b4cf70..d904e73c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -105,7 +105,7 @@ def doInside(script, target, postStep = null) { def doDockerInside(script, target, postStep = null) { docker.withRegistry("https://${env.DOCKER_REGISTRY}", "ecr:eu-west-1:aws-ci-user") { - doInside("./scripts/docker-wrapper.sh ${script}", target, postStep) + doInside(script, target, postStep) } } @@ -113,7 +113,7 @@ def doAndroidBuild(target, postStep = null) { return { node('docker && android') { lock("${env.NODE_NAME}-android") { - doDockerInside("./scripts/test.sh", target, postStep) + doDockerInside("./scripts/docker-android-wrapper.sh ./scripts/test.sh", target, postStep) } } } @@ -122,7 +122,7 @@ def doAndroidBuild(target, postStep = null) { def doDockerBuild(target, postStep = null) { return { node('docker') { - doDockerInside("./scripts/test.sh", target, postStep) + doDockerInside("./scripts/docker-wrapper.sh ./scripts/test.sh", target, postStep) } } } From 1856f04ccec4d35900521fd5cd8d657f058f0446 Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Thu, 24 Nov 2016 17:39:50 +0100 Subject: [PATCH 12/13] Fix for android wrapper --- scripts/docker-android-wrapper.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/docker-android-wrapper.sh b/scripts/docker-android-wrapper.sh index c163539e..6613501e 100755 --- a/scripts/docker-android-wrapper.sh +++ b/scripts/docker-android-wrapper.sh @@ -10,7 +10,7 @@ set -e ./scripts/docker_build_wrapper.sh ci/realm-js:build . -exec docker run --rm -it \ +exec docker run --rm \ -u $(id -u) \ --privileged \ --net=host \ From ad3ea0b8b0ff1ea247c6fb45f3a11cb3c48199fc Mon Sep 17 00:00:00 2001 From: Adam Lebsack Date: Fri, 25 Nov 2016 12:09:16 +0100 Subject: [PATCH 13/13] Only push image on master --- Jenkinsfile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d904e73c..3cf2b794 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -67,7 +67,7 @@ stage('check') { } echo "version: ${version}" - if (['ajl/jenkinsfile', 'master'].contains(env.BRANCH_NAME)) { + 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" @@ -151,9 +151,7 @@ stage('build') { 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_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', {