In this exercise we'll learn how to run tasks in parallel.
In order to run tasks in parallel, we can just add the --parallel
to the command, and it will run the tasks
which can be parallelized in parallel.
Run the lint target for all projects in parallel
- with 1 parallel worker
- reset the cache
- with 5 parallel workers
- see the difference in time
Run lint target in parallel
npx nx run-many -t lint --parallel=1
nx reset
npx nx run-many -t lint --parallel=5
Configure the default parallelization in the nx.json
file.
Configure default parallelization
{
// ...,
"parallel": 5
}
Try to run:
- test
- build
Run more tasks
npx nx run-many -t test
npx nx run-many -t build
Let's update the ci pipeline to run tasks in parallel.
Warning
DON'T RAISE IT TOO HARD PLEASE (MAX 3)! GITHUB IS POOR! :-D
Make the ci run tasks in parallel
- name: Run commands in parallel
run: npx nx affected -t lint build --base=HEAD^ --parallel=3