Skip to content

armgit / mso

Public Imported from GitHub
0

Browser-based graphical shell and control plane for a Linux server you own — real terminal, file manager, live metrics and BYOK AI in one mobile-first workspace. Next.js 16 · React 19 · node-pty · Tailwind v4 · shadcn/ui. Public alpha, self-hosted.

4.7 KB
Raw Blame
#!/usr/bin/env bash
# verify-build.sh — prove HEAD actually compiles and passes mandatory release E2E,
# WITHOUT touching the .next that the live :4005 service is serving from.
#
# Why not simply run `next build` here, and why the pre-push hook keeps `--skip build`:
# the build's FIRST act is to delete everything in distDir except /^(cache|dev|lock)/
# (node_modules/next/dist/build/index.js, the 'clean' trace step). For ~30 s there is no
# .next/static, no .next/server, no BUILD_ID — and since two builds of byte-identical
# source emit different chunk filenames and a fresh BUILD_ID, every page already served
# keeps pointing at names that no longer exist even after it finishes. An in-place build
# in this directory is therefore an outage, not a check. docs/DEVELOPMENT.md says the
# same thing in prose; this script is the way to get the check without the outage.
#
# node_modules is COPIED, never symlinked. Turbopack hard-fails on a symlinked
# node_modules with "Symlink [project]/node_modules is invalid, it points out of the
# filesystem root". The copy costs ~7 s and the build writes nothing back into it.
#
# .env.local is deliberately NOT copied — the build succeeds without it, so no secret
# ever lands in a world-traversable /tmp path.
#
# Scope: this gates HEAD (the last commit), not the working tree, and always HEAD rather
# than the specific ref git hands the hook on stdin. That matches the commit-then-push
# flow this repo uses; pushing a non-HEAD ref would be gated against the wrong tree.
set -euo pipefail

REPO="$(git rev-parse --show-toplevel)"
TMP="$(mktemp -d)"   # 0700
trap 'rm -rf "$TMP"' EXIT

git -C "$REPO" archive HEAD | tar -x -C "$TMP"
# Copy the contents, resolving a worktree's top-level dependency symlink only.
mkdir "$TMP/node_modules"
cp -a "$REPO/node_modules/." "$TMP/node_modules/"

cd "$TMP"
MSO_VERIFY_BUILD_LOG="$TMP/build-output.log"

echo "== verify 1/3: isolated Next build"
# nice/ionice: this box also serves prod. A build gate must not starve :4005.
# A reviewed synthetic viewer origin is needed by iframe journeys. Never inherit
# an installation's public hostname into verification artifacts.
export NEXT_PUBLIC_MANAGED_APP_HOST_TEMPLATE='{id}.mso.example.com'
if ! nice -n 15 ionice -c2 -n7 node node_modules/.bin/next build 2>&1 | tee "$MSO_VERIFY_BUILD_LOG"; then
  echo "verification failed during isolated compile/build" >&2
  exit 40
fi
if grep -Ei "(^|[[:space:]])warnings?[: ]|⚠" "$MSO_VERIFY_BUILD_LOG"; then
  echo "verification failed: build warnings are a release failure; resolve their source before shipping" >&2
  exit 41
fi

echo "== verify: eager shell bundle budget"
# The build described this exact archive, so the stale-build guard must not fire here.
MSO_BUNDLE_BUILD_IS_CURRENT=1 node scripts/check-bundle.mjs

echo "== verify 2/3: Playwright Chromium runtime"
if ! node scripts/ensure-playwright-browser.mjs; then
  echo "verification failed while preparing the browser required by release E2E" >&2
  exit 42
fi

echo "== verify 3/3: mandatory release E2E"
# Reuse this exact built tree for mandatory browser journeys; synthetic stores only.
if ! node scripts/e2e/release.mjs; then
  echo "verification failed during mandatory release E2E" >&2
  exit 43
fi

echo "== verify native Integrations shell journey"
if ! node scripts/e2e/integrations-shell.mjs; then
  echo "verification failed during native Integrations shell E2E" >&2
  exit 43
fi

echo "== verify Integrations credential actions (synthetic accounts)"
if ! node scripts/e2e/integrations.mjs; then
  echo "verification failed during Integrations credential actions E2E" >&2
  exit 43
fi

echo "== verify native Google Integrations UI (synthetic accounts)"
if ! node scripts/e2e/google-integrations.mjs; then
  echo "verification failed during native Google Integrations UI E2E" >&2
  exit 43
fi

echo "== verify shell-native server status"
if ! node scripts/e2e/shell-status.mjs; then
  echo "verification failed during shell-native server status E2E" >&2
  exit 43
fi

echo "== verify Assistant chat UX (synthetic tools and provider)"
if ! node scripts/e2e/assistant-chat-ux.mjs; then
  echo "verification failed during Assistant chat UX E2E" >&2
  exit 43
fi

echo "== verify deferred shell performance"
if ! node scripts/e2e/bundle-performance.mjs; then
  echo "verification failed during deferred shell performance E2E" >&2
  exit 43
fi

echo "== verify reviewed macOS chrome"
node scripts/e2e/macos-figma.mjs

echo "== verify privacy-safe iOS lock"
node scripts/e2e/ios-lock.mjs

# Optional deeper media/native acceptance, using the same isolated built tree.
if [ "${1:-}" = "--extended" ]; then
  echo "== verify extended: desktop native acceptance"
  node scripts/e2e/desktop-native.mjs
  echo "== verify extended: preview acceptance"
  node scripts/e2e/preview.mjs
fi