Distribute Task Execution (DTE)
Nx supports running commands across multiple machines. You can either set it up by hand (by using batching or binning) or use Nx Cloud.
To distribute your task execution, you need to (1) connect to Nx Cloud and (2) enable DTE in your CI workflow. Each of these steps can be enabled with a single command:
nx generate @nrwl/workspace:ci-workflow --ci=github
--ci flag can be
azure. For more details on setting up DTE, read this guide.
CI Execution Flow
There are two main parts to the CI set up:
- The main job that controls what is going to be executed
- The agent jobs that actually execute the tasks
The main job execution flow looks like this:
1# Coordinate the agents to run the tasks 2- npx nx-cloud start-ci-run 3# Run any commands you want here 4- nx affected --target=lint 5- nx affected --target=test 6- nx affected --target=build 7# Stop any run away agents 8- npx nx-cloud stop-all-agents 9
The agent job execution flow is very simple:
1# Wait for tasks to execute 2- npx nx-cloud start-agent 3