0.01
No release in over a year
Enforce Jacoco code coverage on CI.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.2
~> 2.14
= 3.0.7
>= 0
~> 13.0
~> 3.4
>= 0

Runtime

 Project Readme
  • danger-shroud
    • Installation
    • Usage Kover
      • Parameters
      • Examples
    • Usage Jacoco
      • Parameters
      • Examples
    • Development

danger-shroud

A danger plugin for enforcing code coverage coverage via a Kover or Jacoco coverage report.

Shroud Banner Image

Installation

Add this line to your application's Gemfile:

gem 'danger-shroud'

Usage Kover

Shroud depends on having a Kover coverage report generated for your project. For Android projects, kotlinx-kover works well.

Parameters

You can use the following parameters to control how shroud operates:

Param Type Description Example
moduleName String the display name of the project or module. 'Module Name '
file String file path to a Kover xml coverage report. 'path/to/kover/report.xml'
totalProjectThreshold Integer defines the required percentage of total project coverage for a passing build. default 90
modifiedFileThreshold Integer defines the required percentage of files modified in a PR for a passing build. default 90
failIfUnderProjectThreshold Boolean if true, will fail builds that are under the provided thresholds. if false, will only warn. default true
failIfUnderFileThreshold Boolean if true, will fail builds that are under the provided thresholds. if false, will only warn. default true

Examples

Running shroud with default values:

# Report coverage of modified files, fail if either total 
# project coverage or any modified file's coverage is under 90%
shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml'

Running shroud with custom coverage thresholds:

# Report coverage of modified files, fail if total project coverage is under 80%,
# or if any modified file's coverage is under 95%
shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95

Warn on builds instead of fail:

# Report coverage of modified files the same as the above example, except the
# builds will only warn instead of fail if below project thresholds
shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false

Usage Jacoco

Parameters

You can use the following parameters to control how shroud operates:

Param Type Description Example
moduleName String the display name of the project or module. 'Module Name '
file String file path to a Jacoco xml coverage report. 'path/to/jacoco/report.xml'
totalProjectThreshold Integer defines the required percentage of total project coverage for a passing build. default 90
modifiedFileThreshold Integer defines the required percentage of files modified in a PR for a passing build. default 90
failIfUnderProjectThreshold Boolean if true, will fail builds that are under the provided thresholds. if false, will only warn. default true
failIfUnderFileThreshold Boolean if true, will fail builds that are under the provided thresholds. if false, will only warn. default true

Examples

Shroud depends on having a Jacoco coverage report generated for your project. For Android projects, jacoco-android-gradle-plugin works well.

Running shroud with default values:

# Report coverage of modified files, fail if either total 
# project coverage or any modified file's coverage is under 90%
shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml'

Running shroud with custom coverage thresholds:

# Report coverage of modified files, fail if total project coverage is under 80%,
# or if any modified file's coverage is under 95%
shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95

Warn on builds instead of fail:

# Report coverage of modified files the same as the above example, except the
# builds will only warn instead of fail if below thresholds
shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false

Development

  1. Clone this repo
  2. Run bundle install to setup dependencies.
  3. Run bundle exec rake spec to run the tests.
  4. Use bundle exec guard to automatically have tests run as you make changes.
  5. Make your changes.