22 lines
956 B
Bash
Executable File
22 lines
956 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -uo pipefail
|
|
CONTAINER="qihu-aiflow"
|
|
RED='\033[0;31m'; GREEN='\033[0;32m'; NC='\033[0m'
|
|
fail() { echo -e "${RED}[pre-commit] FAIL: $*${NC}" >&2; exit 1; }
|
|
|
|
if ! docker ps --format '{{.Names}}' | grep -qx "$CONTAINER"; then
|
|
echo "[pre-commit] WARNING: container $CONTAINER not running, skip" >&2; exit 0
|
|
fi
|
|
|
|
AUDIT_JSON=$(curl -s --max-time 15 http://localhost:18080/app/api/health/bug-audit 2>/dev/null)
|
|
if [ -z "$AUDIT_JSON" ]; then
|
|
echo "[pre-commit] WARNING: bug-audit not reachable, skip" >&2; exit 0
|
|
fi
|
|
|
|
HEALTHY=$(echo "$AUDIT_JSON" | python3 -c "import json,sys;d=json.load(sys.stdin);dd=d.get('data',d);print(dd.get('healthy',''))" 2>/dev/null)
|
|
if [ "$HEALTHY" != "True" ]; then
|
|
echo "$AUDIT_JSON" | python3 -c "import json,sys;d=json.load(sys.stdin);dd=d.get('data',d);[print(' ISSUE:',i) for i in dd.get('issues',[])]" 2>/dev/null
|
|
fail "bug-audit returned unhealthy"
|
|
fi
|
|
echo "[pre-commit] bug-audit PASSED"; exit 0
|