diff --git a/.travis.yml b/.travis.yml index b7843646..e9bd059a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,49 +1,41 @@ -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 ./.travisAndroidComponents.sh; fi) +before_install: + - if [ $TEST_SUITE == "unit" ]; then + docker pull stefma-docker-hub.bintray.io/android-build-env:0.1-alpha; + 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 + 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: - bash <(curl -s https://codecov.io/bash) \ No newline at end of file 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"