script/test: fail-fast ordering — cheapest deterministic checks first
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) <noreply@anthropic.com>
This commit is contained in:
+19
-14
@@ -11,14 +11,16 @@ export GIT_CONFIG_VALUE_0=master
|
|||||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||||
|
|
||||||
echo "=== Building frontend ==="
|
# Ordered fail-fast: cheapest deterministic checks first, slowest builds and
|
||||||
if [ -d "$PROJECT_ROOT/frontend" ]; then
|
# test suites last. `set -euo pipefail` aborts at the first failure, so a fmt
|
||||||
cd "$PROJECT_ROOT/frontend"
|
# or clippy drift never wastes time on a frontend build or a multi-minute
|
||||||
npm install
|
# test run.
|
||||||
npm run build
|
|
||||||
cd "$PROJECT_ROOT"
|
echo "=== Checking Rust formatting ==="
|
||||||
|
if cargo fmt --version &>/dev/null; then
|
||||||
|
cargo fmt --manifest-path "$PROJECT_ROOT/Cargo.toml" --all --check
|
||||||
else
|
else
|
||||||
echo "Skipping frontend build (no frontend directory)"
|
echo "Skipping Rust formatting check (rustfmt not installed)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "=== Checking for duplicate module files (X.rs and X/mod.rs coexisting) ==="
|
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
|
exit 1
|
||||||
fi
|
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 ==="
|
echo "=== Running cargo clippy ==="
|
||||||
cargo clippy --manifest-path "$PROJECT_ROOT/Cargo.toml" --all-targets --all-features -- -D warnings
|
cargo clippy --manifest-path "$PROJECT_ROOT/Cargo.toml" --all-targets --all-features -- -D warnings
|
||||||
|
|
||||||
echo "=== Checking doc coverage on changed files ==="
|
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
|
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 ==="
|
echo "=== Running Rust tests ==="
|
||||||
cargo test --manifest-path "$PROJECT_ROOT/Cargo.toml" --bin huskies
|
cargo test --manifest-path "$PROJECT_ROOT/Cargo.toml" --bin huskies
|
||||||
cargo test --manifest-path "$PROJECT_ROOT/Cargo.toml" -p source-map-gen
|
cargo test --manifest-path "$PROJECT_ROOT/Cargo.toml" -p source-map-gen
|
||||||
|
|||||||
Reference in New Issue
Block a user