Skip to content

add code coverage in ci #23

add code coverage in ci

add code coverage in ci #23

Workflow file for this run

name: CI Workflow
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
- dev
types: [opened, edited, reopened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
jobs:
build-and-test:
name: Build and Test
strategy:
matrix:
dotnet-version: ["8.0.x", "6.0.x"]
os: ["ubuntu-latest", "windows-latest"]
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
name: Checkout
with:
fetch-depth: 0
- name: Setup dotnet ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}
cache: true
cache-dependency-path: "**/packages.lock.json"
- name: Restore dependencies
run: dotnet restore --no-cache --disable-parallel --verbosity minimal
- name: Build
run: dotnet build --configuration Release --no-restore
- name: Test
run: dotnet test --configuration Release --no-build --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
code-coverage:
name: Code Coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout
with:
fetch-depth: 0
- name: Setup dotnet 8.0
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
cache: true
cache-dependency-path: "**/packages.lock.json"
- name: Code Coverage Report
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: coverage/**/coverage.cobertura.xml
badge: true
fail_below_min: true
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: "60 80"
- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md