Skip to content
This repository was archived by the owner on Aug 30, 2025. It is now read-only.

Commit 6ceae8a

Browse files
committed
ci: Improved test reports
1 parent 7f74c48 commit 6ceae8a

2 files changed

Lines changed: 64 additions & 5 deletions

File tree

.github/workflows/tests.yml

Lines changed: 63 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ jobs:
2222
test-project:
2323
name: "Test nuget"
2424
runs-on: ubuntu-latest
25+
permissions:
26+
contents: read
27+
issues: read
28+
checks: write
29+
pull-requests: write
2530

2631
steps:
2732
- name: "Checkout"
@@ -42,10 +47,64 @@ jobs:
4247
run: dotnet build --configuration Release --no-restore
4348

4449
- name: "Run tests"
45-
run: dotnet test --configuration Release --no-build --verbosity normal --results-directory ${{ env.TEST_RESULTS_DIRECTORY }} --logger "junit;LogFileName=test-result-$(uuidgen).xml" --logger "console;verbosity=detailed"
50+
run: dotnet test --configuration Release --no-build --verbosity normal --results-directory ${{ env.TEST_RESULTS_DIRECTORY }} --collect:"XPlat Code Coverage"
4651

47-
- name: "Publish test results"
48-
uses: test-summary/action@v2
52+
- name: "Combine Coverage Reports" # This is because one report is produced per project, and we want one result for all of them.
53+
uses: danielpalme/ReportGenerator-GitHub-Action@5.2.4
54+
with:
55+
reports: "**/*.cobertura.xml" # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
56+
targetdir: "${{ github.workspace }}" # REQUIRED # The directory where the generated report should be saved.
57+
reporttypes: "Cobertura" # The output formats and scope (separated by semicolon) Values: Badges, Clover, Cobertura, CsvSummary, Html, Html_Dark, Html_Light, Html_BlueRed, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlInline_AzurePipelines_Light, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MarkdownSummaryGithub, MarkdownDeltaSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, TextDeltaSummary, Xml, XmlSummary
58+
verbosity: "Info" # The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off
59+
title: "Code Coverage" # Optional title.
60+
tag: "${{ github.run_number }}_${{ github.run_id }}" # Optional tag or build version.
61+
customSettings: "" # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings.
62+
toolpath: "reportgeneratortool" # Default directory for installing the dotnet tool.
63+
64+
- name: "Upload Combined Coverage"
65+
uses: actions/upload-artifact@v4
66+
with:
67+
name: 'Coverage'
68+
path: ${{ github.workspace }}/Cobertura.xml
69+
70+
- name: "Publish code coverage report"
71+
uses: irongut/CodeCoverageSummary@v1.3.0
72+
with:
73+
filename: "Cobertura.xml"
74+
badge: true
75+
fail_below_min: false # just informative for now
76+
format: markdown
77+
hide_branch_rate: false
78+
hide_complexity: false
79+
indicators: true
80+
output: both
81+
thresholds: "10 30"
82+
83+
- name: "Add Coverage PR Comment"
84+
uses: marocchino/sticky-pull-request-comment@v2
85+
if: github.event_name == 'pull_request'
86+
with:
87+
recreate: true
88+
path: code-coverage-results.md
89+
90+
- name: "Upload Test Results"
91+
uses: actions/upload-artifact@v4
92+
with:
93+
name: 'TestResults'
94+
path: ${{ env.TEST_RESULTS_DIRECTORY }}/**/*
95+
96+
- name: "Publish Test Tesults"
97+
uses: dorny/test-reporter@v1
98+
if: always()
99+
with:
100+
name: "Test Results"
101+
path: "${{ env.TEST_RESULTS_DIRECTORY }}/**/*.trx"
102+
reporter: dotnet-trx
103+
104+
- name: "Publish Test Summary"
105+
uses: EnricoMi/publish-unit-test-result-action@v2.16.1
49106
if: always()
50107
with:
51-
paths: "${{ env.TEST_RESULTS_DIRECTORY }}/**/*.xml"
108+
check_name: "Test Summary"
109+
# NOTE: using trx_files instead of files due to https://github.com/EnricoMi/publish-unit-test-result-action/issues/424
110+
trx_files: "${{ env.TEST_RESULTS_DIRECTORY }}/**/*.trx"

tests/PowerUtils.AspNetCore.ErrorHandler.Tests/PowerUtils.AspNetCore.ErrorHandler.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212

1313
<PropertyGroup>
14+
<VSTestLogger>trx%3bLogFileName=$(MSBuildProjectName)_$(TargetFramework).trx</VSTestLogger>
1415
<DefaultItemExcludes>$(DefaultItemExcludes);coverage.*opencover.xml</DefaultItemExcludes>
1516
</PropertyGroup>
1617

@@ -43,7 +44,6 @@
4344
<PrivateAssets>all</PrivateAssets>
4445
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
4546
</PackageReference>
46-
<PackageReference Include="JunitXml.TestLogger" Version="3.1.12" />
4747
</ItemGroup>
4848

4949
<ItemGroup Condition=" '$(TargetFramework)' == 'net7.0' ">

0 commit comments

Comments
 (0)