Skip to content

Commit 69eb4e4

Browse files
committed
cleaning up
1 parent 95401c0 commit 69eb4e4

File tree

3 files changed

+74
-55
lines changed

3 files changed

+74
-55
lines changed

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

Lines changed: 56 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
all_tutorials=$(find . -name "manifest.yaml" -exec dirname {} \; | sort | sed 's|^\./||')
2121
2222
# Filter out the specified temporal tutorials that are being updated
23-
filtered_tutorials=$(echo "$all_tutorials" | grep -v -E "(10_temporal/050_|10_temporal/070_|10_temporal/080_)")
23+
filtered_tutorials=$(echo "$all_tutorials" | grep -v -E "(temporal)")
2424
2525
# Convert to JSON array
2626
tutorials=$(echo "$filtered_tutorials" | jq -R -s -c 'split("\n") | map(select(length > 0))')
@@ -116,8 +116,24 @@ jobs:
116116
HEALTH_CHECK_PORT: 8080 # Use non-privileged port for temporal worker health checks
117117
run: |
118118
echo "Testing tutorial: ${{ matrix.tutorial }}"
119+
120+
# Create output files
121+
SANITIZED_NAME=$(echo "${{ matrix.tutorial }}" | sed 's/\//-/g')
122+
OUTPUT_FILE="/tmp/test-output-$SANITIZED_NAME.txt"
123+
STATUS_FILE="/tmp/test-status-$SANITIZED_NAME.txt"
124+
125+
# Run the test, show output live, and also capture to file
126+
set +e # Don't exit on error
119127
AGENTEX_API_BASE_URL="http://localhost:5003" \
120-
./run_agent_test.sh --build-cli "${{ matrix.tutorial }}"
128+
./run_agent_test.sh --build-cli "${{ matrix.tutorial }}" 2>&1 | tee "$OUTPUT_FILE"
129+
EXIT_CODE=${PIPESTATUS[0]} # Get exit code from the first command in pipeline
130+
set -e # Re-enable exit on error
131+
132+
# Write the exit code to status file
133+
echo "$EXIT_CODE" > "$STATUS_FILE"
134+
135+
# Exit with the original exit code to make the job succeed/fail correctly
136+
exit $EXIT_CODE
121137
122138
- name: Upload Test Results
123139
if: always()
@@ -128,7 +144,13 @@ jobs:
128144
129145
# Create a temporary directory with the sanitized name
130146
mkdir -p "test-results-$SANITIZED_NAME"
131-
cp /tmp/agentex-*.log "test-results-$SANITIZED_NAME/" 2>/dev/null || echo "No log files to copy"
147+
148+
# Copy the test output and status files
149+
cp "/tmp/test-output-$SANITIZED_NAME.txt" "test-results-$SANITIZED_NAME/" 2>/dev/null || echo "No output file to copy"
150+
cp "/tmp/test-status-$SANITIZED_NAME.txt" "test-results-$SANITIZED_NAME/" 2>/dev/null || echo "No status file to copy"
151+
152+
# Also copy agent logs if they exist
153+
cp /tmp/agentex-*.log "test-results-$SANITIZED_NAME/" 2>/dev/null || echo "No agent log files to copy"
132154
133155
# Upload using the actions/upload-artifact action
134156
echo "artifact-name=test-results-$SANITIZED_NAME" >> $GITHUB_ENV
@@ -161,17 +183,6 @@ jobs:
161183
# Get tutorial list from needs context
162184
tutorials='${{ needs.find-tutorials.outputs.tutorials }}'
163185
164-
# Debug: Show what we're working with
165-
echo "🔍 DEBUG: Tutorial list from find-tutorials job:"
166-
echo "$tutorials"
167-
echo ""
168-
echo "🔍 DEBUG: Downloaded artifacts:"
169-
ls -la test-results/ || echo "No test-results directory found"
170-
echo ""
171-
echo "🔍 DEBUG: Artifact contents:"
172-
find test-results/ -type f -name "*.log" || echo "No log files found"
173-
echo ""
174-
175186
# Initialize counters
176187
total_tutorials=0
177188
passed_tutorials=0
@@ -184,27 +195,31 @@ jobs:
184195
echo "## 📊 Overall Results" >> $GITHUB_STEP_SUMMARY
185196
echo "" >> $GITHUB_STEP_SUMMARY
186197
187-
# Process each tutorial result
188-
for tutorial_dir in test-results/test-results-*/; do
189-
if [ -d "$tutorial_dir" ]; then
190-
# Extract sanitized name and convert back to original tutorial path
191-
sanitized_name=$(basename "$tutorial_dir" | sed 's/test-results-//')
192-
tutorial_name=$(echo "$sanitized_name" | sed 's/-/\//g')
193-
total_tutorials=$((total_tutorials + 1))
194-
195-
# Check if there are any log files in this directory
196-
if find "$tutorial_dir" -name "*.log" -type f | grep -q .; then
197-
# Determine success/failure based on pytest-specific failure patterns
198-
if find "$tutorial_dir" -name "*.log" -exec grep -l "FAILED.*::" {} \; | head -1 >/dev/null || \
199-
find "$tutorial_dir" -name "*.log" -exec grep -l "=== FAILURES ===" {} \; | head -1 >/dev/null || \
200-
find "$tutorial_dir" -name "*.log" -exec grep -l "AssertionError" {} \; | head -1 >/dev/null; then
201-
failed_tutorials=$((failed_tutorials + 1))
202-
failed_tests+=("$tutorial_name")
203-
else
204-
passed_tutorials=$((passed_tutorials + 1))
205-
passed_tests+=("$tutorial_name")
206-
fi
198+
# Process each tutorial and check its status file
199+
echo "$tutorials" | jq -r '.[]' | while read -r tutorial_name; do
200+
total_tutorials=$((total_tutorials + 1))
201+
202+
# Convert tutorial name to sanitized format
203+
sanitized_name=$(echo "$tutorial_name" | sed 's/\//-/g')
204+
tutorial_dir="test-results/test-results-$sanitized_name"
205+
status_file="$tutorial_dir/test-status-$sanitized_name.txt"
206+
207+
if [ -f "$status_file" ]; then
208+
exit_code=$(cat "$status_file")
209+
if [ "$exit_code" = "0" ]; then
210+
passed_tutorials=$((passed_tutorials + 1))
211+
passed_tests+=("$tutorial_name")
212+
echo "✅ $tutorial_name: PASSED (exit code: $exit_code)"
213+
else
214+
failed_tutorials=$((failed_tutorials + 1))
215+
failed_tests+=("$tutorial_name")
216+
echo "❌ $tutorial_name: FAILED (exit code: $exit_code)"
207217
fi
218+
else
219+
# No status file found, assume failed
220+
failed_tutorials=$((failed_tutorials + 1))
221+
failed_tests+=("$tutorial_name")
222+
echo "❌ $tutorial_name: FAILED (no status file)"
208223
fi
209224
done
210225
@@ -226,35 +241,26 @@ jobs:
226241
echo "" >> $GITHUB_STEP_SUMMARY
227242
fi
228243
229-
# Show pytest failures only for failed tests
244+
# Show test output for failed tests
230245
if [ $failed_tutorials -gt 0 ]; then
231246
echo "## ❌ Failed Tutorials ($failed_tutorials)" >> $GITHUB_STEP_SUMMARY
232247
echo "" >> $GITHUB_STEP_SUMMARY
233248
echo '```' >> $GITHUB_STEP_SUMMARY
234249
235-
# Extract and append pytest failures from each failed test
250+
# Show the full output for each failed test
236251
for test in "${failed_tests[@]}"; do
237-
# Find the log file for this test (convert back to sanitized name)
238252
sanitized_test_name=$(echo "$test" | sed 's/\//-/g')
239-
log_file=$(find "test-results/test-results-$sanitized_test_name" -name "*.log" | head -1)
240-
if [ -f "$log_file" ]; then
253+
output_file="test-results/test-results-$sanitized_test_name/test-output-$sanitized_test_name.txt"
254+
255+
if [ -f "$output_file" ]; then
241256
echo "================================================================================================" >> $GITHUB_STEP_SUMMARY
242257
echo "FAILED: $test" >> $GITHUB_STEP_SUMMARY
243258
echo "================================================================================================" >> $GITHUB_STEP_SUMMARY
244-
245-
# Extract pytest output between the delimiters, or show pytest summary if no delimiters
246-
if grep -q "========== PYTEST OUTPUT ==========" "$log_file"; then
247-
sed -n '/========== PYTEST OUTPUT ==========/,/========== END PYTEST OUTPUT ==========/p' "$log_file" | \
248-
sed '1d;$d' >> $GITHUB_STEP_SUMMARY
249-
else
250-
# If no delimiters, try to extract pytest-related lines
251-
grep -E "(FAILED|ERROR|AssertionError|collected.*items|=====.*=====|::.*FAILED)" "$log_file" >> $GITHUB_STEP_SUMMARY || \
252-
echo "No pytest output found in log file" >> $GITHUB_STEP_SUMMARY
253-
fi
259+
cat "$output_file" >> $GITHUB_STEP_SUMMARY
254260
echo "" >> $GITHUB_STEP_SUMMARY
255261
else
256262
echo "================================================================================================" >> $GITHUB_STEP_SUMMARY
257-
echo "FAILED: $test (No log file found)" >> $GITHUB_STEP_SUMMARY
263+
echo "FAILED: $test (No output file found)" >> $GITHUB_STEP_SUMMARY
258264
echo "================================================================================================" >> $GITHUB_STEP_SUMMARY
259265
echo "" >> $GITHUB_STEP_SUMMARY
260266
fi

