Skip to content

Commit dc04e1a

Browse files
committed
cleaning up
1 parent 95401c0 commit dc04e1a

File tree

3 files changed

+73
-101
lines changed

3 files changed

+73
-101
lines changed

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

Lines changed: 55 additions & 96 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))')
@@ -119,40 +119,22 @@ jobs:
119119
AGENTEX_API_BASE_URL="http://localhost:5003" \
120120
./run_agent_test.sh --build-cli "${{ matrix.tutorial }}"
121121
122-
- name: Upload Test Results
122+
- name: Record test result
123+
id: test-result
123124
if: always()
124125
run: |
125-
# Sanitize tutorial name for artifact upload
126-
SANITIZED_NAME=$(echo "${{ matrix.tutorial }}" | sed 's/\//-/g')
127-
echo "Uploading test results for: ${{ matrix.tutorial }} (as: test-results-$SANITIZED_NAME)"
128-
129-
# Create a temporary directory with the sanitized name
130-
mkdir -p "test-results-$SANITIZED_NAME"
131-
cp /tmp/agentex-*.log "test-results-$SANITIZED_NAME/" 2>/dev/null || echo "No log files to copy"
132-
133-
# Upload using the actions/upload-artifact action
134-
echo "artifact-name=test-results-$SANITIZED_NAME" >> $GITHUB_ENV
135-
136-
- name: Upload Artifact
137-
if: always()
138-
uses: actions/upload-artifact@v4
139-
with:
140-
name: ${{ env.artifact-name }}
141-
path: test-results-*
142-
retention-days: 1
126+
if [ "${{ steps.run-test.outcome }}" == "success" ]; then
127+
echo "result=passed" >> $GITHUB_OUTPUT
128+
else
129+
echo "result=failed" >> $GITHUB_OUTPUT
130+
fi
143131
144132
test-summary:
145133
if: always()
146134
needs: [find-tutorials, test-tutorial]
147135
runs-on: ubuntu-latest
148136
name: Test Summary
149137
steps:
150-
- name: Download All Test Results
151-
uses: actions/download-artifact@v4
152-
with:
153-
path: test-results
154-
pattern: test-results-*
155-
156138
- name: Generate Test Summary
157139
run: |
158140
echo "# 🧪 Tutorial Tests Summary" >> $GITHUB_STEP_SUMMARY
@@ -161,53 +143,52 @@ jobs:
161143
# Get tutorial list from needs context
162144
tutorials='${{ needs.find-tutorials.outputs.tutorials }}'
163145
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 ""
146+
# Fetch workflow run jobs to get individual test results
147+
jobs_json=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
148+
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs")
174149
175150
# Initialize counters
176151
total_tutorials=0
177152
passed_tutorials=0
178153
failed_tutorials=0
179154
180-
# Arrays to track results
181-
passed_tests=()
182-
failed_tests=()
183-
184155
echo "## 📊 Overall Results" >> $GITHUB_STEP_SUMMARY
185156
echo "" >> $GITHUB_STEP_SUMMARY
186157
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
207-
fi
158+
# Create temporary files for passed and failed tests
159+
> /tmp/passed_tests.txt
160+
> /tmp/failed_tests.txt
161+
162+
# Process each tutorial
163+
echo "$tutorials" | jq -r '.[]' | while read -r tutorial_name; do
164+
if [ -z "$tutorial_name" ]; then
165+
continue
166+
fi
167+
168+
total_tutorials=$((total_tutorials + 1))
169+
170+
# Find the job for this tutorial
171+
job_name="test-$tutorial_name"
172+
job_conclusion=$(echo "$jobs_json" | jq -r ".jobs[] | select(.name == \"$job_name\") | .conclusion")
173+
174+
if [ "$job_conclusion" == "success" ]; then
175+
passed_tutorials=$((passed_tutorials + 1))
176+
echo "$tutorial_name" >> /tmp/passed_tests.txt
177+
echo "✅ $tutorial_name: PASSED"
178+
else
179+
failed_tutorials=$((failed_tutorials + 1))
180+
echo "$tutorial_name" >> /tmp/failed_tests.txt
181+
echo "❌ $tutorial_name: FAILED (conclusion: $job_conclusion)"
208182
fi
209183
done
210184
185+
# Read the final counts (since the while loop runs in a subshell)
186+
passed_tutorials=$(wc -l < /tmp/passed_tests.txt | tr -d ' ')
187+
failed_tutorials=$(wc -l < /tmp/failed_tests.txt | tr -d ' ')
188+
total_tutorials=$((passed_tutorials + failed_tutorials))
189+
190+
echo "Final counts: total=$total_tutorials, passed=$passed_tutorials, failed=$failed_tutorials"
191+
211192
# Show summary stats
212193
echo "| Status | Count |" >> $GITHUB_STEP_SUMMARY
213194
echo "|--------|-------|" >> $GITHUB_STEP_SUMMARY
@@ -220,53 +201,31 @@ jobs:
220201
if [ $passed_tutorials -gt 0 ]; then
221202
echo "## ✅ Passed Tutorials ($passed_tutorials)" >> $GITHUB_STEP_SUMMARY
222203
echo "" >> $GITHUB_STEP_SUMMARY
223-
for test in "${passed_tests[@]}"; do
224-
echo "- ✅ \`$test\`" >> $GITHUB_STEP_SUMMARY
225-
done
204+
while read -r test; do
205+
if [ -n "$test" ]; then
206+
echo "- ✅ \`$test\`" >> $GITHUB_STEP_SUMMARY
207+
fi
208+
done < /tmp/passed_tests.txt
226209
echo "" >> $GITHUB_STEP_SUMMARY
227210
fi
228211
229-
# Show pytest failures only for failed tests
212+
# Show failed tests
230213
if [ $failed_tutorials -gt 0 ]; then
231214
echo "## ❌ Failed Tutorials ($failed_tutorials)" >> $GITHUB_STEP_SUMMARY
232215
echo "" >> $GITHUB_STEP_SUMMARY
233-
echo '```' >> $GITHUB_STEP_SUMMARY
234-
235-
# Extract and append pytest failures from each failed test
236-
for test in "${failed_tests[@]}"; do
237-
# Find the log file for this test (convert back to sanitized name)
238-
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
241-
echo "================================================================================================" >> $GITHUB_STEP_SUMMARY
242-
echo "FAILED: $test" >> $GITHUB_STEP_SUMMARY
243-
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
254-
echo "" >> $GITHUB_STEP_SUMMARY
255-
else
256-
echo "================================================================================================" >> $GITHUB_STEP_SUMMARY
257-
echo "FAILED: $test (No log file found)" >> $GITHUB_STEP_SUMMARY
258-
echo "================================================================================================" >> $GITHUB_STEP_SUMMARY
259-
echo "" >> $GITHUB_STEP_SUMMARY
216+
echo "Check the individual job logs for failure details." >> $GITHUB_STEP_SUMMARY
217+
echo "" >> $GITHUB_STEP_SUMMARY
218+
while read -r test; do
219+
if [ -n "$test" ]; then
220+
echo "- ❌ \`$test\`" >> $GITHUB_STEP_SUMMARY
260221
fi
261-
done
262-
263-
echo '```' >> $GITHUB_STEP_SUMMARY
222+
done < /tmp/failed_tests.txt
264223
echo "" >> $GITHUB_STEP_SUMMARY
265224
fi
266225
267226
# Set exit code based on results
268227
if [ $failed_tutorials -gt 0 ]; then
269-
echo "❌ Some tutorials failed. Check the details above." >> $GITHUB_STEP_SUMMARY
228+
echo "❌ Some tutorials failed. Check the individual job logs for details." >> $GITHUB_STEP_SUMMARY
270229
exit 1
271230
else
272231
echo "🎉 All tutorials passed successfully!" >> $GITHUB_STEP_SUMMARY

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)