Skip to content

Commit efe7a39

Browse files
authored
[CI] Generate one combined report for Outerloop tests workflow (#8705)
* [CI] Generate one combined report for Outerloop tests workflow - Upload the trx files to a separate artifact - and download that in a single job at the end to print a combined report. - And this removes the per-project report * Update .github/workflows/tests-outerloop.yml Co-authored-by: Igor Velikorossov <[email protected]> * Address review feedback from @ russkie, and change the order of the columns
1 parent e5f0d6e commit efe7a39

File tree

1 file changed

+70
-43
lines changed

1 file changed

+70
-43
lines changed

.github/workflows/tests-outerloop.yml

+70-43
Original file line numberDiff line numberDiff line change
@@ -61,43 +61,81 @@ jobs:
6161
run: |
6262
${{ matrix.tests.command }}
6363
64+
- name: Upload logs, and test results
65+
if: always()
66+
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
67+
with:
68+
name: ${{ matrix.tests.project }}-${{ matrix.tests.os }}-logs
69+
path: |
70+
${{ github.workspace }}/artifacts/log/*/TestLogs/**/*.log
71+
${{ github.workspace }}/artifacts/TestResults/*/*.trx
72+
# Longer retention time to allow scanning runs for quarantined test results
73+
retention-days: 30
74+
75+
results:
76+
if: always()
77+
runs-on: ubuntu-latest
78+
name: Final Results
79+
needs: run_tests
80+
steps:
81+
# get all the test-job-result* artifacts into a single directory
82+
- uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9
83+
with:
84+
pattern: '*-logs'
85+
path: ${{ github.workspace }}/artifacts/all-logs
86+
6487
- name: Process logs and post results
6588
if: always()
6689
shell: pwsh
6790
run: |
68-
$logDirectory = "${{ github.workspace }}/artifacts/TestResults"
91+
$logDirectory = "${{ github.workspace }}/artifacts/all-logs"
6992
$trxFiles = Get-ChildItem -Path $logDirectory -Filter *.trx -Recurse
7093
7194
$testResults = @() # Initialize an array to store test results
7295
7396
foreach ($trxFile in $trxFiles) {
74-
# Load the .trx file as XML
75-
$xmlContent = [xml](Get-Content -Path $trxFile.FullName)
76-
77-
# Extract test results from the XML
78-
foreach ($testResult in $xmlContent.TestRun.Results.UnitTestResult) {
79-
$testName = $testResult.testName
80-
$outcome = $testResult.outcome
81-
$duration = $testResult.duration
82-
83-
# Map outcome to emoji
84-
switch ($outcome) {
85-
"Passed" { $emoji = "✔️" }
86-
"Failed" { $emoji = "❌" }
87-
default { $emoji = "❔" }
88-
}
89-
90-
# Normalize the duration to a consistent format (hh:mm:ss.fff)
91-
$normalizedDuration = [TimeSpan]::Parse($duration).ToString("mm\:ss\.fff")
92-
93-
# Add the test result to the array
94-
$testResults += [PSCustomObject]@{
95-
TestName = $testName
96-
Outcome = $outcome
97-
OutcomeIcon = $emoji
98-
Duration = $normalizedDuration
99-
}
100-
}
97+
# Determine the OS based on the file path
98+
if ($trxFile.FullName -match "ubuntu") {
99+
$OS = "ubuntu"
100+
} elseif ($trxFile.FullName -match "windows") {
101+
$OS = "windows"
102+
} else {
103+
$OS = "unknown"
104+
}
105+
106+
# Load the .trx file as XML
107+
try {
108+
# Attempt to load the .trx file as XML
109+
$xmlContent = [xml](Get-Content -Path $trxFile.FullName)
110+
111+
# Extract test results from the XML
112+
foreach ($testResult in $xmlContent.TestRun.Results.UnitTestResult) {
113+
$testName = $testResult.testName
114+
$outcome = $testResult.outcome
115+
$duration = $testResult.duration
116+
117+
# Map outcome to emoji
118+
switch ($outcome) {
119+
"Passed" { $emoji = "✅" }
120+
"Failed" { $emoji = "❌" }
121+
default { $emoji = "❔" }
122+
}
123+
124+
# Normalize the duration to a consistent format (hh:mm:ss.fff)
125+
$normalizedDuration = [TimeSpan]::Parse($duration).ToString("mm\:ss\.fff")
126+
127+
# Add the test result to the array
128+
$testResults += [PSCustomObject]@{
129+
TestName = $testName
130+
Outcome = $outcome
131+
OutcomeIcon = $emoji
132+
Duration = $normalizedDuration
133+
OS = $OS
134+
}
135+
}
136+
} catch {
137+
Write-Host "::error::Failed to process $($trxFile.FullName): $($_.Exception.Message)"
138+
}
101139
}
102140
103141
if ($testResults.Length -lt 1) {
@@ -123,24 +161,13 @@ jobs:
123161
}
124162
125163
# Format the test results as a console-friendly table
126-
$tableHeader = "{0,-16} {1,-150} {2,-20}" -f "Duration", "Test Name", "Result"
127-
$tableSeparator = "-" * 185
128-
$tableRows = $testResults | ForEach-Object { "{0,-16} {1,-150} {2,-20}" -f $_.Duration, $_.TestName, "$($_.OutcomeIcon) $($_.Outcome)" }
164+
$tableHeader = "{0,-12} {1,-10} {2,-140} {3,-16}" -f "Result", "OS", "Test Name", "Duration"
165+
$tableSeparator = "-" * 190
166+
$tableRows = $testResults | ForEach-Object { "{0,-12} {1,-10} {2,-140} {3,-16}" -f "$($_.OutcomeIcon) $($_.Outcome)", $_.OS, $_.TestName, $_.Duration }
129167
$table = "$tableHeader`n$tableSeparator`n" + ($tableRows -join "`n") + "`n$tableSeparator`n"
130168
Write-Host "`nTest Results:`n`n$table"
131169
132170
# Optionally, save the results to a file for further processing
133-
$outputPath = "${{ github.workspace }}/artifacts/log/Release/TestLogs/summary.log"
171+
$outputPath = "${{ github.workspace }}/artifacts/summary.log"
134172
$table | Out-File -FilePath $outputPath -Encoding utf8
135173
Write-Host "Test results saved to $outputPath"
136-
137-
- name: Upload logs, and test results
138-
if: always()
139-
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
140-
with:
141-
name: logs-${{ matrix.tests.os }}-${{ matrix.tests.project }}
142-
path: |
143-
${{ github.workspace }}/artifacts/log/*/*.binlog
144-
${{ github.workspace }}/artifacts/log/*/TestLogs/**
145-
${{ github.workspace }}/artifacts/TestResults/*/*.trx
146-
retention-days: 5

0 commit comments

Comments
 (0)