Skip to content

Commit

Permalink
Add code coverage report to CI (#108)
Browse files Browse the repository at this point in the history
  • Loading branch information
brantburnett authored Dec 15, 2024
1 parent b1fb9ef commit 119a0ad
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
13 changes: 13 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
"version": "5.4.1",
"commands": [
"reportgenerator"
],
"rollForward": false
}
}
}
50 changes: 47 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ jobs:
- name: Test
run: |
export COMPlus_Enable${{ matrix.disable }}=0 && \
dotnet test --no-build -f ${{ matrix.framework }} --configuration Release --verbosity normal --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
dotnet test --no-build -f ${{ matrix.framework }} --configuration Release --verbosity normal --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" --collect:"XPlat Code Coverage"
- name: Collect Coverage
uses: actions/upload-artifact@v4
with:
name: coverage-${{ matrix.framework }}-${{ matrix.disable }}
path: Snappier.Tests/TestResults/**/*.xml


test-windows:

Expand All @@ -66,8 +72,46 @@ jobs:
run: dotnet restore
- name: Test
run: |-
dotnet test --runtime win-x64 -f net48 --configuration Release --verbosity normal --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
dotnet test --runtime win-x86 -f net48 --configuration Release --verbosity normal --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true"
dotnet test --runtime win-x64 -f net48 --configuration Release --verbosity normal --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" --collect:"XPlat Code Coverage" -- RunConfiguration.DisableAppDomain=true
dotnet test --runtime win-x86 -f net48 --configuration Release --verbosity normal --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" --collect:"XPlat Code Coverage" -- RunConfiguration.DisableAppDomain=true
- name: Collect Coverage
uses: actions/upload-artifact@v4
with:
name: coverage-net4
path: Snappier.Tests/TestResults/**/*.xml

coverage-report:

name: Coverage Report
runs-on: ubuntu-latest
needs:
- test
- test-windows

steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Download Coverage
uses: actions/download-artifact@v4
with:
pattern: coverage-*
path: Snappier.Tests/TestResults
- name: ReportGenerator
uses: danielpalme/ReportGenerator-GitHub-Action@v5
with:
reports: 'Snappier.Tests/TestResults/**/*.xml'
targetdir: 'artifacts/coveragereport'
reporttypes: 'Html'
classfilters: '-System.Diagnostics.*;-System.Runtime.*;-Snappier.Internal.ThrowHelper'
license: ${{ secrets.REPORT_GENERATOR_LICENSE }}
- name: Collect Report
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: artifacts/coveragereport

publish:

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ Couchbase.snk
*.nupkg
BenchmarkDotNet.Artifacts/
test-results/
TestResults/
1 change: 1 addition & 0 deletions Snappier.Tests/Snappier.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
<ItemGroup>
<None Remove="TestData/*" />
<EmbeddedResource Include="TestData/*" />
<None Remove="TestResults/**/*" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 119a0ad

Please # to comment.