Skip to content

Commit 626bdf1

Browse files
committed
Fixing PR comment
1 parent 514b5c0 commit 626bdf1

File tree

1 file changed

+118
-47
lines changed

1 file changed

+118
-47
lines changed

.github/workflows/validation-tests.yml

Lines changed: 118 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,38 @@ jobs:
4444
if: always()
4545
working-directory: ./libraryValidations/Dotnet
4646
run: |
47+
echo "=== Listing all files in current directory ==="
48+
find . -type f -name "*.trx" -o -name "*.xml" -o -name "*.log" | head -20
49+
echo "=========================================="
50+
4751
echo 'results<<EOF' >> $GITHUB_OUTPUT
48-
if [ -f "TestResults/test-results.trx" ]; then
49-
# Extract test results from TRX file
50-
python3 << 'PYTHON'
52+
TRX_FILE=$(find . -name "*.trx" -type f 2>/dev/null | head -1)
53+
if [ ! -z "$TRX_FILE" ]; then
54+
echo "Found TRX file: $TRX_FILE"
55+
export TRX_FILE
56+
python3 <<'PYTHON'
5157
import xml.etree.ElementTree as ET
5258
import json
59+
import os
5360
54-
tree = ET.parse('TestResults/test-results.trx')
55-
root = tree.getroot()
56-
ns = {'ns': 'http://microsoft.com/schemas/VisualStudio/TeamTest/2010'}
57-
58-
results = {}
59-
for test in root.findall('.//ns:UnitTestResult', ns):
60-
test_name = test.get('testName')
61-
outcome = test.get('outcome')
62-
results[test_name] = '✅' if outcome == 'Passed' else '❌'
63-
64-
print(json.dumps(results))
61+
trx_file = os.environ.get('TRX_FILE')
62+
if trx_file:
63+
tree = ET.parse(trx_file)
64+
root = tree.getroot()
65+
ns = {'ns': 'http://microsoft.com/schemas/VisualStudio/TeamTest/2010'}
66+
67+
results = {}
68+
for test in root.findall('.//ns:UnitTestResult', ns):
69+
test_name = test.get('testName')
70+
outcome = test.get('outcome')
71+
results[test_name] = '✅' if outcome == 'Passed' else '❌'
72+
73+
print(json.dumps(results))
74+
else:
75+
print("{}")
6576
PYTHON
6677
else
78+
echo "No TRX file found"
6779
echo "{}"
6880
fi
6981
echo 'EOF' >> $GITHUB_OUTPUT
@@ -103,25 +115,29 @@ jobs:
103115
if: always()
104116
working-directory: ./libraryValidations/Python
105117
run: |
118+
echo "=== Listing Python test output files ==="
119+
ls -la *.xml 2>/dev/null || echo "No XML files found"
120+
echo "=========================================="
121+
106122
echo 'results<<EOF' >> $GITHUB_OUTPUT
107-
python3 << 'PYTHON'
123+
python3 <<'PYTHON'
108124
import xml.etree.ElementTree as ET
109125
import json
110126
import os
111127
112128
results = {}
113129
for xml_file in ['results.xml', 'results_provider.xml']:
114130
if os.path.exists(xml_file):
131+
print(f"Parsing {xml_file}", flush=True)
115132
tree = ET.parse(xml_file)
116133
root = tree.getroot()
117134
118135
for testcase in root.findall('.//testcase'):
119136
test_name = testcase.get('name')
120-
# Check if test failed
121137
failed = testcase.find('failure') is not None or testcase.find('error') is not None
122138
results[test_name] = '❌' if failed else '✅'
123139
124-
print(json.dumps(results))
140+
print(json.dumps(results), flush=True)
125141
PYTHON
126142
echo 'EOF' >> $GITHUB_OUTPUT
127143
@@ -164,25 +180,40 @@ jobs:
164180
if: always()
165181
working-directory: ./libraryValidations/JavaScript
166182
run: |
183+
echo "=== Listing JavaScript test output files ==="
184+
ls -la *.xml 2>/dev/null || echo "No XML files found"
185+
ls -la junit.xml 2>/dev/null || echo "No junit.xml found"
186+
find . -name "*.xml" -type f | head -10
187+
echo "=========================================="
188+
167189
echo 'results<<EOF' >> $GITHUB_OUTPUT
168-
if [ -f "results.xml" ]; then
169-
python3 << 'PYTHON'
190+
if [ -f "results.xml" ] || [ -f "junit.xml" ]; then
191+
XML_FILE=$([ -f "results.xml" ] && echo "results.xml" || echo "junit.xml")
192+
echo "Parsing JavaScript $XML_FILE"
193+
python3 <<'PYTHON'
170194
import xml.etree.ElementTree as ET
171195
import json
196+
import os
172197
173-
tree = ET.parse('results.xml')
174-
root = tree.getroot()
198+
# Try both possible filenames
199+
xml_file = 'results.xml' if os.path.exists('results.xml') else 'junit.xml'
175200
176-
results = {}
177-
for testcase in root.findall('.//testcase'):
178-
test_name = testcase.get('name')
179-
# Check if test failed
180-
failed = testcase.find('failure') is not None or testcase.find('error') is not None
181-
results[test_name] = '❌' if failed else '✅'
182-
183-
print(json.dumps(results))
201+
if os.path.exists(xml_file):
202+
tree = ET.parse(xml_file)
203+
root = tree.getroot()
204+
205+
results = {}
206+
for testcase in root.findall('.//testcase'):
207+
test_name = testcase.get('name')
208+
failed = testcase.find('failure') is not None or testcase.find('error') is not None
209+
results[test_name] = '❌' if failed else '✅'
210+
211+
print(json.dumps(results), flush=True)
212+
else:
213+
print("{}")
184214
PYTHON
185215
else
216+
echo "No JavaScript results.xml found"
186217
echo "{}"
187218
fi
188219
echo 'EOF' >> $GITHUB_OUTPUT
@@ -214,8 +245,13 @@ jobs:
214245
if: always()
215246
working-directory: ./libraryValidations/Spring/validation-tests
216247
run: |
248+
echo "=== Listing Spring test output files ==="
249+
ls -la target/surefire-reports/ 2>/dev/null || echo "No surefire-reports directory"
250+
find target -name "*.xml" -type f 2>/dev/null | head -10
251+
echo "=========================================="
252+
217253
echo 'results<<EOF' >> $GITHUB_OUTPUT
218-
python3 << 'PYTHON'
254+
python3 <<'PYTHON'
219255
import xml.etree.ElementTree as ET
220256
import json
221257
import os
@@ -224,17 +260,19 @@ jobs:
224260
results = {}
225261
xml_files = glob.glob('target/surefire-reports/TEST-*.xml')
226262
263+
print(f"Found {len(xml_files)} Spring test result files", flush=True)
264+
227265
for xml_file in xml_files:
266+
print(f"Parsing {xml_file}", flush=True)
228267
tree = ET.parse(xml_file)
229268
root = tree.getroot()
230269
231270
for testcase in root.findall('.//testcase'):
232271
test_name = testcase.get('name')
233-
# Check if test failed
234272
failed = testcase.find('failure') is not None or testcase.find('error') is not None
235273
results[test_name] = '❌' if failed else '✅'
236274
237-
print(json.dumps(results))
275+
print(json.dumps(results), flush=True)
238276
PYTHON
239277
echo 'EOF' >> $GITHUB_OUTPUT
240278
@@ -249,17 +287,44 @@ jobs:
249287

