All Ruby on Rails Node JS Android iOS React Native Frontend Flutter

Kotlin Multiplatform Guidelines. Continuous Integration

Continuous Integration in Kotlin Multiplatform projects requires a slightly different approach comparing to the Native ones.  In this edition of Kotlin Multiplatform Guidelines we will focus on explaining the possible CI implementation working with the Android, iOS, and Spring backend platforms developed with Kotlin Multiplatform. 

Every change in the common module can affect all the platforms that we support, so it’s required to check if new code doesn’t break anything in every one of them. Moreover, CI service must support building all the platforms that we want to build in our project. Unfortunately currently, none of the existing CI services doesn’t support building Kotlin Multiplatform out of the box. Because of that, we decided to use Bitrise which is the first option in case of mobile projects in Netguru and create a custom configuration with separate app instance per each platform that we need.

 

Android Configuration

Android configuration consists of two workflows:

  • Primary - triggered when the code is merged into the master branch

  • PR - triggered on Pull Request into the master branch


There is a slight difference between those two - Primary workflow has two additional steps which are App signing and Deploying an App.

Each workflow needs to check either common and platform-specific code. An example is presented below:

  1. Run platform-specific steps, e.g. Install Missing Android Dependencies

  2. Run tests from every common module that is used inside the platform-specific code

  3. Run tests from platform-specific code

  4. Build an app


Every step has to be completed without any errors to ensure that the Application works correctly.

Requirements:

  • Stack supporting JDK 1.8 + Android SDK

iOS Configuration

iOS configuration is quite similar to Android one. It also consists of two workflows: Primary and PR which are described in the Android part.

The main difference between iOS and Android configuration is the stack configuration. It’s required that stack supports both iOS and JDK because we need to build common modules via Gradle.

Same as in Android, we need to build and check common modules before switching to the iOS part:

  1. Run platform-specific steps, e.g. Install Missing iOS Dependencies

  2. Run tests from every common module that is used inside the platform-specific code

  3. Build common modules and compile them into the Framework which can be used in iOS code

  4. Run tests from platform-specific code

  5. Build an app


Every step has to be completed without any errors to ensure that the Application works correctly. It’s crucial to be sure that the CI stack covers both iOS and JDK because of common modules.

Requirements:

  • macOS stack + JDK 1.8 support + Android SDK


Backend Configuration

Backend configuration is quite similar to Android one. It also consists of two workflows: Primary and PR which are described in the Android part.


The Primary workflow potentially could have two additional custom steps - App artifact generating and Deploying to the staging environment.

Each workflow needs to check either common and backend-specific code. An example is presented below:

  1. Run backend-specific steps, e.g. Install Missing Spring Dependencies

  2. Run tests from every common module that is used inside the backend-specific code

  3. Run tests from backend-specific code

  4. Build an app


Every step has to be completed without any errors to ensure that Spring app works correctly.

Requirements:

  • Stack supporting JDK 1.8


Possible implementations

  1. Self-hosted CI deploy running on macOS based (virtual) machine.

    1. https://github.com/jenkinsci/jenkins

  2. CircleCI workflows running on a custom-built docker image of macOS

    1. https://circleci.com/docs/2.0/custom-images/#section=configuration

    2. https://circleci.com/docs/2.0/private-images/

digital transformation
Code stories CTA
READ ALSO FROM Kotlin
Read also
Need a successful project?
Estimate project or contact us