Files
proxmox/scripts/deployment/test-all-contracts-before-deploy.sh
defiQUG b3a8fe4496
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
chore: sync all changes to Gitea
- Config, docs, scripts, and backup manifests
- Submodule refs unchanged (m = modified content in submodules)

Made-with: Cursor
2026-03-02 11:37:34 -08:00

88 lines
3.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run all contract tests before deploying (Phase 0.8).
# Usage: ./scripts/deployment/test-all-contracts-before-deploy.sh [--dry-run] [--alltra] [--no-match PATTERN] [--skip-build]
#
# --dry-run Print commands only; do not run forge build/test.
# --alltra Also run forge test and npm run test:e2e in alltra-lifi-settlement.
# --no-match Exclude tests matching PATTERN (e.g. "Fork|Mainnet|Integration|e2e" for unit-only).
# --skip-build Skip forge build; use existing artifacts (forge test still compiles changed files incrementally).
#
# Requires: run from repo root; forge in PATH.
# See: docs/03-deployment/DEPLOYMENT_ORDER_OF_OPERATIONS.md § Phase 0.8
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
DRY_RUN=""
ALLTRA=""
NO_MATCH=""
SKIP_BUILD=""
while [[ $# -gt 0 ]]; do
case "$1" in
--dry-run) DRY_RUN=1; shift ;;
--skip-build) SKIP_BUILD=1; shift ;;
--alltra) ALLTRA=1; shift ;;
--no-match)
if [[ -n "${2:-}" && "${2:0:1}" != "-" ]]; then
NO_MATCH="$2"; shift 2
else
NO_MATCH="Fork|Mainnet|Integration|e2e"; shift
fi
;;
*) shift ;;
esac
done
echo "=== Test all contracts before deploy ==="
echo ""
# 1) smom-dbis-138: forge build (skip if --skip-build or already built)
if [[ -n "$SKIP_BUILD" ]]; then
echo "--- smom-dbis-138: forge build (skipped, using existing artifacts) ---"
elif [[ -n "$DRY_RUN" ]]; then
echo "--- smom-dbis-138: forge build ---"
echo "[DRY-RUN] cd $PROJECT_ROOT/smom-dbis-138 && forge build"
else
echo "--- smom-dbis-138: forge build ---"
(cd "$PROJECT_ROOT/smom-dbis-138" && forge build) || { echo "FAIL: forge build (smom-dbis-138)" >&2; exit 1; }
fi
echo ""
# 2) smom-dbis-138: forge test (includes GRU c* integration: GRUCompliantTokensRegistryTest)
echo "--- smom-dbis-138: forge test ---"
if [[ -n "$NO_MATCH" ]]; then
if [[ -n "$DRY_RUN" ]]; then
echo "[DRY-RUN] cd $PROJECT_ROOT/smom-dbis-138 && forge test --no-match-test \"$NO_MATCH\""
else
(cd "$PROJECT_ROOT/smom-dbis-138" && forge test --no-match-test "$NO_MATCH") || { echo "FAIL: forge test (smom-dbis-138)" >&2; exit 1; }
fi
else
if [[ -n "$DRY_RUN" ]]; then
echo "[DRY-RUN] cd $PROJECT_ROOT/smom-dbis-138 && forge test"
else
(cd "$PROJECT_ROOT/smom-dbis-138" && forge test) || { echo "FAIL: forge test (smom-dbis-138)" >&2; exit 1; }
fi
fi
echo ""
# 3) Optional: alltra-lifi-settlement
if [[ -n "$ALLTRA" ]]; then
echo "--- alltra-lifi-settlement: forge test ---"
if [[ -n "$DRY_RUN" ]]; then
echo "[DRY-RUN] cd $PROJECT_ROOT/alltra-lifi-settlement && forge test"
echo "[DRY-RUN] cd $PROJECT_ROOT/alltra-lifi-settlement && npm run test:e2e"
else
(cd "$PROJECT_ROOT/alltra-lifi-settlement" && forge test) || { echo "FAIL: forge test (alltra-lifi-settlement)" >&2; exit 1; }
(cd "$PROJECT_ROOT/alltra-lifi-settlement" && npm run test:e2e) || { echo "FAIL: npm run test:e2e (alltra-lifi-settlement)" >&2; exit 1; }
fi
echo ""
fi
if [[ -n "$DRY_RUN" ]]; then
echo "Dry-run complete. Run without --dry-run to execute."
else
echo "All contract tests passed. Proceed with deployment (Phase 1+)."
fi