feat: 完成P13治理收尾并创建P14执行合同(Issue: P13-1,P13-2,P13-3,P13-4,P13-5,P13-6,P13-7,P13-8,P14-0)
这个提交包含在:
@@ -0,0 +1,175 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
RR_ENABLED=0
|
||||
RR_OUTPUT_PATH=""
|
||||
RR_TMP_DIR=""
|
||||
RR_STEPS_TSV=""
|
||||
RR_ROOT_DIR=""
|
||||
RR_SCHEMA_VERSION="1.0"
|
||||
|
||||
rr_now_iso() {
|
||||
date -u +"%Y-%m-%dT%H:%M:%SZ"
|
||||
}
|
||||
|
||||
rr_now_ms() {
|
||||
if date +%s%3N >/dev/null 2>&1; then
|
||||
date +%s%3N
|
||||
else
|
||||
echo "$(( $(date +%s) * 1000 ))"
|
||||
fi
|
||||
}
|
||||
|
||||
rr_sanitize() {
|
||||
local value="${1//$'\t'/ }"
|
||||
value="${value//$'\n'/ }"
|
||||
printf '%s' "$value"
|
||||
}
|
||||
|
||||
rr_prepare() {
|
||||
local output_path="$1"
|
||||
local root_dir="$2"
|
||||
|
||||
RR_ENABLED=1
|
||||
RR_OUTPUT_PATH="$output_path"
|
||||
RR_ROOT_DIR="$root_dir"
|
||||
RR_TMP_DIR="$(mktemp -d)"
|
||||
RR_STEPS_TSV="$RR_TMP_DIR/steps.tsv"
|
||||
: > "$RR_STEPS_TSV"
|
||||
}
|
||||
|
||||
rr_record_step() {
|
||||
if [[ "$RR_ENABLED" != "1" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local step_id="$1"
|
||||
local name="$2"
|
||||
local enabled="$3"
|
||||
local command="$4"
|
||||
local status="$5"
|
||||
local exit_code="$6"
|
||||
local started_at="$7"
|
||||
local ended_at="$8"
|
||||
local duration_ms="$9"
|
||||
|
||||
printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n' \
|
||||
"$(rr_sanitize "$step_id")" \
|
||||
"$(rr_sanitize "$name")" \
|
||||
"$(rr_sanitize "$enabled")" \
|
||||
"$(rr_sanitize "$command")" \
|
||||
"$(rr_sanitize "$status")" \
|
||||
"$(rr_sanitize "$exit_code")" \
|
||||
"$(rr_sanitize "$started_at")" \
|
||||
"$(rr_sanitize "$ended_at")" \
|
||||
"$(rr_sanitize "$duration_ms")" \
|
||||
>> "$RR_STEPS_TSV"
|
||||
}
|
||||
|
||||
rr_git_sha() {
|
||||
if command -v git >/dev/null 2>&1 && git -C "$RR_ROOT_DIR" rev-parse --short HEAD >/dev/null 2>&1; then
|
||||
git -C "$RR_ROOT_DIR" rev-parse --short HEAD
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
rr_git_branch() {
|
||||
if command -v git >/dev/null 2>&1 && git -C "$RR_ROOT_DIR" rev-parse --abbrev-ref HEAD >/dev/null 2>&1; then
|
||||
git -C "$RR_ROOT_DIR" rev-parse --abbrev-ref HEAD
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
rr_finalize() {
|
||||
if [[ "$RR_ENABLED" != "1" ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
local overall_status="$1"
|
||||
local overall_duration_ms="$2"
|
||||
local passed="$3"
|
||||
local failed="$4"
|
||||
local skipped="$5"
|
||||
local total="$6"
|
||||
|
||||
local output_dir
|
||||
output_dir="$(dirname "$RR_OUTPUT_PATH")"
|
||||
mkdir -p "$output_dir"
|
||||
|
||||
local git_sha
|
||||
local git_branch
|
||||
local generated_at
|
||||
|
||||
git_sha="$(rr_git_sha)"
|
||||
git_branch="$(rr_git_branch)"
|
||||
generated_at="$(rr_now_iso)"
|
||||
|
||||
python3 - "$RR_STEPS_TSV" "$RR_OUTPUT_PATH" "$RR_SCHEMA_VERSION" "$generated_at" "$git_sha" "$git_branch" "$overall_status" "$overall_duration_ms" "$passed" "$failed" "$skipped" "$total" <<'PY'
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
steps_path = Path(sys.argv[1])
|
||||
output_path = Path(sys.argv[2])
|
||||
schema_version = sys.argv[3]
|
||||
generated_at = sys.argv[4]
|
||||
git_sha = sys.argv[5]
|
||||
git_branch = sys.argv[6]
|
||||
overall_status = sys.argv[7]
|
||||
overall_duration_ms = int(sys.argv[8])
|
||||
passed = int(sys.argv[9])
|
||||
failed = int(sys.argv[10])
|
||||
skipped = int(sys.argv[11])
|
||||
total = int(sys.argv[12])
|
||||
|
||||
steps = []
|
||||
if steps_path.exists():
|
||||
for line in steps_path.read_text(encoding="utf-8").splitlines():
|
||||
if not line.strip():
|
||||
continue
|
||||
parts = line.split("\t")
|
||||
if len(parts) != 9:
|
||||
continue
|
||||
step_id, name, enabled, command, status, exit_code, started_at, ended_at, duration_ms = parts
|
||||
steps.append(
|
||||
{
|
||||
"id": step_id,
|
||||
"name": name,
|
||||
"enabled": enabled == "1",
|
||||
"status": status,
|
||||
"exit_code": int(exit_code),
|
||||
"duration_ms": int(duration_ms),
|
||||
"started_at": started_at,
|
||||
"ended_at": ended_at,
|
||||
"command": command,
|
||||
}
|
||||
)
|
||||
|
||||
payload = {
|
||||
"schema_version": schema_version,
|
||||
"generated_at": generated_at,
|
||||
"git": {
|
||||
"sha": git_sha,
|
||||
"branch": git_branch,
|
||||
},
|
||||
"overall": {
|
||||
"status": overall_status,
|
||||
"duration_ms": overall_duration_ms,
|
||||
"passed": passed,
|
||||
"failed": failed,
|
||||
"skipped": skipped,
|
||||
"total": total,
|
||||
},
|
||||
"steps": steps,
|
||||
}
|
||||
|
||||
output_path.write_text(json.dumps(payload, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
|
||||
PY
|
||||
}
|
||||
|
||||
rr_cleanup() {
|
||||
if [[ -n "$RR_TMP_DIR" && -d "$RR_TMP_DIR" ]]; then
|
||||
rm -rf "$RR_TMP_DIR"
|
||||
fi
|
||||
}
|
||||
+128
-82
@@ -2,6 +2,11 @@
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
ROOT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
# shellcheck source=scripts/lib/regression-report.sh
|
||||
source "$SCRIPT_DIR/lib/regression-report.sh"
|
||||
|
||||
RUN_AUDIT_REGRESSION="${RUN_AUDIT_REGRESSION:-1}"
|
||||
RUN_OCR_REGRESSION="${RUN_OCR_REGRESSION:-1}"
|
||||
RUN_ORG_SETTINGS_REGRESSION="${RUN_ORG_SETTINGS_REGRESSION:-0}"
|
||||
@@ -12,97 +17,138 @@ RUN_BUDGET_REGRESSION="${RUN_BUDGET_REGRESSION:-0}"
|
||||
RUN_INTEGRATIONS_REGRESSION="${RUN_INTEGRATIONS_REGRESSION:-0}"
|
||||
RUN_FEATURE_FLAGS_REGRESSION="${RUN_FEATURE_FLAGS_REGRESSION:-0}"
|
||||
|
||||
echo "=== [1/7] Smoke Test ==="
|
||||
"$SCRIPT_DIR/smoke-test.sh"
|
||||
echo ""
|
||||
JSON_REPORT_PATH=""
|
||||
|
||||
echo "=== [2/7] Dedup Regression ==="
|
||||
"$SCRIPT_DIR/regression-dedup.sh"
|
||||
echo ""
|
||||
usage() {
|
||||
cat <<'USAGE'
|
||||
Usage: ./scripts/regression-all.sh [--json-report <path>]
|
||||
|
||||
echo "=== [3/7] Workflow Actions Regression ==="
|
||||
"$SCRIPT_DIR/regression-workflow-actions.sh"
|
||||
echo ""
|
||||
Options:
|
||||
--json-report <path> Write structured JSON report (schema_version=1.0).
|
||||
USAGE
|
||||
}
|
||||
|
||||
if [[ "$RUN_AUDIT_REGRESSION" == "1" ]]; then
|
||||
echo "=== [4/7] Audit Regression ==="
|
||||
"$SCRIPT_DIR/regression-audit.sh"
|
||||
echo ""
|
||||
else
|
||||
echo "=== [4/7] Audit Regression (skipped, RUN_AUDIT_REGRESSION=$RUN_AUDIT_REGRESSION) ==="
|
||||
echo ""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--json-report)
|
||||
if [[ $# -lt 2 || -z "${2:-}" ]]; then
|
||||
echo "[ERROR] --json-report requires a file path" >&2
|
||||
exit 2
|
||||
fi
|
||||
JSON_REPORT_PATH="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "[ERROR] Unknown argument: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
FAIL_FAST="1"
|
||||
if [[ -n "$JSON_REPORT_PATH" ]]; then
|
||||
FAIL_FAST="0"
|
||||
rr_prepare "$JSON_REPORT_PATH" "$ROOT_DIR"
|
||||
trap rr_cleanup EXIT
|
||||
fi
|
||||
|
||||
if [[ "$RUN_OCR_REGRESSION" == "1" ]]; then
|
||||
echo "=== [5/7] OCR Regression ==="
|
||||
"$SCRIPT_DIR/regression-ocr.sh"
|
||||
echo ""
|
||||
else
|
||||
echo "=== [5/7] OCR Regression (skipped, RUN_OCR_REGRESSION=$RUN_OCR_REGRESSION) ==="
|
||||
echo ""
|
||||
TOTAL_STEPS=12
|
||||
PASSED_STEPS=0
|
||||
FAILED_STEPS=0
|
||||
SKIPPED_STEPS=0
|
||||
RUN_STARTED_MS="$(rr_now_ms)"
|
||||
|
||||
run_step() {
|
||||
local index="$1"
|
||||
local step_id="$2"
|
||||
local step_name="$3"
|
||||
local enabled="$4"
|
||||
local command="$5"
|
||||
local skip_reason="${6:-}"
|
||||
|
||||
local step_started_ms
|
||||
local step_ended_ms
|
||||
local step_duration_ms
|
||||
local step_started_at
|
||||
local step_ended_at
|
||||
local status
|
||||
local exit_code
|
||||
|
||||
step_started_ms="$(rr_now_ms)"
|
||||
step_started_at="$(rr_now_iso)"
|
||||
|
||||
if [[ "$enabled" != "1" ]]; then
|
||||
echo "=== [$index/$TOTAL_STEPS] $step_name (skipped, $skip_reason) ==="
|
||||
echo ""
|
||||
status="skipped"
|
||||
exit_code=0
|
||||
SKIPPED_STEPS=$((SKIPPED_STEPS + 1))
|
||||
else
|
||||
echo "=== [$index/$TOTAL_STEPS] $step_name ==="
|
||||
|
||||
set +e
|
||||
eval "$command"
|
||||
exit_code=$?
|
||||
set -e
|
||||
|
||||
if [[ "$exit_code" -eq 0 ]]; then
|
||||
status="passed"
|
||||
PASSED_STEPS=$((PASSED_STEPS + 1))
|
||||
else
|
||||
status="failed"
|
||||
FAILED_STEPS=$((FAILED_STEPS + 1))
|
||||
echo "[ERROR] $step_name failed (exit=$exit_code)" >&2
|
||||
fi
|
||||
|
||||
echo ""
|
||||
fi
|
||||
|
||||
step_ended_ms="$(rr_now_ms)"
|
||||
step_ended_at="$(rr_now_iso)"
|
||||
step_duration_ms="$((step_ended_ms - step_started_ms))"
|
||||
|
||||
rr_record_step "$step_id" "$step_name" "$enabled" "$command" "$status" "$exit_code" "$step_started_at" "$step_ended_at" "$step_duration_ms"
|
||||
|
||||
if [[ "$status" == "failed" && "$FAIL_FAST" == "1" ]]; then
|
||||
return "$exit_code"
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
run_step 1 "smoke" "Smoke Test" "1" '"$SCRIPT_DIR"/smoke-test.sh'
|
||||
run_step 2 "dedup" "Dedup Regression" "1" '"$SCRIPT_DIR"/regression-dedup.sh'
|
||||
run_step 3 "workflow_actions" "Workflow Actions Regression" "1" '"$SCRIPT_DIR"/regression-workflow-actions.sh'
|
||||
run_step 4 "audit" "Audit Regression" "$RUN_AUDIT_REGRESSION" '"$SCRIPT_DIR"/regression-audit.sh' "RUN_AUDIT_REGRESSION=$RUN_AUDIT_REGRESSION"
|
||||
run_step 5 "ocr" "OCR Regression" "$RUN_OCR_REGRESSION" '"$SCRIPT_DIR"/regression-ocr.sh' "RUN_OCR_REGRESSION=$RUN_OCR_REGRESSION"
|
||||
run_step 6 "org_settings" "Org + Settings Regression" "$RUN_ORG_SETTINGS_REGRESSION" '"$SCRIPT_DIR"/regression-org-settings.sh' "RUN_ORG_SETTINGS_REGRESSION=$RUN_ORG_SETTINGS_REGRESSION"
|
||||
run_step 7 "auth_security" "Auth Security Regression" "$RUN_AUTH_SECURITY_REGRESSION" '"$SCRIPT_DIR"/regression-auth-security.sh' "RUN_AUTH_SECURITY_REGRESSION=$RUN_AUTH_SECURITY_REGRESSION"
|
||||
run_step 8 "verification" "Verification Regression" "$RUN_VERIFICATION_REGRESSION" '"$SCRIPT_DIR"/regression-verification.sh' "RUN_VERIFICATION_REGRESSION=$RUN_VERIFICATION_REGRESSION"
|
||||
run_step 9 "dashboard" "Dashboard Regression" "$RUN_DASHBOARD_REGRESSION" '"$SCRIPT_DIR"/regression-dashboard.sh' "RUN_DASHBOARD_REGRESSION=$RUN_DASHBOARD_REGRESSION"
|
||||
run_step 10 "budget" "Budget Regression" "$RUN_BUDGET_REGRESSION" '"$SCRIPT_DIR"/regression-budget.sh' "RUN_BUDGET_REGRESSION=$RUN_BUDGET_REGRESSION"
|
||||
run_step 11 "integrations" "Integrations Regression" "$RUN_INTEGRATIONS_REGRESSION" '"$SCRIPT_DIR"/regression-integrations.sh' "RUN_INTEGRATIONS_REGRESSION=$RUN_INTEGRATIONS_REGRESSION"
|
||||
run_step 12 "feature_flags" "Feature Flags Regression" "$RUN_FEATURE_FLAGS_REGRESSION" '"$SCRIPT_DIR"/regression-feature-flags.sh' "RUN_FEATURE_FLAGS_REGRESSION=$RUN_FEATURE_FLAGS_REGRESSION"
|
||||
|
||||
RUN_ENDED_MS="$(rr_now_ms)"
|
||||
OVERALL_DURATION_MS="$((RUN_ENDED_MS - RUN_STARTED_MS))"
|
||||
|
||||
OVERALL_STATUS="passed"
|
||||
if [[ "$FAILED_STEPS" -gt 0 ]]; then
|
||||
OVERALL_STATUS="failed"
|
||||
fi
|
||||
|
||||
if [[ "$RUN_ORG_SETTINGS_REGRESSION" == "1" ]]; then
|
||||
echo "=== [6/7] Org + Settings Regression ==="
|
||||
"$SCRIPT_DIR/regression-org-settings.sh"
|
||||
echo ""
|
||||
else
|
||||
echo "=== [6/7] Org + Settings Regression (skipped, RUN_ORG_SETTINGS_REGRESSION=$RUN_ORG_SETTINGS_REGRESSION) ==="
|
||||
echo ""
|
||||
if [[ -n "$JSON_REPORT_PATH" ]]; then
|
||||
rr_finalize "$OVERALL_STATUS" "$OVERALL_DURATION_MS" "$PASSED_STEPS" "$FAILED_STEPS" "$SKIPPED_STEPS" "$TOTAL_STEPS"
|
||||
fi
|
||||
|
||||
if [[ "$RUN_AUTH_SECURITY_REGRESSION" == "1" ]]; then
|
||||
echo "=== [7/7] Auth Security Regression ==="
|
||||
"$SCRIPT_DIR/regression-auth-security.sh"
|
||||
echo ""
|
||||
else
|
||||
echo "=== [7/7] Auth Security Regression (skipped, RUN_AUTH_SECURITY_REGRESSION=$RUN_AUTH_SECURITY_REGRESSION) ==="
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "$RUN_VERIFICATION_REGRESSION" == "1" ]]; then
|
||||
echo "=== [8/11] Verification Regression ==="
|
||||
"$SCRIPT_DIR/regression-verification.sh"
|
||||
echo ""
|
||||
else
|
||||
echo "=== [8/11] Verification Regression (skipped, RUN_VERIFICATION_REGRESSION=$RUN_VERIFICATION_REGRESSION) ==="
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "$RUN_DASHBOARD_REGRESSION" == "1" ]]; then
|
||||
echo "=== [9/11] Dashboard Regression ==="
|
||||
"$SCRIPT_DIR/regression-dashboard.sh"
|
||||
echo ""
|
||||
else
|
||||
echo "=== [9/11] Dashboard Regression (skipped, RUN_DASHBOARD_REGRESSION=$RUN_DASHBOARD_REGRESSION) ==="
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "$RUN_BUDGET_REGRESSION" == "1" ]]; then
|
||||
echo "=== [10/11] Budget Regression ==="
|
||||
"$SCRIPT_DIR/regression-budget.sh"
|
||||
echo ""
|
||||
else
|
||||
echo "=== [10/11] Budget Regression (skipped, RUN_BUDGET_REGRESSION=$RUN_BUDGET_REGRESSION) ==="
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "$RUN_INTEGRATIONS_REGRESSION" == "1" ]]; then
|
||||
echo "=== [11/11] Integrations Regression ==="
|
||||
"$SCRIPT_DIR/regression-integrations.sh"
|
||||
echo ""
|
||||
else
|
||||
echo "=== [11/11] Integrations Regression (skipped, RUN_INTEGRATIONS_REGRESSION=$RUN_INTEGRATIONS_REGRESSION) ==="
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ "$RUN_FEATURE_FLAGS_REGRESSION" == "1" ]]; then
|
||||
echo "=== [12/12] Feature Flags Regression ==="
|
||||
"$SCRIPT_DIR/regression-feature-flags.sh"
|
||||
echo ""
|
||||
else
|
||||
echo "=== [12/12] Feature Flags Regression (skipped, RUN_FEATURE_FLAGS_REGRESSION=$RUN_FEATURE_FLAGS_REGRESSION) ==="
|
||||
echo ""
|
||||
if [[ "$FAILED_STEPS" -gt 0 ]]; then
|
||||
echo "[ERROR] Regressions finished with failures (passed=$PASSED_STEPS failed=$FAILED_STEPS skipped=$SKIPPED_STEPS)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[OK] All regressions passed"
|
||||
|
||||
在新工单中引用
屏蔽一个用户