R30-1 R30-9: 建立零人工发布门禁并补齐高频回归
这个提交包含在:
+114
@@ -0,0 +1,114 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
||||
ARTIFACT_ROOT="${RELEASE_GATE_ARTIFACT_DIR:-${ROOT_DIR}/artifacts/release-gate/$(date +%Y%m%d-%H%M%S)}"
|
||||
MODE="${1:-all}"
|
||||
CURRENT_STAGE=""
|
||||
|
||||
mkdir -p "$ARTIFACT_ROOT"
|
||||
|
||||
usage() {
|
||||
cat <<USAGE
|
||||
Usage: bash scripts/qa/run-release-gate.sh <all|static|smoke-local|full-local|deploy|ci-release|help>
|
||||
|
||||
说明:
|
||||
static 运行部署契约、server Prisma 校验、client typecheck/build
|
||||
smoke-local 运行本地网页 smoke 门禁
|
||||
full-local 运行本地全量门禁(server regression + client full E2E)
|
||||
deploy 调用 deploy/trialrun/deploy.sh,内部会串联 /ready、external deps、runtime smoke 与 live smoke
|
||||
all 依次执行 static -> smoke-local -> full-local -> deploy
|
||||
ci-release 依次执行 static -> full-local -> deploy
|
||||
|
||||
可选环境变量:
|
||||
RELEASE_GATE_ARTIFACT_DIR 失败产物输出目录
|
||||
QA_* 透传给 scripts/qa/run-web-gates.sh
|
||||
LIVE_SMOKE_* 透传给 deploy.sh 与 live smoke
|
||||
DEPLOY_SERVER / REMOTE_DIR / REMOTE_ENV_FILE / SYNC_ENV
|
||||
USAGE
|
||||
}
|
||||
|
||||
collect_failure_artifacts() {
|
||||
local stage_name="${CURRENT_STAGE:-unknown}"
|
||||
local target_dir="${ARTIFACT_ROOT}/${stage_name}"
|
||||
mkdir -p "$target_dir"
|
||||
bash "$ROOT_DIR/scripts/qa/collect-failure-artifacts.sh" "$target_dir" >/dev/null 2>&1 || true
|
||||
echo "[release-gate] 已收集失败产物:$target_dir" >&2
|
||||
}
|
||||
|
||||
handle_error() {
|
||||
local exit_code="$?"
|
||||
echo "[release-gate][FAIL] 阶段 ${CURRENT_STAGE:-unknown} 失败(exit=${exit_code})" >&2
|
||||
collect_failure_artifacts
|
||||
exit "$exit_code"
|
||||
}
|
||||
trap handle_error ERR
|
||||
|
||||
run_stage() {
|
||||
local stage_name="$1"
|
||||
shift
|
||||
CURRENT_STAGE="$stage_name"
|
||||
echo ">>> [release-gate] ${stage_name}"
|
||||
"$@"
|
||||
}
|
||||
|
||||
stage_static() {
|
||||
node "$ROOT_DIR/deploy/trialrun/validate-env-contract.js"
|
||||
(
|
||||
cd "$ROOT_DIR/server"
|
||||
npm run prisma:validate
|
||||
)
|
||||
(
|
||||
cd "$ROOT_DIR/client"
|
||||
npm run typecheck
|
||||
npm run build
|
||||
)
|
||||
}
|
||||
|
||||
stage_smoke_local() {
|
||||
bash "$ROOT_DIR/scripts/qa/run-web-gates.sh" smoke-local
|
||||
}
|
||||
|
||||
stage_full_local() {
|
||||
bash "$ROOT_DIR/scripts/qa/run-web-gates.sh" full-local
|
||||
}
|
||||
|
||||
stage_deploy() {
|
||||
bash "$ROOT_DIR/deploy/trialrun/deploy.sh"
|
||||
}
|
||||
|
||||
case "$MODE" in
|
||||
help|-h|--help)
|
||||
usage
|
||||
;;
|
||||
static)
|
||||
run_stage static stage_static
|
||||
;;
|
||||
smoke-local)
|
||||
run_stage smoke-local stage_smoke_local
|
||||
;;
|
||||
full-local)
|
||||
run_stage full-local stage_full_local
|
||||
;;
|
||||
deploy)
|
||||
run_stage deploy stage_deploy
|
||||
;;
|
||||
ci-release)
|
||||
run_stage static stage_static
|
||||
run_stage full-local stage_full_local
|
||||
run_stage deploy stage_deploy
|
||||
;;
|
||||
all)
|
||||
run_stage static stage_static
|
||||
run_stage smoke-local stage_smoke_local
|
||||
run_stage full-local stage_full_local
|
||||
run_stage deploy stage_deploy
|
||||
;;
|
||||
*)
|
||||
usage >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "[release-gate][PASS] 模式 ${MODE} 通过"
|
||||
echo "[release-gate] 产物目录:${ARTIFACT_ROOT}"
|
||||
在新工单中引用
屏蔽一个用户