How to build 44% faster with parallel workflows?

Oct 14, 2019

In this article, I will be comparing a single workflow and multiple parallel workflows for building, testing & publishing an app on Codemagic.

So, let’s first understand what are workflows on Codemagic.

What is Workflow

A workflow is a set of settings that determines how the app is to be built, tested and published. You can create several workflows for building different configurations of your app.

You can use workflows to get the following advantages:

  1. Separate the builds for different platforms
  2. Separate the release and debug builds
  3. To build and test different branches of a project
  4. To run different tests specific to a platform
  5. To build, test & publish apps in parallel

Creating a workflow

Workflows are really simple to create on Codemagic.

  1. Log in to Codemagic.
  2. From the Applications dashboard, search for the project that you want to build.
  3. Go to the Settings of the project.

You will see that you already have a Default Workflow 4. To create a new workflow, click on Duplicate workflow in the Workflow settings.

5. You can change the name of the workflow from the Workflow settings by clicking on it.

6. Now, you can define the configurations for this workflow.

So, you have now successfully created a workflow.

Build concurrency with Magic seats

Recently, Codemagic has introduced Magic seats for leveraging the Teams functionality.

Teams that consist of only regular seats have a build concurrency of 1 so they can run their builds one at a time. This means that if a new commit to the project is made, it cannot be built before the previous build has finished. With Magic seats, you can speed up the process by running builds in parallel.

Check out the official post for more details here.

Parallel builds

Running parallel builds on Codemagic is very simple.

  1. Create more than one workflow with different configurations.

Now, for running them concurrently, just run the workflows one after another. 2. Go to one workflow and click on Start new build.

3. Make sure the correct workflow is selected and again click on Start new build.

4. After starting the build of one workflow, click on Settings.

5. From here we can start the build of the second workflow by selecting it and then again clicking on Start new build.

6. In this way we can start a number of parallel workflows together by repeating the steps from 2 to 5.

Review of parallel builds

Now, as we know how to run a number of workflows concurrently, let’s do some research to see if parallel workflows are really time saving.

For reviewing this, we will be creating two workflows (for two different platforms), one for Android & the other one for iOS.

And, we will also be leaving the Default Workflow with configuration of both the platforms as it is, so that we compare the result with it later.

Let’s get started.

  1. Create one workflow by clicking on Duplicate workflow.

  2. Name the first duplicate workflow to be Android Workflow

  3. Now, scroll down and click on the Build tab.

  4. Here, select only the Android platform. And click on Save.

  5. Now, complete defining other Android-specific configurations for this workflow.

  6. Create another duplicate workflow from the Default Workflow.

  7. Name it iOS Workflow.

  8. Select only iOS platform in the Build tab and complete defining other iOS-specific configurations.

  9. Run the two workflows one after another, by clicking on Start new build and then selecting the appropriate workflow.

  10. Wait for the builds to finish.

You can see the workflows while they are building in one place by going to the Builds tab.

The results are in now, and we can compare to see which one is faster, parallel workflows or a single workflow for both platforms.

So, from the results we see that the Android Workflow took 4m 10s to run and the iOS Workflow took 3m 35s to run. When we compare it with the Default Workflow which took 7m 29s to run, we can clearly see that using parallel workflows for each platform is much more efficient than running a single workflow for both platforms as the effective time in the case of parallel workflows is only 4m 10s, which is about 44% faster in this case.

In this case parallel workflow is about 44% faster than running single workflow for iOS and Android separately

Conclusion

Concurrent builds on Codemagic is very easy to set up by creating multiple workflows and then running them one after another. With the help of Magic seats, you can increase the number of parallel builds you and your team can run at a time. So, why use a single build when you can run concurrent builds saving a lot of your build time.


This article is written by Souvik Biswas. He is a passionate Mobile App Developer (Android and Flutter) and has worked on a number of mobile apps throughout his journey. Loves open source contribution on GitHub. He is currently pursuing a B.Tech degree in Computer Science and Engineering from Indian Institute of Information Technology Kalyani. He also writes Flutter articles on Medium - Flutter Community.

Codemagic CI for Flutter