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