From 658e02c9b2621d91ce2cb26da0ac6a6d224e36d1 Mon Sep 17 00:00:00 2001 From: Timmy Date: Wed, 13 May 2026 12:54:37 +0100 Subject: [PATCH] =?UTF-8?q?script/test:=20fail-fast=20ordering=20=E2=80=94?= =?UTF-8?q?=20cheapest=20deterministic=20checks=20first?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reorders the gate so fmt --check, duplicate-module scan, clippy, and doc-coverage run before the frontend build and the multi-minute test suites. set -euo pipefail short-circuits on the first failure, so a fmt or clippy drift now fails in seconds instead of after a 30s frontend build. Co-Authored-By: Claude Opus 4.7 (1M context) --- script/test | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/script/test b/script/test index 26a3446a..30b8e629 100755 --- a/script/test +++ b/script/test @@ -11,14 +11,16 @@ export GIT_CONFIG_VALUE_0=master SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" -echo "=== Building frontend ===" -if [ -d "$PROJECT_ROOT/frontend" ]; then - cd "$PROJECT_ROOT/frontend" - npm install - npm run build - cd "$PROJECT_ROOT" +# 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. + +echo "=== Checking Rust formatting ===" +if cargo fmt --version &>/dev/null; then + cargo fmt --manifest-path "$PROJECT_ROOT/Cargo.toml" --all --check else - echo "Skipping frontend build (no frontend directory)" + echo "Skipping Rust formatting check (rustfmt not installed)" fi echo "=== Checking for duplicate module files (X.rs and X/mod.rs coexisting) ===" @@ -42,19 +44,22 @@ if [ "$_dup_found" -eq 1 ]; then exit 1 fi -echo "=== Checking Rust formatting ===" -if cargo fmt --version &>/dev/null; then - cargo fmt --manifest-path "$PROJECT_ROOT/Cargo.toml" --all --check -else - echo "Skipping Rust formatting check (rustfmt not installed)" -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" + npm install + npm run build + cd "$PROJECT_ROOT" +else + echo "Skipping frontend build (no frontend directory)" +fi + 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