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
0 commit comments