#!/usr/bin/env bash 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}" RUN_AUTH_SECURITY_REGRESSION="${RUN_AUTH_SECURITY_REGRESSION:-0}" RUN_VERIFICATION_REGRESSION="${RUN_VERIFICATION_REGRESSION:-0}" RUN_DASHBOARD_REGRESSION="${RUN_DASHBOARD_REGRESSION:-0}" RUN_BUDGET_REGRESSION="${RUN_BUDGET_REGRESSION:-0}" RUN_INTEGRATIONS_REGRESSION="${RUN_INTEGRATIONS_REGRESSION:-0}" RUN_FEATURE_FLAGS_REGRESSION="${RUN_FEATURE_FLAGS_REGRESSION:-0}" JSON_REPORT_PATH="" usage() { cat <<'USAGE' Usage: ./scripts/regression-all.sh [--json-report ] Options: --json-report Write structured JSON report (schema_version=1.0). USAGE } 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 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 [[ -n "$JSON_REPORT_PATH" ]]; then rr_finalize "$OVERALL_STATUS" "$OVERALL_DURATION_MS" "$PASSED_STEPS" "$FAILED_STEPS" "$SKIPPED_STEPS" "$TOTAL_STEPS" fi 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"