This repository uses a custom build system that is agnostic to CI platforms and leverages a remote cache (S3 or MinIO) for caching build artifacts. Our approach enables efficient incremental builds, distributed parallel testing, and consistent deployment to ephemeral infrastructure (e.g., AWS Spot Instances).
We avoid heavy CI vendor lock-in by using shell scripts with a uniform framework (ci3 folder). Each project defines its own bootstrap or build script but relies on the shared ci3 folder for advanced features like:
- Generating content hashes to skip unchanged builds
- Uploading/downloading build artifacts
- Parallelizing & caching test results
- Logging ephemeral output
- Provisioning ephemeral AWS instances for maximum compute at minimal cost
-
Monorepo-friendly Multiple projects within one repository can have separate build steps that only rebuild if their subset of files changes.
-
Remote Caching A stateless approach using S3-compatible storage (AWS S3 or MinIO). This replaces older Docker-image-based caches, streamlines artifact reuse, and easily shares builds across different runners or machines.
-
Content-based Rebuilds We compare content-hashes of relevant files. If no changes, no rebuild. This encourages fine-grained patterns (e.g., ignoring docs changes, but not ignoring new code).
-
Ephemeral Infrastructure We frequently run on EC2 spot instances to take advantage of cost savings. On eviction, the system gracefully shuts down and requeues tasks if needed.
-
Avoiding CI Lock-In We do not rely on special vendor features. Our build is run via shell scripts that can be triggered on any platform.
Instead of tagging artifacts by commit or branch, we compute a hash of the actual files that matter (via .rebuild_patterns). If code, dependencies, or scripts in that set change, we produce a new content hash and thus trigger a fresh build.
All logic is in shell scripts, grouped under the ci3 folder. A minimal layer of environment detection handles toggling debug modes, caches, or ephemeral logs. This means the same build system can run on local machines, ephemeral Docker containers, or GitHub Actions.
Each project folder often contains a .rebuild_patterns file. This file has patterns that, if matched by changed files, triggers a new build. Typical patterns might include: ^yarn-project/foundation/src/.*.ts and other patterns from root.
When cache_content_hash sees new changes in these paths, it regenerates a new hash which prevents a cache download until an S3 artifact with that hash is uploaded.
Tools are provided for the following themes.
-
Caching
cache_content_hash: Takes file patterns (or.rebuild_patterns) to compute a stable content hash.cache_upload,cache_download: Upload/download.tar.gzartifacts from a remote S3-like cache. The cache follows the instance profile (CI3_INSTANCE_PROFILE_NAME), since each profile can write only its own trust level's cache: the shared, publicly readableaztec-ci-artifactsfor ordinary builds and local runs,aztec-ci-release-cachefor release instances,aztec-ci-private-cachefor private ones. A job with no instance profile that needs another level's cache, such as a release's publish job, names it withsource_cache_bucket <bucket>(orCI3_CACHE_BUCKET).cache_upload_flag,cache_download_flag: Mark or detect a particular test's success state. Avoids re-running long tests.
-
Test Parallelization & Caching
parallelize: Reads test commands from STDIN, executes in parallel, aggregates logs.run_test_cmd: Single test runner that can skip tests cached as “already passed.”filter_cached_test_cmd: Filters out test commands known to have succeeded (based on flags in redis).upload_test_artifacts: A test may leave files worth keeping, such as a failed browser test's screenshots, in$TEST_ARTIFACTS_DIR, which every test gets (inside adocker_isolatecontainer too). After the test they are published tohttps://build-cache.aztec-labs.com/test-artifacts/<log id>/, with a link to each in its log. Hidden files (a tool's own bookkeeping, such as Playwright's.last-run.json) are not published.
-
Ephemeral Logging
denoise: Minimizes output spam; prints dots for each line, reveals full logs only if a command fails.cache_log,dump_fail: Captures output for ephemeral storage and prints or reveals logs when needed.
-
AWS Provisioning
aws_request_instance&aws_terminate_instance: Provision ephemeral spot or on-demand instances.aws_handle_evict: Detects spot-instance eviction signals, handles graceful shutdown or requeue.
-
Docker Isolation
docker_isolate: Executes a script in a new Docker container with ephemeral volumes, isolating host environment from side effects.
-
General Utilities
source_bootstrap,source_refname,source_color: Shared environment, color-coded logging, or version detection.echo_header: Prints a heading for better log readability.- ci3/source is the central include-script for Aztec’s build system, automatically configuring Bash strict mode, setting up your
$PATHto include all ci3 utilities (e.g. caching, parallel test commands), and providing helper functions and color-coded logging. Simply add source$(git rev-parse --show-toplevel)/ci3/sourceat the top of any project script to inherit a robust, preconfigured environment.
-
In each project: A
bootstrap.shmight:- Call
cache_content_hashto detect changes. - If changed, do the relevant compile step, then
cache_upload. - If not changed, do
cache_downloadto restore a previously built artifact.
- Call
-
In test scripts:
- We gather test commands (
test_cmds) in a form easily read byparallelize. parallelizecallsrun_test_cmdon each line, skipping or running tests as needed.
- We gather test commands (
-
In local or ephemeral servers:
- Either manually run
./bootstrap.sh fastor let the CI invoke it on a fresh machine. - The system pulls dependencies, attempts to restore from remote caches, rebuilds only if necessary, then parallelizes tests.
- Either manually run
-
On success:
- Artifacts can be re-uploaded or flagged as “passed,” letting future runs skip unchanged steps.
ci3 is consumed as a git submodule at <repo>/ci3. What a consuming repository may rely on is
deliberately narrower than "every file here".
Everything at the top level of this repository, plus aws/, bin/, dashboard/ and lua/. A
script is public because a consuming repository sources or executes it, or because a person runs it
by hand (cache_ls, cache_delete, clean_remote_tags, start_interactive). The scripted set was
established by auditing every reference in the consuming repositories. Changing the name, arguments, output format
or exit codes of anything public is a breaking change for them.
Entry points are sourced by path — source $(git rev-parse --show-toplevel)/ci3/source,
source_bootstrap from a bootstrap.sh, or the minimal source_base — which puts ci3 on PATH,
so the rest is called by name: denoise, cache_download, parallelize, and so on. source
already brings in redis, the ref name and the cache settings; those fragments are internal and
never need sourcing separately. Only source_npm_auth and source_cache_bucket are opt-in.
internal/ holds scripts only ci3 itself uses. It is on PATH so ci3's scripts can call each other
by name, but nothing outside ci3 should: these can change or disappear without notice. A script
moves out of internal/ when a consuming repository needs it, not before.
The dependency runs both ways. ci3 reads these from the repository it is building:
.test_patterns.yml— test skips, retries, owners and Slack notifications (filter_test_cmds,run_test_cmd).scripts/process_flake_log.py— optional; run byparallelizeafter a test run when present.build-images/src/home/.gitconfig— mounted into containers bydocker_isolate.CI3_EVENT_ENDPOINT,CI3_EVENT_TOKENandCI3_EVENT_PROJECT— optional; when all are set,bootstrap_ec2sends aci.instanceevent per build instance throughsend_eventto that OTLP endpoint, for examplehttps://otel.aztec-labs.com.- Permission to renew a build instance's lease. Each build instance shuts itself down, and so terminates, once its
LeaseUntiltag has passed, and whoever launched it renews that tag every minute while it runs (internal/source_instance_lease). The AWS role that launches instances, in CI and on a build instance launching another (such as the benchmark box), needsec2:CreateTagsfor theLeaseUntilkey on instances tagged with itsGroup. Without it, every instance shuts down 10 minutes after boot. - One
Groupper instance profile. An instance'sGrouptag is its instance profile's name without theci3-prefix and-profilesuffix (CI3_INSTANCE_PROFILE_NAME, defaultci3-build-instance-profile, sobuild-instance). Scope each launching role's EC2 and SSM permissions to the groups of the profiles it may pass, so a build of one trust level cannot drive instances of another. - What reaches the build container.
bootstrap_ec2passes ci3's own settings. Anything else the repository's build needs it names, usually in itsci.sh:CI3_PASS_ENV, variables passed as they are;CI3_PASS_FILES, variables holding the path of a file on the runner, which is copied to the instance under/tmp/ci3-filesand passed pointing at the copy. .github/ci3_post_checkout.sh— optional; executable. Run on the instance right after checkout and beforeci3/sourcederivesCOMMIT_HASH, with the build's environment and AWS role, so it can change the tree (apply and commit a patch, say). Its stdout is printed at the start of the run; its stderr shows only if it fails, which fails the run.execintobootstrap_ec2orbootstrap_ec2_multi, all the way from the CI step:run: exec ./ci.sh fastin the workflow,exec bootstrap_ec2 …inci.sh. CI cancels a job by signalling only the process it started (GitHub Actions sends that one process SIGINT, then SIGTERM, then SIGKILL 10 seconds later), so that process must be the ci3 script that terminates the instances. A script in between that runs it withoutexec, including as part of a pipeline, keeps the signal to itself, and the instances run on until their leases run out.tests/cancel_testcovers this.
A repository pins its own ci3, and a build can involve more than one pin: a repository and a
submodule of it each use their own. What has to stay compatible across versions is therefore not
the scripts but the state they share: redis key shapes (ci-run-<org>/<repo>/<section>,
history_*, hb-*, the test cache), S3 log keys (logs/<prefix>/<key>.log.gz), build-cache
artifact names, and the <hash>[:VAR=val] <cmd> test command format.