Skip to content

Commit 7a3d855

Browse files
committed
chore: add codecoverage settings
[skip ci]
1 parent 4bdba3a commit 7a3d855

File tree

5 files changed

+61
-5
lines changed

5 files changed

+61
-5
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,36 @@ jobs:
4848
$env:PLAYWRIGHT_NODEJS_PATH = (Get-Command node).Path
4949
./playwright.ps1 install chromium --only-shell
5050
51-
- run: dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal" -- --seed ${{ env.seed }}
51+
- name: Install `dotnet-coverage` as .NET Global Tool
52+
run: dotnet tool install -g dotnet-coverage
53+
54+
- name: Start dotnet-coverage with background server mode
55+
run: dotnet coverage collect --session-id docfx_coverage --settings test/CodeCoverage.runsettings --server-mode --background
56+
57+
- run: dotnet coverage connect docfx_coverage "dotnet test -c Release -f net8.0 --no-build -- --seed ${{ env.seed }}"
5258
id: test-net80
5359

54-
- run: dotnet test -c Release -f net9.0 --no-build --collect:"XPlat Code Coverage" --consoleLoggerParameters:"Summary;Verbosity=Minimal" -- --seed ${{ env.seed }}
60+
- run: dotnet coverage connect docfx_coverage "dotnet test -c Release -f net9.0 --no-build -- --seed ${{ env.seed }}"
5561
if: matrix.os == 'ubuntu-latest'
5662
id: test-net90
5763

5864
- run: npm i -g @percy/cli
5965
if: matrix.os == 'ubuntu-latest'
6066

61-
- run: percy exec -- dotnet test -c Release -f net8.0 --no-build --collect:"XPlat Code Coverage" -- --filter-trait "Stage=Percy"
67+
- run: dotnet coverage connect docfx_coverage "percy exec -- dotnet test -c Release -f net8.0 --no-build -- --filter-trait "Stage=Percy" --seed ${{ env.seed }}"
6268
if: matrix.os == 'ubuntu-latest'
6369
env:
6470
PERCY_TOKEN: ${{ secrets.PERCY_TOKEN }}
6571

72+
- name: Shutdown dotnet-coverage server.
73+
run: dotnet coverage shutdown docfx_coverage --timeout 60000
74+
6675
- uses: codecov/codecov-action@v5
6776
if: matrix.os == 'ubuntu-latest'
6877
with:
6978
fail_ci_if_error: false
7079
token: ${{ secrets.CODECOV_TOKEN }}
80+
directory: test/TestResults/code-coverages
7181

7282
- run: echo "DOTNET_DbgEnableMiniDump=1" >> $GITHUB_ENV
7383
if: matrix.os == 'ubuntu-latest'

docfx.sln

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ EndProject
1515
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{926A0726-B806-4215-82EF-AF8E22D0FACF}"
1616
ProjectSection(SolutionItems) = preProject
1717
test\Directory.Build.props = test\Directory.Build.props
18+
test\CodeCoverage.runsettings = test\CodeCoverage.runsettings
1819
test\Directory.Packages.props = test\Directory.Packages.props
1920
test\xunit.runner.json = test\xunit.runner.json
2021
EndProjectSection

test/.editorconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ dotnet_diagnostic.CA1869.severity = none # CA1869: Cache and reuse 'JsonSerializ
1111

1212
dotnet_diagnostic.SYSLIB1045.severity = silent # SYSLIB1045: Convert to 'GeneratedRegexAttribute'.
1313

14-
[*.runsettings]
1514
indent_size = 2

test/CodeCoverage.runsettings

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Configuration>
3+
<!-- Available Options: https://github.com/microsoft/codecoverage/blob/main/docs/configuration.md -->
4+
<CoverageFileName>coverage.cobertura.xml</CoverageFileName>
5+
<Format>cobertura</Format>
6+
<IncludeTestAssembly>false</IncludeTestAssembly>
7+
<DeterministicReport>true</DeterministicReport>
8+
<CollectFromChildProcesses>true</CollectFromChildProcesses>
9+
<CodeCoverage>
10+
<ModulePaths>
11+
<Include>
12+
<ModulePath>.*Docfx.*\.dll$</ModulePath>
13+
</Include>
14+
<Exclude>
15+
<!-- Exclude test DLLs -->
16+
<ModulePath>.*Docfx\.Tests\.Common\.dll$</ModulePath>
17+
<ModulePath>.*\.Tests\.dll$</ModulePath>
18+
19+
<!-- Exclude third party DLLs -->
20+
<ModulePath>.*ICSharpCode\.Decompiler\.dll$</ModulePath>
21+
<ModulePath>.*Spectre\.Console\.Cli\.dll$</ModulePath>
22+
<ModulePath>.*Spectre\.Console\.dll$</ModulePath>
23+
<ModulePath>.*DiffEngine\.dll$</ModulePath>
24+
25+
<!-- Following DLLs are included when using `dotnet coverage` commands -->
26+
<ModulePath>.*Argon\.dll$</ModulePath>
27+
<ModulePath>.*EmptyFiles\.dll$</ModulePath>
28+
<ModulePath>.*Verify\.dll$</ModulePath>
29+
<ModulePath>.*Verify\.DiffPlex\.dll$</ModulePath>
30+
<ModulePath>.*Verify\.XunitV3\.dll$</ModulePath>
31+
</Exclude>
32+
</ModulePaths>
33+
<Attributes>
34+
<Exclude>
35+
<Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
36+
</Exclude>
37+
</Attributes>
38+
<Sources>
39+
<Exclude>
40+
<Source>.*\\[^\\]*\.g\.cs</Source>
41+
</Exclude>
42+
</Sources>
43+
<!-- Disable following settings. Because C++ code is not contained (See: https://github.com/microsoft/codecoverage/blob/main/README.md#get-started)-->
44+
<EnableStaticNativeInstrumentation>False</EnableStaticNativeInstrumentation>
45+
<EnableDynamicNativeInstrumentation>False</EnableDynamicNativeInstrumentation>
46+
</CodeCoverage>
47+
</Configuration>

test/docfx.Snapshot.Tests/PercyTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Diagnostics;
54
using System.Net.Http.Json;
65
using System.Net.NetworkInformation;
76
using System.Text.RegularExpressions;

0 commit comments

Comments
 (0)