Skip to content

Commit 9c70074

Browse files
committed
Fixing PR comment
1 parent 514b5c0 commit 9c70074

1 file changed

Lines changed: 125 additions & 52 deletions

File tree

.github/workflows/validation-tests.yml

Lines changed: 125 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -37,33 +37,45 @@ jobs:
3737
id: test
3838
continue-on-error: true
3939
working-directory: ./libraryValidations/Dotnet
40-
run: dotnet test --logger "trx;LogFileName=test-results.trx" --logger "console;verbosity=detailed"
40+
run: dotnet test --logger trx --results-directory ./TestResults
4141

4242
- name: Parse .NET test results
4343
id: test-details
4444
if: always()
4545
working-directory: ./libraryValidations/Dotnet
4646
run: |
47+
echo "=== Listing all files in TestResults directory ==="
48+
find ./TestResults -type f 2>/dev/null || echo "No TestResults directory"
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 ./TestResults -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
@@ -152,37 +168,54 @@ jobs:
152168
id: test
153169
continue-on-error: true
154170
working-directory: ./libraryValidations/JavaScript
155-
env:
156-
JEST_JUNIT_OUTPUT_DIR: ./
157-
JEST_JUNIT_OUTPUT_NAME: results.xml
158171
run: |
159172
npm install --save-dev jest-junit
160-
npm run test -- --reporters=default --reporters=jest-junit || true
173+
npx jest --reporters=jest-junit --testResultsProcessor=jest-junit || true
161174
162175
- name: Parse JavaScript test results
163176
id: test-details
164177
if: always()
165178
working-directory: ./libraryValidations/JavaScript
166179
run: |
180+
echo "=== Listing JavaScript test output files ==="
181+
ls -la junit.xml 2>/dev/null || echo "No junit.xml found"
182+
find . -maxdepth 2 -name "*.xml" -type f 2>/dev/null | head -10
183+
echo "=========================================="
184+
167185
echo 'results<<EOF' >> $GITHUB_OUTPUT
168-
if [ -f "results.xml" ]; then
169-
python3 << 'PYTHON'
186+
XML_FILE=""
187+
if [ -f "junit.xml" ]; then
188+
XML_FILE="junit.xml"
189+
elif [ -f "test-results/junit.xml" ]; then
190+
XML_FILE="test-results/junit.xml"
191+
fi
192+
193+
if [ ! -z "$XML_FILE" ]; then
194+
echo "Parsing JavaScript $XML_FILE"
195+
export XML_FILE
196+
python3 <<'PYTHON'
170197
import xml.etree.ElementTree as ET
171198
import json
199+
import os
172200
173-
tree = ET.parse('results.xml')
174-
root = tree.getroot()
175-
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 '✅'
201+
xml_file = os.environ.get('XML_FILE')
182202
183-
print(json.dumps(results))
203+
if xml_file and os.path.exists(xml_file):
204+
tree = ET.parse(xml_file)
205+
root = tree.getroot()
206+
207+
results = {}
208+
for testcase in root.findall('.//testcase'):
209+
test_name = testcase.get('name')
210+
failed = testcase.find('failure') is not None or testcase.find('error') is not None
211+
results[test_name] = '❌' if failed else '✅'
212+
213+
print(json.dumps(results), flush=True)
214+
else:
215+
print("{}")
184216
PYTHON
185217
else
218+
echo "No JavaScript test results XML found"
186219
echo "{}"
187220
fi
188221
echo 'EOF' >> $GITHUB_OUTPUT
@@ -214,8 +247,13 @@ jobs:
214247
if: always()
215248
working-directory: ./libraryValidations/Spring/validation-tests
216249
run: |
250+
echo "=== Listing Spring test output files ==="
251+
ls -la target/surefire-reports/ 2>/dev/null || echo "No surefire-reports directory"
252+
find target -name "*.xml" -type f 2>/dev/null | head -10
253+
echo "=========================================="
254+
217255
echo 'results<<EOF' >> $GITHUB_OUTPUT
218-
python3 << 'PYTHON'
256+
python3 <<'PYTHON'
219257
import xml.etree.ElementTree as ET
220258
import json
221259
import os
@@ -224,17 +262,19 @@ jobs:
224262
results = {}
225263
xml_files = glob.glob('target/surefire-reports/TEST-*.xml')
226264
265+
print(f"Found {len(xml_files)} Spring test result files", flush=True)
266+
227267
for xml_file in xml_files:
268+
print(f"Parsing {xml_file}", flush=True)
228269
tree = ET.parse(xml_file)
229270
root = tree.getroot()
230271
231272
for testcase in root.findall('.//testcase'):
232273
test_name = testcase.get('name')
233-
# Check if test failed
234274
failed = testcase.find('failure') is not None or testcase.find('error') is not None
235275
results[test_name] = '❌' if failed else '✅'
236276
237-
print(json.dumps(results))
277+
print(json.dumps(results), flush=True)
238278
PYTHON
239279
echo 'EOF' >> $GITHUB_OUTPUT
240280
@@ -249,17 +289,44 @@ jobs:
249289

