-
-
Notifications
You must be signed in to change notification settings - Fork 69
376 lines (326 loc) · 13.1 KB
/
Copy pathdotnet-tests.yml
File metadata and controls
376 lines (326 loc) · 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
name: Test .NET Libraries
on:
push:
branches:
- master
paths-ignore:
- '*.md'
- 'Docs/**'
- 'Examples/**'
- 'Website/**'
- '.github/workflows/website-ci.yml'
- '.github/workflows/deploy-website.yml'
- '.gitignore'
pull_request:
branches:
- master
paths-ignore:
- '*.md'
- 'Docs/**'
- 'Examples/**'
- 'Website/**'
- '.github/workflows/website-ci.yml'
- '.github/workflows/deploy-website.yml'
- '.gitignore'
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
DOTNET_VERSION: |
8.0.418
10.0.103
BUILD_CONFIGURATION: 'Release'
TEST_VERBOSITY: minimal # set to 'detailed' to restore full test output
SUMMARIZE_FAILURES: true # set to 'false' to disable summarizing failing tests
jobs:
build-matrix:
name: 'Cross-platform build'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore OfficeIMO.sln
- name: Build solution
run: dotnet build OfficeIMO.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore
test-windows:
name: 'Windows'
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore OfficeIMO.sln
- name: Build solution
run: dotnet build OfficeIMO.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore
- name: Run tests
run: |
# Ubuntu and macOS matrix jobs already cover net8.0/net10.0 for the test matrix.
# Keep the Windows job focused on the unique .NET Framework coverage so it stays inside the timeout budget.
dotnet test OfficeIMO.CSV.Tests/OfficeIMO.CSV.Tests.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --framework net472 --verbosity ${{ env.TEST_VERBOSITY }} --logger "console;verbosity=${{ env.TEST_VERBOSITY }}" --logger trx
- name: Summarize failing tests
if: failure() && env.SUMMARIZE_FAILURES == 'true'
shell: pwsh
run: |
$trxFiles = Get-ChildItem -Recurse -Filter *.trx
if ($trxFiles.Count -eq 0) {
Write-Host "No TRX files found for failure analysis"
exit 0
}
Write-Host "=== Failed Tests Summary ==="
$failureCount = 0
foreach ($file in $trxFiles) {
try {
Select-Xml -Path $file.FullName -XPath "//UnitTestResult[@outcome='Failed']" |
ForEach-Object {
$name = $_.Node.testName
$msg = $_.Node.Output.ErrorInfo.Message ?? "No error message available"
Write-Host "❌ $name"
Write-Host " $msg"
$failureCount++
}
} catch {
Write-Host "Warning: Could not parse TRX file $($file.Name): $($_.Exception.Message)"
}
}
if ($failureCount -eq 0) {
Write-Host "No failed tests found in TRX files"
} else {
Write-Host "=== Total failed tests: $failureCount ==="
}
- name: Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results-windows
path: '**/*.trx'
test-ubuntu-matrix:
name: 'Ubuntu ${{ matrix.framework }}'
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
framework: [net8.0, net10.0]
include:
- framework: net8.0
collectCoverage: true
- framework: net10.0
collectCoverage: false
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore OfficeIMO.sln
- name: Build solution
run: dotnet build OfficeIMO.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore
- name: Run tests
run: |
# Collect coverage once on the primary Linux net8.0 leg; the other OS/framework legs stay as full test runs without coverage overhead.
if [ "${{ matrix.collectCoverage }}" = "true" ]; then
dotnet test OfficeIMO.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity ${{ env.TEST_VERBOSITY }} --framework ${{ matrix.framework }} --logger "console;verbosity=${{ env.TEST_VERBOSITY }}" --logger trx --collect:"XPlat Code Coverage"
else
dotnet test OfficeIMO.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity ${{ env.TEST_VERBOSITY }} --framework ${{ matrix.framework }} --logger "console;verbosity=${{ env.TEST_VERBOSITY }}" --logger trx
fi
- name: Summarize failing tests
if: failure() && env.SUMMARIZE_FAILURES == 'true'
shell: pwsh
run: |
$trxFiles = Get-ChildItem -Recurse -Filter *.trx
if ($trxFiles.Count -eq 0) {
Write-Host "No TRX files found for failure analysis"
exit 0
}
Write-Host "=== Failed Tests Summary ==="
$failureCount = 0
foreach ($file in $trxFiles) {
try {
Select-Xml -Path $file.FullName -XPath "//UnitTestResult[@outcome='Failed']" |
ForEach-Object {
$name = $_.Node.testName
$msg = $_.Node.Output.ErrorInfo.Message ?? "No error message available"
Write-Host "❌ $name"
Write-Host " $msg"
$failureCount++
}
} catch {
Write-Host "Warning: Could not parse TRX file $($file.Name): $($_.Exception.Message)"
}
}
if ($failureCount -eq 0) {
Write-Host "No failed tests found in TRX files"
} else {
Write-Host "=== Total failed tests: $failureCount ==="
}
- name: Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results-ubuntu-${{ matrix.framework }}
path: '**/*.trx'
- name: Upload coverage to Codecov
if: ${{ matrix.collectCoverage }}
uses: codecov/codecov-action@v5
with:
files: '**/coverage.cobertura.xml'
fail_ci_if_error: false
continue-on-error: true
test-ubuntu:
name: 'Ubuntu'
runs-on: ubuntu-latest
needs: test-ubuntu-matrix
if: always()
steps:
- name: Check Ubuntu test matrix
run: |
if [ "${{ needs.test-ubuntu-matrix.result }}" != "success" ]; then
echo "Ubuntu test matrix result: ${{ needs.test-ubuntu-matrix.result }}"
exit 1
fi
echo "Ubuntu test matrix passed."
test-macos-matrix:
name: 'macOS platform smoke'
runs-on: macos-latest
# Linux covers the full net8.0/net10.0 solution test contract. Hosted macOS
# runners are scarce for the organization, so keep this lane to one focused
# platform smoke that proves macOS restore/build/test execution still works.
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
include:
- framework: net8.0
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore OfficeIMO.sln
- name: Build solution
run: dotnet build OfficeIMO.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore
- name: Run tests
run: |
dotnet test OfficeIMO.Tests/OfficeIMO.Tests.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity ${{ env.TEST_VERBOSITY }} --framework ${{ matrix.framework }} --filter "FullyQualifiedName=OfficeIMO.Tests.Word.Test_WordDocument_SaveAsPdf|FullyQualifiedName~OfficeIMO.Tests.Pdf.PdfReadStreamTests|FullyQualifiedName~OfficeIMO.Tests.HtmlCoreTests|FullyQualifiedName~OfficeIMO.Tests.Markdown.Test_SaveAsMarkdown_FileAndRead" --logger "console;verbosity=${{ env.TEST_VERBOSITY }}" --logger trx
dotnet test OfficeIMO.CSV.Tests/OfficeIMO.CSV.Tests.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity ${{ env.TEST_VERBOSITY }} --framework ${{ matrix.framework }} --filter "FullyQualifiedName~OfficeIMO.CSV.Tests" --logger "console;verbosity=${{ env.TEST_VERBOSITY }}" --logger trx
dotnet test OfficeIMO.VerifyTests/OfficeIMO.VerifyTests.csproj --configuration ${{ env.BUILD_CONFIGURATION }} --no-build --verbosity ${{ env.TEST_VERBOSITY }} --framework ${{ matrix.framework }} --filter "FullyQualifiedName~OfficeIMO.VerifyTests" --logger "console;verbosity=${{ env.TEST_VERBOSITY }}" --logger trx
- name: Summarize failing tests
if: failure() && env.SUMMARIZE_FAILURES == 'true'
shell: pwsh
run: |
$trxFiles = Get-ChildItem -Recurse -Filter *.trx
if ($trxFiles.Count -eq 0) {
Write-Host "No TRX files found for failure analysis"
exit 0
}
Write-Host "=== Failed Tests Summary ==="
$failureCount = 0
foreach ($file in $trxFiles) {
try {
Select-Xml -Path $file.FullName -XPath "//UnitTestResult[@outcome='Failed']" |
ForEach-Object {
$name = $_.Node.testName
$msg = $_.Node.Output.ErrorInfo.Message ?? "No error message available"
Write-Host "❌ $name"
Write-Host " $msg"
$failureCount++
}
} catch {
Write-Host "Warning: Could not parse TRX file $($file.Name): $($_.Exception.Message)"
}
}
if ($failureCount -eq 0) {
Write-Host "No failed tests found in TRX files"
} else {
Write-Host "=== Total failed tests: $failureCount ==="
}
- name: Upload test results
uses: actions/upload-artifact@v7
if: always()
with:
name: test-results-macos-${{ matrix.framework }}
path: '**/*.trx'
test-macos:
name: 'macOS'
runs-on: ubuntu-latest
needs: test-macos-matrix
if: always()
steps:
- name: Check macOS test matrix
run: |
if [ "${{ needs.test-macos-matrix.result }}" != "success" ]; then
echo "macOS test matrix result: ${{ needs.test-macos-matrix.result }}"
exit 1
fi
echo "macOS test matrix passed."
aot-trim-analyzers:
name: 'AOT/Trim analyzers'
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
- name: Cache NuGet packages
uses: actions/cache@v5
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore dependencies
run: dotnet restore OfficeIMO.sln
- name: Run AOT/Trim analyzers (net8.0)
run: dotnet build OfficeIMO.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore -p:EnableTrimAnalyzer=true -p:EnableAotAnalyzer=true -p:TargetFramework=net8.0
- name: Run AOT/Trim analyzers (net10.0)
run: dotnet build OfficeIMO.sln --configuration ${{ env.BUILD_CONFIGURATION }} --no-restore -p:EnableTrimAnalyzer=true -p:EnableAotAnalyzer=true -p:TargetFramework=net10.0