forked from Haroldwonder/AnchorKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_all.ps1
More file actions
80 lines (65 loc) · 2.13 KB
/
validate_all.ps1
File metadata and controls
80 lines (65 loc) · 2.13 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
69
70
71
72
73
74
75
76
77
78
79
80
# PowerShell equivalent of validate_all.sh
# AnchorKit Pre-Deployment Validation for Windows
$ErrorActionPreference = "Stop"
Write-Output "🔍 AnchorKit Pre-Deployment Validation"
Write-Output "========================================"
Write-Output ""
# Check if Python is available
try {
$pythonVersion = python --version 2>&1
Write-Output "✅ Python found: $pythonVersion"
} catch {
Write-Error "❌ Python3 is required but not installed. Download from: https://www.python.org/downloads/"
exit 1
}
# Check if required Python packages are installed
Write-Output "📦 Checking Python dependencies..."
try {
python -c "import jsonschema, toml" 2>$null
Write-Output "✅ Python dependencies OK"
} catch {
Write-Output "⚠️ Missing Python dependencies. Installing..."
pip install jsonschema toml --quiet
Write-Output "✅ Dependencies installed"
}
Write-Output ""
# Validate all configuration files
Write-Output "📋 Validating configuration files..."
$ConfigDir = "configs"
$SchemaFile = "config_schema.json"
$Failed = 0
if (-not (Test-Path $SchemaFile)) {
Write-Error "❌ Schema file not found: $SchemaFile"
exit 1
}
$configFiles = Get-ChildItem -Path $ConfigDir -Include *.json,*.toml -File
foreach ($configFile in $configFiles) {
Write-Output " Validating $($configFile.Name)..."
$result = python validate_config_strict.py $configFile.FullName $SchemaFile 2>&1
if ($LASTEXITCODE -eq 0) {
Write-Output " ✅ $($configFile.Name)"
} else {
Write-Error " ❌ $($configFile.Name): $result"
$Failed = 1
}
}
if ($Failed -eq 1) {
Write-Output ""
Write-Error "❌ Configuration validation failed"
exit 1
}
Write-Output ""
Write-Output "✅ All configurations valid"
Write-Output ""
# Run Rust tests
Write-Output "🧪 Running Rust validation tests..."
$testOutput = cargo test --quiet config 2>&1 | Out-String
if ($testOutput -match "test result: ok") {
Write-Output "✅ Rust tests passed"
} else {
Write-Error "❌ Rust tests failed"
cargo test config
exit 1
}
Write-Output ""
Write-Output "🎉 All validations passed! Ready for deployment."