a3bb78e06b
Security Quality Gate / npm audit, Bandit, pip-audit, detect-secrets (pull_request) Failing after 16m35s
80 lines
2.2 KiB
PowerShell
80 lines
2.2 KiB
PowerShell
param(
|
|
[string]$WebBaseUrl = "http://localhost:3000",
|
|
[string]$ContractApiBaseUrl = "http://localhost:8100",
|
|
[string]$AiPlatformBaseUrl = "http://localhost:8101"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
function Invoke-JsonCheck {
|
|
param(
|
|
[string]$Name,
|
|
[string]$Url,
|
|
[scriptblock]$Validate
|
|
)
|
|
|
|
$startedAt = Get-Date
|
|
try {
|
|
$payload = Invoke-RestMethod -Uri $Url -Method Get -TimeoutSec 12
|
|
& $Validate $payload
|
|
[ordered]@{
|
|
name = $Name
|
|
status = "ok"
|
|
url = $Url
|
|
elapsed_ms = [int]((Get-Date) - $startedAt).TotalMilliseconds
|
|
}
|
|
} catch {
|
|
[ordered]@{
|
|
name = $Name
|
|
status = "error"
|
|
url = $Url
|
|
message = $_.Exception.Message
|
|
elapsed_ms = [int]((Get-Date) - $startedAt).TotalMilliseconds
|
|
}
|
|
}
|
|
}
|
|
|
|
$checks = @()
|
|
|
|
$checks += Invoke-JsonCheck "contract-api-health" "$ContractApiBaseUrl/health" {
|
|
param($payload)
|
|
if ($payload.status -ne "ok") { throw "Contract API health status is not ok." }
|
|
}
|
|
|
|
$checks += Invoke-JsonCheck "contract-api-config" "$ContractApiBaseUrl/api/v1/runtime/config-check" {
|
|
param($payload)
|
|
if ($payload.status -eq "error") { throw "Contract API runtime config has errors." }
|
|
}
|
|
|
|
$checks += Invoke-JsonCheck "ai-platform-health" "$AiPlatformBaseUrl/health" {
|
|
param($payload)
|
|
if ($payload.status -ne "ok") { throw "AI Platform health status is not ok." }
|
|
}
|
|
|
|
$checks += Invoke-JsonCheck "ai-platform-worker-health" "$AiPlatformBaseUrl/api/v1/runtime/worker-health" {
|
|
param($payload)
|
|
if ($null -eq $payload) { throw "AI Platform worker health payload is empty." }
|
|
}
|
|
|
|
$checks += Invoke-JsonCheck "ai-platform-object-storage" "$AiPlatformBaseUrl/api/v1/runtime/object-storage/check" {
|
|
param($payload)
|
|
if ($payload.status -ne "ok") { throw "Object storage check is not ok: $($payload.message)" }
|
|
}
|
|
|
|
$checks += Invoke-JsonCheck "contract-web-health" "$WebBaseUrl/health" {
|
|
param($payload)
|
|
if ($null -eq $payload) { throw "Contract Web health payload is empty." }
|
|
}
|
|
|
|
$summary = [ordered]@{
|
|
status = if ($checks.status -contains "error") { "error" } else { "ok" }
|
|
checked_at = (Get-Date).ToString("o")
|
|
checks = $checks
|
|
}
|
|
|
|
$summary | ConvertTo-Json -Depth 6
|
|
|
|
if ($summary.status -ne "ok") {
|
|
exit 1
|
|
}
|