Skip to content

Commit 31a6299

Browse files
committed
tests
1 parent 9a9e330 commit 31a6299

File tree

1 file changed

+49
-5
lines changed

1 file changed

+49
-5
lines changed

.github/workflows/ci.yml

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,56 @@ jobs:
246246
name: test-results
247247
path: artifacts/test-results
248248

249-
- name: Publish test results
249+
- name: Publish test results summary
250250
if: always()
251-
uses: actions/upload-test-results@v1
252-
with:
253-
test-results: artifacts/test-results/TestResults.trx
254-
check-name: dotnet tests
251+
run: |
252+
python - <<'PY'
253+
import os
254+
import xml.etree.ElementTree as ET
255+
256+
trx_path = "artifacts/test-results/TestResults.trx"
257+
summary_path = os.environ.get("GITHUB_STEP_SUMMARY")
258+
259+
if not os.path.exists(trx_path) or not summary_path:
260+
print("No test results found to summarize.")
261+
raise SystemExit(0)
262+
263+
ns = {"trx": "http://microsoft.com/schemas/VisualStudio/TeamTest/2010"}
264+
root = ET.parse(trx_path).getroot()
265+
counters = root.find(".//trx:ResultSummary/trx:Counters", ns)
266+
267+
with open(summary_path, "a", encoding="utf-8") as summary:
268+
summary.write("### Test Results\n\n")
269+
270+
if counters is not None:
271+
metrics = {
272+
"Total": counters.attrib.get("total", "0"),
273+
"Executed": counters.attrib.get("executed", "0"),
274+
"Passed": counters.attrib.get("passed", "0"),
275+
"Failed": counters.attrib.get("failed", "0"),
276+
"Errors": counters.attrib.get("error", "0"),
277+
"Timeouts": counters.attrib.get("timeout", "0"),
278+
"Aborted": counters.attrib.get("aborted", "0"),
279+
"Inconclusive": counters.attrib.get("inconclusive", "0"),
280+
"Skipped": counters.attrib.get("notExecuted", "0")
281+
}
282+
283+
for label, value in metrics.items():
284+
if value and value != "0":
285+
summary.write(f"- {label}: {value}\n")
286+
else:
287+
summary.write("- No counters were present in the TRX log.\n")
288+
289+
failed_results = root.findall(".//trx:UnitTestResult[@outcome!='Passed']", ns)
290+
if failed_results:
291+
summary.write("\nFailed Tests:\n")
292+
for result in failed_results:
293+
test_name = result.attrib.get("testName", "(unknown test)")
294+
outcome = result.attrib.get("outcome", "Unknown")
295+
summary.write(f"- {test_name} ({outcome})\n")
296+
297+
summary.write("\n")
298+
PY
255299

256300
release:
257301
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

0 commit comments

Comments
 (0)