Continuous integration
urepo replaces path filters and cache steps in GitHub Actions with one check workflow. It runs only the tasks that are stale, one job per runner label.
Generated workflows
urepo config init writes two workflows under .github/workflows/. Both pass on a new repository with no store, no variables and no secrets: the steps that need them skip, and urepo uses the local store of each machine.
check.yml runs on pull requests and on pushes to main. It has three jobs:
planrunsurepo ci jobs, which lists the runner labels that have stale tasks.runis a matrix over those labels. Each job runsurepo ci run <runner>on its runner. That command runs every stale task on that label, with the tasks it waits for, and writes a table of its tasks to the job's summary page.resultalways runs and fails unlessplansucceeded andrunsucceeded or was skipped. Make it the one required check of your branch ruleset.
release.yml runs after each successful check of main and on each dispatch. Its pending job runs urepo ci apply --list, and its apply jobs run urepo ci apply <project>@<environment>, each in the GitHub environment of its urepo environment. See Releases.
Every job installs urepo with the installer, which then runs the version [workspace] urepo pins.
Try the planner locally in examples/tally:
$ urepo ci jobs
runner stale tasks
ubuntu-latest app:build, app:show, docs:build, lib:build, lib:test, tally:lintWith GITHUB_OUTPUT set, urepo ci jobs also appends runners=<json> for the matrix. With GITHUB_STEP_SUMMARY set, urepo ci run appends its table there. urepo ci run checks staleness again before it runs, so work an earlier job finished counts as done.
The ci commands do not show in urepo --help, since the workflows call them. urepo ci --help lists them.
The run job may take up to 60 minutes, which leaves room for the first check of a workspace, when no task has a record yet. Change timeout-minutes in check.yml when your tasks need more.
The job's log
In a job, urepo ci run writes a line as each task starts and as it ends, with its state and time, so the log always shows what is running. Each task's output follows its end line, folded in a group named after that line. The table at the end repeats every task, with the last lines of each failed one.
When GitHub cancels a job or it reaches its timeout, the runner sends SIGINT or SIGTERM. urepo then stops the processes of the running tasks, writes the output they had written so far, names them in its last line, and exits 130 or 143:
lib:test did not finish
error: SIGTERM stopped the run while these tasks were running: lib:testWhich tasks run, and where
Continuous integration runs every task except tasks with confirm and local tasks without outputs, such as a dependency install. A local task still runs before the tasks that wait for it. The ci column of urepo task list shows the same rule for each task: cached, uncached for a task with cache = false, which runs in every check, or no.
A task runs on its runner label; without one, on the root file's [workspace] runner, such as a larger runner of the organization; and without that, on ubuntu-latest. urepo keys each task for the platform of its runner, so a laptop plans what each runner will find. It reads the platform from labels GitHub hosts:
| Label | Platform |
|---|---|
ubuntu-* |
linux-x86_64, or linux-aarch64 when the label ends in -arm |
macos-* |
macos-aarch64, or macos-x86_64 when the label ends in -intel |
windows-* |
windows-x86_64, or windows-aarch64 when the label ends in -arm |
Any other label, such as a self-hosted runner's, needs platform beside it:
[task.e2e]
run = "pnpm e2e"
runner = "linux-8cpu"
platform = "linux-x86_64"A task with platform = "any" has one key for every platform, so its label needs no platform. In GitHub Actions, urepo ci run refuses a machine whose platform differs from the one its tasks are keyed for, since the planner would never find what it records.
The store
Set [store] remote = "s3://bucket" in .urepo/urepo.toml. Every job reads the store. Only a push to main writes it, under trusted/. A pull request reads trusted/ and writes nothing there, so its jobs share nothing with each other through the bucket. A laptop also only reads. The store never fails a run: a bucket that can't be read is a miss, and a write it refuses or fails keeps the result in the local store, stops that run writing to the bucket, and prints a warning naming the problem.
urepo reads whether to write from the GitHub Actions event: it writes when GITHUB_EVENT_NAME is push and GITHUB_REF is the main branch. The bucket decides what each key may do, so give pull requests a key that can only read.
On main, the plan and run jobs run in the GitHub environment main, named for the branch. Create it before the first push, limit its deployment branches to main, and put nothing else in it. GitHub matches that limit against the run's ref, and a pull request's ref is refs/pull/<number>/merge, so a pull request that edits the workflow to name main gets neither its secrets nor its role. urepo config init names this step.
Pull request jobs run in no GitHub environment: the environment name is ${{ github.event_name == 'push' && 'main' || '' }}, which is empty on a pull request.
Without credentials, a step that sets them skips, and urepo uses only the local store of each machine. Set UREPO_STORE_REMOTE=off to make urepo ignore [store] remote for one process.
With roles
urepo config init writes workflows that assume an AWS IAM role through GitHub's identity token. Define three repository variables:
| Variable | Value |
|---|---|
UREPO_STORE_REGION |
The bucket's region |
UREPO_STORE_ROLE |
A role that reads the bucket. Trust repo:<owner>/<repository>:* |
UREPO_STORE_TRUSTED_ROLE |
A role that reads the bucket and writes under trusted/. Trust only repo:<owner>/<repository>:environment:main |
The store step skips until UREPO_STORE_REGION is set, and on pull requests from forks and Dependabot, which get no identity token.
With static keys
A bucket that takes no IAM role, such as Cloudflare R2, is reached with static keys. urepo config init --store-keys writes workflows whose store step reads keys from secrets and sets AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION and AWS_ENDPOINT_URL for the steps after it. Define:
| Where | Name | Value |
|---|---|---|
| Repository variable | UREPO_STORE_REGION |
The bucket's region, auto for R2 |
| Repository variable | UREPO_STORE_ENDPOINT |
The service's address, such as https://<account>.r2.cloudflarestorage.com; empty for Amazon S3 |
| Repository secrets | UREPO_STORE_ACCESS_KEY_ID, UREPO_STORE_SECRET_ACCESS_KEY |
A key that only reads the bucket |
Secrets of the GitHub environment main |
UREPO_STORE_TRUSTED_ACCESS_KEY_ID, UREPO_STORE_TRUSTED_SECRET_ACCESS_KEY |
A key that reads the bucket and writes under trusted/ |
The store step skips until UREPO_STORE_REGION is set. A pull request from a fork gets no secrets, so it reads the bucket without a key, which a private bucket refuses; its tasks then run as if nothing were recorded.
The release jobs use the read-only key or role: they read trusted/ for the checks gate. A command a release runs sees the store's key in AWS_ACCESS_KEY_ID, so a deployment to AWS sets its own variables.
Expire old objects
Records and blobs under trusted/ are never deleted by urepo. Add one lifecycle rule to the bucket that expires objects 90 days after they are written. A record whose blob has expired counts as missing, and the next push to main that runs the task writes both again.
With Amazon S3, save this as lifecycle.json:
{
"Rules": [
{
"ID": "urepo-expire",
"Status": "Enabled",
"Filter": { "Prefix": "" },
"Expiration": { "Days": 90 }
}
]
}Then apply it:
aws s3api put-bucket-lifecycle-configuration --bucket <bucket> --lifecycle-configuration file://lifecycle.jsonWith Cloudflare R2, add the same rule in the bucket's settings under object lifecycle rules: delete objects 90 days after upload.
A compile cache for Rust
urepo keeps a task's result, not the compiler's work inside it, so a Rust task that reruns on a fresh runner compiles every dependency again. sccache keeps each compiled crate in a bucket instead, and the store's bucket can hold it under its own prefix. Start its server in the run job after the store step, so it holds the store's key: it writes on a push to main and only reads on a pull request.
- if: runner.os == 'Linux' && vars.UREPO_STORE_REGION != ''
env:
VERSION: "0.20.1"
SHA256: c9f6c5a3ae84d9da0956b28c357a365827bda33f3383647fc0b67484c74a5ea9
SCCACHE_BUCKET: <bucket>
SCCACHE_S3_KEY_PREFIX: sccache/
SCCACHE_REGION: ${{ vars.UREPO_STORE_REGION }}
SCCACHE_ENDPOINT: ${{ vars.UREPO_STORE_ENDPOINT }}
SCCACHE_S3_RW_MODE: ${{ github.event_name == 'push' && 'READ_WRITE' || 'READ_ONLY' }}
SCCACHE_IDLE_TIMEOUT: "0"
run: |
archive="sccache-v$VERSION-x86_64-unknown-linux-musl"
curl -fsSL -o "$RUNNER_TEMP/$archive.tar.gz" "https://github.com/mozilla/sccache/releases/download/v$VERSION/$archive.tar.gz"
echo "$SHA256 $RUNNER_TEMP/$archive.tar.gz" | sha256sum --check --quiet
tar -xzf "$RUNNER_TEMP/$archive.tar.gz" -C "$RUNNER_TEMP"
"$RUNNER_TEMP/$archive/sccache" --start-server
echo "RUSTC_WRAPPER=$RUNNER_TEMP/$archive/sccache" >> "$GITHUB_ENV"The cargo tasks pass RUSTC_WRAPPER to Cargo, so they compile through the server. sccache caches nothing that Cargo builds incrementally, so set CARGO_INCREMENTAL: "0" in the workflow's env too; the tasks pass it as well. Its objects expire under the same lifecycle rule as the store's.