Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* Updated ProGuard configuration in order not to depend on Android's default configuration (#2972).
* Fixed a race condition between Realms notifications and other UI events. This could e.g. cause ListView to crash (#2990).
* Fixed a bug that allowed both `RealmConfiguration.Builder.assetFile()`/`deleteRealmIfMigrationNeeded()` to be configured at the same time, which leads to the asset file accidentally being deleted in migrations (#2933).
* Realm crashed outright when the same Realm file was opened in two processes. Realm will now optimistically retry opening for 1 second before throwing an Error (#2459).

### Enhancements

Expand Down
43 changes: 43 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ubuntu:16.04

# 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"

# Set the environment variables
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64
ENV ANDROID_HOME /opt/android-sdk-linux
ENV NDK_HOME /opt/android-ndk
ENV PATH ${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
ENV PATH ${PATH}:${NDK_HOME}

# 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
RUN DEBIAN_FRONTEND=noninteractive dpkg --add-architecture i386 \
&& apt-get update -qq \
&& apt-get install -y file git curl wget zip unzip \
build-essential \
openjdk-8-jdk-headless \
libc6:i386 libstdc++6:i386 libgcc1:i386 libncurses5:i386 libz1:i386 \
&& apt-get clean

# Install the Android SDK
RUN cd /opt && wget -q https://dl.google.com/android/android-sdk_r24.4.1-linux.tgz -O android-sdk.tgz
RUN cd /opt && tar -xvzf android-sdk.tgz
RUN cd /opt && rm -f android-sdk.tgz

# Grab what's needed in the SDK
RUN echo y | android update sdk --no-ui --all --filter platform-tools | grep 'package installed'
RUN echo y | android update sdk --no-ui --all --filter extra-android-support | grep 'package installed'
RUN echo y | android update sdk --no-ui --all --filter android-23 | grep 'package installed'
RUN echo y | android update sdk --no-ui --all --filter build-tools-23.0.0 | grep 'package installed'

# Install the NDK
RUN mkdir /opt/android-ndk-tmp
RUN cd /opt/android-ndk-tmp && wget -q http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin -O android-ndk.bin
RUN cd /opt/android-ndk-tmp && chmod a+x ./android-ndk.bin && ./android-ndk.bin
RUN cd /opt/android-ndk-tmp && mv ./android-ndk-r10e /opt/android-ndk
RUN rm -rf /opt/android-ndk-tmp
235 changes: 91 additions & 144 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,92 @@
#!groovy

{ ->
try {
node('docker') {
stage 'SCM'
if (isPullRequest()) {
checkout([
$class: 'GitSCM',
branches: [[name: "origin/pull/${GITHUB_PR_NUMBER}/head"]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CleanCheckout']],
gitTool: 'native git',
submoduleCfg: [],
userRemoteConfigs: [[
credentialsId: '1642fb1a-1a82-4b10-a25e-f9e95f43c93f',
name: 'origin',
refspec: "+refs/heads/master:refs/remotes/origin/master +refs/pull/${GITHUB_PR_NUMBER}/head:refs/remotes/origin/pull/${GITHUB_PR_NUMBER}/head",
url: 'https://github.com/realm/realm-java.git'
]]
])
} else {
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CleanCheckout']],
gitTool: 'native git',
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/realm/realm-java.git']]
])
}

stage 'Docker build'
def buildEnv = docker.build 'realm-java:snapshot'
buildEnv.inside("--privileged -v /dev/bus/usb:/dev/bus/usb -v ${env.HOME}/gradle-cache:/root/.gradle") {
stage 'JVM tests'
try {
gradle 'assemble check javadoc'
} finally {
storeJunitResults 'realm/realm-annotations-processor/build/test-results/TEST-*.xml'
}

try {
sh 'cd examples && ./gradlew unitTestExample:check --stacktrace'
} finally {
storeJunitResults 'examples/unitTestExample/build/test-results/**/TEST-*.xml'
}

stage 'Static code analysis'
try {
sh 'cd realm && ./gradlew findbugs pmd checkstyle --stacktrace'
} finally {
publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'realm/realm-library/build/findbugs', reportFiles: 'findbugs-output.html', reportName: 'Findbugs issues'])
publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'realm/realm-library/build/reports/pmd', reportFiles: 'pmd.html', reportName: 'PMD Issues'])
}

stage 'Run instrumented tests'
try {
sh 'cd realm && ./gradlew connectedCheck --stacktrace'
} finally {
storeJunitResults 'realm/realm-library/build/outputs/androidTest-results/connected/TEST-*.xml'
}

// TODO: add support for running monkey on the example apps

if (env.BRANCH_NAME == 'master') {
stage 'Collect metrics'
collectAarMetrics()

stage 'Publish to OJO'
sh 'chmod +x gradlew && ./gradlew assemble ojoUpload'
}
}
}

currentBuild.rawBuild.setResult(Result.SUCCESS)
} catch (Exception e) {
echo "The job failed with the following exception: ${e.getMessage()}"
currentBuild.rawBuild.setResult(Result.FAILURE)
} finally {
if (isPullRequest()) {
node {
reportResultToGithub()
}
}
}
}

