tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

261 lignes · 13559 octetsBrut · Historique
1#!/usr/bin/env bash
2# Every check CI must run. Forge-specific CI config should just call this.
3#
4# Profiles (LOUISE_CI_PROFILE, or `scripts/ci.sh PROFILE`):
5# full everything (default on a runner, CI=true)
6# docs rustfmt, clippy, unit tests, the Louise fmt check
7# compiler docs + native differential tests, examples, stress
8# runtime everything: loom, aarch64, the ABI spike, sanitizers
9# auto pick from the diff against origin/main (default locally)
10# Parts (LOUISE_CI_PART), which CI runs as parallel jobs (ci.yml); unset or
11# `all` runs every one, as locally:
12# check rustfmt, clippy, the unit tests, the generated and Louise
13# formatting checks
14# native the native programs (hibernated, unoptimised, the release
15# compiler verifying, the benchmarks both ways), the fuzzer
16# examples the examples (their packages come from louise-lang/packages),
17# the demo under load, tree-sitter, the stress run
18# runtime aarch64, the loom models, the ABI spikes
19# On a shared host (several agents, one machine) LOUISE_CI_SHARED_HOST=1
20# serializes the heavy lanes through /tmp/louise-ci-heavy.lock, niced.
21set -euo pipefail
22cd "$(dirname "$0")/.."
23# mold, when installed, for faster links, and heavy(), the shared-host
24# heavy-lane lock (lib.sh; override the links with RUSTFLAGS).
25source scripts/lib.sh
26
27# Each step's time, until the next one starts (the slowest first at the
28# end, also on a failure): what to shorten next is measured, not guessed.
29step_name="" step_start=$SECONDS
30timings=()
31step_done() {
32 if [ -n "$step_name" ]; then timings+=("$(printf '%5ds %s' $((SECONDS - step_start)) "$step_name")"); fi
33 step_name=""
34}
35timings_summary() {
36 step_done
37 if [ ${#timings[@]} -gt 0 ]; then printf '\n== the steps, slowest first\n'; printf '%s\n' "${timings[@]}" | sort -rn; fi
38}
39trap timings_summary EXIT
40step() {
41 step_done
42 step_name="$*" step_start=$SECONDS
43 printf '\n== %s\n' "$*"
44 if [ "${CI:-}" = true ]; then df -h . | tail -1; fi
45}
46# On a runner the heavy one-off target dirs are peak disk, not caches:
47# the job's store is bounded, and a full one fails the link with "No
48# space left on device" (2026-10-22; local runs keep the cache warm).
49sweep() { if [ "${CI:-}" = true ]; then chmod -R u+w "$1" 2>/dev/null || true; rm -rf "$1"; fi; }
50# The compiler, as built from this checkout (debug), from any directory.
51louise() { cargo run --quiet -p louise -- "$@"; }
52# The sanitizer suites of the test programs run in their own workflow
53# (.toboggan/workflows/asan.yml); ci.sh keeps only the quick ABI spike under
54# ASan+UBSan (runtime lane, when clang exists).
55
56# The tests compile every tests/run program several times over: with the
57# compiler optimised, much faster than with a debug one. Debug assertions
58# and overflow checks stay on.
59export CARGO_PROFILE_DEV_OPT_LEVEL="${CARGO_PROFILE_DEV_OPT_LEVEL:-1}"
60# Line tables only, not full debuginfo: file:line in backtraces stays, the
61# test binaries (most link the whole compiler) and liblouise_rt.a shrink,
62# and so do the links. No check reads Rust's debuginfo (the file:line
63# checks are the generated C's, through clang's -g); a debugger session
64# builds with cargo's defaults, outside ci.sh.
65export CARGO_PROFILE_DEV_DEBUG="${CARGO_PROFILE_DEV_DEBUG:-line-tables-only}"
66# The quick lane (LOUISE_CI_FULL=0, which ci.yml sets for pull requests)
67# leaves out the native part's longer runs: every parked actor hibernated,
68# the differential fuzzer's full batch, the release build's verification,
69# and the benchmark programs both ways. Pushes to main, manual runs and
70# local runs do everything.
71full="${LOUISE_CI_FULL:-1}"
72
73profile="${1:-${LOUISE_CI_PROFILE:-}}"
74if [ -z "$profile" ]; then
75 if [ "${CI:-}" = true ]; then profile=full; else profile=auto; fi
76fi
77if [ "$profile" = auto ]; then
78 # Pick from the diff: docs only → docs; runtime/ → runtime; anything
79 # else → compiler. Unsure (no origin/main, no git) → full.
80 { git diff --name-only origin/main...HEAD 2>/dev/null || git diff --name-only HEAD 2>/dev/null; } > /tmp/louise-ci-diff.$$ || true
81 git status --porcelain=v1 -uall 2>/dev/null | awk '{print $2}' >> /tmp/louise-ci-diff.$$ || true
82 if [ ! -s /tmp/louise-ci-diff.$$ ]; then
83 profile=full
84 elif ! grep -qvE '^(docs/|.*\.md$|\.toboggan/|\.worktrees/)' /tmp/louise-ci-diff.$$; then
85 profile=docs
86 elif grep -q '^runtime/' /tmp/louise-ci-diff.$$; then
87 profile=runtime
88 else
89 profile=compiler
90 fi
91 rm -f /tmp/louise-ci-diff.$$
92 echo "ci: auto profile from the diff: $profile"
93fi
94lanes=$profile
95[ "$profile" = full ] && lanes="docs,compiler,runtime"
96lane() { # lane NAME — whether this profile runs the lane
97 case ",$lanes," in *",$1,"*) return 0;; esac
98 echo "ci: skipping the $1 lane (the $profile profile)"
99 return 1
100}
101ci_part="${LOUISE_CI_PART:-all}"
102case $ci_part in all|check|native|examples|runtime) ;; *) echo "ci: no part $ci_part" >&2; exit 2;; esac
103part() { # part NAME... — whether this job runs one of these parts
104 [ "$ci_part" = all ] && return 0
105 local p; for p in "$@"; do [ "$ci_part" = "$p" ] && return 0; done
106 return 1
107}
108
109if part check; then
110 step "rustfmt"; cargo fmt --all --check
111 step "clippy"; cargo clippy --workspace --all-targets -- -D warnings
112fi
113# Every profile: some of the driver's unit tests link liblouise_rt.a.
114step "runtime library"; cargo build --quiet -p louise_rt # native tests link it
115if part native examples && { lane compiler || lane runtime; }; then
116 # The fast runtime too, next to the debug louise: the tests' release builds
117 # link it (ADR 0031). The archives are installed into target/debug; the
118 # whole-std LTO build dirs are big and never needed again (the job's
119 # store is bounded: run #738 died here with "No space left on device").
120 step "fast runtime"; without_mold scripts/runtime.sh debug
121 sweep target/fast
122 sweep target/lto
123fi
124# aarch64: tested under qemu where it is installed (scripts/aarch64.sh),
125# else type-checked and assembled. Without mimalloc and ring then: their
126# build scripts need a C cross-compiler, and the allocator and the hashes
127# are not what this checks (without `crypto`, the crypto externs exist and
128# panic "crypto support not built in", the `tls` precedent).
129if part runtime && lane runtime; then
130 if scripts/aarch64.sh --available; then
131 step "runtime and native programs on aarch64 (qemu)"; heavy scripts/aarch64.sh
132 sweep target/arm64-sysroot
133 else
134 step "runtime on aarch64 (type-check and assemble; no qemu here)"
135 cargo check --quiet -p louise_rt --all-targets --no-default-features --features stats --target aarch64-unknown-linux-gnu
136 cargo build --quiet -p louise_rt --lib --no-default-features --features stats --target aarch64-unknown-linux-gnu
137 fi
138fi
139if part check; then
140 # built, then run: the step timings tell compiling and linking the test
141 # binaries (most of them link the whole compiler) from running them
142 step "unit tests (build)"; cargo test --workspace --quiet --no-run
143 step "unit tests"; cargo test --workspace --quiet
144fi
145if part runtime && lane runtime; then
146 step "loom models (scheduler hand-offs, timers, mailbox)"; heavy scripts/loom.sh
147 sweep target/loom
148fi
149if part native && { lane compiler || lane runtime; }; then
150 # Hibernation (ADR 0028) normally reaches only actors parked for 400 ms:
151 # here every parked actor is hibernated and thawed, in every program.
152 if [ "$full" = 1 ]; then
153 step "native programs, every parked actor hibernated"
154 LOUISE_PARKED_EPOCH_MS=0 cargo test --quiet -p louise_codegen_c --test native
155 fi
156 # Both back ends run optimised Core, so the optimiser is checked against
157 # the same programs unoptimised (issue gabla108/louise#219; the interpreter's half runs
158 # with the unit tests).
159 step "native programs, unoptimised"
160 cargo test --quiet -p louise_codegen_c --test native -- --ignored run_programs_natively_unoptimised
161 # The differential fuzzer (issue gabla108/louise#352): random small programs from fuzz/,
162 # each run interpreted and natively and compared on stdout, exit code and
163 # the leak oracle. Bounded by LOUISE_FUZZ_RUNS; the base seed is printed
164 # so a failure reproduces (LOUISE_FUZZ_SEED=<seed> LOUISE_FUZZ_RUNS=1
165 # cargo test -p louise_codegen_c --test fuzz). A small fixed batch also
166 # runs with the unit tests above (LOUISE_FUZZ_RUNS defaults to 25).
167 if [ "$full" = 1 ]; then
168 step "differential fuzzer (issue #352)"
169 fuzz_seed="${LOUISE_FUZZ_SEED:-$((RANDOM % 1000000))}"
170 echo "fuzz base seed: $fuzz_seed"
171 LOUISE_FUZZ_SEED="$fuzz_seed" LOUISE_FUZZ_RUNS="${LOUISE_FUZZ_RUNS:-200}" \
172 cargo test --quiet -p louise_codegen_c --test fuzz
173 # 200 compiled programs are hundreds of MB; the store is bounded.
174 sweep target/fuzz
175 fi
176 # Verify after every opt pass with a release compiler (issue gabla108/louise#350): the
177 # debug compiler the other lanes run verifies already; LOUISE_VERIFY=1
178 # keeps a release-only miscompilation visible. Full mode only: a second
179 # (release) build of the workspace is not cheap enough for the quick
180 # lane.
181 if [ "$full" = 1 ]; then
182 step "release compiler verifies every opt pass (issue #350)"
183 heavy env LOUISE_VERIFY=1 CARGO_TARGET_DIR=target/verify \
184 cargo build --quiet --release -p louise_rt
185 heavy env LOUISE_VERIFY=1 CARGO_TARGET_DIR=target/verify \
186 cargo test --quiet --release -p louise_codegen_c --test native
187 sweep target/verify
188 fi
189 # The benchmarks' checksums predate the optimiser: built optimised and
190 # unoptimised, they must print them (issue gabla108/louise#219).
191 if [ "$full" = 1 ]; then
192 step "benchmark programs, optimised and unoptimised"
193 cargo test --quiet -p louise_codegen_c --test native -- --ignored bench_programs_natively_both_ways
194 fi
195fi
196if part check; then
197 step "prelude tuple impls are generated"; scripts/gen-tuple-impls.py --check
198 step "Louise formatting"; louise fmt --check std tests/run tests/ui tests/stress tests/bench tests/compare examples fuzz
199 # A program checks only the std modules it reaches (ADR 0074): this
200 # checks all of them, `@fip` included, with their warnings.
201 step "all of std checks"; louise check --all-std --deps-warnings --deny-warnings tests/run/hello.lse
202fi
203if part examples && { lane compiler || lane runtime; }; then
204 step "examples are warning-free"
205 for pkg in examples/http_demo examples/event_store examples/qsort examples/cluster fuzz; do
206 (cd "$pkg" && louise check --deny-warnings --locked)
207 done
208 step "demo tests (native)"; (cd examples/http_demo && louise test --native --locked)
209 # The event store's live tests need a database (LOUISE_PG_URL); without
210 # one they skip, and the in-memory handler's tests run.
211 step "event store example"; (cd examples/event_store && louise test --locked && louise test --native --locked)
212 # Responses and the leak oracle under concurrent keep-alive connections,
213 # on 1 and 8 threads; a small load, as timings are not checked here.
214 step "demo under load (leak oracle)"
215 LOAD_CONNECTIONS=16 LOAD_REQUESTS=100 cargo test --quiet -p louise --test demo -- --ignored the_demo_under_load
216 step "qsort example: C callbacks, generated bindings (native)"; (cd examples/qsort && louise test --native --locked)
217 # The store on one node; crates/louise/tests/dist.rs runs both nodes.
218 step "cluster example"; (cd examples/cluster && louise test --locked && louise test --native --locked)
219 # Every package/example above built native test binaries into its build/;
220 # dead weight for the rest of the job (the store is bounded; run #778).
221 for d in examples/*/build fuzz/build; do sweep "$d"; done
222fi
223if part examples && { lane compiler || lane runtime; }; then
224 if command -v tree-sitter >/dev/null; then
225 step "tree-sitter grammar"
226 (cd editors/tree-sitter-louise && tree-sitter generate && git diff --exit-code -- src && tree-sitter test)
227 else
228 echo "skipping tree-sitter generate/test: the tree-sitter CLI is not installed (cargo test covers parsing)"
229 fi
230 step "stress (several threads)"; heavy scripts/stress.sh
231 # stress.sh's release build (compiler + runtime archives) is the job's
232 # peak disk; nothing after it needs target/release.
233 sweep target/release
234fi
235if part runtime && lane runtime; then
236 step "ABI spike"; heavy scripts/spike.sh
237 step "ABI spike (release)"; heavy env CARGO_TARGET_DIR=target/spike-release scripts/spike.sh --release
238 sweep target/spike-release
239 if command -v clang >/dev/null; then
240 step "ABI spike (ASan+UBSan)"; heavy scripts/spike.sh --asan
241 # The sanitizer suites of the test programs live in their own workflow
242 # (.toboggan/workflows/asan.yml): the full lane's store filled here
243 # (run #738), so they run as their own job, as tsan.yml does.
244 else
245 echo "skipping ASan spike: clang not found"
246 fi
247fi
248# Opt-in here: it needs a nightly toolchain with rust-src. On the forge it
249# is its own workflow (.toboggan/workflows/tsan.yml), which runs
250# scripts/tsan.sh.
251if [ "${LOUISE_CI_TSAN:-0}" = 1 ]; then
252 step "ThreadSanitizer (runtime, native programs)"; heavy without_mold scripts/tsan.sh
253 sweep target/tsan
254else
255 echo "skipping ThreadSanitizer: set LOUISE_CI_TSAN=1 (needs nightly with rust-src, and clang); the tsan workflow runs it"
256fi
257if [ "$full" = 1 ]; then
258 printf '\nci: all checks passed (profile: %s, part: %s)\n' "$profile" "$ci_part"
259else
260 printf '\nci: the quick lane passed (profile: %s, part: %s; LOUISE_CI_FULL=0: pushes to main run the rest)\n' "$profile" "$ci_part"
261fi