#!/usr/bin/env bash # §12 收尾验证车道(2026-10-17) # # 为什么写成脚本而不是逐条手敲:本仓反复栽在「取退出码的写法把闸吞掉」—— # `cmd | tail` 拿的是 tail 的状态,`A && B; echo $?` 会把 A 的红丢掉。 # 这里每条命令都单独重定向到文件、紧跟 `echo $?` 记进汇总,汇总就是证据。 # # 用法: # nohup bash docs/acceptance/2026-10-17-final/run-lane.sh > /tmp/12-lane.out 2>&1 & # tail -f /tmp/12-lane-summary.txt # # 前提:先 `npm run build`(本脚本不代跑 build;E2E_TARGET=production 打的是 # dist/standalone/server.js,postbuild 须已装配 dist/static + public)。 # 端口:车道内所有步骤串行,避免与残留 server 抢 3000(本仓有「静默复用旧服务」的历史坑)。 set -u cd "$(git rev-parse --show-toplevel)" || exit 1 LOGDIR=/tmp/12-lane mkdir -p "$LOGDIR" SUM=/tmp/12-lane-summary.txt : > "$SUM" step() { local name="$1"; shift local log="$LOGDIR/$name.log" echo ">>> $name" | tee -a "$SUM" "$@" > "$log" 2>&1 local code=$? echo " $name EXIT=$code (log: $log)" | tee -a "$SUM" } # 装配自检:产物缺 dist/static 时,axe 会 bgMismatch 报红而 Lighthouse 仍错误 exit 0(§5.34) if [ -d dist/standalone/dist/static ] && [ -d dist/standalone/public ]; then echo " assembly OK (dist/static + public present)" | tee -a "$SUM" else echo " assembly MISSING -> 先 npm run build" | tee -a "$SUM" exit 2 fi step type-check npm run type-check step lint npm run lint step coverage npm run test:coverage step integration-real npm run test:integration:real step a11y npm run check:a11y step visual-grammar npm run check:visual step accents npm run check:accents step dead npm run check:dead step motion npm run check:motion # GA4 那 16 例只在 production 目标下真断言:dev 下 GoogleAnalytics.tsx 提前 return null, # 用例内 test.skip 触发 ⇒ 记为 skipped 而不是 passed(§5 表格的口径)。 step ga4-prod bash -c 'cd e2e && E2E_TARGET=production npx playwright test ga4-event-tracking.spec.ts --project=chromium --project=chromium-mobile --project=firefox --project=webkit' step e2e-fast npm run test:e2e:fast step security-headers npm run test:security:headers step axe-routes npm run check:axe:routes step axe npm run check:axe step lighthouse npm run lighthouse # 视觉只读比对(不写基线)。AUTH-VISUAL 的写入是单独动作,不在本车道内。 step visual-readonly bash -c 'cd e2e && npx playwright test visual-regression.spec.ts --update-snapshots=none' echo "=== DONE ===" | tee -a "$SUM" grep -c 'EXIT=0' "$SUM" | sed 's/^/green_steps=/' | tee -a "$SUM" grep -c 'EXIT=[1-9]' "$SUM" | sed 's/^/nonzero_steps=/' | tee -a "$SUM"