Skip to content

Commit 54ebd3f

Browse files
authored
Merge pull request #3 from irihitech/copilot/fix-2
Add test coverage reporting to GitHub workflow for pull requests
2 parents f38b39f + a2f3367 commit 54ebd3f

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

.github/workflows/test.yml

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,41 @@ jobs:
2222
- name: Checkout
2323
uses: actions/[email protected]
2424
- name: Unit Test
25-
run: dotnet test test/UnitTest
25+
run: dotnet test test/UnitTest --configuration Release --logger trx --collect:"XPlat Code Coverage;Format=cobertura" --results-directory ./TestResults/
26+
- name: Combine Coverage Reports # This is because one report is produced per project, and we want one result for all of them.
27+
uses: danielpalme/[email protected]
28+
with:
29+
reports: '**/*.cobertura.xml' # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
30+
targetdir: "${{ github.workspace }}" # REQUIRED # The directory where the generated report should be saved.
31+
reporttypes: 'HtmlInline;Cobertura'
32+
- name: Publish Code Coverage Report
33+
uses: irongut/[email protected]
34+
with:
35+
filename: "Cobertura.xml"
36+
badge: true
37+
fail_below_min: false # just informative for now
38+
format: markdown
39+
hide_branch_rate: false
40+
hide_complexity: false
41+
indicators: true
42+
output: both
43+
thresholds: "10 30"
44+
- name: Add Coverage PR Comment
45+
uses: marocchino/sticky-pull-request-comment@v2
46+
if: github.event_name == 'pull_request'
47+
with:
48+
recreate: true
49+
path: code-coverage-results.md
50+
- name: Upload Test Result Files
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: test-results
54+
path: |
55+
${{ github.workspace }}/**/TestResults/**/*
56+
${{ github.workspace }}/**/CoverageReports/**/*
57+
retention-days: 5
58+
- name: Publish Test Results
59+
uses: EnricoMi/[email protected]
60+
if: always()
61+
with:
62+
trx_files: "${{ github.workspace }}/**/*.trx"

0 commit comments

Comments
 (0)