Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Everything of CI/CD in Kyash Android

Everything of CI/CD in Kyash Android

circleci japan meetup: mobile edition

Keisuke Kobayashi

August 20, 2017
Tweet

More Decks by Keisuke Kobayashi

Other Decks in Programming

Transcript

  1. About me • Keisuke Kobayashi • GitHub, Qiita: kobakei •

    Twitter: kobakei122 • Kyash, Inc • Using CircleCI for 3+ years
  2. Kyash Android • Full Kotlin • About 40 activities +

    Bottom Navigation • Architecture • MVVM + Layered architecture • Library • Rx, Dagger, Data binding, Retrofit & OkHttp, Picasso, Orma, Gson
  3. Unit testing • Robolectric + Mockito • No emulator =

    fast • Focus on ViewModel and Model. 
 Activity and Fragment are not target. • Easy to inject mock objects by Dagger 2 • Run by git push on Circle CI
  4. @Test fun doAction_doesSomething(){ /* Given */ val mock = mock<MyClass>

    { on { getText() } doReturn "text" } val classUnderTest = ClassUnderTest(mock) /* When */ classUnderTest.doAction() /* Then */ verify(mock).doSomething(any()) }
  5. jacoco-android-gradle-plugin • Add gradle tasks to run unit test and

    code coverage • Need to exclude classes generated by kapt • Data binding, ORM, Parcelable, etc • No badge now • Codecov, Coveralls
  6. ktlint-gradle • Coding style checker and formatter for Kotlin •

    Default style is official style from kotlinlang.org • Not same as Android Studio default setting • Override: ktlint —apply-to-idea • Run style check on Circle CI
  7. UI testing • Espresso + UI automator • Use Espresso

    basically • Use UI automator to OS/other app UI (ex. permission dialog) • Don’t run on CI due to long exec time • Run before release to confirm important flows don’t degrade • ex. Sign up flow
  8. Mock in UI testing • MockWebServer of Retrofit • Unlike

    Mockito, JSON parse can be tested • Share MockWebServer object between Application class and test classes • Change API response at every test case
  9. Firebase Test Lab • Still experimental • Run UI testing

    on OS x device matrix • In parallel • Video recording in testing • 5 or 10 tests/day in free plan • Run before release manually?
  10. Crashlytics • Share the latest apk to team • master

    branch = debug build • Development endpoint • Debug screen with debot • Deploy at every git push (10~ times / day) • release/1.2.3 branch = beta build • Production endpoint • Deploy at code freeze
  11. Google Play • gradle-play-publisher • Gradle wrapper of Google Play

    Developer API • Need to set up Google API console • Can publish as alpha, beta and staging rollout • Triggered by GitHub Release (git tag) • However CircleCI 2.0 doesn't support tag…
  12. Version name and code // App version def versionMajor =

    1 def versionMinor = 11 def versionPatch = 2 // version code def vc = 0 if (System.getenv("CIRCLE_TAG") != null) { // tag = release build vc = versionMajor * 10000 + versionMinor * 100 + versionPatch } else if ("true" == System.getenv("CI")) { // no tag but CI = dev build vc = System.getenv("CIRCLE_BUILD_NUM") as Integer } else { // otherwise = local build vc = versionMajor * 10000 + versionMinor * 100 + versionPatch }
  13. Like • Can start by free event if private repo

    • Many users • We can search YAML file on GitHub • Kind support • ex. Memory limit of my project has been increased before
  14. I want… • Trigger by git tag • Firebase Test

    Lab on CircleCI 2.0 • Docs • There is only docs for CircleCI 1.0 • May need Docker image?