Add code covarage report and check #29
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: CI | |
on: | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: 8.0.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Build | |
run: dotnet build --no-restore -c Release | |
- name: Test | |
continue-on-error: true | |
run: dotnet test --no-build -c Release -no-restore --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=cobertura | |
- name: ReportGenerator | |
uses: im-open/code-coverage-report-generator@4 | |
with: | |
reports: '*/**/coverage.opencover.xml' | |
targetdir: './coverage-results' | |
title: dotnet code coverage | |
reporttypes: 'MarkdownSummary;' | |
assemblyfilters: '-xunit*;-Dapper;-MyProj.Tests.Shared;' | |
- name: Create a status check for the code coverage results | |
id: dotnet-coverage-check | |
# You may also reference just the major or major.minor version | |
uses: im-open/process-code-coverage-summary@v2.2.3 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
summary-file: './coverage-results/dotnet-summary.md' | |
create-status-check: true # Default: true | |
create-pr-comment: true # Default: true | |
update-comment-if-one-exists: true # Default: true | |
update-comment-key: 'dotnet' # Default: N/A, used to further identify a comment to update if this action is used more than once in a workflow | |
ignore-threshold-failures: false # Default: false | |
line-threshold: 80 # Default: 0, which means thresholds are not applied | |
branch-threshold: 80 # Default: 0, which means thresholds are not applied | |
- name: Fail if there were coverage failures | |
if: steps.dotnet-coverage-check.outputs.coverage-outcome == 'Failed' | |
run: | | |
echo "There were code coverage threshold failures." | |
exit 1 |