250288
- name: Generate test matrix
251289
id: matrix
290+
env:
291+
DOTNET_RESULTS: ${{ needs.dotnet-tests.outputs.results }}
292+
PYTHON_RESULTS: ${{ needs.python-tests.outputs.results }}
293+
JAVASCRIPT_RESULTS: ${{ needs.javascript-tests.outputs.results }}
294+
SPRING_RESULTS: ${{ needs.spring-tests.outputs.results }}
252295
run: |
253-
python3 << 'PYTHON'
296+
python3 <<'PYTHON'
254297
import json
255298
import os
256-
import glob
299+
300+
# Debug: print raw results
301+
print("=== Debug: Raw Results ===")
302+
print(f"DOTNET: {os.environ.get('DOTNET_RESULTS', 'EMPTY')}")
303+
print(f"PYTHON: {os.environ.get('PYTHON_RESULTS', 'EMPTY')}")
304+
print(f"JAVASCRIPT: {os.environ.get('JAVASCRIPT_RESULTS', 'EMPTY')}")
305+
print(f"SPRING: {os.environ.get('SPRING_RESULTS', 'EMPTY')}")
306+
print("========================\n")
257307
258308
# Parse results from each language
259-
dotnet_results = json.loads('''${{ needs.dotnet-tests.outputs.results }}''') if '${{ needs.dotnet-tests.outputs.results }}' else {}
260-
python_results = json.loads('''${{ needs.python-tests.outputs.results }}''') if '${{ needs.python-tests.outputs.results }}' else {}
261-
javascript_results = json.loads('''${{ needs.javascript-tests.outputs.results }}''') if '${{ needs.javascript-tests.outputs.results }}' else {}
262-
spring_results = json.loads('''${{ needs.spring-tests.outputs.results }}''') if '${{ needs.spring-tests.outputs.results }}' else {}
309+
try:
310+
dotnet_results = json.loads(os.environ.get('DOTNET_RESULTS', '{}'))
311+
except:
312+
dotnet_results = {}
313+
314+
try:
315+
python_results = json.loads(os.environ.get('PYTHON_RESULTS', '{}'))
316+
except:
317+
python_results = {}
318+
319+
try:
320+
javascript_results = json.loads(os.environ.get('JAVASCRIPT_RESULTS', '{}'))
321+
except:
322+
javascript_results = {}
323+
324+
try:
325+
spring_results = json.loads(os.environ.get('SPRING_RESULTS', '{}'))
326+
except:
327+
spring_results = {}
263328
264329
# Collect all unique test names across all languages
265330
all_tests = set()
@@ -271,20 +336,26 @@ jobs:
271336
# Sort tests for consistent output
272337
sorted_tests = sorted(all_tests)
273338
339+
print(f"Found {len(sorted_tests)} unique tests")
340+
274341
# Generate markdown table
275342
with open('summary.md', 'w') as f:
276343
f.write("## 🧪 Validation Test Results\n\n")
277-
f.write("| Test Name | .NET | Python | JavaScript | Spring |\n")
278-
f.write("|-----------|------|--------|------------|--------|\n")
279344
280-
for test in sorted_tests:
281-
# Get result for each language, default to ⚠️ if not found
282-
dotnet = dotnet_results.get(test, '⚠️')
283-
python = python_results.get(test, '⚠️')
284-
javascript = javascript_results.get(test, '⚠️')
285-
spring = spring_results.get(test, '⚠️')
345+
if not sorted_tests:
346+
f.write("⚠️ No test results found. Check individual job outputs for details.\n\n")
347+
else:
348+
f.write("| Test Name | .NET | Python | JavaScript | Spring |\n")
349+
f.write("|-----------|------|--------|------------|--------|\n")
286350
287-
f.write(f"| {test} | {dotnet} | {python} | {javascript} | {spring} |\n")
351+
for test in sorted_tests:
352+
# Get result for each language, default to ⚠️ if not found
353+
dotnet = dotnet_results.get(test, '⚠️')
354+
python = python_results.get(test, '⚠️')
355+
javascript = javascript_results.get(test, '⚠️')
356+
spring = spring_results.get(test, '⚠️')
357+
358+
f.write(f"| {test} | {dotnet} | {python} | {javascript} | {spring} |\n")
288359
289360
f.write(f"\n_Workflow run: ${{ github.run_id }}_\n")
290361

0 commit comments

Comments
 (0)