From 49af014a84cd9d29ee1b1c20263d9a123692fbb4 Mon Sep 17 00:00:00 2001 From: Timmy Date: Sun, 17 May 2026 18:40:24 +0100 Subject: [PATCH] fix: build frontend before cargo in script/test (merge gate self-heal) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Story 1113 added `#[derive(RustEmbed)] #[folder = "../frontend/dist"]` plus a unit test that calls `EmbeddedAssets::iter()`. The macro only generates `iter()` when the folder exists at compile time, so the Rust build now has a hard compile-time dependency on `frontend/dist/`. `script/test` ran `cargo clippy` (line 48) before the frontend build (line 53+). In a fresh merge worktree with no `frontend/dist/`, clippy failed immediately on the `iter()` call and the script exited before `npm run build` ever ran — the gate could never self-heal. Blocked 1116's merge today; would block every future merge. Move the frontend build above all cargo invocations. Verified by running script/test in a fresh worktree with `node_modules` and `frontend/dist` removed: 385/385 frontend tests + cargo tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- script/test | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/script/test b/script/test index c8920f03..4df7523c 100755 --- a/script/test +++ b/script/test @@ -11,10 +11,12 @@ export GIT_CONFIG_VALUE_0=master SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" -# Ordered fail-fast: cheapest deterministic checks first, slowest builds and -# test suites last. `set -euo pipefail` aborts at the first failure, so a fmt -# or clippy drift never wastes time on a frontend build or a multi-minute -# test run. +# Ordered fail-fast: cheapest deterministic checks first. The frontend build +# must run *before* anything that compiles Rust, because story 1113 introduced +# a compile-time dependency on `frontend/dist/` via `rust-embed` — a fresh +# merge worktree without that directory will fail `cargo clippy` on +# `EmbeddedAssets::iter()` before the frontend build has a chance to populate +# it. `set -euo pipefail` aborts at the first failure. echo "=== Checking Rust formatting ===" if cargo fmt --version &>/dev/null; then @@ -44,12 +46,6 @@ if [ "$_dup_found" -eq 1 ]; then exit 1 fi -echo "=== Running cargo clippy ===" -cargo clippy --manifest-path "$PROJECT_ROOT/Cargo.toml" --all-targets --all-features -- -D warnings - -echo "=== Checking doc coverage on changed files ===" -cargo run --manifest-path "$PROJECT_ROOT/Cargo.toml" -p source-map-gen --bin source-map-check --quiet -- --worktree "$PROJECT_ROOT" --base master - echo "=== Building frontend ===" if [ -d "$PROJECT_ROOT/frontend" ]; then cd "$PROJECT_ROOT/frontend" @@ -75,6 +71,12 @@ else echo "Skipping frontend build (no frontend directory)" fi +echo "=== Running cargo clippy ===" +cargo clippy --manifest-path "$PROJECT_ROOT/Cargo.toml" --all-targets --all-features -- -D warnings + +echo "=== Checking doc coverage on changed files ===" +cargo run --manifest-path "$PROJECT_ROOT/Cargo.toml" -p source-map-gen --bin source-map-check --quiet -- --worktree "$PROJECT_ROOT" --base master + echo "=== Running Rust tests ===" cargo test --manifest-path "$PROJECT_ROOT/Cargo.toml" --bin huskies cargo test --manifest-path "$PROJECT_ROOT/Cargo.toml" -p source-map-gen