Task Definitions

Tasks are defined in rnr.yaml at the root of your repository. rnr supports three levels of task definition syntax, from simple to powerful.

Shorthand Syntax

The simplest way to define tasks - just a name and command:

build: cargo build --release
test: cargo test
lint: npm run lint
fmt: cargo fmt

Run with ./rnr build, ./rnr test, etc.

Full Task Definition

For more control, use the full task definition format:

build:
  description: Build for production
  dir: src/backend
  env:
    NODE_ENV: production
    DEBUG: "false"
  cmd: npm run build

Available Fields

FieldDescription
descriptionShows in rnr --list output
dirWorking directory (relative to project root)
envEnvironment variables for this task
cmdShell command to execute

Task Orchestration

Compose complex workflows using steps for sequential execution or parallel for concurrent execution.

Sequential Steps

Run tasks one after another:

ci:
  description: Run full CI pipeline
  steps:
    - task: lint
    - task: test
    - task: build

Parallel Execution

Run tasks concurrently:

build-all:
  description: Build all services simultaneously
  steps:
    - cmd: echo "Starting builds..."
    - parallel:
        - task: build-api
        - task: build-web
        - task: build-worker
    - cmd: echo "All builds complete!"

Mixed Sequential and Parallel

Combine both patterns for sophisticated workflows:

deploy:
  description: Deploy all services
  steps:
    - task: test
    - parallel:
        - dir: services/api
          cmd: ./deploy.sh
        - dir: services/web
          cmd: ./deploy.sh
    - cmd: echo "✅ Deployment complete"

Task Delegation

Delegate to tasks defined in subdirectory rnr.yaml files - perfect for monorepos:

api:build:
  dir: services/api
  task: build

This runs the build task from services/api/rnr.yaml.

Environment Variables

Set task-specific environment variables:

dev:
  description: Start development server
  env:
    NODE_ENV: development
    PORT: "3000"
    DEBUG: "true"
  cmd: npm run dev

Environment variables from the task definition are merged with the current environment.

Working Directories

All paths in dir are relative to the project root (where rnr.yaml lives):

backend:test:
  dir: packages/backend
  cmd: npm test

frontend:test:
  dir: packages/frontend
  cmd: npm test

Complete Example

# Simple shorthand tasks
fmt: cargo fmt
clippy: cargo clippy -- -D warnings

# Full task with description and environment
build:
  description: Build release binary
  env:
    RUSTFLAGS: "-C target-cpu=native"
  cmd: cargo build --release

# Sequential workflow
check:
  description: Run all checks
  steps:
    - task: fmt
    - task: clippy
    - task: test

# Parallel builds for multiple platforms
build-all:
  description: Build for all platforms
  steps:
    - parallel:
        - cmd: cargo build --release --target x86_64-unknown-linux-gnu
        - cmd: cargo build --release --target x86_64-apple-darwin
        - cmd: cargo build --release --target x86_64-pc-windows-msvc

# Test task
test:
  description: Run test suite
  cmd: cargo test