Skip to content

Improve Coverage and tests reporting #490

Improve Coverage and tests reporting

Improve Coverage and tests reporting #490

Workflow file for this run

name: Dotnet Build and Test
on: [push]
permissions:
contents: read
actions: read
checks: write
pages: write
id-token: write
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
dotnet-version: ["6.0.x", "7.0.x", "8.0.x"]
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
- name: Install tools
run: |
dotnet tool update dotnet-coverage
dotnet tool update dotnet-reportgenerator-globaltool
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build
- name: Test with Coverage
run: >
dotnet coverage collect -o ${{ github.workspace }}/Tests/Coverage.xml -f cobertura -s coverage.runsettings
dotnet test --no-build --logger "trx;LogFileName=TestResults-${{ matrix.dotnet-version }}.trx"
|| true
- name: Generate Coverage Report
run: >
dotnet reportgenerator
-reports:${{ github.workspace }}/Tests/Coverage.xml
-targetdir:"${{ github.workspace }}/Tests-${{ matrix.dotnet-version }}/"
-reporttypes:'MarkdownSummaryGithub;Html;Badges'
- name: Test Report
uses: dorny/test-reporter@v1
if: always()
with:
name: DotNET Tests (${{ matrix.dotnet-version }})
artifact: test-results-${{ matrix.dotnet-version }}
path: "**/TestResults-${{ matrix.dotnet-version }}.trx"
reporter: dotnet-trx
fail-on-error: true
list-suites: failed
list-tests: failed
- name: Coverage Summary Report
if: always()
run: cat Tests-${{ matrix.dotnet-version }}/SummaryGithub.md >> $GITHUB_STEP_SUMMARY
- name: Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: Tests/SummaryGithub.md
- name: Upload Coverage artifact
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-${{ matrix.dotnet-version }}
path: ${{ github.workspace }}/Tests-${{ matrix.dotnet-version }}/
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
if: ${{ matrix.dotnet-version == '8.0.x' }}
with:
path: test/Html
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4