Skip to content

Commit

Permalink
Closes #1: Setup CI (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmeissner authored Sep 1, 2017
1 parent e65f3d9 commit 48e5061
Show file tree
Hide file tree
Showing 12 changed files with 204 additions and 57 deletions.
4 changes: 2 additions & 2 deletions .idea/modules.xml

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

40 changes: 40 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<YOUR_API_KEY>"
INFURA_API_KEY=<YOUR_API_KEY>
```

Replace `<YOUR_API_KEY>` with the key that you get from Infura.
98 changes: 50 additions & 48 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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'
})
}
11 changes: 5 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -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"
}
}

Expand Down
11 changes: 11 additions & 0 deletions buildsystem/constants.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
ext {
javaTypes = [
NULL: "null",
TRUE: "true",
FALSE: "false",
BOOLEAN: "boolean",
STRING: "String",
INT: "int",
LONG: "long"
]
}
33 changes: 33 additions & 0 deletions buildsystem/dependencies.gradle
Original file line number Diff line number Diff line change
@@ -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',
]
}
35 changes: 35 additions & 0 deletions buildsystem/helpers.gradle
Original file line number Diff line number Diff line change
@@ -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
}
5 changes: 5 additions & 0 deletions ci/build_debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
# fail if any commands fails
set -e

./gradlew clean assembleDebug
10 changes: 10 additions & 0 deletions ci/notify_slack.sh
Original file line number Diff line number Diff line change
@@ -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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
12 changes: 12 additions & 0 deletions ci/prepare_env.sh
Original file line number Diff line number Diff line change
@@ -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
Binary file added debug.keystore
Binary file not shown.

0 comments on commit 48e5061

Please sign in to comment.