Slide 1

Slide 1 text

Continuous Integration for your Android projects Sergii Zhuk Android Developer at DAXX BV Kyiv, UA Mobile 2014 1

Slide 2

Slide 2 text

Agenda • CI in general • Popular CI systems and tools – Travis CI – Circle CI – Jenkins – Continuous Deployment • Demo projects • Q&A 2

Slide 3

Slide 3 text

Continuous integration • Every developer keeps his work-in-progress continually integrated with every other developer • Requires build to be automated and self- testing • Makes results of the latest build visible 3 http://martinfowler.com/articles/continuousIntegration.html

Slide 4

Slide 4 text

• Making a build (periodically, triggered) • Running a unit and integration tests • Returning artifacts, test reports, code coverage reports etc. • Notifications • Deploying to continuous deployment tools 4 Practical outcomes that CI provides

Slide 5

Slide 5 text

Practical outcomes that CI provides 5 Illustration from https://www.jetbrains.com/teamcity/features/deployment.html

Slide 6

Slide 6 text

Travis CI: overview • Hosted, open-source • GitHub-only integration • Free for public GitHub repositories, starting from $129/mo for private ones • Easy to setup: always one .travis.yml file • Officially supports Android platform since 2014 6

Slide 7

Slide 7 text

Travis CI: setup • Hosted Travis Webapp setup, add your GitHub account • .travis.yml configuration file • Validate your configuration file http://lint.travis-ci.org/ [yaml syntax] 7

Slide 8

Slide 8 text

Travis CI: configuration options (1) • Programming language your project uses • Commands/scripts you want to be executed before each build (e.g. install dependencies) • Command is used to run test suite • Emails, Campfire and IRC rooms to notify about failures 8

Slide 9

Slide 9 text

Travis CI: configuration options (2) • Code coverage (for Java/Android): external hosted tool Coveralls, uses JaCoCo reports, from $5/mo • Limited functionality in uploading artifacts, but friendly with Amazon S3 • Scheduled builds only by external tool 9

Slide 10

Slide 10 text

Travis CI: configuration example language: android android: components: # The BuildTools version used by your project - build-tools-19.1.0 # The SDK version used to compile your project - android-19 before_install: - chmod +x gradlew install: - ./gradlew assemble script: - ./gradlew test # For Robolectric tests 10

Slide 11

Slide 11 text

Circle CI: overview • Hosted service • GitHub-only integration • Starts from $19/mo • Easy to setup: 2 additional files for Android • SSH access to build VM for 30 minutes after build 11

Slide 12

Slide 12 text

• What programming language your project uses • What commands/scripts you want to be executed before each build (e.g. install dependencies) • What command is used to run test suite • Artifacts to collect • Nightly builds (using extra script) 12 Circle CI: configuration options

Slide 13

Slide 13 text

Circle CI: configuration (1): circle.yml 13 machine: environment: ANDROID_HOME: /usr/local/android-sdk-linux dependencies: cache_directories: - ~/.android - ~/android override: - bash install-dependencies.sh test: override: - chmod +x gradlew - ./gradlew assemble test Looks like Travis CI, doesn’t it?

Slide 14

Slide 14 text

Circle CI: configuration (2): dependencies script export PATH="$ANDROID_HOME/platform- tools:$ANDROID_HOME/tools:$PATH" DEPS="$ANDROID_HOME/installed-dependencies" if [ ! -e $DEPS ]; then echo y | android update sdk -u -a -t android-19 && echo y | android update sdk -u -a -t platform-tools && echo y | android update sdk -u -a -t extra && echo y | android update sdk -u -a -t build-tools-19.1.0 && touch $DEPS fi 14

Slide 15

Slide 15 text

Jenkins: overview • Hudson  Jenkins • Open-Source • Java WebApp in container • Should be hosted on your private server • Multiple users, matrix permissions 15

Slide 16

Slide 16 text

Jenkins: setup • Network-enabled server • Install Jenkins bundle with servlet container • Install Android SDK and support repos • Add Jenkins plugins for Git, Gradle etc. • Add your Git keys 16

Slide 17

Slide 17 text

• Extremely flexible • Hundreds of plugins 17 Jenkins: configuration options

Slide 18

Slide 18 text

Jenkins: useful plugins • Android Lint plugin • HTML Report plugin • JaCoCo plugin • HockeyApp plugin • Google Play Android Publisher plugin 18

Slide 19

Slide 19 text

Continuous deployment • Submit latest builds to test devices • TestFlight RIP 19

Slide 20

Slide 20 text

Continuous deployment tools HockeyApp Appaloosa TestFairy Play Store Apphance Continuous deployment API X X X X X Mobile version X X X Distribution list permissioning X X X X Cost First month free, next from $30/mo Free, limited to 1 app and 10 users Free Registration fee Free, limited to 1 app and 50 devices 20 http://www.thoughtworks.com/insights/blog/testflight-alternatives-android

Slide 21

Slide 21 text

Some other CI products • CruiseControl : open-source, last updated in 2010 • Ship.io (ex CIsimple) : hosted, easy to setup, but still a startup with bugs & limited functionality • TeamCity by JetBrains : good IntelliJ products integration, server-based, has free version • Atlassian Bamboo : good JIRA integration, starts from $10/month 21

Slide 22

Slide 22 text

Demo: Example Android project • Simple • Gradle-based • Robolectric unit tests • Hosted on GitHub 22

Slide 23

Slide 23 text

Demo 23

Slide 24

Slide 24 text

Useful links • General http://martinfowler.com/articles/continuousIntegration.html https://devblog.toopher.com/2013/07/05/enabling-travis-ci-for-fun-and-profit/ http://ruenzuo.github.io/continuous-delivery-on-android-part-ii/index.html • Jenkins setup http://sanketdangi.com/post/62715793234/install-configure-jenkins-on-amazon-linux https://www.digitalocean.com/community/tutorials/how-to-build-android-apps-with-jenkins http://stackoverflow.com/questions/18045712/gradle-build-android-project-could-not- resolve-all-dependencies-error-but-i-t 24

Slide 25

Slide 25 text

25 Q&A

Slide 26

Slide 26 text

Thanks! Contact me: [email protected] http://ua.linkedin.com/in/sergiizhuk http://fb.com/sergii.zhuk 26