Repository navigation
173 lines (143 loc) · 6.13 KB
/
Copy pathgenerate-coverage-report.yaml
File metadata and controls
173 lines (143 loc) · 6.13 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
name: generate-coverage-report
run-name: Generate coverage coverage report ${{ github.event.head_commit.message }}
on:
workflow_dispatch:
inputs:
skip_integration_tests:
type: boolean
description: Set `true` to skip integration tests.
default: true
concurrency:
group: ${{ github.workflow }}-${{ github.event.inputs.skip_integration_tests }}-${{ github.head_ref || github.ref || github.run_id }}
cancel-in-progress: true
jobs:
collect-coverage:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: pwsh
strategy:
matrix:
# Note: ARM64 on linux/macos are not supported.
# https://github.com/microsoft/codecoverage/blob/main/docs/supported-os.md
os: [windows-latest, ubuntu-latest, macos-26-intel, windows-11-arm]
steps:
- uses: actions/checkout@v7
# Ensure DOTNET_ROOT environment variable set on macOS
- uses: actions/setup-dotnet@v6
with:
dotnet-version: |
10.x
# Setup additional tools
- name: Setup additional tools for Wasm/NativeAot tests
if: ${{ github.event.inputs.skip_integration_tests == 'false'}}
uses: ./.github/actions/setup-additional-tools
- name: Install dotnet-coverage
run: dotnet tool install --global dotnet-coverage
- name: Run task 'build'
run: dotnet build BenchmarkDotNet.slnx -c Release
- name: Start dotnet-coverage with background server mode
run: dotnet coverage collect --session-id bdn_coverage --settings tests/CodeCoverage.config --server-mode --background
- name: Collect Code Coverage
run: |
dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Tests -c Release --no-build --framework net10.0"
dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net10.0"
- name: Collect Code Coverage for BenchmarkDotNet.IntegrationTests
if: ${{ github.event.inputs.skip_integration_tests == 'false'}}
run: |
dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net10.0"
- name: Shutdown dotnet-coverage server.
run: dotnet coverage shutdown bdn_coverage --timeout 60000
- name: Upload coverage artifact
uses: actions/upload-artifact@v7
with:
name: coverage-${{ matrix.os }}
path: "**/*.cobertura.xml"
collect-coverage-netfx:
runs-on: windows-latest
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v7
- name: Setup additional tools for Wasm/NativeAot tests
if: ${{ github.event.inputs.skip_integration_tests == 'false'}}
uses: ./.github/actions/setup-additional-tools
- name: Install dotnet-coverage
run: dotnet tool install --global dotnet-coverage
- name: Run task 'build'
run: dotnet build BenchmarkDotNet.slnx -c Release
- name: Start dotnet-coverage with background server mode
run: dotnet coverage collect --session-id bdn_coverage --settings tests/CodeCoverage.config --server-mode --background
- name: Collect Code Coverage
run: |
dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Tests -c Release --no-build --framework net472"
dotnet coverage connect bdn_coverage "dotnet test tests/BenchmarkDotNet.Analyzers.Tests -c Release --no-build --framework net472"
- name: Collect Code Coverage for BenchmarkDotNet.IntegrationTests
if: ${{ github.event.inputs.skip_integration_tests == 'false'}}
run: |
dotnet coverage connect bdn_coverage 'dotnet test tests/BenchmarkDotNet.IntegrationTests -c Release --no-build --framework net472'
- name: Shutdown dotnet-coverage server.
run: dotnet coverage shutdown bdn_coverage --timeout 60000
- name: Upload coverage artifact
uses: actions/upload-artifact@v7
with:
name: coverage-windows-netfx
path: "**/*.cobertura.xml"
generate-coverage-report:
needs: [collect-coverage, collect-coverage-netfx]
runs-on: ubuntu-latest
defaults:
run:
shell: pwsh
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
path: coverage
- name: Upload raw coverage data
uses: actions/upload-artifact@v7
with:
name: coverage
path: coverage
- name: Rewrite file path map to absolute path
run: |
$baseSourcePath = Get-Location
$files = [IO.Directory]::GetFiles("coverage", "coverage.cobertura.xml", [IO.SearchOption]::AllDirectories)
foreach($file in $files)
{
$content = [IO.File]::ReadAllText($file).Replace("/_/", [Environment]::CurrentDirectory + '/')
[IO.File]::WriteAllText($file, $content)
}
- name: Install ReportGenerator as global tool
run: dotnet tool install --global dotnet-reportgenerator-globaltool
- name: Geterate reports
run: |
reportgenerator `
-reports:"coverage/**/coverage.cobertura.xml" `
-targetdir:"coverage_report/reports" `
-reporttypes:"Html;MarkdownSummaryGithub"
- name: Create index.html
run: |
$html = @"
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=reports/index.html">
<title>Redirect</title>
</head>
<body>
<p>If you are not redirected automatically, <a href="reports/index.html">click here</a>.</p>
</body>
</html>
"@
[IO.File]::WriteAllText("coverage_report/index.html", $html)
- name: Write coverage summary
run: |
$markdown = Get-Content coverage_report/reports/SummaryGithub.md -Raw
Write-Output $markdown >> $env:GITHUB_STEP_SUMMARY
- name: Upload HTML report files
uses: actions/upload-artifact@v7
with:
name: coverage_report
path: coverage_report