Skip to content

Commit

Permalink
docs(nx-cloud): add example for manual assignment rules
Browse files Browse the repository at this point in the history
  • Loading branch information
lourw committed Jan 6, 2025
1 parent d67c324 commit 8f24935
Showing 1 changed file with 54 additions and 7 deletions.
61 changes: 54 additions & 7 deletions docs/nx-cloud/reference/assignment-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,23 @@ assignment-rules:

A typical `assignment-rules.yaml` file might look like this:

```yaml
```yaml {% fileName=".nx/workflows/assignment-rules.yaml" %}
assignment-rules:
- project: app1
target: build
configuration: production
runs-on:
- linux-large-js
- linux-medium-js
- linux-large
- linux-medium
- target: lint
runs-on:
- linux-medium-js
- linux-medium
- configuration: development
runs-on:
- linux-medium-js
- linux-large-js
- linux-medium
- linux-large
```

Note that the labels supplied in the `runs-ons` property will be used to determine which agents will have rules applied to them. When using self-hosted agents, you must supply these labels to your agents via an environment variable: `NX_AGENT_LAUNCH_TEMPLATE`.
Expand All @@ -99,8 +99,55 @@ npx nx-cloud start-ci-run --assignment-rules='.nx/workflows/assignment-rules.yam

The following is an example of what this looks like within a github actions pipeline:

```angular2html
```yaml {% fileName=".github/workflows/ci.yaml" %}
...
jobs:
main:
displayName: Main Job
...
steps:
...
- run: npx nx-cloud start-ci-run --assignment-rules=.nx/workflows/assignment-rules.yaml --stop-agents-after="e2e-ci"
- ..
medium-agents:
displayName: Agents ${{ matrix.agent }}
runs-on:
group: medium-agents
strategy:
matrix:
agent: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v4
...
- name: Start Agent ${{ matrix.agent }}
run: npx nx-cloud start-agent
env:
NX_AGENT_NAME: ${{ matrix.agent }}
NX_AGENT_LAUNCH_TEMPLATE: "linux-medium" # This value needs to match one of the 'runs-on' values defined in the assignment rules
large-agents:
displayName: Agents ${{ matrix.agent }}
runs-on:
group: large-agents
strategy:
matrix:
agent: [1, 2, 3]
steps:
- name: Checkout
uses: actions/checkout@v4
... # other setup steps
- name: Start Agent ${{ matrix.agent }}
run: npx nx-cloud start-agent
env:
NX_AGENT_NAME: ${{ matrix.agent }}
NX_AGENT_LAUNCH_TEMPLATE: "linux-large" # This value needs to match one of the 'runs-on' values defined in the assignment rules
```

## Using Assignment Rules with Dynamic Nx Agents
Expand Down

0 comments on commit 8f24935

Please sign in to comment.