@@ -30,35 +30,88 @@ jobs:
3030 run : |
3131 echo "Testing responses-basic-aoai-v1.py script..."
3232
33+ # Create test results directory
34+ mkdir -p test-results
35+
36+ # Get current timestamp
37+ timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
38+ echo "Test run timestamp: $timestamp"
39+
3340 # Run the script and capture output
3441 python responses-basic-aoai-v1.py > output.txt 2>&1
3542 exit_code=$?
3643
44+ # Initialize test result variables
45+ pass_fail="PASS"
46+ error_code=""
47+ output_text=""
48+
3749 # Check if script executed successfully
3850 if [ $exit_code -eq 0 ]; then
3951 echo "✅ Script executed successfully"
52+
53+ # Check if output was generated and capture it
54+ if [ -s output.txt ]; then
55+ output_text=$(cat output.txt)
56+ echo "✅ Script produced output:"
57+ echo "$output_text"
58+
59+ # Test whether response.output_text contains a valid string
60+ # Valid means: non-empty, no error indicators, and actual content
61+ if [ -n "$output_text" ] && ! echo "$output_text" | grep -qi "error\|exception\|traceback\|failed\|none\|null"; then
62+ echo "✅ Output contains valid string content"
63+ pass_fail="PASS"
64+ else
65+ echo "❌ Output does not contain valid string content"
66+ pass_fail="FAIL"
67+ error_code="INVALID_OUTPUT"
68+ fi
69+ else
70+ echo "❌ Script produced no output"
71+ pass_fail="FAIL"
72+ error_code="NO_OUTPUT"
73+ fi
4074 else
4175 echo "❌ Script failed with exit code: $exit_code"
4276 echo "Error output:"
4377 cat output.txt
44- exit 1
78+ output_text=$(cat output.txt)
79+ pass_fail="FAIL"
80+ error_code="SCRIPT_ERROR_$exit_code"
4581 fi
4682
47- # Check if output was generated
48- if [ -s output.txt ]; then
49- echo "✅ Script produced output:"
50- cat output.txt
51-
52- # Basic validation that output is not empty and doesn't contain common error patterns
53- if grep -qi "error\|exception\|traceback\|failed" output.txt; then
54- echo "❌ Output contains error indicators"
55- exit 1
56- else
57- echo "✅ Output appears to be valid (no error indicators found)"
58- fi
59- else
60- echo "❌ Script produced no output"
83+ # Create test results JSON (using jq for proper JSON formatting)
84+ jq -n \
85+ --arg timestamp "$timestamp" \
86+ --arg output "$output_text" \
87+ --arg pass_fail "$pass_fail" \
88+ --arg error_code "$error_code" \
89+ '{
90+ test_last_run_date: $timestamp,
91+ output: $output,
92+ pass_fail: $pass_fail,
93+ error_code: $error_code
94+ }' > test-results/test-results.json
95+
96+ # Display final results
97+ echo "=== Test Results ==="
98+ echo "Timestamp: $timestamp"
99+ echo "Pass/Fail: $pass_fail"
100+ echo "Error Code: $error_code"
101+ echo "Output: $output_text"
102+
103+ # Exit with error if test failed
104+ if [ "$pass_fail" = "FAIL" ]; then
105+ echo "❌ Test failed"
61106 exit 1
107+ else
108+ echo "🎉 Test completed successfully!"
62109 fi
63110
64- echo "🎉 Test completed successfully!"
111+ - name : Upload test results artifact
112+ uses : actions/upload-artifact@v4
113+ if : always() # Upload artifact even if the test fails
114+ with :
115+ name : azure-openai-test-results
116+ path : test-results/
117+ retention-days : 30
0 commit comments