Skip to content

Commit 95401c0

Browse files
committed
testing this
1 parent cebe84d commit 95401c0

File tree

2 files changed

+100
-40
lines changed

2 files changed

+100
-40
lines changed

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

Lines changed: 76 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,21 @@ jobs:
1616
id: get-tutorials
1717
run: |
1818
cd examples/tutorials
19-
tutorials=$(find . -name "manifest.yaml" -exec dirname {} \; | sort | sed 's|^\./||' | jq -R -s -c 'split("\n") | map(select(length > 0))')
19+
# Find all tutorials and exclude specific temporal ones
20+
all_tutorials=$(find . -name "manifest.yaml" -exec dirname {} \; | sort | sed 's|^\./||')
21+
22+
# 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_)")
24+
25+
# Convert to JSON array
26+
tutorials=$(echo "$filtered_tutorials" | jq -R -s -c 'split("\n") | map(select(length > 0))')
27+
2028
echo "tutorials=$tutorials" >> $GITHUB_OUTPUT
21-
echo "Found tutorials: $tutorials"
29+
echo "All tutorials found: $(echo "$all_tutorials" | wc -l)"
30+
echo "Filtered tutorials: $(echo "$filtered_tutorials" | wc -l)"
31+
echo "Excluded tutorials:"
32+
echo "$all_tutorials" | grep -E "(10_temporal/050_|10_temporal/070_|10_temporal/080_)" || echo " (none matched exclusion pattern)"
33+
echo "Final tutorial list: $tutorials"
2234
2335
test-tutorial:
2436
needs: find-tutorials
@@ -101,19 +113,32 @@ jobs:
101113
working-directory: ./examples/tutorials
102114
env:
103115
OPENAI_API_KEY: ${{ secrets.TUTORIAL_OPENAI_API_KEY }}
104-
HEALTH_CHECK_PORT: 8080 # Use non-privileged port for temporal worker health checks
116+
HEALTH_CHECK_PORT: 8080 # Use non-privileged port for temporal worker health checks
105117
run: |
106118
echo "Testing tutorial: ${{ matrix.tutorial }}"
107119
AGENTEX_API_BASE_URL="http://localhost:5003" \
108120
./run_agent_test.sh --build-cli "${{ matrix.tutorial }}"
109121
110122
- name: Upload Test Results
123+
if: always()
124+
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
111137
if: always()
112138
uses: actions/upload-artifact@v4
113139
with:
114-
name: test-results-${{ replace(matrix.tutorial, '/', '-') }}
115-
path: |
116-
/tmp/agentex-*.log
140+
name: ${{ env.artifact-name }}
141+
path: test-results-*
117142
retention-days: 1
118143

119144
test-summary:
@@ -136,6 +161,17 @@ jobs:
136161
# Get tutorial list from needs context
137162
tutorials='${{ needs.find-tutorials.outputs.tutorials }}'
138163
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+
139175
# Initialize counters
140176
total_tutorials=0
141177
passed_tutorials=0
@@ -156,13 +192,18 @@ jobs:
156192
tutorial_name=$(echo "$sanitized_name" | sed 's/-/\//g')
157193
total_tutorials=$((total_tutorials + 1))
158194
159-
# Determine success/failure based on presence of error logs or patterns
160-
if find "$tutorial_dir" -name "*.log" -exec grep -l "FAILED\|ERROR\|Traceback" {} \; | head -1 >/dev/null; then
161-
failed_tutorials=$((failed_tutorials + 1))
162-
failed_tests+=("$tutorial_name")
163-
else
164-
passed_tutorials=$((passed_tutorials + 1))
165-
passed_tests+=("$tutorial_name")
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
166207
fi
167208
fi
168209
done
@@ -185,42 +226,42 @@ jobs:
185226
echo "" >> $GITHUB_STEP_SUMMARY
186227
fi
187228
188-
# Show failed tests with details
229+
# Show pytest failures only for failed tests
189230
if [ $failed_tutorials -gt 0 ]; then
190231
echo "## ❌ Failed Tutorials ($failed_tutorials)" >> $GITHUB_STEP_SUMMARY
191232
echo "" >> $GITHUB_STEP_SUMMARY
233+
echo '```' >> $GITHUB_STEP_SUMMARY
192234
235+
# Extract and append pytest failures from each failed test
193236
for test in "${failed_tests[@]}"; do
194-
echo "### 🔍 \`$test\`" >> $GITHUB_STEP_SUMMARY
195-
echo "" >> $GITHUB_STEP_SUMMARY
196-
197237
# Find the log file for this test (convert back to sanitized name)
198238
sanitized_test_name=$(echo "$test" | sed 's/\//-/g')
199239
log_file=$(find "test-results/test-results-$sanitized_test_name" -name "*.log" | head -1)
200240
if [ -f "$log_file" ]; then
201-
# Extract pytest failures
202-
if grep -q "FAILED\|ERROR" "$log_file"; then
203-
echo "**Failed Tests:**" >> $GITHUB_STEP_SUMMARY
204-
echo '```' >> $GITHUB_STEP_SUMMARY
205-
grep -A 5 -B 1 "FAILED\|ERROR" "$log_file" | head -20 >> $GITHUB_STEP_SUMMARY
206-
echo '```' >> $GITHUB_STEP_SUMMARY
207-
echo "" >> $GITHUB_STEP_SUMMARY
208-
fi
209-
210-
# Show any Python tracebacks
211-
if grep -q "Traceback" "$log_file"; then
212-
echo "**Error Details:**" >> $GITHUB_STEP_SUMMARY
213-
echo '```' >> $GITHUB_STEP_SUMMARY
214-
# Get the last traceback in the file
215-
awk '/Traceback \(most recent call last\)/{p=1} p{print} /^[^ ]/ && p && !/Traceback/{p=0}' "$log_file" | tail -20 >> $GITHUB_STEP_SUMMARY
216-
echo '```' >> $GITHUB_STEP_SUMMARY
217-
echo "" >> $GITHUB_STEP_SUMMARY
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
218253
fi
254+
echo "" >> $GITHUB_STEP_SUMMARY
219255
else
220-
echo "_No log file found for detailed error analysis_" >> $GITHUB_STEP_SUMMARY
256+
echo "================================================================================================" >> $GITHUB_STEP_SUMMARY
257+
echo "FAILED: $test (No log file found)" >> $GITHUB_STEP_SUMMARY
258+
echo "================================================================================================" >> $GITHUB_STEP_SUMMARY
221259
echo "" >> $GITHUB_STEP_SUMMARY
222260
fi
223261
done
262+
263+
echo '```' >> $GITHUB_STEP_SUMMARY
264+
echo "" >> $GITHUB_STEP_SUMMARY
224265
fi
225266
226267
# Set exit code based on results

