Skip to content

Commit

Permalink
ci: Improved test reports
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonBN committed Jun 30, 2024
1 parent 3dc37f9 commit 112421a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 2 deletions.
70 changes: 68 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,19 @@ env:
SDK_VERSION_6: '6.0.420'
SDK_VERSION_5: '5.0.408'
SDK_VERSION_3: '3.1.426'
TEST_RESULTS_DIRECTORY: './TestResults'


jobs:

test-project:
name: "Test nuget"
runs-on: ubuntu-latest
permissions:
contents: read
issues: read
checks: write
pull-requests: write

steps:
- name: "Checkout"
Expand All @@ -40,5 +46,65 @@ jobs:
- name: "Build"
run: dotnet build --configuration Release --no-restore

- name: "Test"
run: dotnet test --configuration Release --no-build --verbosity normal --logger "console;verbosity=detailed"
- name: "Run tests"
run: dotnet test --configuration Release --no-build --verbosity normal --results-directory ${{ env.TEST_RESULTS_DIRECTORY }} --collect:"XPlat Code Coverage"

- name: "Combine Coverage Reports" # This is because one report is produced per project, and we want one result for all of them.
uses: danielpalme/[email protected]
with:
reports: "**/*.cobertura.xml" # REQUIRED # The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
targetdir: "${{ github.workspace }}" # REQUIRED # The directory where the generated report should be saved.
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
verbosity: "Info" # The verbosity level of the log messages. Values: Verbose, Info, Warning, Error, Off
title: "Code Coverage" # Optional title.
tag: "${{ github.run_number }}_${{ github.run_id }}" # Optional tag or build version.
customSettings: "" # Optional custom settings (separated by semicolon). See: https://github.com/danielpalme/ReportGenerator/wiki/Settings.
toolpath: "reportgeneratortool" # Default directory for installing the dotnet tool.

- name: "Upload Combined Coverage"
uses: actions/upload-artifact@v4
with:
name: 'Coverage'
path: ${{ github.workspace }}/Cobertura.xml

- name: "Publish code coverage report"
uses: irongut/[email protected]
with:
filename: "Cobertura.xml"
badge: true
fail_below_min: false # just informative for now
format: markdown
hide_branch_rate: false
hide_complexity: false
indicators: true
output: both
thresholds: "10 30"

- 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

- name: "Upload Test Results"
uses: actions/upload-artifact@v4
with:
name: 'TestResults'
path: ${{ env.TEST_RESULTS_DIRECTORY }}/**/*

- name: "Publish Test Tesults"
uses: dorny/test-reporter@v1
if: always()
with:
name: "Test Results"
path: "${{ env.TEST_RESULTS_DIRECTORY }}/**/*.trx"
reporter: dotnet-trx

- name: "Publish Test Summary"
uses: EnricoMi/[email protected]
if: always()
with:
check_name: "Test Summary"
# NOTE: using trx_files instead of files due to https://github.com/EnricoMi/publish-unit-test-result-action/issues/424
trx_files: "${{ env.TEST_RESULTS_DIRECTORY }}/**/*.trx"
1 change: 1 addition & 0 deletions tests/PowerUtils.xUnit.Extensions.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


<PropertyGroup>
<VSTestLogger>trx%3bLogFileName=$(MSBuildProjectName)_$(TargetFramework).trx</VSTestLogger>
<DefaultItemExcludes>$(DefaultItemExcludes);coverage.*opencover.xml</DefaultItemExcludes>
</PropertyGroup>

Expand Down

0 comments on commit 112421a

Please sign in to comment.