Using Travis, CircleCI, CodeCov, Coveralls, Codeclimate, Codacy, Codebeat to create a zero config, zero maintenance, zero infra continuous integration and deployment pipeline.
Assumption 1: Open Source • Usually indie projects are open source • Non-profits / OSS orgs would want free CI/CD • If you’re a small startup, why not make your frontend OSS ? (Surely there’s no IP in frontend?) • If not OSS (you probably have the $$$ to pay) – $5/month for CI, – $5/month for code-coverage, – $5/month for static code analysis
Assumption 2: Trust CI host with key • Your .jks file will be encrypted • It is decrypted in a automated process • Still, theoretically it is possible for the CI host (an employee thereof) to decrypt, read and abuse it.
What all do we get ? • Build checks ? • Unit tests ? • Integration tests ? • Coverage reports ? • Code style checks ? • Code complexity ? • Automated code review? • Deploy to Play Store ? ü ü ü ü ü ü ü ü
What this setup provides ? a) (a==b) instead of (a!=b) won’t happen if the tests are in place, but still. . . b) Open Github on a browser (even on your mobile) c) Edit within Github d) Within few hours, corrected App published to Play Store.
Builds, Unit Tests, Integration Tests • Travis CI • Only Github repos • Has Mac OS servers (Yay! iOS too) • Circle CI • Faster, if using v2.0 config (warn: verbose to setup) • Supports Butbucket and Gitlab as well
Builds, Unit Tests, Integration Tests • Gitlab Builds • Free (even closed source) • Slow, limited slots, not very reliable • Bitbucket Builds • 500 min free with base back • Cost approx $1~2 per developer (unlimited repos) • Appveyor • Allows building on Windows • Can be used for Electron app builds for Windows
Code Coverage Reports • Codecov • Zero-config setup with Travis/Circle CI • Only Github • Cool Chrome/Firefox extension to view coverage inside Github • Wider support of coverage formats (lcov, jacoco and more) • Coveralls • Faster & snappier web ui • Not locked to Github
Static Code Analysis • CodeClimate • Supports way too many things • Requires verbose config file • Also supports coverage report • Some reports are not generated (no way to force re- generate)
Static Code Analysis • Codacy • Works well with Java code • Fast and clean web UI • Ambiguos marking scheme • CodeBeat • Opt-in configs, automatically reads code too • Best marking scheme (personal experience) • Complexity analysis is top notch
Deployments • Library • Jitpack (publish directly from Github) • Skip the Maven/Jcenter publishing headache • App (Play Store) – Fastlane • A tool/script, not a service • Needs to be configured and run from Travis/Circle
git push build Static analysis passed notify github notify github run tests passed no yes no Deploy to Play Store yes • Github • Travis/CricleCI • Code Analysis Service • Google Play API Process Overview
What kind of tests ? • Unit Tests • Runs on local JVM • Cannot use Android SDK stuff (com.android.** ) • Integration Tests • Runs on a device/emulator/cloud device farm • PRETTY DAMN slow (many tests = builds in hours) • Robolectric (the middle ground) • Mockito on steroids, done correctly, for Android • Run integration tests on local JVM
Unit Tests • Business logic • Does not depend on Android SDK • Try to get 100% coverage of non Android component code here Robolectric Tests • Depends on Android SDK, but not UI • SQLite, HTTPClient, JSON libcrypto all work OK • Cover everything that’s not UI or requires lifecycle Integration Tests • UI tests and lifecycle tests • Tests are flaky, so do not depend critically • Use Espresso for UI tests
Merging coverage reports • Android Studio shows coverage in-IDE for unit tests. Not for integration tests • gradle generates jacoco xml report for integration tests, not unit tests. • UGGGGGHHHHHHHHHHH!!!!!! • Let’s merge them
Bonus: Previews • Using Appetize.io API • Publish to Appetize on every RC build • Preview App over web (easy to show project managers without having them build/install)
Bonus: Automated Github Releases • Supported by both Travis and Circle (Travis easier to configure) • Release on every tag • Specify particular branches • Specify release artifacts to upload