From 48e5061059553e08e05dc355ce97ad1b6119bf84 Mon Sep 17 00:00:00 2001 From: Richard Meissner Date: Sat, 2 Sep 2017 00:28:35 +0200 Subject: [PATCH] Closes #1: Setup CI (#2) --- .idea/modules.xml | 4 +- .travis.yml | 40 +++++++++++++ README.md | 2 +- app/build.gradle | 98 ++++++++++++++++---------------- build.gradle | 11 ++-- buildsystem/constants.gradle | 11 ++++ buildsystem/dependencies.gradle | 33 +++++++++++ buildsystem/helpers.gradle | 35 ++++++++++++ ci/build_debug.sh | 5 ++ ci/notify_slack.sh | 10 ++++ ci/prepare_env.sh | 12 ++++ debug.keystore | Bin 0 -> 1261 bytes 12 files changed, 204 insertions(+), 57 deletions(-) create mode 100644 .travis.yml create mode 100644 buildsystem/constants.gradle create mode 100644 buildsystem/dependencies.gradle create mode 100644 buildsystem/helpers.gradle create mode 100755 ci/build_debug.sh create mode 100755 ci/notify_slack.sh create mode 100755 ci/prepare_env.sh create mode 100644 debug.keystore diff --git a/.idea/modules.xml b/.idea/modules.xml index f4055e8194..0056832ac7 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,7 +3,7 @@ - + - \ No newline at end of file + diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..b709155285 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,40 @@ +language: android +android: + components: + - tools + - platform-tools + - tools + + # The BuildTools version used by your project + - build-tools-26.0.1 + + # The SDK version used to compile your project + - android-26 + + - extra-android-m2repository + +cache: + directories: + - $HOME/.gradle/caches/ + - $HOME/.gradle/wrapper/ + - $HOME/.android/build-cache + +before_cache: + - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock + - rm -fr $HOME/.gradle/caches/*/plugin-resolution/ + +script: + - . ./ci/prepare_env.sh + - ./ci/build_debug.sh + +deploy: + provider: releases + api_key: "${GITHUB_API_KEY}" + file_glob: true + file: app/build/outputs/apk/*/*.apk + skip_cleanup: true + on: + tags: true + +after_deploy: + - ./ci/notify_slack.sh \ No newline at end of file diff --git a/README.md b/README.md index 1144014f4a..9805b08188 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ A default account is created per installation. The Json RPC depends on [Infura](https://infura.io/). You need to get an API key and create a file named `project_keys` with the following contents: ``` -INFURA_API_KEY = "" +INFURA_API_KEY= ``` Replace `` with the key that you get from Infura. diff --git a/app/build.gradle b/app/build.gradle index 6229998b0e..5c5c6628fb 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,30 +10,40 @@ android { applicationId "pm.gnosis.android.app.wallet" minSdkVersion 16 targetSdkVersion 26 - versionCode 1 - versionName "1.0" + versionCode getInt("APP_VERSION_CODE", 1) + versionName getKey("APP_VERSION_NAME", "1.0") testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + vectorDrawables.useSupportLibrary = true + + project.ext.set("archivesBaseName", String.format("gnosis-authenticator-%s", defaultConfig.versionCode)) + javaCompileOptions { annotationProcessorOptions { - arguments = ["room.schemaLocation": - "$projectDir/schemas".toString()] + arguments = ["room.schemaLocation": "$projectDir/schemas".toString()] } } } defaultConfig { - buildConfigField "String", "BLOCKCHAIN_NET_URL", '"https://mainnet.infura.io"' - buildConfigField "String", "INFURA_API_KEY", getKey("INFURA_API_KEY") - buildConfigField "boolean", "PRIVATE_TEST_NET", "false" + buildConfigField javaTypes.STRING, "BLOCKCHAIN_NET_URL", asString("https://mainnet.infura.io") + buildConfigField javaTypes.STRING, "INFURA_API_KEY", asString(getKey("INFURA_API_KEY")) + buildConfigField javaTypes.BOOLEAN, "PRIVATE_TEST_NET", javaTypes.FALSE + } + + signingConfigs { + debug { + // We add the debug keystore to repo so that the travis build will always have the same signature + storeFile file("../debug.keystore") + } } buildTypes { chainTest { signingConfig signingConfigs.debug minifyEnabled false - buildConfigField "String", "BLOCKCHAIN_NET_URL", getKey("BLOCKCHAIN_NET_URL") - buildConfigField "boolean", "PRIVATE_TEST_NET", getKey("PRIVATE_TEST_NET", "false") + buildConfigField javaTypes.STRING, "BLOCKCHAIN_NET_URL", asString(getKey("BLOCKCHAIN_NET_URL")) + buildConfigField javaTypes.BOOLEAN, "PRIVATE_TEST_NET", getKey("PRIVATE_TEST_NET", javaTypes.FALSE) } debug { @@ -54,57 +64,49 @@ android { exclude 'META-INF/rxjava.properties' exclude 'META-INF/LICENSE' } -} -static def getKey(String property, String defaultValue = "") { - Properties properties = new Properties() - properties.load(new FileInputStream("project_keys")) - String value = properties.getProperty(property) - return value != null ? value : defaultValue + lintOptions { + abortOnError false + } } - dependencies { - final SUPPORT_LIB_VERSION = '26.0.1' - final DAGGER_VERSION = '2.11' - final RETROFIT_VERSION = '2.3.0' - final ARCHITECTURE_COMPONENTS_VERSION = '1.0.0-alpha9' - implementation fileTree(dir: 'libs', include: ['*.jar']) - androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', { - exclude group: 'com.android.support', module: 'support-annotations' - }) - implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version" - implementation "com.android.support:appcompat-v7:$SUPPORT_LIB_VERSION" - implementation "com.android.support:cardview-v7:$SUPPORT_LIB_VERSION" - implementation "com.android.support:design:$SUPPORT_LIB_VERSION" + implementation "org.jetbrains.kotlin:kotlin-stdlib-jre7:$versions.kotlin" + implementation "com.android.support:appcompat-v7:$versions.android_support" + implementation "com.android.support:cardview-v7:$versions.android_support" + implementation "com.android.support:design:$versions.android_support" - implementation "android.arch.persistence.room:runtime:$ARCHITECTURE_COMPONENTS_VERSION" - kapt "android.arch.persistence.room:compiler:$ARCHITECTURE_COMPONENTS_VERSION" - implementation "android.arch.persistence.room:rxjava2:$ARCHITECTURE_COMPONENTS_VERSION" + implementation "android.arch.persistence.room:runtime:$versions.architecture_components" + kapt "android.arch.persistence.room:compiler:$versions.architecture_components" + implementation "android.arch.persistence.room:rxjava2:$versions.architecture_components" - implementation "com.jakewharton.timber:timber:4.5.1" + implementation "com.jakewharton.timber:timber:$versions.timber" //https://github.com/square/moshi/issues/315 - implementation "com.squareup.moshi:moshi:1.4.0" - implementation "io.reactivex.rxjava2:rxandroid:2.0.1" - implementation "io.reactivex.rxjava2:rxjava:2.1.2" - implementation 'io.reactivex.rxjava2:rxkotlin:2.1.0' - implementation "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION" - implementation "com.squareup.retrofit2:converter-moshi:$RETROFIT_VERSION" - implementation "com.squareup.retrofit2:adapter-rxjava2:$RETROFIT_VERSION" - implementation "com.gojuno.koptional:koptional:1.2.0" - - implementation "com.google.zxing:core:3.3.0" - implementation "com.github.clans:fab:1.6.4" - implementation "me.zhanghai.android.materialprogressbar:library:1.4.1" + implementation "com.squareup.moshi:moshi:$versions.moshi" + implementation "io.reactivex.rxjava2:rxandroid:$versions.rxandroid" + implementation "io.reactivex.rxjava2:rxjava:$versions.rxjava" + implementation "io.reactivex.rxjava2:rxkotlin:$versions.rxkotlin" + implementation "com.squareup.retrofit2:retrofit:$versions.retrofit" + implementation "com.squareup.retrofit2:converter-moshi:$versions.retrofit" + implementation "com.squareup.retrofit2:adapter-rxjava2:$versions.retrofit" + implementation "com.gojuno.koptional:koptional:$versions.koptional" + + implementation "com.google.zxing:core:$versions.zxing" + implementation "com.github.clans:fab:$versions.floating_action_button" + implementation "me.zhanghai.android.materialprogressbar:library:$versions.material_progressbar" //Dagger - implementation "com.google.dagger:dagger:$DAGGER_VERSION" - kapt "com.google.dagger:dagger-compiler:$DAGGER_VERSION" + implementation "com.google.dagger:dagger:$versions.dagger" + kapt "com.google.dagger:dagger-compiler:$versions.dagger" //Ethereum - implementation "org.ethereum:geth:1.6.6" + implementation "org.ethereum:geth:$versions.geth" + + testImplementation "junit:junit:$versions.junit" - testImplementation 'junit:junit:4.12' + androidTestImplementation("com.android.support.test.espresso:espresso-core:$versions.espresso", { + exclude group: 'com.android.support', module: 'support-annotations' + }) } diff --git a/build.gradle b/build.gradle index 2066080f93..250c5db341 100644 --- a/build.gradle +++ b/build.gradle @@ -1,17 +1,16 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - ext.kotlin_version = '1.1.4' + apply from: 'buildsystem/constants.gradle' + apply from: 'buildsystem/helpers.gradle' + apply from: 'buildsystem/dependencies.gradle' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.0.0-beta2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + classpath "com.android.tools.build:gradle:$versions.android_tools" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin" } } diff --git a/buildsystem/constants.gradle b/buildsystem/constants.gradle new file mode 100644 index 0000000000..11fb33b1c3 --- /dev/null +++ b/buildsystem/constants.gradle @@ -0,0 +1,11 @@ +ext { + javaTypes = [ + NULL: "null", + TRUE: "true", + FALSE: "false", + BOOLEAN: "boolean", + STRING: "String", + INT: "int", + LONG: "long" + ] +} \ No newline at end of file diff --git a/buildsystem/dependencies.gradle b/buildsystem/dependencies.gradle new file mode 100644 index 0000000000..98f87e1c27 --- /dev/null +++ b/buildsystem/dependencies.gradle @@ -0,0 +1,33 @@ +ext { + + versions = [ + // Plug-Ins + android_tools : '3.0.0-beta2', + google_services : '3.1.0', + kotlin : '1.1.4', + + // Runtime dependencies + android_support : '26.0.2', + architecture_components: '1.0.0-alpha9', + dagger : '2.11', + floating_action_button : '1.6.4', + geth : '1.6.6', + koptional : '1.2.0', + material_progressbar : '1.4.1', + moshi : '1.4.0', + okhttp : '3.8.1', + okio : '1.13.0', + retrofit : '2.3.0', + room : '1.0.0-alpha8', + rxandroid : '2.0.1', + rxjava : '2.1.2', + rxkotlin : '2.1.0', + timber : '4.5.1', + zxing : '3.3.0', + + // Test dependencies + espresso : '3.0.0', + junit : '4.12', + mockito : '2.8.47', + ] +} \ No newline at end of file diff --git a/buildsystem/helpers.gradle b/buildsystem/helpers.gradle new file mode 100644 index 0000000000..c3ebfcc7b3 --- /dev/null +++ b/buildsystem/helpers.gradle @@ -0,0 +1,35 @@ +static def getKey(String name, String defaultValue = null) { + def value = null + try { + Properties properties = new Properties() + properties.load(new FileInputStream("project_keys")) + value = properties.getProperty(name) + } catch (Exception ignored) { + // noop + } + if (value == null) { + value = System.getenv(name) + } + if (value == null) { + return defaultValue + } + return value +} + +def getInt(String name, int defaultValue) { + def envValue = getKey(name) + if (envValue == null) { + return defaultValue + } + return Integer.parseInt(envValue) +} + +static def asString(String input) { + return input == null ? null : "\"" + input + "\"" +} + +ext { + getKey = this.&getKey + getInt = this.&getInt + asString = this.&asString +} \ No newline at end of file diff --git a/ci/build_debug.sh b/ci/build_debug.sh new file mode 100755 index 0000000000..231e5039ca --- /dev/null +++ b/ci/build_debug.sh @@ -0,0 +1,5 @@ +#!/bin/bash +# fail if any commands fails +set -e + +./gradlew clean assembleDebug \ No newline at end of file diff --git a/ci/notify_slack.sh b/ci/notify_slack.sh new file mode 100755 index 0000000000..25b85e3ebd --- /dev/null +++ b/ci/notify_slack.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# fail if any commands fails +set -e + +repo_url="$(git config --get remote.origin.url)" +release_path="/releases/tag/${TRAVIS_TAG}" +release_url="${repo_url/.git/$release_path}" +curl -X POST -H 'Content-type: application/json' \ +--data "{\"text\":\"<${release_url}|Version ${APP_VERSION_NAME}> for ${TRAVIS_REPO_SLUG} is out!\"}" \ +https://hooks.slack.com/services/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 \ No newline at end of file diff --git a/ci/prepare_env.sh b/ci/prepare_env.sh new file mode 100755 index 0000000000..5800b04ddd --- /dev/null +++ b/ci/prepare_env.sh @@ -0,0 +1,12 @@ +#!/bin/bash +# fail if any commands fails +set -e + +git branch + +# write your script here +export APP_VERSION_CODE=$TRAVIS_BUILD_NUMBER +# strip the first char as that should always be "v" (as tags should be in the format "vX.X.X") +description="$(git describe --tags)" +export APP_VERSION_NAME=${description:1} +export APP_RELEASE_NOTES=$TRAVIS_COMMIT_MESSAGE diff --git a/debug.keystore b/debug.keystore new file mode 100644 index 0000000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