Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript
1.5 KB
Raw Blame
#!/usr/bin/env bash
# CI gate: admin React app must compile.
#
# Catches missing-symbol bugs (e.g., calling loadApiKeys() when only
# loadAgents is defined) before they reach E2E. Codex flagged this gap
# during the PR #586 review pass — five Claude review passes missed
# the loadApiKeys reference because the bash test pipeline doesn't run
# Vite builds. This script runs `bun install` in admin/ to ensure
# react/vite/etc. are present, then runs Vite's build which performs
# TypeScript type-check + bundle.
#
# Skip with GBRAIN_SKIP_ADMIN_BUILD=1 (e.g., for fast inner-loop test
# runs that don't touch admin/src). Production CI must NOT skip.
set -euo pipefail

if [ "${GBRAIN_SKIP_ADMIN_BUILD:-0}" = "1" ]; then
  echo "[check:admin-build] GBRAIN_SKIP_ADMIN_BUILD=1, skipping"
  echo "GBRAIN_CHECK_SKIPPED: GBRAIN_SKIP_ADMIN_BUILD=1"
  exit 0
fi

cd "$(dirname "$0")/.."

if [ ! -d admin ]; then
  echo "[check:admin-build] no admin/ directory, skipping"
  echo "GBRAIN_CHECK_SKIPPED: no admin/ directory"
  exit 0
fi

cd admin

# Idempotent install — bun is fast enough on no-op (~50ms).
bun install --silent >/dev/null 2>&1 || bun install

# Build runs `vite build` into a throwaway directory. Exit non-zero on TS
# error, missing symbol, or Vite bundling error. Never into the committed
# admin/dist/: vite empties its outDir first, so a parallel verify check that
# reads tracked files (check:privacy) would find them missing mid-build.
out=$(mktemp -d "${TMPDIR:-/tmp}/gbrain-admin-build.XXXXXX")
trap 'rm -rf "$out"' EXIT
bun run build --outDir "$out" --emptyOutDir