Tutorial
This tutorial builds tally, a three-project workspace that needs only sh: lib sorts a word list, app counts the sorted words, and docs appends the list to a page. The finished workspace lives in examples/tally and is verified by crates/cli/tests/suite/examples.rs.
Install urepo once. On Linux and macOS:
curl -fsSL https://github.com/2xf-org/urepo/releases/latest/download/install.sh | shOn Windows, in PowerShell:
irm https://github.com/2xf-org/urepo/releases/latest/download/install.ps1 | iexThe installer puts urepo in ~/.urepo/bin and adds that folder to your PATH. Open a new shell after it runs.
Create the workspace
mkdir tally && cd tally
urepo config initurepo config init creates .urepo/urepo.toml, .urepo/.gitignore, and starter workflows under .github/workflows/.
Add the first project
Create lib/words.txt with one word per line (including duplicates):
tally
count
tally
sum
countCreate lib/urepo.toml:
# lib/urepo.toml
[project]
name = "lib"
[task.build]
description = "Sort the words and drop the repeats"
run = ["mkdir -p dist", "sort -u words.txt > dist/vocabulary.txt"]
inputs = ["words.txt"]
outputs = ["dist/vocabulary.txt"]List the workspace's tasks:
$ urepo task list
task state ci supplier description
lib:build stale cached explicit Sort the words and drop the repeatsRun build twice:
$ urepo run build
task state time
lib:build ran 11ms
$ urepo run build
task state
lib:build currenturepo run is a shortcut for urepo task run. Progress lines go to standard error, and the summary table goes to standard output. In a pipe or a log, the progress is a line as each task starts and ends, with the task's output after its end line. On the second run, urepo hashes the task's commands and words.txt, finds the record in ~/.urepo/store, and skips execution.
Inspect staleness and restore outputs
Edit lib/words.txt and ask why lib:build is stale:
$ echo mean >> lib/words.txt
$ urepo task why lib:build
task lib:build
state stale
reason no record under its key
key ffa1b9c
changed before after
inputs 9230ff9 2d28a84
input file change
lib/words.txt modifiedRun urepo run build to record the new output, then delete lib/dist and run again:
urepo run build
rm -r lib/dist
urepo run buildlib:build reports current without running, and lib/dist/vocabulary.txt is restored from the store.
Add dependent projects and see early cutoff
Create app/src/report.sh:
#!/bin/sh
set -eu
words=$(wc -l < ../lib/dist/vocabulary.txt | tr -d ' ')
echo "the vocabulary holds $words words"Create app/urepo.toml:
# app/urepo.toml
[project]
name = "app"
depends = ["lib"]
[task.build]
description = "Count the words of the library"
run = ["mkdir -p dist", "sh src/report.sh > dist/report.txt"]
after = ["^build"]
inputs = ["src/**"]
outputs = ["dist/report.txt"]
[task.show]
description = "Print the report"
run = "cat dist/report.txt"
after = ["build"]
inputs = []
cache = falseafter = ["^build"] waits for build in every project listed in depends and includes the hash of their outputs in app:build's key. Add a third project in docs/page.txt (Tally counts words.) and docs/urepo.toml using an explicit cross-project task reference after = ["lib:build"], and add a same-project test task to lib/urepo.toml with after = ["build"].
Now run urepo run build, then append a duplicate word to lib/words.txt and run again:
$ urepo run build
task state time
lib:build ran 12ms
app:build ran 40ms
docs:build ran 9ms
$ echo count >> lib/words.txt
$ urepo run build
task state time
lib:build ran 11ms
app:build current
docs:build currentlib:build ran because words.txt changed, produced the same dist/vocabulary.txt, and both app:build and docs:build stayed current.
Inspect the graph, uncached tasks, and root tasks
List the tasks with what each waits for:
$ urepo task list
task state ci supplier after description
app:build current cached explicit lib:build Count the words of the library
app:show stale uncached explicit app:build Print the report
docs:build current cached explicit lib:build Join the page and the vocabulary
lib:build current cached explicit Sort the words and drop the repeats
lib:test stale cached explicit lib:build Check that the vocabulary is not empty
tally:lint stale cached explicit Check that every script stops at its first errorRun the uncached show task (cache = false always runs without recording, while its prerequisites stay current):
urepo run show appPass extra arguments after -- to append them to the last command (this marks the run partial and records nothing):
urepo run show app -- ../lib/words.txtYou can also place [task.<name>] directly in .urepo/urepo.toml. That makes the workspace root a project owning every file outside nested projects and .urepo/ (see tally:lint in examples/tally/.urepo/urepo.toml).
Preview changes and read JSON
Pass --dry-run to preview what would run without changing files or records, and --json to print the same command view as JSON on standard output:
urepo run build --dry-run
urepo run test lib --jsonNext steps
- Workspaces and projects for project discovery and addresses.
- Tasks, keys, and the store for variables, secrets, and shared S3 stores.
- Tools, stacks, and images for locked toolchains and Compose stacks.
- Releases for gated GitHub releases.
- Commands for every subcommand and flag.