-
Notifications
You must be signed in to change notification settings - Fork 7
310 lines (254 loc) Β· 10.8 KB
/
agentex-tutorials-test.yml
File metadata and controls
310 lines (254 loc) Β· 10.8 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
name: Test Tutorial Agents
on:
workflow_dispatch:
jobs:
test-tutorials:
timeout-minutes: 15
name: test-tutorial-${{ matrix.tutorial }}
runs-on: ubuntu-latest
steps:
- name: Checkout agentex-python repo
uses: actions/checkout@v4
- name: Install UV
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Checkout scale-agentex repo
uses: actions/checkout@v4
with:
repository: scaleapi/scale-agentex
path: scale-agentex
- name: Configure Docker Compose for host networking
run: |
cd scale-agentex/agentex
echo "π§ Configuring AgentEx container for GitHub Actions networking..."
# Install yq for YAML manipulation
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
# Add extra_hosts to agentex service to make host.docker.internal work
# This allows the AgentEx container to reach the GitHub runner host
yq eval '.services.agentex.extra_hosts = ["host.docker.internal:host-gateway"]' -i docker-compose.yml
echo "β
Added extra_hosts configuration to agentex service"
- name: Navigate to scale-agentex repo
run: |
cd scale-agentex/agentex
echo "π Starting dependencies (Postgres, Redis, Temporal, MongoDB)..."
# Start all services
docker compose up -d
echo "β³ Waiting for dependencies to be healthy..."
# Wait for services to be healthy
for i in {1..30}; do
if docker compose ps | grep -q "healthy"; then
echo "β
Dependencies are healthy"
break
fi
echo " Attempt $i/30: Waiting for services..."
sleep 5
done
# Wait specifically for AgentEx server to be ready
echo "β³ Waiting for AgentEx server to be ready..."
for i in {1..30}; do
if curl -s --max-time 5 http://localhost:5003/health >/dev/null 2>&1; then
echo "β
AgentEx server is ready"
break
fi
echo " Attempt $i/30: Waiting for AgentEx server..."
sleep 5
done
- name: Build AgentEx SDK
run: |
echo "π¨ Building AgentEx SDK wheel..."
uv build
echo "β
SDK built successfully"
ls -la dist/
- name: Run Parallel Tutorial Tests
working-directory: ./examples/tutorials
run: |
# Verify uv is working
echo "UV version: $(uv --version)"
echo "UV path: $(which uv)"
# Start background job to continuously poll AgentEx container logs
echo "π Starting AgentEx container log polling in background..."
(
echo "Log polling started at $(date)"
# Function to get container logs
get_logs() {
echo "=== AgentEx Container Logs $(date) ==="
docker logs agentex --tail=20 2>/dev/null || {
echo "β οΈ Failed to get logs from 'agentex' container"
echo "Available containers:"
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
}
echo "=== End Logs ==="
echo ""
}
# Poll logs every 2 seconds (very frequent for debugging)
while true; do
get_logs
sleep 2
done
) &
LOG_POLLER_PID=$!
echo "π Log poller started with PID: $LOG_POLLER_PID"
# Find all tutorial directories
tutorial_paths=()
for dir in $(find . -name "manifest.yaml" -exec dirname {} \; | sort); do
tutorial_paths+=("${dir#./}") # Remove leading ./
done
echo "Found ${#tutorial_paths[@]} tutorials:"
printf ' %s\n' "${tutorial_paths[@]}"
# Run tests in parallel with unique ports
pids=()
failed_tests=()
passed_tests=()
# Run all tutorial tests
for i in "${!tutorial_paths[@]}"; do
tutorial="${tutorial_paths[$i]}"
port=$((8000 + i))
echo ""
echo "========================================="
echo "Starting test $((i+1))/${#tutorial_paths[@]}: $tutorial (port $port)"
echo "========================================="
# Modify manifest.yaml to use unique port
manifest_path="$tutorial/manifest.yaml"
if [ -f "$manifest_path" ]; then
# Backup original manifest
cp "$manifest_path" "$manifest_path.backup"
# Update port in manifest (modify the line containing 'port: 8000' or 'port: XXXX')
sed -i "s/port: [0-9]*/port: $port/" "$manifest_path"
# Keep host_address as host.docker.internal for CI (allows Docker container to reach GitHub runner host)
# Note: The AgentEx server runs in Docker and needs host.docker.internal to reach the tutorial agent on the host
echo "Updated $manifest_path to use port $port (keeping host_address: host.docker.internal)"
fi
# Run test in background with unique port
(
AGENTEX_API_BASE_URL="http://localhost:5003" \
./run_agent_test.sh --build-cli "$tutorial"
if [ $? -eq 0 ]; then
echo "β
PASSED: $tutorial (port $port)"
echo "$tutorial" > "/tmp/passed_$i.txt"
else
echo "β FAILED: $tutorial (port $port)"
echo "$tutorial" > "/tmp/failed_$i.txt"
fi
) &
pids+=($!)
done
# Wait for all tests to complete
echo ""
echo "Waiting for all tests to complete..."
for pid in "${pids[@]}"; do
wait "$pid"
done
# Always show AgentEx server container logs immediately after tests complete
echo ""
echo "========================================="
echo "AGENTEX SERVER CONTAINER LOGS"
echo "========================================="
# Show AgentEx server container logs
echo "π AgentEx server container logs:"
echo "----------------------------------------"
echo "Available containers:"
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
echo ""
echo "AgentEx container logs (last 100 lines):"
docker logs agentex --tail=100 2>/dev/null || {
echo "β Failed to get logs from 'agentex' container"
echo "Available containers:"
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
}
echo "----------------------------------------"
# Stop the log poller
echo "π Stopping log poller (PID: $LOG_POLLER_PID)"
kill $LOG_POLLER_PID 2>/dev/null || echo "Log poller already stopped"
# Restore all original manifests
echo ""
echo "Restoring original manifest files..."
for tutorial in "${tutorial_paths[@]}"; do
if [ -f "$tutorial/manifest.yaml.backup" ]; then
mv "$tutorial/manifest.yaml.backup" "$tutorial/manifest.yaml"
echo "Restored $tutorial/manifest.yaml"
fi
done
# Collect results
for i in "${!tutorial_paths[@]}"; do
if [ -f "/tmp/passed_$i.txt" ]; then
passed_tests+=($(cat "/tmp/passed_$i.txt"))
elif [ -f "/tmp/failed_$i.txt" ]; then
failed_tests+=($(cat "/tmp/failed_$i.txt"))
fi
done
# Print summary
echo ""
echo "========================================="
echo "TEST SUMMARY"
echo "========================================="
echo "Total: ${#tutorial_paths[@]}"
echo "Passed: ${#passed_tests[@]}"
echo "Failed: ${#failed_tests[@]}"
if [ ${#failed_tests[@]} -gt 0 ]; then
echo ""
echo "Failed tests:"
for test in "${failed_tests[@]}"; do
echo " β $test"
done
exit 1
else
echo ""
echo "π All tests passed!"
fi
- name: Debug Logs for Failed Tests
if: always()
run: |
cd scale-agentex/agentex
echo ""
echo "================================================================================"
echo "π DEBUG LOGS (for troubleshooting)"
echo "================================================================================"
# Show AgentEx server container logs
echo ""
echo "========================================="
echo "AGENTEX SERVER LOGS"
echo "========================================="
echo "π AgentEx server container logs (last 200 lines):"
echo "----------------------------------------"
docker logs agentex --tail=200 2>/dev/null || {
echo "β Failed to get logs from 'agentex' container"
echo "Available containers:"
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
}
echo "----------------------------------------"
# Show tutorial agent logs for failed tests
cd ../../examples/tutorials
# Check if there were any failed tests
failed_tests=()
for i in {0..20}; do # Check up to 20 possible tests
if [ -f "/tmp/failed_$i.txt" ]; then
failed_tests+=($(cat "/tmp/failed_$i.txt"))
fi
done
if [ ${#failed_tests[@]} -gt 0 ]; then
echo ""
echo "========================================="
echo "TUTORIAL AGENT LOGS FOR FAILED TESTS"
echo "========================================="
for test in "${failed_tests[@]}"; do
test_name=$(basename "$test")
logfile="/tmp/agentex-${test_name}.log"
echo ""
echo "π Tutorial agent logs for $test:"
echo "----------------------------------------"
if [ -f "$logfile" ]; then
echo "Tutorial agent logs (last 100 lines):"
tail -100 "$logfile"
else
echo "β οΈ No agent log file found at: $logfile"
echo "Available agent log files:"
ls -la /tmp/agentex-*.log 2>/dev/null || echo " (none)"
fi
echo "----------------------------------------"
done
else
echo ""
echo "β
No failed tests - no agent logs to show"
fi