Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/livefront/danger-shroud
🧛🏼♂️A danger plugin for enforcing code coverage via a Jacoco coverage report 🧛🏼♂️
https://github.com/livefront/danger-shroud
Last synced: 3 months ago
JSON representation
🧛🏼♂️A danger plugin for enforcing code coverage via a Jacoco coverage report 🧛🏼♂️
- Host: GitHub
- URL: https://github.com/livefront/danger-shroud
- Owner: livefront
- License: apache-2.0
- Created: 2019-06-07T20:32:16.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-19T02:38:50.000Z (11 months ago)
- Last Synced: 2024-10-20T09:56:47.983Z (4 months ago)
- Language: Ruby
- Homepage:
- Size: 126 KB
- Stars: 10
- Watchers: 10
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-danger - danger-shroud - A danger plugin for enforcing code coverage via a Jacoco coverage report. (Plugins / Ruby (danger))
README
- [danger-shroud](#danger-shroud)
- [Installation](#installation)
- [Usage Kover](#usage-kover)
- [Parameters](#parameters)
- [Examples](#examples)
- [Usage Jacoco](#usage-jacoco)
- [Parameters](#parameters-1)
- [Examples](#examples-1)
- [Development](#development)# danger-shroud
A danger plugin for enforcing code coverage coverage via a Kover or Jacoco coverage report.
![Shroud Banner Image](images/bannerImage.png)
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'danger-shroud'
```## Usage Kover
Shroud depends on having a Kover coverage report generated for your project. For Android projects, [kotlinx-kover](https://github.com/Kotlin/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:
```ruby
# Report coverage of modified files, fail if either total
# project coverage or any modified file's coverage is under 90%
shroud.reportKover 'Module Name', 'path/to/kover/report.xml'
```Running shroud with custom coverage thresholds:
```ruby
# 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 'Module Name', 'path/to/kover/report.xml', 80, 95
```Warn on builds instead of fail:
```ruby
# 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 'Module Name', 'path/to/kover/report.xml', 80, 95, false, 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 Kover 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](https://github.com/arturdm/jacoco-android-gradle-plugin) works well.
Running shroud with default values:
```ruby
# Report coverage of modified files, fail if either total
# project coverage or any modified file's coverage is under 90%
shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml'
```Running shroud with custom coverage thresholds:
```ruby
# 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 'Module Name', 'path/to/jacoco/report.xml', 80, 95
```Warn on builds instead of fail:
```ruby
# 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 'Module Name', 'path/to/jacoco/report.xml', 80, 95, false, 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.