chore(workspace): native Rust toolchain as the primary path, builder image as the reproducible alternative

scripts/rust-check.sh and scripts/wasm-build.sh (moved from docker/) run
natively on the user-level rustup toolchain pinned by rust-toolchain.toml;
scripts/rust-env.sh puts ~/.cargo/bin on PATH for non-interactive shells.
Root scripts: rust:check and wasm:build native, rust:check:docker and
wasm:build:docker through docker/rust-run.sh, check:all = scripts/check-all.sh,
the whole pre-merge gate in one command (rust check, types drift, wasm build,
pnpm check, application image, worker:test, worker:image started read-only).
The native check now runs the worker's unit tests (cargo test --workspace);
the sandbox tests stay feature-gated and Docker-only.
This commit is contained in:
bchanot committed 2026-10-13 01:19:13 +02:00
1 parent bd9c7d1968
commit f2cf93668e
12 files changed
+100 -34

No files matched your search

+8 -5
View File
@@ -1,12 +1,15 @@
# Faunosteo reference Rust build environment (plan R0, RUST_ARCHITECTURE_REVIEW Annex B).
# Every Rust command of the repository runs through this image (CI and local), so the
# toolchain is identical everywhere and the production VPS never needs Rust.
# Faunosteo reference Rust build environment (plan R0, RUST_ARCHITECTURE_REVIEW Annex B,
# amended 2026-10-13). Daily development runs cargo natively on the Ubuntu development
# machine (rustup, docs/development/RUST.md §1); this image is the reproducible
# alternative (`pnpm rust:check:docker`, `pnpm wasm:build:docker`), the reference for a
# future runner, and the proof that the production VPS never needs Rust.
#
# docker build -f docker/rust-builder.Dockerfile -t faunosteo_rust_builder:1.99.0 docker
# bash docker/rust-run.sh cargo test --workspace --exclude faunosteo-worker
# bash docker/rust-run.sh cargo test --workspace
#
# The pinned versions below must match rust-toolchain.toml (channel) and Cargo.lock
# (wasm-bindgen crate): docker/wasm-build.sh refuses to run when they differ.
# (wasm-bindgen crate): scripts/wasm-build.sh refuses to run when they differ. The same
# three tools are installed natively with rustup / cargo install at these versions.
FROM rust:1.99.0-bookworm
ARG WASM_BINDGEN_VERSION=0.2.129
-16
View File
@@ -1,16 +0,0 @@
#!/usr/bin/env bash
# The Rust quality gate, identical in CI and locally: `pnpm rust:check`.
# Runs inside the builder image (glibc). The worker's sandbox tests run in its own
# Alpine/musl image (crates/worker/Dockerfile, stage `test`) because the seccomp
# allowlist is derived for the musl static binary that ships.
set -euo pipefail
cd "$(dirname "$0")/.."
cargo fmt --all --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --exclude faunosteo-worker --locked
# Exports the TypeScript types of the contracts (ts-rs) into packages/core-wasm/types;
# CI fails on a diff so the committed types never drift from the Rust structs.
cargo test -p faunosteo-core --features ts --locked
cargo deny check licenses bans sources
+6 -5
View File
@@ -1,11 +1,12 @@
#!/usr/bin/env bash
# Runs a command inside the reference Rust builder image with the repository mounted
# at /w. Cargo's registry and the target directory live in named Docker volumes
# (faunosteo_ prefix, DEPLOY.md "Docker resource naming") so incremental builds stay
# fast across runs while the host needs no Rust toolchain.
# at /w: the reproducible alternative to the native toolchain of the development machine
# (docs/development/RUST.md §1). Cargo's registry and the target directory live in named
# Docker volumes (faunosteo_ prefix, DEPLOY.md "Docker resource naming"), separate from
# the native ./target, so incremental builds stay fast across runs.
#
# bash docker/rust-run.sh cargo test --workspace --exclude faunosteo-worker
# bash docker/rust-run.sh bash docker/wasm-build.sh
# bash docker/rust-run.sh cargo test --workspace
# bash docker/rust-run.sh bash scripts/wasm-build.sh # = pnpm wasm:build:docker
set -euo pipefail
IMAGE="${FAUNOSTEO_RUST_BUILDER:-faunosteo_rust_builder:1.99.0}"
-27
View File
@@ -1,27 +0,0 @@
#!/usr/bin/env bash
# Builds the browser module of crates/wasm into packages/core-wasm/pkg (git-ignored).
# Runs inside the builder image: `pnpm wasm:build` or `bash docker/rust-run.sh bash docker/wasm-build.sh`.
# The wasm-bindgen CLI must be the exact version of the wasm-bindgen crate in Cargo.lock
# (wasm-bindgen >= 0.2.128 refuses a mismatch at runtime; we refuse it up front).
set -euo pipefail
cd "$(dirname "$0")/.."
lock_version="$(awk '/^name = "wasm-bindgen"$/ { getline; sub(/^version = "/, ""); sub(/"$/, ""); print; exit }' Cargo.lock)"
cli_version="$(wasm-bindgen --version | awk '{ print $2 }')"
if [ "$lock_version" != "$cli_version" ]; then
echo "wasm-bindgen crate ${lock_version} (Cargo.lock) != wasm-bindgen-cli ${cli_version} (builder image)" >&2
exit 1
fi
# `proofs`: the R0 trap exports; dropped when R2 builds the module the application ships.
cargo build -p faunosteo-wasm --release --target wasm32-unknown-unknown --locked --features proofs
out=packages/core-wasm/pkg
rm -rf "$out"
wasm-bindgen --target web --out-dir "$out" --out-name faunosteo_wasm \
target/wasm32-unknown-unknown/release/faunosteo_wasm.wasm
raw=$(wc -c < "$out/faunosteo_wasm_bg.wasm")
gz=$(gzip -9 -c "$out/faunosteo_wasm_bg.wasm" | wc -c)
echo "faunosteo_wasm_bg.wasm: ${raw} bytes raw, ${gz} bytes gzip -9"