From 119a0ad6b09ef744f63cd1cfa237eea0b2a856de Mon Sep 17 00:00:00 2001 From: Brant Burnett Date: Sat, 14 Dec 2024 23:21:48 -0500 Subject: [PATCH] Add code coverage report to CI (#108) --- .config/dotnet-tools.json | 13 ++++++++ .github/workflows/main.yml | 50 ++++++++++++++++++++++++++-- .gitignore | 1 + Snappier.Tests/Snappier.Tests.csproj | 1 + 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 .config/dotnet-tools.json diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json new file mode 100644 index 0000000..69f9eeb --- /dev/null +++ b/.config/dotnet-tools.json @@ -0,0 +1,13 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-reportgenerator-globaltool": { + "version": "5.4.1", + "commands": [ + "reportgenerator" + ], + "rollForward": false + } + } +} \ No newline at end of file diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f62daca..6e4dfbc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -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: diff --git a/.gitignore b/.gitignore index 95b43cb..8839678 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ Couchbase.snk *.nupkg BenchmarkDotNet.Artifacts/ test-results/ +TestResults/ diff --git a/Snappier.Tests/Snappier.Tests.csproj b/Snappier.Tests/Snappier.Tests.csproj index 9f926da..e3d5574 100644 --- a/Snappier.Tests/Snappier.Tests.csproj +++ b/Snappier.Tests/Snappier.Tests.csproj @@ -16,6 +16,7 @@ +