@@ -50,20 +50,128 @@ jobs:
5050 "host": "${{ secrets.SCM_HOST }}",
5151 "protocol": "${{ secrets.SCM_PROTOCOL }}",
5252 "scope": "${{ secrets.SCM_SCOPE }}",
53- "logging": "quiet ",
53+ "logging": "${{ secrets.SCM_LOGGING }} ",
5454 "skip_verify_certificate": ${{ secrets.SCM_SKIP_VERIFY_CERTIFICATE }}
5555 }
5656 EOF
5757
5858 - name : Run tests for ${{ matrix.service }}
5959 run : |
6060 set +e
61- output=$(go test -skip "LogicalRouters|Test_objects_ApplicationsAPIService_List" ./generated/${{ matrix.service }}/... 2>&1)
61+
62+ # Run tests with JSON output for parsing
63+ go test -timeout 60m -parallel 10 -v -json -skip "Test_objects_ApplicationsAPIService_List" ./generated/${{ matrix.service }}/... > test-output.json 2>&1
6264 exit_code=$?
6365
66+ # Parse JSON output and create summary with failure logs
67+ cat > parse_tests.py << 'PYTHON'
68+ import json
69+ import sys
70+
71+ passed = []
72+ failed = []
73+ skipped = []
74+ test_outputs = {} # Store output for each test
75+ current_test = None
76+
77+ with open('test-output.json', 'r') as f:
78+ for line in f:
79+ try:
80+ data = json.loads(line)
81+ action = data.get('Action')
82+ test_name = data.get('Test', '')
83+
84+ # Track current test for output collection
85+ if action == 'run' and test_name:
86+ current_test = test_name
87+ test_outputs[test_name] = []
88+
89+ # Collect output lines for tests
90+ if action == 'output' and current_test and 'Output' in data:
91+ output_line = data['Output'].rstrip()
92+ if output_line:
93+ test_outputs[current_test].append(output_line)
94+
95+ # Record test results
96+ if action == 'pass' and test_name:
97+ elapsed = data.get('Elapsed', 0)
98+ passed.append((test_name, elapsed))
99+ elif action == 'fail' and test_name:
100+ elapsed = data.get('Elapsed', 0)
101+ failed.append((test_name, elapsed))
102+ elif action == 'skip' and test_name:
103+ skipped.append(test_name)
104+ except:
105+ pass
106+
107+ # Print summary to console
108+ print(f"\n{'='*60}")
109+ print(f"Test Results: ${{ matrix.service }}")
110+ print(f"{'='*60}")
111+ print(f"✅ Passed: {len(passed)}")
112+ print(f"❌ Failed: {len(failed)}")
113+ print(f"⏭️ Skipped: {len(skipped)}")
114+ print(f"{'='*60}\n")
115+
116+ # Write to GITHUB_STEP_SUMMARY
117+ summary_file = sys.argv[1] if len(sys.argv) > 1 else '/dev/stdout'
118+ with open(summary_file, 'a') as f:
119+ f.write(f"## Test Results: ${{ matrix.service }}\n\n")
120+ f.write(f"**Summary:** {len(passed)} passed ✅, {len(failed)} failed ❌, {len(skipped)} skipped ⏭️\n\n")
121+
122+ if failed:
123+ f.write("### ❌ Failed Tests\n\n")
124+ for test, elapsed in failed:
125+ f.write(f"#### `{test}` ({elapsed:.2f}s)\n\n")
126+
127+ # Extract and display failure output
128+ if test in test_outputs:
129+ output = test_outputs[test]
130+ # Find relevant error messages
131+ error_lines = []
132+ for i, line in enumerate(output):
133+ # Capture lines with errors, failures, or important context
134+ if any(keyword in line for keyword in ['Error:', 'FAIL:', 'panic:', '504 Gateway Timeout', 'expected', 'actual']):
135+ # Include context (previous 2 lines and next 5 lines)
136+ start = max(0, i - 2)
137+ end = min(len(output), i + 6)
138+ error_lines.extend(output[start:end])
139+ break
140+
141+ if error_lines:
142+ f.write("<details>\n<summary>📋 Error Details</summary>\n\n")
143+ f.write("```\n")
144+ f.write('\n'.join(error_lines[-20:])) # Last 20 lines to avoid huge output
145+ f.write("\n```\n")
146+ f.write("</details>\n\n")
147+ else:
148+ f.write("_No detailed error output captured_\n\n")
149+
150+ f.write("---\n\n")
151+
152+ if passed:
153+ f.write("### ✅ Passed Tests\n\n")
154+ f.write("<details>\n<summary>Click to expand ({} tests)</summary>\n\n".format(len(passed)))
155+ f.write("| Test Name | Duration |\n")
156+ f.write("|-----------|----------|\n")
157+ for test, elapsed in passed:
158+ f.write(f"| `{test}` | {elapsed:.2f}s |\n")
159+ f.write("\n</details>\n\n")
160+
161+ if skipped:
162+ f.write("### ⏭️ Skipped Tests\n\n")
163+ f.write("<details>\n<summary>Click to expand ({} tests)</summary>\n\n".format(len(skipped)))
164+ f.write("| Test Name |\n")
165+ f.write("|-----------|\n")
166+ for test in skipped:
167+ f.write(f"| `{test}` |\n")
168+ f.write("\n</details>\n\n")
169+ PYTHON
170+
171+ python3 parse_tests.py "$GITHUB_STEP_SUMMARY"
172+
64173 if [ $exit_code -ne 0 ]; then
65174 echo "❌ Tests failed for ${{ matrix.service }}"
66- echo "$output" | grep -E "(FAIL|--- FAIL:|panic:|Error:)" || echo "$output"
67175 exit $exit_code
68176 else
69177 echo "✅ All tests passed for ${{ matrix.service }}"
0 commit comments