forked from Haroldwonder/AnchorKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre_deploy_validate.sh
More file actions
executable file
·68 lines (57 loc) · 1.7 KB
/
Copy pathpre_deploy_validate.sh
File metadata and controls
executable file
·68 lines (57 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
# Pre-deployment validation script
# Validates all configurations before contract deployment
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SCHEMA_FILE="$SCRIPT_DIR/config_schema.json"
VALIDATOR="$SCRIPT_DIR/validate_config_strict.py"
CONFIGS_DIR="$SCRIPT_DIR/configs"
echo "🔍 AnchorKit Pre-Deployment Validation"
echo "========================================"
echo ""
# Check dependencies
if ! command -v python3 &> /dev/null; then
echo "❌ Python3 not found. Please install Python 3.7+"
exit 1
fi
# Install required Python packages
echo "📦 Checking Python dependencies..."
pip3 install -q jsonschema toml 2>/dev/null || {
echo "⚠️ Installing jsonschema and toml..."
pip3 install jsonschema toml
}
# Validate schema file exists
if [ ! -f "$SCHEMA_FILE" ]; then
echo "❌ Schema file not found: $SCHEMA_FILE"
exit 1
fi
# Validate all config files
echo ""
echo "🔎 Validating configuration files..."
echo ""
FAILED=0
PASSED=0
for config in "$CONFIGS_DIR"/*.toml "$CONFIGS_DIR"/*.json; do
if [ -f "$config" ]; then
echo -n " Validating $(basename "$config")... "
if python3 "$VALIDATOR" "$config" "$SCHEMA_FILE" > /dev/null 2>&1; then
echo "✓"
((PASSED++))
else
echo "✗"
python3 "$VALIDATOR" "$config" "$SCHEMA_FILE" 2>&1 | sed 's/^/ /'
((FAILED++))
fi
fi
done
echo ""
echo "========================================"
echo "Results: $PASSED passed, $FAILED failed"
echo ""
if [ $FAILED -gt 0 ]; then
echo "❌ Validation failed. Fix errors before deployment."
exit 1
else
echo "✅ All configurations valid. Ready for deployment."
exit 0
fi