Skip to content

im-open/code-coverage-report-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ReportGenerator

This action is a simplied version of [danielpalme/ReportGenerator-GitHub-Action]. It functions as a wrapper for the dotnet-reportgenerator-globaltool.

[ReportGenerator] converts coverage reports generated by OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.

This action does not generate the code coverage reports itself, those must be created by a previous action.

Index

Inputs

Parameter Is Required Default Value Description
reports false */**/coverage.opencover.xml The coverage reports that should be parsed (separated by semicolon). Globbing is supported.
targetdir false coverage-results The directory where the generated report should be saved.
reporttypes false Html;MarkdownSummary; The output formats and scope (separated by semicolon)
Values: Badges, Clover, Cobertura, CsvSummary, Html, HtmlChart, HtmlInline, HtmlInline_AzurePipelines, HtmlInline_AzurePipelines_Dark, HtmlSummary, JsonSummary, Latex, LatexSummary, lcov, MarkdownSummary, MHtml, PngChart, SonarQube, TeamCitySummary, TextSummary, Xml, XmlSummary
assemblyfilters false +* Optional list of assemblies that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
classfilters false +* Optional list of classes that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
filefilters false +* Optional list of files that should be included or excluded in the report. Exclusion filters take precedence over inclusion filters. Wildcards are allowed.
verbosity false Info The verbosity level of the log messages.
Values: Verbose, Info, Warning, Error, Off
title false '' Optional title.
tag false ${{ github.run_number }}_${{ github.run_id }} Optional tag or build version.

Outputs

Output Description
error-reason If there are failures, a brief description of the error.

Usage Examples

- name: Setup .NET Core         # Required to execute ReportGenerator
  uses: actions/setup-dotnet@v1
  with:
    dotnet-version: 8.x  # Needs to be 5.0 or higher

- name: dotnet test with coverage
  continue-on-error: true
  run: dotnet test ${{ env.SOLUTION }} --no-restore --logger trx --configuration Release /property:CollectCoverage=True /property:CoverletOutputFormat=opencover

- name: ReportGenerator
  # You may also reference the major or major.minor version
  uses: im-open/code-coverage-report-generator@v5.0.0
  with:
    reports: '*/**/coverage.opencover.xml'
    targetdir: ${{ env.CODE_COVERAGE_DIR }}'
    reporttypes: 'Html;MarkdownSummary'
    assemblyfilters: '-xunit*;-Dapper;'
    classfilters: '+*'
    filefilters: '-Startup.cs;-Program.cs;-*.cshtml'
    verbosity: 'Warning'
    title: ${{ env.CODE_COVERAGE_REPORT_NAME }}
    tag: '${{ github.workflow}}_${{ github.run_id }}'
    

- name: Upload coverage report artifact
  uses: actions/upload-artifact@v4
  with:
    name: Coverage Report
    path: ${{ env.CODE_COVERAGE_DIR }}

- name: Create a PR comment from the summary file
  uses: im-open/process-code-coverage-summary@v2
  with:
    github-token: ${{ secrets.GITHUB_TOKEN }}
    summary-file: '${{ env.CODE_COVERAGE_DIR }}/Summary.md'
    create-pr-comment: true
    create-status-check: false

Breaking changes

4.9.2 to v5.0.0

  • The toolpath input was removed since it was underutilized. v5 and above will check for the presence of the tool in the ./reportgeneratortool directory, which was the default location in prior versions. If that directory does not exist, the tool will be installed with v4.8.12. If desired, a different version of the global tool can be installed in this location prior to this action but different versions of the report generator tool may or may not be compatible with this action's code.
    • The 4.8.12 version of the tool is older but will continue to be used to preserve metrics in the generated reports that newer versions no longer produce.
  • The following inputs were not utilized and have been removed completely from the action starting with v5.
    • sourcedirs
    • historydir
    • plugins
    • customSettings
  • Previously, each version of the action had two tags, one with the v prefix and one without it. There will only be one tag per version going forward and it includes the v prefix.

Contributing

When creating PRs, please review the following guidelines:

  • The action code does not contain sensitive information.
  • At least one of the commit messages contains the appropriate +semver: keywords listed under Incrementing the Version for major and minor increments.
  • The action has been recompiled. See Recompiling Manually for details.
  • The README.md has been updated with the latest version of the action. See Updating the README.md for details.

Incrementing the Version

This repo uses git-version-lite in its workflows to examine commit messages to determine whether to perform a major, minor or patch increment on merge if source code changes have been made. The following table provides the fragment that should be included in a commit message to active different increment strategies.

Increment Type Commit Message Fragment
major +semver:breaking
major +semver:major
minor +semver:feature
minor +semver:minor
patch default increment type, no comment needed

Source Code Changes

The files and directories that are considered source code are listed in the files-with-code and dirs-with-code arguments in both the build-and-review-pr and increment-version-on-merge workflows.

If a PR contains source code changes, the README.md should be updated with the latest action version and the action should be recompiled. The build-and-review-pr workflow will ensure these steps are performed when they are required. The workflow will provide instructions for completing these steps if the PR Author does not initially complete them.

If a PR consists solely of non-source code changes like changes to the README.md or workflows under ./.github/workflows, version updates and recompiles do not need to be performed.

Recompiling Manually

This command utilizes esbuild to bundle the action and its dependencies into a single file located in the dist folder. If changes are made to the action's source code, the action must be recompiled by running the following command:

# Installs dependencies and bundles the code
npm run build

Updating the README.md

If changes are made to the action's source code, the usage examples section of this file should be updated with the next version of the action. Each instance of this action should be updated. This helps users know what the latest tag is without having to navigate to the Tags page of the repository. See Incrementing the Version for details on how to determine what the next version will be or consult the first workflow run for the PR which will also calculate the next version.

Code of Conduct

This project has adopted the im-open's Code of Conduct.

License

Copyright © 2024, Extend Health, LLC. Code released under the MIT license.