文件
hyb-oa/scripts/qa/run-release-gate.sh
T

128 行
3.3 KiB
Bash
可执行文件
原始文件 Blame 文件历史

此文件含有模棱两可的 Unicode 字符
此文件含有可能会与其他字符混淆的 Unicode 字符。 如果您是想特意这样的,可以安全地忽略该警告。 使用 Escape 按钮显示他们。
#!/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|r66-trialrun|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
r66-trialrun R66 小团队试点门禁:static -> server regression-all -> smoke-local
可选环境变量:
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_server_regression_all() {
(
cd "$ROOT_DIR/server"
./scripts/regression-all.sh
)
}
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
;;
r66-trialrun)
run_stage static stage_static
run_stage server-regression-all stage_server_regression_all
run_stage smoke-local stage_smoke_local
;;
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}"