examples/tutorials/10_agentic/00_base/040_other_sdks/tests/test_agent.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def test_send_event_and_poll_simple_query(self, client: AsyncAgentex, agen
114114
break
115115

116116
# Verify state has been updated by polling the states for 10 seconds
117-
for i in range(10):
117+
for i in range(20):
118118
if i == 9:
119119
raise Exception("Timeout waiting for state updates")
120120
states = await client.states.list(agent_id=agent_id, task_id=task.id)
@@ -187,7 +187,12 @@ async def test_multi_turn_conversation_with_state(self, client: AsyncAgentex, ag
187187
sleep_interval=1.0,
188188
):
189189
assert isinstance(message, TaskMessage)
190-
if message.content and message.content.type == "text" and message.content.author == "agent" and message.content.content:
190+
if (
191+
message.content
192+
and message.content.type == "text"
193+
and message.content.author == "agent"
194+
and message.content.content
195+
):
191196
break
192197

193198
## keep polling the states for 10 seconds for the input_list and turn_number to be updated
@@ -216,7 +221,12 @@ async def test_multi_turn_conversation_with_state(self, client: AsyncAgentex, ag
216221
timeout=30,
217222
sleep_interval=1.0,
218223
):
219-
if message.content and message.content.type == "text" and message.content.author == "agent" and message.content.content:
224+
if (
225+
message.content
226+
and message.content.type == "text"
227+
and message.content.author == "agent"
228+
and message.content.content
229+
):
220230
response_text = message.content.content.lower()
221231
assert "blue" in response_text
222232
found_response = True
@@ -273,7 +283,10 @@ async def stream_messages() -> None:
273283
# For full messages, content is at the top level
274284
# For delta messages, we need to check parent_task_message
275285
if msg_type == "full":
276-
if event.get("content", {}).get("type") == "text" and event.get("content", {}).get("author") == "user":
286+
if (
287+
event.get("content", {}).get("type") == "text"
288+
and event.get("content", {}).get("author") == "user"
289+
):
277290
user_message_found = True
278291
elif msg_type == "done":
279292
break

examples/tutorials/run_agent_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ run_test() {
263263

264264

265265
# Run the tests with retry mechanism
266-
local max_retries=3
266+
local max_retries=5
267267
local retry_count=0
268268
local exit_code=1
269269

0 commit comments

Comments
 (0)