Adding a Parallel Workflow

Getting started with parallel workflows

Some tasks in your build may be able to run at the same time instead of sequentially. For example, in a Node.js project, you could run lint tasks and unit test tasks at the same time since they are independent of each other and make your pipeline faster.

Let's take an example set of tasks and see how to introduce parallelism:

.sail.yml with tasks only

tasks:
install:
image: node:carbon
command:
- yarn
args:
- install
lint:
image: node:carbon
command:
- yarn
args:
- lint
test:
image: node:carbon
command:
- yarn
args:
- test
build:

deploy:

Above we have a set of tasks that do some checks and then build and deploy our application. Since both lint and test are dependent on install, it makes sense to let install run first. But after that, we can start lint and test in parallel. If both these are successful, then we could move on to the build and deploy tasks.

.sail.yml workflow

workflow:  
- install
- sail:parallel:
- lint
- test
- build
- deploy

sail:parallel is a special workflow item that makes any tasks inside it run at the same time. All tasks will run to completion but if any fail then the whole pipeline will fail and it will not move onto the next item in the workflow.

Any tasks run within sail:parallel will receive a snapshot of the current workspace and at this time can not persist anything back to this workspace. Sequential tasks always have full write capability to the workspace throughout the lifecycle of the pipeline.