07Distributed task execution
Run one task on a different machine
Give end-to-end tests machines of their own, while every other task shares the usual ones.
exec: { command: 'playwright test', worker: 'e2e',}Declare a second type
Section titled “Declare a second type”Add e2e next to linux. Order matters: a task that names no type goes to the first one with a machine of its platform.
dte({ workers: { linux: { machines: { cpu4: { max: 8, cpu: 4, memory: '8GB', }, }, }, e2e: { machines: { cpu4: { max: 2, cpu: 4, memory: '8GB', }, }, }, }, adapter: github(),}),You can now keep a separate pool of machines for one kind of work.
Name it on the task
Section titled “Name it on the task”e2e: { dependsOn: ['build'], exec: { command: 'playwright test', worker: 'e2e', }, inputs: { files: ['src/**', 'tests/**'] },},Run vx lock, then vx dte init to add the new machines to vx-worker.yml. Now run it:
Tasks status cache ±usual time cpu mem outputs blocks worker task success miss +1ms 16ms 24% 1.8MB 3B 2 linux.cpu4#1 @demo/ui#build success miss +0ms 3ms 141% 1.8MB 3B 1 linux.cpu4#1 @demo/web#build success miss +1ms 19ms 5% 1.7MB 0B 0 e2e.cpu4#1 @demo/web#e2e workers e2e.cpu4#1 stopped 1 done · warm-up 0.2s · @demo/web#e2e linux.cpu4#1 left 2 done · warm-up 0.1s · @demo/ui#build, @demo/web#buildRead the worker column: both builds ran on linux.cpu4#1, the tests on e2e.cpu4#1. Each worker left when its work was done.
Check yourself You add a lint task with no exec.worker. Which machines run it?
linux: it is listed first and runs on the same platform. e2e only gets tasks that name it.
You can now send one task to its own machines and see it land there.
PatternsCommon setups
Playwright on Ubuntu, the rest on Alpine
Section titled “Playwright on Ubuntu, the rest on Alpine”Each type can run on different CI runners, with their own images and tools:
workers: { // runsOn: a self-hosted runner label of yours alpine: { machines: { cpu4: { max: 8, cpu: 4, memory: '16GB', runsOn: 'alpine-4-cores', }, }, }, ubuntu: { machines: { cpu4: { max: 2, cpu: 4, memory: '16GB', }, }, },},e2e: { exec: { command: 'playwright test', worker: 'ubuntu' } },A type for another platform
Section titled “A type for another platform”A type listed later gets the tasks no type before it can run, such as tasks for macOS:
workers: { linux: { machines: { cpu4: { max: 8, cpu: 4, memory: '16GB', }, }, }, mac: { machines: { m1: { max: 2, cpu: 3, memory: '7GB', platform: 'darwin-arm64', }, }, },},A task with exec.platforms: ['darwin-arm64'] runs on mac. Every other task runs on linux.
You can now split work by tools or by platform with nothing but types and their order.
DetailsEvery rule
exec.worker
Section titled “exec.worker”| Fact | exec.worker |
|---|---|
| What it does | Runs the task only on machines of that worker type. |
| Default | none: the first type in workers that fits the task. |
| Value | a type’s name from dte({ workers }). |
| In the cache key | no: moving a task to another type never changes its key. |
| On your machine | ignored: a run without workers runs it here. |
Where a task goes
Section titled “Where a task goes”- A task that names no type goes to the first type with a machine of its platform.
- A task with
exec.platformsruns only on a worker of one of them. - A task no worker can take stops the run before any task starts, and names it.
- A task that reads what an uncached task leaves on its worker, where
exec.workerorexec.platformsrule out the reader’s machine, stops the run too. Cache the upstream task, or run both alike.