Skip to content
This repository has been archived by the owner on Mar 16, 2021. It is now read-only.

Move travis to docker #116

Closed
wants to merge 3 commits into from

Conversation

StefMa
Copy link
Contributor

@StefMa StefMa commented Sep 26, 2017

Based on #115

  • Do two build environments: unit and instrumentation (run in parallel)
  • Moved unit test to docker (because of the andoird images you can't really start a emulator in docker)

Benefits of using docker:

  • The docker image contains only the "sdkamanger". The sdkmanager install every build-tools or android images if they needed automatically. We don't need to update the travis.yml anymore \o\
  • We can trust the docker. If the underlined host (travis <-> trusty, zenty) changed, everything just works as before. As long as we can run docker in that environment.

Benefits of the new travisscript:

  • It parses automatically the BUILD_TOOLS_VERSION and the SDK_VERSION from the build.gradle file and put it into the the travis android components. We don't need to update the travis.yml anymore /o/

Do we have speed benefits?

  • Unfortunately not really. Because travis is very slow with starting a emulator and stuff it won't decrease the build time. Maybe 10 seconds or so because travis don't run the unit tests anymore :)

What do test:

  • If codecov works as aspected -> Checked ✅ works

@StefMa
Copy link
Contributor Author

StefMa commented Sep 27, 2017

Seems that UnitTests are working now in docker 👍
That is great...
Moving now InstrumentationTests back to travis...

@StefMa
Copy link
Contributor Author

StefMa commented Sep 27, 2017

Read also that: https://docs.travis-ci.com/user/speeding-up-the-build/

Thinking about to have two parallel builds:

  1. Native for Instrumentation Tests
  2. Docker for Junit, codecov etc.

@StefMa
Copy link
Contributor Author

StefMa commented Sep 27, 2017

\o/ 💛 :awesome: :sweet: 🍬

Here is a 🌮

@StefMa
Copy link
Contributor Author

StefMa commented Sep 27, 2017

Next step is to cache the dependencies
https://docs.travis-ci.com/user/caching/

And other 🍬 :

  • Read the android components from a file instead of having it directly in the travis.yml. Maybe we can read the build-tools and sdkVersion from the build.gradle somehow 🤔


before_install:
- if [ $TEST_SUITE == "unit" ]; then
docker pull stefma-docker-hub.bintray.io/android-build-env:0.1-alpha;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can we update this docker image?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an open source project.
you can find it here: https://github.com/StefMa/AndroidBuildEnv

@StefMa
Copy link
Contributor Author

StefMa commented Sep 27, 2017

Don't cache.
Because we can't really delete the cache ...
Make no sense with that mechanism...

* Splitting unit and instrumentation tests
* Let's run unit tests in docker
@StefMa StefMa force-pushed the feature/move_travis_to_docker branch from 3d6443d to d6d91ec Compare September 27, 2017 12:21
.travis.yml Outdated
- 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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we make the echo multiline?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently I create a script.sh which reads the BUILD_TOOLS_VERSION and SDK_VERSION and replace the given numbers.
These script return then all components..

.travis.yml Outdated
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";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to the script section

@StefMa
Copy link
Contributor Author

StefMa commented Sep 27, 2017

🤦‍♂️

@StefMa StefMa force-pushed the feature/move_travis_to_docker branch 2 times, most recently from bb055cc to 4efa5da Compare September 28, 2017 07:37
@StefMa StefMa force-pushed the feature/move_travis_to_docker branch from 4efa5da to 70d8af7 Compare September 28, 2017 07:47
@StefMa
Copy link
Contributor Author

StefMa commented Sep 28, 2017

Currently build-tools got not parsed correctly..
geist_1506584908395

@StefMa StefMa force-pushed the feature/move_travis_to_docker branch from 68bd304 to 5c2ba57 Compare September 28, 2017 09:46
@StefMa
Copy link
Contributor Author

StefMa commented Sep 28, 2017

Rebased all.
Works now 👊

Problem was that \' is valid on "mac sed" but not on "gnu sed".
Replaced it with just '. Works on both sed versions...

@StefMa
Copy link
Contributor Author

StefMa commented Sep 28, 2017


# 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/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we put this in the .travis.yml, too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. Unfortunately this isn't possible because of the limitations of the travis.yml file

@StefMa StefMa force-pushed the feature/move_travis_to_docker branch 2 times, most recently from 4c4569d to 5c2ba57 Compare September 29, 2017 09:14
@StefMa StefMa closed this Oct 26, 2018
@StefMa StefMa deleted the feature/move_travis_to_docker branch October 26, 2018 10:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

Successfully merging this pull request may close these issues.

None yet

2 participants