Skip to content

Commit 1feda9f

Browse files
committed
cleaning up
1 parent ba43d93 commit 1feda9f

File tree

2 files changed

+110
-67
lines changed

2 files changed

+110
-67
lines changed

.github/workflows/agentex-tutorials-test.yml

Lines changed: 103 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
jobs:
77
test-tutorials:
88
timeout-minutes: 15
9-
name: test-tutorial-${{ matrix.tutorial }}
9+
name: test-tutorials
1010
runs-on: ubuntu-latest
1111

1212
steps:
@@ -86,32 +86,32 @@ jobs:
8686
echo "UV version: $(uv --version)"
8787
echo "UV path: $(which uv)"
8888
89-
# Start background job to continuously poll AgentEx container logs
90-
echo "🔍 Starting AgentEx container log polling in background..."
89+
# Start background job to poll AgentEx container logs and write to file
9190
(
92-
echo "Log polling started at $(date)"
91+
echo "AgentEx container log polling started at $(date)" > /tmp/agentex_container_logs.txt
9392
9493
# Function to get container logs
9594
get_logs() {
96-
echo "=== AgentEx Container Logs $(date) ==="
97-
docker logs agentex --tail=20 2>/dev/null || {
98-
echo "⚠️ Failed to get logs from 'agentex' container"
99-
echo "Available containers:"
100-
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
101-
}
102-
echo "=== End Logs ==="
103-
echo ""
95+
echo "=== AgentEx Container Logs $(date) ===" >> /tmp/agentex_container_logs.txt
96+
docker logs agentex --tail=20 2>/dev/null >> /tmp/agentex_container_logs.txt || {
97+
echo "⚠️ Failed to get logs from 'agentex' container" >> /tmp/agentex_container_logs.txt
98+
echo "Available containers:" >> /tmp/agentex_container_logs.txt
99+
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}" >> /tmp/agentex_container_logs.txt
100+
} 2>/dev/null
101+
echo "=== End Logs ===" >> /tmp/agentex_container_logs.txt
102+
echo "" >> /tmp/agentex_container_logs.txt
104103
}
105104
106-
# Poll logs every 2 seconds (very frequent for debugging)
105+
# Poll logs every 10 seconds during test execution
107106
while true; do
108107
get_logs
109-
sleep 2
108+
sleep 10
110109
done
111110
) &
112111
113112
LOG_POLLER_PID=$!
114-
echo "📋 Log poller started with PID: $LOG_POLLER_PID"
113+
echo "📋 AgentEx log polling started in background (PID: $LOG_POLLER_PID)"
114+
115115
116116
# Find all tutorial directories
117117
tutorial_paths=()
@@ -148,23 +148,30 @@ jobs:
148148
149149
# Keep host_address as host.docker.internal for CI (allows Docker container to reach GitHub runner host)
150150
# Note: The AgentEx server runs in Docker and needs host.docker.internal to reach the tutorial agent on the host
151-
152-
echo "Updated $manifest_path to use port $port (keeping host_address: host.docker.internal)"
153151
fi
154152
155153
156-
# Run test in background with unique port
154+
# Run test in background with unique port and show output in real-time
157155
(
156+
test_output_file="/tmp/test_output_$i.log"
157+
echo "Running test: $tutorial" | tee "$test_output_file"
158+
echo "Port: $port" | tee -a "$test_output_file"
159+
echo "========================================" | tee -a "$test_output_file"
160+
158161
AGENTEX_API_BASE_URL="http://localhost:5003" \
159-
./run_agent_test.sh --build-cli "$tutorial"
162+
./run_agent_test.sh --build-cli "$tutorial" 2>&1 | tee -a "$test_output_file"
160163
161-
if [ $? -eq 0 ]; then
164+
exit_code=${PIPESTATUS[0]}
165+
if [ $exit_code -eq 0 ]; then
162166
echo "✅ PASSED: $tutorial (port $port)"
163167
echo "$tutorial" > "/tmp/passed_$i.txt"
168+
echo "$test_output_file" > "/tmp/passed_output_$i.txt"
164169
else
165170
echo "❌ FAILED: $tutorial (port $port)"
166171
echo "$tutorial" > "/tmp/failed_$i.txt"
172+
echo "$test_output_file" > "/tmp/failed_output_$i.txt"
167173
fi
174+
exit $exit_code
168175
) &
169176
170177
pids+=($!)
@@ -177,32 +184,6 @@ jobs:
177184
wait "$pid"
178185
done
179186
180-
# Always show AgentEx server container logs immediately after tests complete
181-
echo ""
182-
echo "========================================="
183-
echo "AGENTEX SERVER CONTAINER LOGS"
184-
echo "========================================="
185-
186-
# Show AgentEx server container logs
187-
echo "📋 AgentEx server container logs:"
188-
echo "----------------------------------------"
189-
190-
echo "Available containers:"
191-
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
192-
193-
echo ""
194-
echo "AgentEx container logs (last 100 lines):"
195-
docker logs agentex --tail=100 2>/dev/null || {
196-
echo "❌ Failed to get logs from 'agentex' container"
197-
echo "Available containers:"
198-
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
199-
}
200-
echo "----------------------------------------"
201-
202-
# Stop the log poller
203-
echo "🛑 Stopping log poller (PID: $LOG_POLLER_PID)"
204-
kill $LOG_POLLER_PID 2>/dev/null || echo "Log poller already stopped"
205-
206187
# Restore all original manifests
207188
echo ""
208189
echo "Restoring original manifest files..."
@@ -223,6 +204,10 @@ jobs:
223204
done
224205
225206
207+
# Stop the background log poller
208+
echo "🛑 Stopping AgentEx log poller (PID: $LOG_POLLER_PID)"
209+
kill $LOG_POLLER_PID 2>/dev/null || echo "Log poller already stopped"
210+
226211
# Print summary
227212
echo ""
228213
echo "========================================="
@@ -238,14 +223,65 @@ jobs:
238223
for test in "${failed_tests[@]}"; do
239224
echo " ❌ $test"
240225
done
241-
242-
243-
exit 1
244226
else
245227
echo ""
246228
echo "🎉 All tests passed!"
247229
fi
248230
231+
# Show pytest results for all tests
232+
echo ""
233+
echo "========================================="
234+
echo "PYTEST RESULTS"
235+
echo "========================================="
236+
237+
# Show passed test results
238+
if [ ${#passed_tests[@]} -gt 0 ]; then
239+
echo ""
240+
echo "✅ PASSED TESTS:"
241+
for i in "${!tutorial_paths[@]}"; do
242+
if [ -f "/tmp/passed_$i.txt" ]; then
243+
test_name=$(cat "/tmp/passed_$i.txt")
244+
output_file=$(cat "/tmp/passed_output_$i.txt")
245+
echo ""
246+
echo "📋 $test_name:"
247+
echo "----------------------------------------"
248+
if [ -f "$output_file" ]; then
249+
# Show just the pytest summary line for passed tests
250+
grep -E "(PASSED|FAILED|ERROR|::.*ok)" "$output_file" | tail -10 || echo "No pytest output found"
251+
else
252+
echo "No output file found"
253+
fi
254+
echo "----------------------------------------"
255+
fi
256+
done
257+
fi
258+
259+
# Show failed test results
260+
if [ ${#failed_tests[@]} -gt 0 ]; then
261+
echo ""
262+
echo "❌ FAILED TESTS:"
263+
for i in "${!tutorial_paths[@]}"; do
264+
if [ -f "/tmp/failed_$i.txt" ]; then
265+
test_name=$(cat "/tmp/failed_$i.txt")
266+
output_file=$(cat "/tmp/failed_output_$i.txt")
267+
echo ""
268+
echo "📋 $test_name:"
269+
echo "----------------------------------------"
270+
if [ -f "$output_file" ]; then
271+
# Show full pytest output for failed tests
272+
tail -50 "$output_file"
273+
else
274+
echo "No output file found"
275+
fi
276+
echo "----------------------------------------"
277+
fi
278+
done
279+
fi
280+
281+
if [ ${#failed_tests[@]} -gt 0 ]; then
282+
exit 1
283+
fi
284+
249285
- name: Debug Logs for Failed Tests
250286
if: always()
251287
run: |
@@ -256,19 +292,27 @@ jobs:
256292
echo "🐛 DEBUG LOGS (for troubleshooting)"
257293
echo "================================================================================"
258294
259-
# Show AgentEx server container logs
295+
# Show collected AgentEx server container logs
260296
echo ""
261297
echo "========================================="
262-
echo "AGENTEX SERVER LOGS"
298+
echo "AGENTEX SERVER LOGS (COLLECTED DURING TESTS)"
263299
echo "========================================="
264-
echo "📋 AgentEx server container logs (last 200 lines):"
265-
echo "----------------------------------------"
266-
docker logs agentex --tail=200 2>/dev/null || {
267-
echo "❌ Failed to get logs from 'agentex' container"
268-
echo "Available containers:"
269-
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
270-
}
271-
echo "----------------------------------------"
300+
if [ -f "/tmp/agentex_container_logs.txt" ]; then
301+
echo "📋 AgentEx server logs collected during test execution:"
302+
echo "----------------------------------------"
303+
cat /tmp/agentex_container_logs.txt
304+
echo "----------------------------------------"
305+
else
306+
echo "⚠️ No AgentEx container logs file found"
307+
echo "📋 Attempting to get current container logs:"
308+
echo "----------------------------------------"
309+
docker logs agentex --tail=50 2>/dev/null || {
310+
echo "❌ Failed to get logs from 'agentex' container"
311+
echo "Available containers:"
312+
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
313+
}
314+
echo "----------------------------------------"
315+
fi
272316
273317
# Show tutorial agent logs for failed tests
274318
cd ../../examples/tutorials

examples/tutorials/run_agent_test.sh

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,12 @@ start_agent() {
121121

122122
if [ "$BUILD_CLI" = true ]; then
123123

124-
# From tutorial subdirectory, we need to go up 4 levels to reach repo root
125-
# tutorials/00_sync/000_hello_acp -> tutorials -> examples -> agentex-python
126-
local wheel_file=$(ls ../../../../dist/agentex_sdk-*.whl 2>/dev/null | head -n1)
124+
# Use wheel from dist directory at repo root
125+
local wheel_file=$(ls /home/runner/work/*/*/dist/agentex_sdk-*.whl 2>/dev/null | head -n1)
127126
if [[ -z "$wheel_file" ]]; then
128-
echo -e "${RED}❌ No built wheel found in ../../../../dist/agentex_sdk-*.whl${NC}"
127+
echo -e "${RED}❌ No built wheel found in dist/agentex_sdk-*.whl${NC}"
129128
echo -e "${YELLOW}💡 Please build the local SDK first by running: uv build${NC}"
130-
echo -e "${YELLOW}💡 From the repo root directory: /Users/roxanne.farhad/Desktop/scale/agentex-python${NC}"
129+
echo -e "${YELLOW}💡 From the repo root directory${NC}"
131130
cd "$original_dir"
132131
return 1
133132
fi
@@ -338,12 +337,12 @@ check_built_wheel() {
338337
return 1
339338
}
340339

341-
# Check if wheel exists
342-
local wheel_file=$(ls dist/agentex_sdk-*.whl 2>/dev/null | head -n1)
340+
# Check if wheel exists in dist directory at repo root
341+
local wheel_file=$(ls /home/runner/work/*/*/dist/agentex_sdk-*.whl 2>/dev/null | head -n1)
343342
if [[ -z "$wheel_file" ]]; then
344343
echo -e "${RED}❌ No built wheel found in dist/agentex_sdk-*.whl${NC}"
345344
echo -e "${YELLOW}💡 Please build the local SDK first by running: uv build${NC}"
346-
echo -e "${YELLOW}💡 From the repo root directory: $(pwd)${NC}"
345+
echo -e "${YELLOW}💡 From the repo root directory${NC}"
347346
cd "$original_dir"
348347
return 1
349348
fi

0 commit comments

Comments
 (0)