Parallelize steps inside jobs

Hey there!

I’m busy setting up a few pipelines in the development process of my organization.

However, I stumbled upon an issue I can’t seem to wrap my head around.
I already tried searching for a solution on this forum, as well as on Github, StackOverflow, …

Problem

Let me first explain the situation.

I’m developing a whitelabel expo app (React Native). This means I have to build and deploy multiple versions of the app to the native app stores (Google Play Store & App Store). As you can guess, this is the perfect opportunity to begin working with a CI/CD pipeline to really smooth the whole integration and deployment process.
Now, I set up a job to publish all these different versions of the app. As you can see below, the job contains three steps, two of them being the publishing of an app version (so, two versions in total).

publish-mobile-staging:
  environment:
    EXPO_RELEASE_CHANNEL: staging
    CONFIG: 
  docker:
    - image: cimg/node:14.15.1
  steps:
    - expo-login
    - publish-mobile:
        config: tenants/version1/app.config.js
    - publish-mobile:
        config: tenants/version2/app.config.js

Now, the problem is that the two publish steps take 4 mins each, which makes 8 mins in total. In itself not a major problem, but in the near future there will soon be 2 more versions. This will result in 16 mins of running time, only for those steps alone.

Do you see the problem there? :slight_smile:

Question

Is there a way I can parallelize the publish-mobile steps? Taking into account the first step (expo-login) shouldn’t be parallelized, but should be run first before the other ones.

I already found how to parallelize test suits, but that doesn’t seem to answer my question.

Thank you!

Tom

There is no way (currently) to parellelize individual steps in a job. However, because your job is so simple you can easily factor it out into a parameterized job, managed by a workflow:

version: 2.0 (or higher)

...

jobs:
  ...
  publish-mobile-staging:
    parameters:
      product_version:
        description: Version to publish.
        type: string
    environment:
      EXPO_RELEASE_CHANNEL: staging
      CONFIG: 
    docker:
      - image: cimg/node:14.15.1
    steps:
      - expo-login
      - publish-mobile:
          config: tenants/<< parameters.product_version >>/app.config.js

workflows:
  ...
  publish:
    jobs:
      ...
      - publish-mobile-staging:
          requires:
            <publish job dependencies>
          matrix:
            parameters:
              product_version:
                - version1
                - version2

You can find some more documentation on parameters here: Reusable Config Reference Guide - CircleCI

Now every time you have another version to publish, you just add an element to the matrix section of the job in the workflow and it’ll add that job to the workflow.

Thanks, solves my problem!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.