93 行
3.4 KiB
Bash
可执行文件
93 行
3.4 KiB
Bash
可执行文件
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
CLIENT_DIR="$ROOT_DIR/client"
|
|
PUBLIC_BASE_URL="${LIVE_SMOKE_BASE_URL:-https://oa.hyinda.com}"
|
|
REPORT_DIR="${LIVE_SMOKE_READINESS_DIR:-$ROOT_DIR/artifacts/qa-flow/live-smoke-readiness-$(date +%Y%m%d-%H%M%S)}"
|
|
|
|
mkdir -p "$REPORT_DIR"
|
|
|
|
write_summary() {
|
|
local exit_code="$?"
|
|
local status="PASS"
|
|
if [[ "$exit_code" -ne 0 ]]; then
|
|
status="FAIL"
|
|
fi
|
|
QA_REPORT_DIR="$REPORT_DIR" \
|
|
QA_ISSUE_ID="${QA_ISSUE_ID:-}" \
|
|
QA_BASE_URL="$PUBLIC_BASE_URL" \
|
|
QA_MODE="live-smoke-readiness" \
|
|
QA_STATUS="$status" \
|
|
QA_SUMMARY_NOTES="公网 /ready、public bundle、pending OCR、live smoke 和真实 OCR 可用性检查;缺少凭据或样票时按脚本规则记录 SKIP。" \
|
|
node "$ROOT_DIR/scripts/qa/write-qa-summary.mjs" >/dev/null 2>&1 || true
|
|
return "$exit_code"
|
|
}
|
|
|
|
trap write_summary EXIT
|
|
|
|
has_live_smoke_credentials() {
|
|
[[ -n "${LIVE_SMOKE_ADMIN_IDENTIFIER:-}" ]] &&
|
|
[[ -n "${LIVE_SMOKE_ADMIN_PASSWORD:-}" ]] &&
|
|
[[ -n "${LIVE_SMOKE_EMPLOYEE_IDENTIFIER:-}" ]] &&
|
|
[[ -n "${LIVE_SMOKE_EMPLOYEE_PASSWORD:-}" ]]
|
|
}
|
|
|
|
has_live_ocr_credentials() {
|
|
if [[ -n "${PLAYWRIGHT_OCR_LIVE_IDENTIFIER:-}" && -n "${PLAYWRIGHT_OCR_LIVE_PASSWORD:-}" ]]; then
|
|
return 0
|
|
fi
|
|
[[ -n "${LIVE_SMOKE_EMPLOYEE_IDENTIFIER:-}" ]] && [[ -n "${LIVE_SMOKE_EMPLOYEE_PASSWORD:-}" ]]
|
|
}
|
|
|
|
has_live_ocr_sample() {
|
|
if [[ -n "${PLAYWRIGHT_OCR_LIVE_FILE:-}" && -f "$PLAYWRIGHT_OCR_LIVE_FILE" ]]; then
|
|
return 0
|
|
fi
|
|
if [[ -n "${LIVE_OCR_INVOICE_FILE:-}" && -f "$LIVE_OCR_INVOICE_FILE" ]]; then
|
|
export PLAYWRIGHT_OCR_LIVE_FILE="$LIVE_OCR_INVOICE_FILE"
|
|
return 0
|
|
fi
|
|
if [[ -n "${PLAYWRIGHT_OCR_LIVE_DIR:-}" && -d "$PLAYWRIGHT_OCR_LIVE_DIR" ]]; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
echo ">>> [live-readiness] 环境与公网入口检查"
|
|
node "$ROOT_DIR/scripts/qa/check-live-smoke-env.mjs" --json > "$REPORT_DIR/env.json"
|
|
node "$ROOT_DIR/scripts/qa/check-live-smoke-env.mjs"
|
|
|
|
echo ">>> [live-readiness] /ready: $PUBLIC_BASE_URL"
|
|
curl -fsS "$PUBLIC_BASE_URL/ready" >/dev/null
|
|
|
|
echo ">>> [live-readiness] 公网资源文案扫描"
|
|
node "$ROOT_DIR/scripts/qa/check-public-bundle-copy.mjs" "$PUBLIC_BASE_URL" | tee "$REPORT_DIR/public-bundle-copy.txt"
|
|
|
|
echo ">>> [live-readiness] pending OCR 扫描"
|
|
node "$ROOT_DIR/scripts/qa/check-pending-ocr.mjs" --thresholds=2,5,10 | tee "$REPORT_DIR/pending-ocr.txt"
|
|
|
|
if has_live_smoke_credentials; then
|
|
echo ">>> [live-readiness] 执行公网 live smoke"
|
|
LIVE_SMOKE_BASE_URL="$PUBLIC_BASE_URL" bash "$ROOT_DIR/scripts/qa/run-web-gates.sh" smoke-live | tee "$REPORT_DIR/live-smoke.txt"
|
|
else
|
|
echo ">>> [live-readiness] SKIP live smoke:缺少完整 LIVE_SMOKE_* 凭据" | tee "$REPORT_DIR/live-smoke.txt"
|
|
fi
|
|
|
|
if has_live_ocr_credentials && has_live_ocr_sample; then
|
|
echo ">>> [live-readiness] 执行真实 OCR 样本复核"
|
|
(
|
|
cd "$CLIENT_DIR"
|
|
PLAYWRIGHT_MANUAL=1 \
|
|
PLAYWRIGHT_OCR_LIVE=1 \
|
|
PLAYWRIGHT_OCR_ALLOW_DUPLICATE="${PLAYWRIGHT_OCR_ALLOW_DUPLICATE:-1}" \
|
|
E2E_BASE_URL="$PUBLIC_BASE_URL" \
|
|
npx playwright test tests/e2e/manual/live-invoice-ocr.spec.ts --workers=1 --reporter=list
|
|
) | tee "$REPORT_DIR/live-ocr.txt"
|
|
else
|
|
echo ">>> [live-readiness] SKIP 真实 OCR:缺少 smoke 员工凭据或 PLAYWRIGHT_OCR_LIVE_FILE/PLAYWRIGHT_OCR_LIVE_DIR" | tee "$REPORT_DIR/live-ocr.txt"
|
|
fi
|
|
|
|
echo "[live-readiness][PASS] readiness 检查完成"
|
|
echo "[live-readiness] report=$REPORT_DIR"
|