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.
Defining Tasks
Section titled “Defining Tasks”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"] }}Running Tasks
Section titled “Running Tasks”Use the cuenv task command to run tasks:
# List available taskscuenv task
# Run a specific taskcuenv task buildDependencies & Parallelism
Section titled “Dependencies & Parallelism”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:
lintandteststart in parallel.buildwaits for bothlintandtestto complete successfully.- If either fails,
buildis skipped.
Caching
Section titled “Caching”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.)
Environment Injection
Section titled “Environment Injection”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" } }}Hermeticity (Planned)
Section titled “Hermeticity (Planned)”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.