Skip to content

update the existing dotnet.yml to add test reporting #14

update the existing dotnet.yml to add test reporting

update the existing dotnet.yml to add test reporting #14

Workflow file for this run

name: .NET Build and Test
on:
workflow_dispatch:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
checks: write
pull-requests: write
concurrency:
group: dotnet-ci-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 10.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Install dotnet-coverage
run: dotnet tool install -g dotnet-coverage
- name: Run tests with coverage (MTP v2 compatible)
run: |
mkdir -p coverage
dotnet-coverage collect \
-o coverage/coverage.cobertura.xml \
-f cobertura \
"dotnet test --no-build --configuration Release"
- name: Publish test results
uses: EnricoMi/publish-unit-test-result-action@v2.23.0
if: always()
with:
files: TestResults/**/*.trx
check_name: Test results
fail_on: test failures
- name: Upload coverage to GitHub
uses: actions/upload-artifact@v4
with:
name: coverage
path: coverage/coverage.cobertura.xml