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:
1 parent
bd9c7d1968
commit
f2cf93668e
12 files changed
+100
-34
No files matched your search
+2
-1
@@ -1,6 +1,7 @@
|
||||
# Faunosteo Rust workspace (plan R0, docs/development/RUST_ARCHITECTURE_REVIEW.md Part III).
|
||||
# Three crates: core (feature-gated library), wasm (browser facade), worker (service binary).
|
||||
# Every command runs through the builder image: docs/development/RUST.md.
|
||||
# Commands run on the native toolchain of the development machine (rustup, the channel of
|
||||
# rust-toolchain.toml) or inside the builder image: docs/development/RUST.md §1.
|
||||
[workspace]
|
||||
resolver = "3"
|
||||
members = ["crates/core", "crates/wasm", "crates/worker"]
|
||||
|
||||
@@ -14,7 +14,7 @@ path = "src/lib.rs"
|
||||
[features]
|
||||
default = []
|
||||
# The R0 trap proofs (panic_for_test, recurse_for_test): built for the proofs, never for the
|
||||
# module the application ships (docker/wasm-build.sh passes it until R2 wires the real loader).
|
||||
# module the application ships (scripts/wasm-build.sh passes it until R2 wires the real loader).
|
||||
proofs = []
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! wasm-bindgen facade over `faunosteo-core` (review III.3): JSON strings in and out, closed
|
||||
//! outcome kinds. Built by `docker/wasm-build.sh` into `packages/core-wasm/pkg`; loaded
|
||||
//! outcome kinds. Built by `scripts/wasm-build.sh` into `packages/core-wasm/pkg`; loaded
|
||||
//! lazily by the application from R2 on (never at R0).
|
||||
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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}"
|
||||
|
||||
+5
-2
@@ -19,6 +19,7 @@
|
||||
"lint": "pnpm -r lint",
|
||||
"format": "prettier --write .",
|
||||
"check": "pnpm typecheck && pnpm test:run && pnpm lint && pnpm build",
|
||||
"check:all": "bash scripts/check-all.sh",
|
||||
"report:compare": "pnpm --filter @faunosteo/app report:compare",
|
||||
"import:equine": "pnpm --filter @faunosteo/anatomy import:equine",
|
||||
"db:start": "supabase start",
|
||||
@@ -31,8 +32,10 @@
|
||||
"build:preview": "SHEET_BUNDLE=draft pnpm --filter @faunosteo/app build",
|
||||
"preview:draft": "SHEET_BUNDLE=draft pnpm --filter @faunosteo/app build && pnpm --filter @faunosteo/app preview",
|
||||
"rust:builder": "docker build -f docker/rust-builder.Dockerfile -t faunosteo_rust_builder:1.99.0 docker",
|
||||
"rust:check": "bash docker/rust-run.sh bash docker/rust-check.sh",
|
||||
"wasm:build": "bash docker/rust-run.sh bash docker/wasm-build.sh",
|
||||
"rust:check": "bash scripts/rust-check.sh",
|
||||
"rust:check:docker": "bash docker/rust-run.sh bash scripts/rust-check.sh",
|
||||
"wasm:build": "bash scripts/wasm-build.sh",
|
||||
"wasm:build:docker": "bash docker/rust-run.sh bash scripts/wasm-build.sh",
|
||||
"worker:test": "docker build -f crates/worker/Dockerfile --target test -t faunosteo_worker:test .",
|
||||
"worker:image": "docker build -f crates/worker/Dockerfile -t faunosteo_worker:dev ."
|
||||
},
|
||||
|
||||
+3
-1
@@ -1,6 +1,8 @@
|
||||
# Pinned toolchain, identical to docker/rust-builder.Dockerfile (FROM rust:1.99.0-bookworm)
|
||||
# and crates/worker/Dockerfile (FROM rust:1.99.0-alpine3.24). Bump the three together.
|
||||
# The wasm32 target is added by the builder image only (the worker image never needs it).
|
||||
# A native rustup installs this channel on first use (`rustup show` from the repository);
|
||||
# the wasm32 target is added by hand (`rustup target add wasm32-unknown-unknown`) and by the
|
||||
# builder image; the worker image never needs it.
|
||||
[toolchain]
|
||||
channel = "1.99.0"
|
||||
components = ["rustfmt", "clippy"]
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env bash
|
||||
# Every technical check a branch must pass before a merge, in one command: `pnpm check:all`.
|
||||
# It runs on the development machine; no CI is configured on the forge today, and a future
|
||||
# runner calls these same stages (docs/development/RUST.md §4). Stops at the first failure.
|
||||
# Needs the native Rust toolchain (RUST.md §1) and Docker for the image stages. The local
|
||||
# Supabase stack is not required: the SQL suite runs on PGlite inside `pnpm test:run`, and
|
||||
# `pnpm db:test` is the real-stack complement after a change under supabase/.
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
stage() {
|
||||
printf '\n== %s (%s)\n' "$1" "$(date +%H:%M:%S)"
|
||||
}
|
||||
|
||||
stage "rust: fmt, clippy, tests, ts-rs export, cargo-deny (native toolchain)"
|
||||
bash scripts/rust-check.sh
|
||||
stage "rust: committed TypeScript types match the Rust contracts"
|
||||
git diff --exit-code -- packages/core-wasm/types
|
||||
stage "wasm: browser module (the core-wasm proofs run on it in the Node pipeline)"
|
||||
bash scripts/wasm-build.sh
|
||||
stage "node: typecheck, tests, lint, build"
|
||||
pnpm check
|
||||
stage "docker: application image"
|
||||
docker build -t faunosteo:check .
|
||||
stage "docker: worker sandbox tests and seccomp derivation on the musl binary that ships"
|
||||
pnpm worker:test
|
||||
stage "docker: worker runtime image starts read-only"
|
||||
pnpm worker:image
|
||||
docker run --rm --read-only --cap-drop ALL --security-opt no-new-privileges:true \
|
||||
faunosteo_worker:dev run --check
|
||||
stage "all checks passed"
|
||||
Executable
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
# The Rust quality gate, one file for every environment: `pnpm rust:check` runs it on the
|
||||
# native toolchain of the development machine (rustup selects the channel pinned by
|
||||
# rust-toolchain.toml); `pnpm rust:check:docker` runs the same file inside the reference
|
||||
# builder image (docker/rust-builder.Dockerfile) when a reproducible run is wanted.
|
||||
# The worker's sandbox tests are feature-gated (`test-hooks`) and run only in its own
|
||||
# Alpine/musl image (crates/worker/Dockerfile stage `test`, `pnpm worker:test`): the seccomp
|
||||
# allowlist is derived for the musl static binary that ships. The plain `cargo test` below
|
||||
# therefore covers the worker's unit tests and the whole of core and wasm.
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
. scripts/rust-env.sh
|
||||
|
||||
cargo fmt --all --check
|
||||
cargo clippy --workspace --all-targets --locked -- -D warnings
|
||||
cargo test --workspace --locked
|
||||
# Exports the TypeScript types of the contracts (ts-rs) into packages/core-wasm/types.
|
||||
# `git diff --exit-code -- packages/core-wasm/types` must stay empty afterwards
|
||||
# (scripts/check-all.sh, .gitea/workflows/ci.yml): the committed types never drift from
|
||||
# the Rust structs.
|
||||
cargo test -p faunosteo-core --features ts --locked
|
||||
cargo deny check licenses bans sources
|
||||
@@ -0,0 +1,10 @@
|
||||
# Sourced by the Rust scripts (never executed): puts the user-level rustup toolchain on
|
||||
# PATH when the calling shell did not. Non-interactive shells skip ~/.bashrc, so editor
|
||||
# tasks, git hooks and agent shells start without ~/.cargo/bin. rustup then selects the
|
||||
# channel pinned by rust-toolchain.toml. Nothing here installs anything.
|
||||
cargo_bin="${CARGO_HOME:-$HOME/.cargo}/bin"
|
||||
if ! command -v cargo >/dev/null 2>&1 && [ -x "$cargo_bin/cargo" ]; then
|
||||
PATH="$cargo_bin:$PATH"
|
||||
export PATH
|
||||
fi
|
||||
unset cargo_bin
|
||||
@@ -1,16 +1,23 @@
|
||||
#!/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`.
|
||||
# `pnpm wasm:build` runs it on the native toolchain (wasm32-unknown-unknown target and the
|
||||
# wasm-bindgen CLI installed by rustup / cargo install, docs/development/RUST.md §1);
|
||||
# `pnpm wasm:build:docker` runs the same file inside the reference builder image.
|
||||
# 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")/.."
|
||||
. scripts/rust-env.sh
|
||||
|
||||
lock_version="$(awk '/^name = "wasm-bindgen"$/ { getline; sub(/^version = "/, ""); sub(/"$/, ""); print; exit }' Cargo.lock)"
|
||||
if ! command -v wasm-bindgen >/dev/null 2>&1; then
|
||||
echo "wasm-bindgen CLI not found on PATH: cargo install wasm-bindgen-cli --version ${lock_version} --locked" >&2
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
echo "wasm-bindgen crate ${lock_version} (Cargo.lock) != wasm-bindgen-cli ${cli_version} on PATH: cargo install wasm-bindgen-cli --version ${lock_version} --locked" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in new issue
Block a user