Skip to content

Commit

Permalink
docs(core): expand nx agents feature (#21804)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacplmann authored Feb 14, 2024
1 parent 3b384c7 commit d5e1451
Showing 1 changed file with 13 additions and 29 deletions.
42 changes: 13 additions & 29 deletions docs/shared/features/distribute-task-execution.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
# Distribute Task Execution (Nx Agents)

{% youtube
src="https://youtu.be/XLOUFZeqRpM"
title="Nx Agents in action splitting e2e tests at a file level"
src="https://youtu.be/XS-exYYP_Gg"
title="Nx Agents Walkthrough"
/%}

**Nx Agents** let you distribute your CI across many machines with minimal configuration. It comes with features such as dynamically allocating agents based on the size of the PR, flaky task re-running, and intelligent task splitting and distribution. Keep reading to learn more.
**Nx Agents** let you distribute your CI across many machines with minimal configuration. It also comes with the following features:

- [Dynamically allocate the number and size of agents](/ci/features/dynamic-agents) based on the size of the PR
- [Re-run flaky tasks](/ci/features/flaky-tasks) automatically whenever they fail in CI
- Automatically [split large e2e tasks](/ci/features/split-e2e-tasks) into smaller tasks that can be distributed more efficiently

## Making a Distributed CI Pipeline Is Hard

Expand Down Expand Up @@ -41,42 +45,22 @@ Add the `start-ci-run` command to your CI pipeline configuration after checking
```yaml {% fileName=".github/workflows/main.yaml" %}
# After checkout repository
- name: Start CI run
run: 'npx nx-cloud start-ci-run --distribute-on="8 linux-medium-js" --stop-agents-after="e2e-ci"'
run: 'npx nx-cloud start-ci-run --distribute-on="8 linux-medium-js"'
# Before install node_modules
# Run any nx commands as if running on a single machine
```

The `--distribute-on` flag instructs Nx Cloud to distribute tasks across 8 agents of type `linux-medium-js`. `linux-medium-js` is the name of the launch template that will be used to provision the agent. The default launch templates [can be found here](https://github.com/nrwl/nx-cloud-workflows/blob/main/launch-templates/linux.yaml)

## Launch Templates

You can also define your own "launch templates" (here's an [example from the Nx repo](https://github.com/nrwl/nx/blob/master/.nx/workflows/agents.yaml)):
The `--distribute-on` flag instructs Nx Cloud to distribute tasks across 8 agents of type `linux-medium-js`. `linux-medium-js` is the name of the launch template that will be used to provision the agent. Use on of the [default launch templates](https://github.com/nrwl/nx-cloud-workflows/blob/main/launch-templates/linux.yaml) or create your own [custom launch template](/ci/reference/launch-templates).

```yaml {% fileName=".nx/workflows/agents.yaml" %}
launch-templates:
linux-medium:
resource-class: 'docker_linux_amd64/medium+'
init-steps:
- name: Pnpm Install
script: |
pnpm install --frozen-lockfile
- name: Install Cypress
script: pnpm exec cypress install

- name: Install Rust
- ...
```
Here are the [available resource classes](https://nx.app/pricing#resource-classes).
## Related Features
## Nx Agents Features

{% cards %}

{% card title="Create Custom Launch Templates" description="Define your own launch templates to set up agents in the exact right way" type="documentation" url="/ci/reference/launch-templates" /%}

{% card title="Dynamically Allocate Agents" description="Assign a different number of agents to a pipeline based on the size of the PR" type="documentation" url="/ci/features/dynamic-agents" /%}

{% card title="Automatically Split E2E Tasks" description="Split large e2e tasks into separate tasks for each spec file" type="documentation" url="/ci/features/split-e2e-tasks" /%}
{% card title="Automatically Split E2E Tasks" description="Split large e2e tasks into a separate task for each spec file" type="documentation" url="/ci/features/split-e2e-tasks" /%}

{% card title="Identify and Re-run Flaky Tasks" description="Re-run flaky tasks in CI whenever they fail" url="/ci/features/flaky-tasks" /%}

Expand Down

0 comments on commit d5e1451

Please sign in to comment.