250290
- name: Generate test matrix
251291
id: matrix
292+
env:
293+
DOTNET_RESULTS: ${{ needs.dotnet-tests.outputs.results }}
294+
PYTHON_RESULTS: ${{ needs.python-tests.outputs.results }}
295+
JAVASCRIPT_RESULTS: ${{ needs.javascript-tests.outputs.results }}
296+
SPRING_RESULTS: ${{ needs.spring-tests.outputs.results }}
252297
run: |
253-
python3 << 'PYTHON'
298+
python3 <<'PYTHON'
254299
import json
255300
import os
256-
import glob
301+
302+
# Debug: print raw results
303+
print("=== Debug: Raw Results ===")
304+
print(f"DOTNET: {os.environ.get('DOTNET_RESULTS', 'EMPTY')}")
305+
print(f"PYTHON: {os.environ.get('PYTHON_RESULTS', 'EMPTY')}")
306+
print(f"JAVASCRIPT: {os.environ.get('JAVASCRIPT_RESULTS', 'EMPTY')}")
307+
print(f"SPRING: {os.environ.get('SPRING_RESULTS', 'EMPTY')}")
308+
print("========================\n")
257309
258310
# 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 {}
311+
try:
312+
dotnet_results = json.loads(os.environ.get('DOTNET_RESULTS', '{}'))
313+
except:
314+
dotnet_results = {}
315+
316+
try:
317+
python_results = json.loads(os.environ.get('PYTHON_RESULTS', '{}'))
318+
except:
319+
python_results = {}
320+
321+
try:
322+
javascript_results = json.loads(os.environ.get('JAVASCRIPT_RESULTS', '{}'))
323+
except:
324+
javascript_results = {}
325+
326+
try:
327+
spring_results = json.loads(os.environ.get('SPRING_RESULTS', '{}'))
328+
except:
329+
spring_results = {}
263330
264331
# Collect all unique test names across all languages
265332
all_tests = set()
@@ -271,20 +338,26 @@ jobs:
271338
# Sort tests for consistent output
272339
sorted_tests = sorted(all_tests)
273340
341+
print(f"Found {len(sorted_tests)} unique tests")
342+
274343
# Generate markdown table
275344
with open('summary.md', 'w') as f:
276345
f.write("## 🧪 Validation Test Results\n\n")
277-
f.write("| Test Name | .NET | Python | JavaScript | Spring |\n")
278-
f.write("|-----------|------|--------|------------|--------|\n")
279346
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, '⚠️')
347+
if not sorted_tests:
348+
f.write("⚠️ No test results found. Check individual job outputs for details.\n\n")
349+
else:
350+
f.write("| Test Name | .NET | Python | JavaScript | Spring |\n")
351+
f.write("|-----------|------|--------|------------|--------|\n")
286352
287-
f.write(f"| {test} | {dotnet} | {python} | {javascript} | {spring} |\n")
353+
for test in sorted_tests:
354+
# Get result for each language, default to ⚠️ if not found
355+
dotnet = dotnet_results.get(test, '⚠️')
356+
python = python_results.get(test, '⚠️')
357+
javascript = javascript_results.get(test, '⚠️')
358+
spring = spring_results.get(test, '⚠️')
359+
360+
f.write(f"| {test} | {dotnet} | {python} | {javascript} | {spring} |\n")
288361
289362
f.write(f"\n_Workflow run: ${{ github.run_id }}_\n")
290363

0 commit comments

Comments
 (0)