examples/tutorials/10_agentic/10_temporal/010_agent_chat/tests/test_agent.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ async def test_multi_turn_conversation(self, client: AsyncAgentex, agent_id: str
160160
sleep_interval=1.0,
161161
):
162162
assert isinstance(message, TaskMessage)
163-
if message.content and message.content.type == "text" and message.content.author == "agent" and message.content.content:
163+
if (
164+
message.content
165+
and message.content.type == "text"
166+
and message.content.author == "agent"
167+
and message.content.content
168+
):
164169
break
165170

166171
# Wait a bit for state to update
@@ -177,7 +182,12 @@ async def test_multi_turn_conversation(self, client: AsyncAgentex, agent_id: str
177182
timeout=30,
178183
sleep_interval=1.0,
179184
):
180-
if message.content and message.content.type == "text" and message.content.author == "agent" and message.content.content:
185+
if (
186+
message.content
187+
and message.content.type == "text"
188+
and message.content.author == "agent"
189+
and message.content.content
190+
):
181191
response_text = message.content.content.lower()
182192
assert "blue" in response_text, f"Expected 'blue' in response but got: {response_text}"
183193
found_response = True
@@ -211,16 +221,24 @@ async def stream_messages() -> None: # noqa: ANN101
211221
async for event in stream_agent_response(
212222
client=client,
213223
task_id=task.id,
214-
timeout=20,
224+
timeout=60,
215225
):
216226
msg_type = event.get("type")
217227
if msg_type == "full":
218228
task_message_update = StreamTaskMessageFull.model_validate(event)
219229
if task_message_update.parent_task_message and task_message_update.parent_task_message.id:
220230
finished_message = await client.messages.retrieve(task_message_update.parent_task_message.id)
221-
if finished_message.content and finished_message.content.type == "text" and finished_message.content.author == "user":
231+
if (
232+
finished_message.content
233+
and finished_message.content.type == "text"
234+
and finished_message.content.author == "user"
235+
):
222236
user_message_found = True
223-
elif finished_message.content and finished_message.content.type == "text" and finished_message.content.author == "agent":
237+
elif (
238+
finished_message.content
239+
and finished_message.content.type == "text"
240+
and finished_message.content.author == "agent"
241+
):
224242
agent_response_found = True
225243
elif finished_message.content and finished_message.content.type == "reasoning":
226244
tool_response_found = True
@@ -243,5 +261,6 @@ async def stream_messages() -> None: # noqa: ANN101
243261
assert user_message_found, "User message not found in stream"
244262
assert agent_response_found, "Agent response not found in stream"
245263

264+
246265
if __name__ == "__main__":
247266
pytest.main([__file__, "-v"])

0 commit comments

Comments
 (0)