@@ -61,43 +61,81 @@ jobs:
61
61
run : |
62
62
${{ matrix.tests.command }}
63
63
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
+
64
87
- name : Process logs and post results
65
88
if : always()
66
89
shell : pwsh
67
90
run : |
68
- $logDirectory = "${{ github.workspace }}/artifacts/TestResults "
91
+ $logDirectory = "${{ github.workspace }}/artifacts/all-logs "
69
92
$trxFiles = Get-ChildItem -Path $logDirectory -Filter *.trx -Recurse
70
93
71
94
$testResults = @() # Initialize an array to store test results
72
95
73
96
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
+ }
101
139
}
102
140
103
141
if ($testResults.Length -lt 1) {
@@ -123,24 +161,13 @@ jobs:
123
161
}
124
162
125
163
# 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 }
129
167
$table = "$tableHeader`n$tableSeparator`n" + ($tableRows -join "`n") + "`n$tableSeparator`n"
130
168
Write-Host "`nTest Results:`n`n$table"
131
169
132
170
# 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"
134
172
$table | Out-File -FilePath $outputPath -Encoding utf8
135
173
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