From a32fd057793583f815f07223c3bc4243af6b8d33 Mon Sep 17 00:00:00 2001 From: Jesse Kela Date: Tue, 11 Mar 2025 22:26:55 +0200 Subject: [PATCH] Coverage report in test summary --- .github/workflows/test.yml | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6bd39c9..ee4ab2e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,7 +15,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: ["ubuntu-latest", "windows-latest"] + os: ["ubuntu-latest"] dotnet: ["9.0.x"] steps: - uses: actions/checkout@v4 @@ -23,9 +23,24 @@ jobs: uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ matrix.dotnet }} + - name: Install Report Generator + run: dotnet tool install --global dotnet-reportgenerator-globaltool - name: Restore run: dotnet restore - name: Build - run: dotnet build --configuration Release --no-restore - - name: Test - run: dotnet test --configuration Release --no-restore --no-build + run: dotnet build -c Release --no-restore + - name: Test & collect coverage + run: | + dotnet test -- --coverage --coverage-output-format xml --coverage-output ${{ github.workspace }}/coverage.xml + - name: Find coverage files and generate report + run: | + reportgenerator -reports:"${{ github.workspace }}/**/coverage.xml" \ + -targetdir:"coverage-report" \ + -reporttypes:MarkdownSummaryGithub + - name: Upload coverage report + uses: actions/upload-artifact@v4 + with: + name: coverage-report + path: coverage-report + - name: Add coverage to summary + run: cat coverage-report/SummaryGithub.md >> $GITHUB_STEP_SUMMARY