Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0ac2039

Browse files
authored
Merge pull request #426 from microsoft/cc/mergeCodeCoverage2
Leveraging ReportGenerator to merge multiple coverage reports
2 parents 2fdaf66 + c6f759f commit 0ac2039

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

.github/workflows/pr.yml

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: |
2727
scripts/DisableStrongName.ps1
2828
29-
- name: Setup .NET 8.x
29+
- name: Setup .NET
3030
uses: actions/setup-dotnet@v3
3131
with:
3232
# Semantic version range syntax or exact version of a dotnet version
@@ -71,28 +71,57 @@ jobs:
7171
pull-requests: write
7272
if: ${{ always() && needs.Build.result == 'success' }}
7373
steps:
74+
- name: Check out repository code
75+
uses: actions/checkout@v4
76+
with:
77+
fetch-depth: 1 # Don't need full history for this job
78+
7479
- name: Download Code Coverage
7580
uses: actions/download-artifact@v4
7681
with:
7782
name: CodeCoverage
7883
path: TestResults
7984

85+
- name: Setup .NET
86+
uses: actions/setup-dotnet@v3
87+
with:
88+
dotnet-version: '8.x'
89+
dotnet-quality: 'ga'
90+
91+
- name: ReportGenerator
92+
uses: danielpalme/[email protected]
93+
with:
94+
reports: TestResults/**/coverage.cobertura.xml
95+
targetdir: CodeCoverageReport
96+
sourcedirs: src
97+
reporttypes: HtmlInline;MarkdownSummaryGithub;Cobertura
98+
99+
- name: Upload coverage report artifact
100+
uses: actions/upload-artifact@v4
101+
with:
102+
name: CodeCoverageReport # Artifact name
103+
path: CodeCoverageReport # Directory containing files to upload
104+
80105
- name: Code Coverage Report
81106
uses: irongut/[email protected]
82107
with:
83-
filename: TestResults/**/coverage.cobertura.xml
108+
filename: CodeCoverageReport/Cobertura.xml
84109
badge: true
85110
fail_below_min: true
86111
format: markdown
87112
hide_branch_rate: false
88113
hide_complexity: true
89114
indicators: true
90115
output: both
91-
thresholds: '17 80'
116+
thresholds: '25 80'
92117

93118
- name: Add Coverage PR Comment
94119
uses: marocchino/sticky-pull-request-comment@v2
95120
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == false
96121
with:
97122
recreate: true
98123
path: code-coverage-results.md
124+
125+
- name: Publish coverage in build summary # Only applicable if 'MarkdownSummaryGithub' or one of the other Markdown report types is generated
126+
run: cat CodeCoverageReport/SummaryGithub.md >> $GITHUB_STEP_SUMMARY # Adjust path and filename if necessary
127+
shell: bash

0 commit comments

Comments
 (0)