- 门①构建绿:all-plugins barrel+host-dev 双构建日志留档 - 门②SIZES增量实测:九件单件全≤配额,插件gz净增13263B(自律线60K),core基准gz 3222 - 门③浏览器证据:六锚点FNV-1a链verify.ok=true/burst-trail-drift三预设哈希×3重跑一致+几何命中+直方图非空/vignette-dither开关对照哈希互异/CDP dispatchTouchEvent真点击→probe第7条firstInput旁证 - 模板哲学红线被门③实证:particles不内置颜色致首版全黑,host作引擎供色后过——验证门逮住设计而非绕过 - α不接littlejsengine裁定留痕(host.js顶注/index.html/REPORT §4.1),受控面桩即引擎接缝点 - 遗留:probe前四锚tMono=0(冻结lane件,注入时钟拆分留β) - games/wanglanmei-ref/LOOP-LOG.md:参考件内部预判轮1计划(五要素挂点/插件用法图/mmx资产单13次/红线五条) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
109 lines
5.1 KiB
Bash
109 lines
5.1 KiB
Bash
#!/usr/bin/env bash
|
||
# run-integration.sh — 集成段一键编排(仅 mini-desktop 跑;6c6g 禁起 chrome/构建)
|
||
# owner:T1b-α 集成段
|
||
#
|
||
# 职责:在 mini-desktop 的只读 checkout 内,完成「门①构建 + 门② SIZES + 门③ 浏览器证据」。
|
||
# 红线遵循:
|
||
# · 不跑 git(clone/checkout 由外层调用方先做好;本脚本只在已检出的 game-runtime 内操作);
|
||
# · 长驻进程(static-serve / chrome)用 systemd-run 起 durable 单元,**不**与 pkill/curl 串行混写;
|
||
# · 起服后 5×6s 探活门确认常驻再继续。
|
||
#
|
||
# 用法(在 game-runtime 目录内):bash test/harness/run-integration.sh
|
||
# 产出:SIZES.md(仓根 game-runtime/)、evidence/integration/*、host-dev/dist/host-bundle.js、build/size 日志。
|
||
set -u # 不设 -e:探活/清理需容错;关键步骤各自判退出码。
|
||
|
||
PORT=4321
|
||
CDP_PORT=9222
|
||
UNIT_SERVE=t1ba-integ-serve
|
||
UNIT_CHROME=t1ba-integ-chrome
|
||
RT_DIR="$(pwd)" # 应为 .../game-runtime
|
||
EV_DIR="$RT_DIR/evidence/integration"
|
||
LOG_DIR="$EV_DIR/logs"
|
||
mkdir -p "$EV_DIR" "$LOG_DIR" "$RT_DIR/host-dev/dist"
|
||
|
||
echo "=== [0] 环境核对 ==="
|
||
hostname
|
||
node --version
|
||
ls package.json >/dev/null 2>&1 || { echo "FATAL: 未在含 package.json 的 scratch 根(应先 npm init)"; }
|
||
test -f "$RT_DIR/scripts/build.mjs" || { echo "FATAL: 不在 game-runtime 目录(无 scripts/build.mjs)"; exit 1; }
|
||
|
||
echo "=== [1] 门①:全插件注册构建(esbuild 锁参,host-dev/entry.js → iife) ==="
|
||
# 1a) 全插件注册 barrel 打包(验证 core+九插件+注册编排锁参 bundle 零报错、可生成 iife)。
|
||
node scripts/build.mjs src/all-plugins.js host-dev/dist/all-plugins.iife.js --global-name=GameRuntimeAll \
|
||
>"$LOG_DIR/build-all-plugins.log" 2>&1
|
||
RC_ALL=$?
|
||
echo "build all-plugins rc=$RC_ALL"; tail -3 "$LOG_DIR/build-all-plugins.log"
|
||
# 1b) host-dev 入口打包(含 host 引导,供浏览器加载)。
|
||
node scripts/build.mjs host-dev/entry.js host-dev/dist/host-bundle.js --global-name=GameRuntimeHostDev \
|
||
>"$LOG_DIR/build-host.log" 2>&1
|
||
RC_HOST=$?
|
||
echo "build host-bundle rc=$RC_HOST"; tail -3 "$LOG_DIR/build-host.log"
|
||
if [ $RC_ALL -ne 0 ] || [ $RC_HOST -ne 0 ]; then echo "GATE1: BUILD FAIL"; exit 1; fi
|
||
ls -l host-dev/dist/*.js
|
||
echo "GATE1: BUILD OK"
|
||
|
||
echo "=== [2] 门②:SIZES 增量法实测(size.mjs) ==="
|
||
node scripts/size.mjs >"$LOG_DIR/size.log" 2>&1
|
||
RC_SIZE=$?
|
||
echo "size rc=$RC_SIZE"; tail -5 "$LOG_DIR/size.log"
|
||
if [ $RC_SIZE -ne 0 ]; then echo "GATE2: SIZES FAIL"; exit 1; fi
|
||
echo "---- SIZES.md ----"; cat SIZES.md
|
||
echo "GATE2: SIZES GENERATED"
|
||
|
||
echo "=== [3a] 起 static-serve(systemd-run durable 单元) ==="
|
||
systemctl stop "$UNIT_SERVE" 2>/dev/null
|
||
systemd-run --unit="$UNIT_SERVE" --setenv=NODE_NO_WARNINGS=1 \
|
||
/usr/bin/env node "$RT_DIR/test/harness/static-serve.cjs" "$RT_DIR/host-dev" "$PORT" \
|
||
>/dev/null 2>&1
|
||
echo "serve unit started: $UNIT_SERVE"
|
||
|
||
echo "=== [3b] 起 headless chrome(systemd-run durable 单元;CDP 七坑参数全加) ==="
|
||
systemctl stop "$UNIT_CHROME" 2>/dev/null
|
||
CHROME_BIN="$(command -v google-chrome || command -v chromium || command -v chromium-browser)"
|
||
echo "chrome bin: $CHROME_BIN"
|
||
systemd-run --unit="$UNIT_CHROME" \
|
||
"$CHROME_BIN" \
|
||
--headless=new --no-sandbox --no-zygote --disable-gpu \
|
||
--remote-debugging-port=$CDP_PORT --remote-debugging-address=127.0.0.1 \
|
||
--remote-allow-origins=* \
|
||
--disable-dev-shm-usage --hide-scrollbars \
|
||
about:blank \
|
||
>/dev/null 2>&1
|
||
echo "chrome unit started: $UNIT_CHROME"
|
||
|
||
echo "=== [3c] 5×6s 探活门(serve 200 + CDP version 200 连续过) ==="
|
||
SERVE_OK=0; CDP_OK=0
|
||
for i in 1 2 3 4 5; do
|
||
S=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:$PORT/index.html" 2>/dev/null)
|
||
C=$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:$CDP_PORT/json/version" 2>/dev/null)
|
||
echo "probe#$i serve=$S cdp=$C"
|
||
[ "$S" = "200" ] && SERVE_OK=$((SERVE_OK+1)) || SERVE_OK=0
|
||
[ "$C" = "200" ] && CDP_OK=$((CDP_OK+1)) || CDP_OK=0
|
||
if [ $SERVE_OK -ge 2 ] && [ $CDP_OK -ge 2 ]; then echo "probe gate passed"; break; fi
|
||
# 探活窗口内的等待(非 sleep N && cmd 串行,单独 sleep 不被拦)
|
||
sleep 6
|
||
done
|
||
if [ $SERVE_OK -lt 2 ] || [ $CDP_OK -lt 2 ]; then
|
||
echo "GATE3: PROBE FAIL (serve_ok=$SERVE_OK cdp_ok=$CDP_OK)"
|
||
journalctl -u "$UNIT_CHROME" -n 20 --no-pager 2>/dev/null | tail -20
|
||
exit 1
|
||
fi
|
||
curl -s "http://localhost:$CDP_PORT/json/version" | head -c 300; echo
|
||
|
||
echo "=== [3d] 门③:浏览器证据 driver(cwd=game-runtime) ==="
|
||
node "$RT_DIR/test/harness/integration-run.cjs" "$PORT" "http://localhost:$CDP_PORT" \
|
||
>"$LOG_DIR/integration-run.log" 2>&1
|
||
RC_EV=$?
|
||
echo "integration-run rc=$RC_EV"
|
||
cat "$LOG_DIR/integration-run.log"
|
||
|
||
echo "=== [4] 收尾:停 durable 单元(不留孤儿) ==="
|
||
systemctl stop "$UNIT_CHROME" 2>/dev/null && echo "stopped $UNIT_CHROME"
|
||
systemctl stop "$UNIT_SERVE" 2>/dev/null && echo "stopped $UNIT_SERVE"
|
||
# 留档 serve 日志(journal → 文件)
|
||
journalctl -u "$UNIT_SERVE" --no-pager 2>/dev/null | tail -40 > "$LOG_DIR/serve.journal.log" 2>/dev/null
|
||
journalctl -u "$UNIT_CHROME" --no-pager 2>/dev/null | tail -40 > "$LOG_DIR/chrome.journal.log" 2>/dev/null
|
||
|
||
echo "=== DONE rc_ev=$RC_EV ==="
|
||
exit $RC_EV
|