Skip to content

Tasks

cuenv provides a powerful task runner that leverages CUE for defining tasks, their dependencies, and their inputs/outputs. This enables parallel execution, caching, and hermetic builds.

Tasks are defined in the tasks block of your configuration.

package cuenv
tasks: {
// A simple command task
hello: {
command: "echo"
args: ["Hello, World!"]
}
// A task with dependencies and specific inputs
build: {
description: "Build the application"
command: "cargo"
args: ["build", "--release"]
// Dependencies to run before this task
dependsOn: ["lint", "test"]
// Inputs to track for caching (files/globs)
inputs: [
"src/**/*",
"Cargo.toml",
"Cargo.lock"
]
// Outputs generated by this task
outputs: ["target/release/myapp"]
}
lint: {
command: "cargo"
args: ["clippy"]
}
test: {
command: "cargo"
args: ["test"]
}
}

Use the cuenv task command to run tasks:

Terminal window
# List available tasks
cuenv task
# Run a specific task
cuenv task build

cuenv analyzes the dependency graph defined by dependsOn. Tasks that do not depend on each other will be executed in parallel, maximizing resource usage.

In the example above:

  1. lint and test start in parallel.
  2. build waits for both lint and test to complete successfully.
  3. If either fails, build is skipped.

cuenv supports computation caching. By defining inputs and outputs, cuenv can determine if a task needs to be re-run.

  • Inputs: Files or glob patterns that the task reads. If these haven’t changed since the last successful run, the task might be skipped.
  • Outputs: Files or directories created by the task.

(Note: Full caching implementation is currently in development. Check the project status for updates.)

Tasks inherit the environment variables defined in your env block. You can also define task-specific environment variables:

tasks: {
test: {
command: "bun"
args: ["test"]
env: {
// Override or add specific variables
CI: "true"
LOG_LEVEL: "debug"
}
}
}

Future versions of cuenv will support hermetic execution, where tasks run in isolated environments (sandboxes) with only declared inputs available. This ensures reproducibility and prevents “it works on my machine” issues.