#!/usr/bin/env bash # Every check CI must run. Forge-specific CI config should just call this. # # Profiles (LOUISE_CI_PROFILE, or `scripts/ci.sh PROFILE`): # full everything (default on a runner, CI=true) # docs rustfmt, clippy, unit tests, the Louise fmt check # compiler docs + native differential tests, packages, examples, stress # runtime everything: loom, aarch64, the ABI spike, sanitizers # auto pick from the diff against origin/main (default locally) # Parts (LOUISE_CI_PART), which CI runs as parallel jobs (ci.yml); unset or # `all` runs every one, as locally: # check rustfmt, clippy, the unit tests, the generated and Louise # formatting checks # native the native programs (hibernated, unoptimised, the release # compiler verifying, the benchmarks both ways), the fuzzer # packages the packages and examples, the demo under load, tree-sitter, # the stress run # runtime aarch64, the loom models, the ABI spikes # On a shared host (several agents, one machine) LOUISE_CI_SHARED_HOST=1 # serializes the heavy lanes through /tmp/louise-ci-heavy.lock, niced. set -euo pipefail cd "$(dirname "$0")/.." # mold, when installed, for faster links, and heavy(), the shared-host # heavy-lane lock (lib.sh; override the links with RUSTFLAGS). source scripts/lib.sh # Each step's time, until the next one starts (the slowest first at the # end, also on a failure): what to shorten next is measured, not guessed. step_name="" step_start=$SECONDS timings=() step_done() { if [ -n "$step_name" ]; then timings+=("$(printf '%5ds %s' $((SECONDS - step_start)) "$step_name")"); fi step_name="" } timings_summary() { step_done if [ ${#timings[@]} -gt 0 ]; then printf '\n== the steps, slowest first\n'; printf '%s\n' "${timings[@]}" | sort -rn; fi } trap timings_summary EXIT step() { step_done step_name="$*" step_start=$SECONDS printf '\n== %s\n' "$*" if [ "${CI:-}" = true ]; then df -h . | tail -1; fi } # On a runner the heavy one-off target dirs are peak disk, not caches: # the job's store is bounded, and a full one fails the link with "No # space left on device" (2026-10-22; local runs keep the cache warm). sweep() { if [ "${CI:-}" = true ]; then chmod -R u+w "$1" 2>/dev/null || true; rm -rf "$1"; fi; } # The compiler, as built from this checkout (debug), from any directory. louise() { cargo run --quiet -p louise -- "$@"; } # The sanitizer suites of the test programs run in their own workflow # (.toboggan/workflows/asan.yml); ci.sh keeps only the quick ABI spike under # ASan+UBSan (runtime lane, when clang exists). # The tests compile every tests/run program several times over: with the # compiler optimised, much faster than with a debug one. Debug assertions # and overflow checks stay on. export CARGO_PROFILE_DEV_OPT_LEVEL="${CARGO_PROFILE_DEV_OPT_LEVEL:-1}" # Line tables only, not full debuginfo: file:line in backtraces stays, the # test binaries (most link the whole compiler) and liblouise_rt.a shrink, # and so do the links. No check reads Rust's debuginfo (the file:line # checks are the generated C's, through clang's -g); a debugger session # builds with cargo's defaults, outside ci.sh. export CARGO_PROFILE_DEV_DEBUG="${CARGO_PROFILE_DEV_DEBUG:-line-tables-only}" # The quick lane (LOUISE_CI_FULL=0, which ci.yml sets for pull requests) # leaves out the native part's longer runs: every parked actor hibernated, # the differential fuzzer's full batch, the release build's verification, # and the benchmark programs both ways. Pushes to main, manual runs and # local runs do everything. full="${LOUISE_CI_FULL:-1}" profile="${1:-${LOUISE_CI_PROFILE:-}}" if [ -z "$profile" ]; then if [ "${CI:-}" = true ]; then profile=full; else profile=auto; fi fi if [ "$profile" = auto ]; then # Pick from the diff: docs only → docs; runtime/ → runtime; anything # else → compiler. Unsure (no origin/main, no git) → full. { git diff --name-only origin/main...HEAD 2>/dev/null || git diff --name-only HEAD 2>/dev/null; } > /tmp/louise-ci-diff.$$ || true git status --porcelain=v1 -uall 2>/dev/null | awk '{print $2}' >> /tmp/louise-ci-diff.$$ || true if [ ! -s /tmp/louise-ci-diff.$$ ]; then profile=full elif ! grep -qvE '^(docs/|.*\.md$|\.toboggan/|\.worktrees/)' /tmp/louise-ci-diff.$$; then profile=docs elif grep -q '^runtime/' /tmp/louise-ci-diff.$$; then profile=runtime else profile=compiler fi rm -f /tmp/louise-ci-diff.$$ echo "ci: auto profile from the diff: $profile" fi lanes=$profile [ "$profile" = full ] && lanes="docs,compiler,runtime" lane() { # lane NAME — whether this profile runs the lane case ",$lanes," in *",$1,"*) return 0;; esac echo "ci: skipping the $1 lane (the $profile profile)" return 1 } ci_part="${LOUISE_CI_PART:-all}" case $ci_part in all|check|native|packages|runtime) ;; *) echo "ci: no part $ci_part" >&2; exit 2;; esac part() { # part NAME... — whether this job runs one of these parts [ "$ci_part" = all ] && return 0 local p; for p in "$@"; do [ "$ci_part" = "$p" ] && return 0; done return 1 } if part check; then step "rustfmt"; cargo fmt --all --check step "clippy"; cargo clippy --workspace --all-targets -- -D warnings fi # Every profile: some of the driver's unit tests link liblouise_rt.a. step "runtime library"; cargo build --quiet -p louise_rt # native tests link it if part native packages && { lane compiler || lane runtime; }; then # The fast runtime too, next to the debug louise: the tests' release builds # link it (ADR 0031). The archives are installed into target/debug; the # whole-std LTO build dirs are big and never needed again (the job's # store is bounded: run #738 died here with "No space left on device"). step "fast runtime"; without_mold scripts/runtime.sh debug sweep target/fast sweep target/lto fi # aarch64: tested under qemu where it is installed (scripts/aarch64.sh), # else type-checked and assembled. Without mimalloc and ring then: their # build scripts need a C cross-compiler, and the allocator and the hashes # are not what this checks (without `crypto`, the crypto externs exist and # panic "crypto support not built in", the `tls` precedent). if part runtime && lane runtime; then if scripts/aarch64.sh --available; then step "runtime and native programs on aarch64 (qemu)"; heavy scripts/aarch64.sh sweep target/arm64-sysroot else step "runtime on aarch64 (type-check and assemble; no qemu here)" cargo check --quiet -p louise_rt --all-targets --no-default-features --features stats --target aarch64-unknown-linux-gnu cargo build --quiet -p louise_rt --lib --no-default-features --features stats --target aarch64-unknown-linux-gnu fi fi if part check; then # built, then run: the step timings tell compiling and linking the test # binaries (most of them link the whole compiler) from running them step "unit tests (build)"; cargo test --workspace --quiet --no-run step "unit tests"; cargo test --workspace --quiet fi if part runtime && lane runtime; then step "loom models (scheduler hand-offs, timers, mailbox)"; heavy scripts/loom.sh sweep target/loom fi if part native && { lane compiler || lane runtime; }; then # Hibernation (ADR 0028) normally reaches only actors parked for 400 ms: # here every parked actor is hibernated and thawed, in every program. if [ "$full" = 1 ]; then step "native programs, every parked actor hibernated" LOUISE_PARKED_EPOCH_MS=0 cargo test --quiet -p louise_codegen_c --test native fi # Both back ends run optimised Core, so the optimiser is checked against # the same programs unoptimised (issue #219; the interpreter's half runs # with the unit tests). step "native programs, unoptimised" cargo test --quiet -p louise_codegen_c --test native -- --ignored run_programs_natively_unoptimised # The differential fuzzer (issue #352): random small programs from fuzz/, # each run interpreted and natively and compared on stdout, exit code and # the leak oracle. Bounded by LOUISE_FUZZ_RUNS; the base seed is printed # so a failure reproduces (LOUISE_FUZZ_SEED= LOUISE_FUZZ_RUNS=1 # cargo test -p louise_codegen_c --test fuzz). A small fixed batch also # runs with the unit tests above (LOUISE_FUZZ_RUNS defaults to 25). if [ "$full" = 1 ]; then step "differential fuzzer (issue #352)" fuzz_seed="${LOUISE_FUZZ_SEED:-$((RANDOM % 1000000))}" echo "fuzz base seed: $fuzz_seed" LOUISE_FUZZ_SEED="$fuzz_seed" LOUISE_FUZZ_RUNS="${LOUISE_FUZZ_RUNS:-200}" \ cargo test --quiet -p louise_codegen_c --test fuzz # 200 compiled programs are hundreds of MB; the store is bounded. sweep target/fuzz fi # Verify after every opt pass with a release compiler (issue #350): the # debug compiler the other lanes run verifies already; LOUISE_VERIFY=1 # keeps a release-only miscompilation visible. Full mode only: a second # (release) build of the workspace is not cheap enough for the quick # lane. if [ "$full" = 1 ]; then step "release compiler verifies every opt pass (issue #350)" heavy env LOUISE_VERIFY=1 CARGO_TARGET_DIR=target/verify \ cargo build --quiet --release -p louise_rt heavy env LOUISE_VERIFY=1 CARGO_TARGET_DIR=target/verify \ cargo test --quiet --release -p louise_codegen_c --test native sweep target/verify fi # The benchmarks' checksums predate the optimiser: built optimised and # unoptimised, they must print them (issue #219). if [ "$full" = 1 ]; then step "benchmark programs, optimised and unoptimised" cargo test --quiet -p louise_codegen_c --test native -- --ignored bench_programs_natively_both_ways fi fi if part check; then step "prelude tuple impls are generated"; scripts/gen-tuple-impls.py --check step "Louise formatting"; louise fmt --check std tests/run tests/ui tests/stress tests/bench tests/compare packages examples fuzz # A program checks only the std modules it reaches (ADR 0074): this # checks all of them, `@fip` included, with their warnings. step "all of std checks"; louise check --all-std --deps-warnings --deny-warnings tests/run/hello.lse fi if part packages && { lane compiler || lane runtime; }; then step "packages and examples are warning-free" for pkg in packages/argon2 packages/uuid packages/postgres packages/form packages/gen packages/search packages/web packages/blindindex packages/stringzilla packages/json packages/eventsourcing packages/log packages/url packages/multipart packages/fetch packages/resilience packages/throttle packages/secrets examples/http_demo examples/event_store examples/qsort examples/cluster fuzz; do (cd "$pkg" && louise check --deny-warnings --locked) done step "argon2 package (native)"; (cd packages/argon2 && louise test --native --locked) step "uuid package"; (cd packages/uuid && louise test --locked && louise test --native --locked) step "form package"; (cd packages/form && louise test --locked && louise test --native --locked) step "gen package"; (cd packages/gen && louise test --locked && louise test --native --locked) step "log package"; (cd packages/log && louise test --locked && louise test --native --locked) step "web package"; (cd packages/web && louise test --locked && louise test --native --locked) step "json package"; (cd packages/json && louise test --locked && louise test --native --locked) step "url package"; (cd packages/url && louise test --locked && louise test --native --locked) step "multipart package"; (cd packages/multipart && louise test --locked && louise test --native --locked) # Its loopback tests need LOUISE_NET_TESTS (native only); without it # they skip, and the parsers' tests run in both back ends. step "fetch package"; (cd packages/fetch && louise test --locked && louise test --native --locked) step "resilience package"; (cd packages/resilience && louise test --locked && louise test --native --locked) # Its shared buckets' tests need LOUISE_PG_URL (native only); without it # they skip, and the local throttle and the store's checks still run. step "throttle package"; (cd packages/throttle && louise test --locked && louise test --native --locked --jobs 1) step "secrets package"; (cd packages/secrets && louise test --locked && louise test --native --locked) # Its PostgreSQL tests need LOUISE_PG_URL; without it they skip. step "eventsourcing package"; (cd packages/eventsourcing && louise test --locked && louise test --native --locked --jobs 1) # Deterministic loopback/wire tests run only in the native backend; the # interpreter skips them. Real PostgreSQL service cases still need # LOUISE_PG_URL and skip without it. step "postgres package"; (cd packages/postgres && louise test --locked && LOUISE_NET_TESTS=1 louise test --native --locked) step "demo tests (native)"; (cd examples/http_demo && louise test --native --locked) # The event store's live tests need a database (LOUISE_PG_URL); without # one they skip, and the in-memory handler's tests run. step "event store example"; (cd examples/event_store && louise test --locked && louise test --native --locked) # Responses and the leak oracle under concurrent keep-alive connections, # on 1 and 8 threads; a small load, as timings are not checked here. step "demo under load (leak oracle)" LOAD_CONNECTIONS=16 LOAD_REQUESTS=100 cargo test --quiet -p louise --test demo -- --ignored the_demo_under_load step "qsort example: C callbacks, generated bindings (native)"; (cd examples/qsort && louise test --native --locked) # The store on one node; crates/louise/tests/dist.rs runs both nodes. step "cluster example"; (cd examples/cluster && louise test --locked && louise test --native --locked) # Every package/example above built native test binaries into its build/; # dead weight for the rest of the job (the store is bounded; run #778). for d in packages/*/build examples/*/build fuzz/build; do sweep "$d"; done fi if part packages && { lane compiler || lane runtime; }; then if command -v tree-sitter >/dev/null; then step "tree-sitter grammar" (cd editors/tree-sitter-louise && tree-sitter generate && git diff --exit-code -- src && tree-sitter test) else echo "skipping tree-sitter generate/test: the tree-sitter CLI is not installed (cargo test covers parsing)" fi step "stress (several threads)"; heavy scripts/stress.sh # stress.sh's release build (compiler + runtime archives) is the job's # peak disk; nothing after it needs target/release. sweep target/release fi if part runtime && lane runtime; then step "ABI spike"; heavy scripts/spike.sh step "ABI spike (release)"; heavy env CARGO_TARGET_DIR=target/spike-release scripts/spike.sh --release sweep target/spike-release if command -v clang >/dev/null; then step "ABI spike (ASan+UBSan)"; heavy scripts/spike.sh --asan # The sanitizer suites of the test programs live in their own workflow # (.toboggan/workflows/asan.yml): the full lane's store filled here # (run #738), so they run as their own job, as tsan.yml does. else echo "skipping ASan spike: clang not found" fi fi # Opt-in here: it needs a nightly toolchain with rust-src. On the forge it # is its own workflow (.toboggan/workflows/tsan.yml), which runs # scripts/tsan.sh. if [ "${LOUISE_CI_TSAN:-0}" = 1 ]; then step "ThreadSanitizer (runtime, native programs)"; heavy without_mold scripts/tsan.sh sweep target/tsan else echo "skipping ThreadSanitizer: set LOUISE_CI_TSAN=1 (needs nightly with rust-src, and clang); the tsan workflow runs it" fi if [ "$full" = 1 ]; then printf '\nci: all checks passed (profile: %s, part: %s)\n' "$profile" "$ci_part" else printf '\nci: the quick lane passed (profile: %s, part: %s; LOUISE_CI_FULL=0: pushes to main run the rest)\n' "$profile" "$ci_part" fi