From d6d91ec3084e1b4e9aeaf37dc5defc9fdddb9a5f Mon Sep 17 00:00:00 2001 From: StefMa Date: Tue, 26 Sep 2017 16:31:10 +0200 Subject: [PATCH 1/3] Update travis: * Splitting unit and instrumentation tests * Let's run unit tests in docker --- .travis.yml | 71 ++++++++++++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/.travis.yml b/.travis.yml index b7843646..fd15d2f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,49 +1,42 @@ -language: android -jdk: - - oraclejdk8 +sudo: required +language: android +jdk: oraclejdk8 + +services: + - docker + +env: + - TEST_SUITE=unit + - TEST_SUITE=instrumentation + android: components: - # Uncomment the lines below if you want to - # use the latest revision of Android SDK Tools - - 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-22 - - android-26 - - # Additional components - - extra-google-google_play_services - - extra-google-m2repository - - extra-android-m2repository - - addon-google_apis-google-24 - - # Specify at least one system image, - # if you need to run emulator(s) during your tests - - sys-img-armeabi-v7a-android-22 - - + - $(if [ $TEST_SUITE == "instrumentation" ]; then echo "tools,platform-tools,tools,build-tools-26.0.1,android-22,android-26,extra-google-google_play_services,extra-google-m2repository,extra-android-m2repository,addon-google_apis-google-24,sys-img-armeabi-v7a-android-22"; fi) + +before_install: + - if [ $TEST_SUITE == "unit" ]; then + docker pull stefma-docker-hub.bintray.io/android-build-env:0.1-alpha; + docker run -i -v $PWD:/project -t stefma-docker-hub.bintray.io/android-build-env:0.1-alpha /bin/bash -c "./gradlew build jacocoTestReport"; + fi + before_script: - - # First assemble the project before launching the emulator - - ./gradlew assemble - - # List available emulators - - android list targets - # Emulator Management: Create, Start and Wait - - echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a - - emulator -avd test -no-skin -no-audio -no-window & - - android-wait-for-emulator - - adb shell input keyevent 82 & + - if [ $TEST_SUITE == "instrumentation" ]; then + ./gradlew assemble; + echo no | android create avd --force -n test -t android-22 --abi armeabi-v7a; + emulator -avd test -no-skin -no-audio -no-window & + android-wait-for-emulator; + adb shell input keyevent 82 & + fi script: - - ./gradlew build jacocoTestReport assembleAndroidTest connectedCheck + - if [ $TEST_SUITE == "instrumentation" ]; then + ./gradlew assembleAndroidTest connectedCheck; + fi + - if [ $TEST_SUITE == "unit" ]; then + echo "Everything is done already in the before_install docker..."; + fi after_success: - bash <(curl -s https://codecov.io/bash) \ No newline at end of file From d08f7e7bf77a29d848114519995b38479c3c8ea5 Mon Sep 17 00:00:00 2001 From: StefMa Date: Thu, 28 Sep 2017 09:37:51 +0200 Subject: [PATCH 2/3] Move docker run into script --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fd15d2f5..3e7debfc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,7 +17,6 @@ android: before_install: - if [ $TEST_SUITE == "unit" ]; then docker pull stefma-docker-hub.bintray.io/android-build-env:0.1-alpha; - docker run -i -v $PWD:/project -t stefma-docker-hub.bintray.io/android-build-env:0.1-alpha /bin/bash -c "./gradlew build jacocoTestReport"; fi before_script: @@ -35,7 +34,7 @@ script: ./gradlew assembleAndroidTest connectedCheck; fi - if [ $TEST_SUITE == "unit" ]; then - echo "Everything is done already in the before_install docker..."; + docker run -i -v $PWD:/project -t stefma-docker-hub.bintray.io/android-build-env:0.1-alpha /bin/bash -c "./gradlew build jacocoTestReport"; fi after_success: From 5c2ba57fdf35738b40d97bff013b9565fdb2625e Mon Sep 17 00:00:00 2001 From: StefMa Date: Wed, 27 Sep 2017 15:46:42 +0200 Subject: [PATCH 3/3] Extract android components to its own script --- .travis.yml | 2 +- .travisAndroidComponents.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100755 .travisAndroidComponents.sh diff --git a/.travis.yml b/.travis.yml index 3e7debfc..e9bd059a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,7 +12,7 @@ env: android: components: - - $(if [ $TEST_SUITE == "instrumentation" ]; then echo "tools,platform-tools,tools,build-tools-26.0.1,android-22,android-26,extra-google-google_play_services,extra-google-m2repository,extra-android-m2repository,addon-google_apis-google-24,sys-img-armeabi-v7a-android-22"; fi) + - $(if [ $TEST_SUITE == "instrumentation" ]; then ./.travisAndroidComponents.sh; fi) before_install: - if [ $TEST_SUITE == "unit" ]; then diff --git a/.travisAndroidComponents.sh b/.travisAndroidComponents.sh new file mode 100755 index 00000000..c95d16dd --- /dev/null +++ b/.travisAndroidComponents.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Read the BUILD_TOOL_VERSION and COMPILE_SDK_VERSION +BUILD_TOOLS_VERSION=$(cat build.gradle | grep "BUILD_TOOLS_VERSION*" | sed -e "s/^.*'\(.*\)'/\1/") +COMPILE_SDK_VERSION=$(cat build.gradle | grep "COMPILE_SDK_VERSION*" | sed -e "s/^.*= \(.*\)$/\1/") + +# Echo every componnent we need to install and replace the BUILD_TOOLS_VERSION and COMPILE_SDK_VERSION +echo "tools,platform-tools,tools,build-tools-$BUILD_TOOLS_VERSION,android-22,android-$COMPILE_SDK_VERSION,extra-google-google_play_services,extra-google-m2repository,extra-android-m2repository,addon-google_apis-google-24,sys-img-armeabi-v7a-android-22"