forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathci-native-eval.sh
More file actions
executable file
·137 lines (118 loc) · 4.35 KB
/
Copy pathci-native-eval.sh
File metadata and controls
executable file
·137 lines (118 loc) · 4.35 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/usr/bin/env bash
set -euo pipefail
# ci-native-eval.sh — Start showcase integrations natively (no Docker)
# for CI evaluation. Installs deps, starts dev servers + agents,
# waits for health, then runs showcase eval --ci.
#
# Usage: ci-native-eval.sh [--level d5] [--scope affected|all] [--parallel N]
#
# Environment:
# SHOWCASE_ROOT — path to showcase/ directory (default: auto-detect)
# AIMOCK_PORT — port for aimock (default: 4010)
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SHOWCASE_ROOT="${SHOWCASE_ROOT:-$(cd "$SCRIPT_DIR/.." && pwd)}"
SHARED_DIR="$SHOWCASE_ROOT/shared"
INTEGRATIONS_DIR="$SHOWCASE_ROOT/integrations"
LOCAL_PORTS="$SHARED_DIR/local-ports.json"
AIMOCK_PORT="${AIMOCK_PORT:-4010}"
LEVEL="d5"
SCOPE="affected"
PARALLEL="8"
PIDS=()
# Parse args
while [[ $# -gt 0 ]]; do
case "$1" in
--level) LEVEL="$2"; shift 2 ;;
--scope) SCOPE="$2"; shift 2 ;;
--parallel) PARALLEL="$2"; shift 2 ;;
*) echo "Unknown arg: $1" >&2; exit 1 ;;
esac
done
cleanup() {
echo "[ci-native-eval] Tearing down..."
for pid in "${PIDS[@]}"; do
kill "$pid" 2>/dev/null || true
done
wait 2>/dev/null || true
echo "[ci-native-eval] Cleanup complete."
}
trap cleanup EXIT
# ── 1. Start aimock ──────────────────────────────────────────────────
echo "[ci-native-eval] Starting aimock on :${AIMOCK_PORT}..."
npx aimock --port "$AIMOCK_PORT" &
PIDS+=($!)
for i in $(seq 1 30); do
curl -sf "http://localhost:${AIMOCK_PORT}/health" >/dev/null 2>&1 && break || sleep 1
done
curl -sf "http://localhost:${AIMOCK_PORT}/health" >/dev/null 2>&1 || {
echo "[ci-native-eval] ERROR: aimock did not become healthy" >&2
exit 1
}
echo "[ci-native-eval] aimock healthy."
# ── 2. Read slug->port mapping ──────────────────────────────────────
SLUGS=$(node -e "console.log(Object.keys(require('$LOCAL_PORTS')).join(' '))")
# ── 3. Install deps + start services ────────────────────────────────
for slug in $SLUGS; do
port=$(node -e "console.log(require('$LOCAL_PORTS')['$slug'])")
agent_port=$((port + 100))
slug_dir="$INTEGRATIONS_DIR/$slug"
[ -d "$slug_dir" ] || continue
echo "[ci-native-eval] Starting $slug (frontend :$port, agent :$agent_port)..."
cd "$slug_dir"
# Install Node deps
if [ -f package.json ]; then
pnpm install --ignore-scripts 2>/dev/null || npm install --legacy-peer-deps 2>/dev/null || true
fi
# Install Python deps + start agent
if [ -f requirements.txt ]; then
pip install -r requirements.txt --prefer-binary -q 2>/dev/null || true
PYTHONPATH=. \
OPENAI_BASE_URL="http://localhost:${AIMOCK_PORT}/v1" \
OPENAI_API_KEY="aimock" \
python -m uvicorn agent_server:app \
--host 127.0.0.1 --port "$agent_port" \
--log-level warning &
PIDS+=($!)
fi
# Start Next.js dev server
PORT="$port" \
NEXT_PUBLIC_COPILOTKIT_URL="http://localhost:${agent_port}/api/copilotkit" \
npx next dev --turbopack --port "$port" &
PIDS+=($!)
cd "$SHOWCASE_ROOT"
done
# ── 4. Health-wait ───────────────────────────────────────────────────
echo "[ci-native-eval] Waiting for services to become healthy..."
HEALTHY=0
TOTAL=0
for slug in $SLUGS; do
port=$(node -e "console.log(require('$LOCAL_PORTS')['$slug'])")
slug_dir="$INTEGRATIONS_DIR/$slug"
[ -d "$slug_dir" ] || continue
TOTAL=$((TOTAL + 1))
ok=false
for i in $(seq 1 120); do
if curl -sf "http://localhost:$port" >/dev/null 2>&1; then
ok=true
break
fi
sleep 1
done
if $ok; then
echo "[ci-native-eval] + $slug :$port"
HEALTHY=$((HEALTHY + 1))
else
echo "[ci-native-eval] x $slug :$port (timeout)"
fi
done
echo "[ci-native-eval] ${HEALTHY}/${TOTAL} services healthy."
# ── 5. Run eval ──────────────────────────────────────────────────────
echo "[ci-native-eval] Running showcase eval..."
"$SHOWCASE_ROOT/bin/showcase" eval \
"--$LEVEL" \
--scope "$SCOPE" \
--parallel "$PARALLEL" \
--json \
--baseline compare \
--timeout 60000 \
--ci