Skip to content

Commit cb6da37

Browse files
committed
ci: report failed test names to step summary
1 parent 53801fc commit cb6da37

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ jobs:
4444
dotnet test tests/GeneralZip.Tests/GeneralZip.Tests.csproj -c Release --nologo
4545
--logger "trx" --results-directory "$(pwd)/test-results"
4646
47+
- name: Report failed tests
48+
if: failure()
49+
shell: pwsh
50+
run: |
51+
$trx = Get-ChildItem "test-results" -Filter *.trx -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object -First 1
52+
if ($trx) {
53+
[xml]$doc = Get-Content $trx.FullName
54+
$failed = $doc.SelectNodes("//UnitTestResult[@outcome='Failed']")
55+
"### Failed tests ($($failed.Count))" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
56+
foreach ($f in $failed) {
57+
"- ``$($f.GetAttribute('testName'))``" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
58+
$msg = $f.SelectSingleNode(".//message")?.InnerText
59+
if ($msg) { " ``````" + $msg + " ``````" | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append }
60+
}
61+
}
62+
Get-Content $trx.FullName | Select-String "testName" | Select-Object -First 30 | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append
63+
4764
- name: Upload test results
4865
if: failure() || cancelled()
4966
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)