#!/bin/bash set -e # CONTRACT: docs/BUDGETS.md # DO NOT CHANGE THESE VALUES WITHOUT UPDATING THE CONTRACT FIRST. MAX_BUILD_SECONDS=120 REPO_ROOT=$(git rev-parse --show-toplevel) WEB_DIR="$REPO_ROOT/apps/web" echo "📍 Frontend Build Performance Check" echo "📜 Contract: docs/BUDGETS.md" echo "⏱️ Budget: ${MAX_BUILD_SECONDS}s" cd "$WEB_DIR" START_TIME=$(date +%s) # Run build independently of the other build test to measure PURE time # In a real CI, we might skip if artifact exists, but here we enforce speed of build npm run build > /dev/null 2>&1 END_TIME=$(date +%s) DURATION=$((END_TIME - START_TIME)) echo "📊 Build took: ${DURATION}s" if [ "$DURATION" -gt "$MAX_BUILD_SECONDS" ]; then echo "❌ FATAL: Build deemed TOO SLOW for a vital component." echo " Limit: ${MAX_BUILD_SECONDS}s" echo " Actual: ${DURATION}s" echo " See docs/FRUGALITY.md for policy." exit 1 fi echo "✅ Build speed within limits."