Switch to dark theme

Tasks, keys, and the store

Every build, test, lint, or codegen step is a task. Tasks come from extensions or explicit [task.<name>] tables in urepo.toml. An explicit task with the same name replaces an inferred one, a [task.<name>] without run extends the inferred task with the keys it states (such as outputs), and [task] lint = false removes an inferred task.

Declaring tasks and after

A task's run value is a single shell string or a list of commands executed in order via sh -c inside the project folder. Commands stop at the first failure.

after orders tasks and feeds upstream outputs into downstream keys. Three reference forms are accepted:

Form Meaning
build Task build in the same project
lib:build Task build in project lib
^build Task build in every project listed in this project's depends (projects without build are skipped)

inputs (default [".", "^"]) lists patterns applied in order, each adding files to or removing them from the task's key:

Pattern Selects
. The project's tree
^ The trees of every project it depends on
src/**/*.py Files of the project's tree, relative to the project folder
!docs/** Removes files under the project folder
/compose.yaml, /tools/testing/**, /**/*.py Files relative to the workspace root, such as a shared script or configuration, or every file of a kind for a workspace-wide check
!/tools/testing/fixtures/** Removes files relative to the workspace root

A pattern without wildcards that names a file adds it even when git ignores it. A / glob walks everything under its folders before the first wildcard, the files of nested projects included, since it names workspace paths: /**/*.py is every Python file the workspace tracks. No pattern may contain a .. segment. The key records every selected path relative to the workspace root.

Other task options include outputs (globs inside the project folder; git-tracked files cannot be outputs), cache = false (always run, never record), local = true (record locally only), confirm = "<prompt>" (prompt before running unless --yes is passed), platform = "any" (share one key across OS and CPU platforms), runner (the CI runner label, with platform naming its platform when GitHub does not host it), and cpus.

Task environment variables

Tasks start from an empty environment so undeclared shell state cannot poison cached results. urepo populates variables in this order, with later entries replacing earlier ones:

  1. PATH: the project's locked tool folders followed by $CARGO_HOME/bin (or $HOME/.cargo/bin), the folder that supplies cargo on the caller's PATH when that one has none (a rustup that a package manager installed), and a fixed OS system path (PATH is excluded from keys).
  2. HOME, TMPDIR, LANG, TERM, CARGO_HOME, and RUSTUP_HOME copied from the caller when set (plus SYSTEMROOT on Windows). These are excluded from keys.
  3. UREPO_CPUS: processors granted to the task, and UREPO_ROOT: the absolute path of the workspace root, so a task can call a shared script as "$UREPO_ROOT/tools/check.sh" (excluded from keys, since it differs between machines and worktrees).
  4. UREPO_PORT_<PROJECT>_<PORT>: the ports of the worktree's stacks, and UREPO_STACK_<PROJECT>: each stack's Docker Compose project name (both excluded from keys).
  5. Workspace [env] then project [env] (hashed by value).
  6. Caller variables named in pass (hashed by value), secrets (hashed by name only; secret values are masked in output, and any task naming secrets stays local), and ambient (not hashed).

ambient is for variables that change how a task runs but not what it produces, such as a build cache's endpoint and token (ACTIONS_CACHE_URL, ACTIONS_RESULTS_URL, ACTIONS_RUNTIME_TOKEN), CI, DOCKER_HOST, or a worker-count hint. A task lists them in [task.N] ambient, and a top-level ambient = [...] list in the root file, written before the first table, adds names to every task of the workspace. A project file has no top-level ambient: urepo refuses one and asks to move its names to the tasks that need them. Since no key holds them, a record made with one value is reused under another, so a variable that does change the outputs belongs in pass.

Keys and caching

Before running a cached task, urepo builds a canonical JSON key document and hashes it with BLAKE3 into a b3:<hex> key. The document records:

  • Task address, supplier and extension schema version, and exact run commands.
  • Declared [env] and pass values, plus secrets names.
  • Pinned tool versions and the SHA-256 checksums the lock records for their archives.
  • Platform (<os>-<arch> or "any").
  • Content hash of every declared input file (plus executable bits) and any extra inputs from extensions, respecting .gitignore, the repository's exclude file, and your global excludes file. The repository's exclude file is .git/info/exclude, or in a linked worktree or a submodule, the info/exclude of the git folder its .git file points to. The global excludes file is the one core.excludesFile names in ~/.gitconfig or $XDG_CONFIG_HOME/git/config, or else $XDG_CONFIG_HOME/git/ignore (~/.config/git/ignore when XDG_CONFIG_HOME is unset). It differs between machines, so ignore files that matter to a task in the repository's .gitignore.
  • For every task in after, the hash of its outputs archive, or its key if it declares no outputs. Local-only setup tasks with no outputs (local = true and outputs = [], such as js install) order execution without folding machine-local keys into downstream portable keys.
  • Keys of any images listed in images.

Because after hashes the upstream task's output archive, urepo gets early cutoff automatically: if an upstream task reruns after an edit but produces byte-identical outputs, downstream keys do not change and downstream tasks stay current.

Extensions may also name required on-disk paths in their inputs answer (present, such as node_modules for js install). If a required path is absent on disk, urepo marks the task stale (missing <path>) and reruns it even when its key already sits in the local store.

Run urepo task why <project>:<task> to compare the current key document against the previous run saved under .urepo/local/keys/ and print the exact changed fields and modified files.

Scheduling and states

The scheduler runs ready tasks in parallel up to the machine's CPU count, respecting cpus. Every task finishes in one of five states: ran, current, failed, blocked (an upstream task failed or --fail-fast halted scheduling), or not applicable (a required tool has no archive for the host platform). Dry runs and urepo task list also report stale and waiting.

When urepo receives SIGINT or SIGTERM during a run, it stops the processes of every running task at once and ends with the signal's exit status, 130 or 143, naming the tasks that were running. Nothing those tasks did is recorded, so the next run runs them again.

Local and remote stores

The local store lives under ~/.urepo/store/v1/ and holds compressed zstd blobs (blobs/), JSON success records (records/), failure metadata (failures/), unpacked output trees (trees/), and LRU use marks (used/). A record is readable only when both its outputs and log blobs exist in the same store. Failed tasks never satisfy lookups.

Configure a shared S3-compatible bucket in .urepo/urepo.toml:

TOML
# .urepo/urepo.toml
[workspace]
name  = "cloud"
urepo = "202612.4.0"

[store]
remote = "s3://acme-urepo"
keep   = "40GB"

The remote bucket holds records under trusted/, which only a GitHub Actions job for a push to main writes (see The store). Pull requests and laptops only read it. Lookups check the local store, then trusted/, copying remote hits locally and restoring outputs atomically without touching git-tracked files. A bucket that can't be read or written never fails a run; urepo warns and carries on with the local store.

UREPO_STORE_REMOTE=off turns the remote store off for one process: urepo neither reads nor writes the bucket, as if [store] named no remote, and uses the local store alone. Use it for runs that have no credentials for the bucket, such as pull requests from forks. Any value other than off or empty is an error.

Inspect and trim the local store with urepo store status and urepo store clean (or urepo store clean --all).