def isPullRequest() {
return binding.variables.containsKey('GITHUB_PR_NUMBER')
}
Expand Down Expand Up @@ -34,10 +121,10 @@ def storeJunitResults(String path) {
def collectAarMetrics() {
dir('realm/realm-library/build/outputs/aar') {
sh '''set -xe
unzip realm-android-library-release.aar -d unzipped
find $ANDROID_HOME -name dx | sort -r | head -n 1 > dx
$(cat dx) --dex --output=temp.dex unzipped/classes.jar
cat temp.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d"' > methods
unzip realm-android-library-release.aar -d unzipped
find $ANDROID_HOME -name dx | sort -r | head -n 1 > dx
$(cat dx) --dex --output=temp.dex unzipped/classes.jar
cat temp.dex | head -c 92 | tail -c 4 | hexdump -e '1/4 "%d"' > methods
'''
sendMetrics('methods', readFile('methods'))

Expand All @@ -55,143 +142,3 @@ def collectAarMetrics() {
def gradle(String commands) {
sh "chmod +x gradlew && ./gradlew ${commands} --stacktrace"
}

@NonCPS
def getDeviceNames(String commandOutput) {
return commandOutput
.split('\n')
.findAll { it.contains('\t') }
.collect { it.split('\t')[0].trim() }
}

def transformIntoStep(device) {
// We need to wrap what we return in a Groovy closure, or else it's invoked
// when this method is called, not when we pass it to parallel.
// To do this, you need to wrap the code below in { }, and either return
// that explicitly, or use { -> } syntax.
return {
sh "adb -s ${device} shell getprop ro.product.model | tee model-name.txt"
def modelName = readFile('model-name.txt').trim().replaceAll(' ', '_')

sh "adb -s ${device} uninstall io.realm.test"
sh "adb -s ${device} install realm-android-library-debug-androidTest-unaligned.apk"
sh "adb -s ${device} shell am instrument -w -r io.realm.test/android.support.test.runner.AndroidJUnitRunner > test_result_${modelName}_${device}.txt"
sh "java -jar /opt/log-converter.jar test_result_${modelName}_${device}.txt"
}
}

{ ->
try {
node('FastLinux') {
if (isPullRequest()) {
checkout([
$class: 'GitSCM',
branches: [[name: "origin/pull/${GITHUB_PR_NUMBER}/head"]],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CleanCheckout']],
gitTool: 'native git',
submoduleCfg: [],
userRemoteConfigs: [[
credentialsId: '1642fb1a-1a82-4b10-a25e-f9e95f43c93f',
name: 'origin',
refspec: "+refs/heads/master:refs/remotes/origin/master +refs/pull/${GITHUB_PR_NUMBER}/head:refs/remotes/origin/pull/${GITHUB_PR_NUMBER}/head",
url: 'https://github.com/realm/realm-java.git'
]]
])
} else {
checkout([
$class: 'GitSCM',
branches: [[name: '*/master']],
doGenerateSubmoduleConfigurations: false,
extensions: [[$class: 'CleanCheckout']],
gitTool: 'native git',
submoduleCfg: [],
userRemoteConfigs: [[url: 'https://github.com/realm/realm-java.git']]
])
}

stage 'JVM tests'
try {
gradle 'assemble check javadoc'
} finally {
storeJunitResults 'realm/realm-annotations-processor/build/test-results/TEST-*.xml'
}
if (env.BRANCH_NAME == 'master') {
collectAarMetrics()
}
// TODO: add support for running monkey on the example apps
//stash includes: 'examples/*/build/outputs/apk/*debug.apk', name: 'examples'

dir('examples') {
try {
gradle 'check'
} finally {
storeJunitResults 'unitTestExample/build/test-results/**/TEST-*.xml'
}
}

stage 'static code analysis'
try {
dir('realm') {
gradle 'findbugs pmd checkstyle'
}
} finally {
publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'realm/realm-library/build/findbugs', reportFiles: 'findbugs-output.html', reportName: 'Findbugs issues'])
publishHTML(target: [allowMissing: false, alwaysLinkToLastBuild: false, keepAll: true, reportDir: 'realm/realm-library/build/reports/pmd', reportFiles: 'pmd.html', reportName: 'PMD Issues'])
}

stage 'build instrumented tests'
dir('realm') {
gradle 'assembleDebugAndroidTest'
dir('realm-library/build/outputs/apk') {
stash name: 'test-apk', includes: 'realm-android-library-debug-androidTest-unaligned.apk'
}
}
}

node('android-hub') {
stage 'run instrumented tests'
sh 'rm -rf *'
unstash 'test-apk'

sh 'adb devices | tee devices.txt'
def adbDevices = readFile('devices.txt')
def devices = getDeviceNames(adbDevices)

if (!devices) {
throw new IllegalStateException('No devices were found')
}

def parallelSteps = [:]
devices.each { device ->
parallelSteps[device] = transformIntoStep(device)
}

parallel parallelSteps
storeJunitResults 'test_result_*.xml'

// TODO: add support for running monkey on the example apps
// stage 'monkey examples'
// sh 'rm -rf *'
// unstash 'examples'
}

if (env.BRANCH_NAME == 'master') {
node('FastLinux') {
stage 'publish to OJO'
unstash 'java'
sh 'chmod +x gradlew && ./gradlew assemble ojoUpload'
}
}
currentBuild.rawBuild.setResult(Result.SUCCESS)
} catch (Exception e) {
echo e.getMessage()
currentBuild.rawBuild.setResult(Result.FAILURE)
} finally {
if (isPullRequest()) {
node {
reportResultToGithub()
}
}
}
}
10 changes: 10 additions & 0 deletions realm/config/findbugs/findbugs-filter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@
<Field name="minDepth" />
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD" />
</Match>
<Match>
<Class name="io.realm.internal.SharedGroup" />
<Field name="INCREMENTAL_BACKOFF_MS" />
<Bug pattern="MS_FINAL_PKGPROTECT" />
</Match>
<Match>
<Class name="io.realm.internal.SharedGroup" />
<Field name="INCREMENTAL_BACKOFF_LIMIT_MS" />
<Bug pattern="MS_SHOULD_BE_FINAL" />
</Match>

<!-- Unit tests -->
<Match>
Expand Down
2 changes: 1 addition & 1 deletion realm/realm-annotations-processor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {
testCompile files("${System.properties['java.home']}/../lib/tools.jar") // This is needed otherwise compile-testing won't be able to find it
testCompile group:'junit', name:'junit', version:'4.12'
testCompile group:'com.google.testing.compile', name:'compile-testing', version:'0.6'
testCompile files(file("${System.env.ANDROID_HOME}/platforms/android-21/android.jar"))
testCompile files(file("${System.env.ANDROID_HOME}/platforms/android-23/android.jar"))
}

// for Ant filter
Expand Down
2 changes: 1 addition & 1 deletion realm/realm-jni/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ext.coreArchiveDir = System.getenv("REALM_CORE_DOWNLOAD_DIR")
// To obtain the ABI of the connected device, execute "adb shell getprop ro.product.cpu.abi"
ext.buildTargetAbis = project.hasProperty('buildTargetABIs') ? project.getProperty('buildTargetABIs').split(',').collect {it.trim()} : null

def commonCflags = [ '-Os', '-std=c++11' ]
def commonCflags = [ '-Os', '-std=c++11', '-Wmissing-declarations' , '-Werror']
// LTO and debugging don't play well together
if (!ext.debugBuild) {
commonCflags += [ '-fvisibility=hidden', '-ffunction-sections', '-fdata-sections', '-flto' ]
Expand Down
8 changes: 0 additions & 8 deletions realm/realm-jni/src/io_realm_internal_CheckedRow.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading