Skip to content

Improve Word market readiness #4718

Improve Word market readiness

Improve Word market readiness #4718

Workflow file for this run

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