danger-shroud 0.0.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +1 -1
- data/CHANGELOG.md +39 -0
- data/Gemfile.lock +61 -80
- data/README.md +72 -12
- data/lib/shroud/gem_version.rb +1 -1
- data/lib/shroud/plugin.rb +95 -41
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50b853e23a0b373fe8fd2d46815c09a2d4d56cd0ac66a41bacecffc7672446d3
|
4
|
+
data.tar.gz: af1b4ef7224ff201129b4dde31a3d08ab3a5d518e52e1721df8e1268d7d13c1a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82769480c25715d5e29c5d07f70a5b5621f20bee17b19385245c730b6c1697827f820a86457817cf3f86df47a79d7e21fc5ac907bb074cbde434d4b648cc203a
|
7
|
+
data.tar.gz: 21a734fba89debfb859fdda47f3ccfafe62c50cdeda68c3ad8c94d4419fcbb2ba75e75a22a9caaa23fb168d48453cb3f7478a778fd87add19cf1889a5572aab7
|
data/.github/dependabot.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
Change Log
|
2
|
+
==========
|
3
|
+
|
4
|
+
Version Next
|
5
|
+
----------------------------
|
6
|
+
|
7
|
+
|
8
|
+
Version 1.0.0
|
9
|
+
----------------------------
|
10
|
+
|
11
|
+
* Add 'coverageType' property and set default to ':line' instead of ':instruction'. (API Change)
|
12
|
+
* Add Named Parameters for all functions; users must now specify the name of each parameter being passed in. (Breaking Change)
|
13
|
+
* Remove 'report' function; users must now use 'reportKover' or 'reportJacoco' directly. (Breaking Change)
|
14
|
+
|
15
|
+
Version 0.0.7
|
16
|
+
----------------------------
|
17
|
+
|
18
|
+
* Add separate variables for the 'failIfUnderProjectThreshold' and 'failIfUnderFileThreshold'.
|
19
|
+
|
20
|
+
Version 0.0.6
|
21
|
+
----------------------------
|
22
|
+
|
23
|
+
* Target Ruby 2.7.2.
|
24
|
+
* Update publishing logic.
|
25
|
+
|
26
|
+
Version 0.0.5
|
27
|
+
----------------------------
|
28
|
+
|
29
|
+
* Add support for Kover test reports.
|
30
|
+
|
31
|
+
Version 0.0.4
|
32
|
+
----------------------------
|
33
|
+
|
34
|
+
* Migrate to Github Actions.
|
35
|
+
|
36
|
+
Version 0.0.3
|
37
|
+
----------------------------
|
38
|
+
|
39
|
+
* Initial release.
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
danger-shroud (0.0
|
4
|
+
danger-shroud (1.0.0)
|
5
5
|
danger-plugin-api (~> 1.0)
|
6
6
|
nokogiri
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
addressable (2.8.
|
12
|
-
public_suffix (>= 2.0.2, <
|
11
|
+
addressable (2.8.7)
|
12
|
+
public_suffix (>= 2.0.2, < 7.0)
|
13
13
|
ast (2.4.2)
|
14
|
+
base64 (0.2.0)
|
14
15
|
claide (1.1.0)
|
15
16
|
claide-plugins (0.9.2)
|
16
17
|
cork
|
@@ -20,53 +21,36 @@ GEM
|
|
20
21
|
colored2 (3.1.2)
|
21
22
|
cork (0.3.0)
|
22
23
|
colored2 (~> 3.1)
|
23
|
-
danger (9.1
|
24
|
+
danger (9.5.1)
|
25
|
+
base64 (~> 0.2)
|
24
26
|
claide (~> 1.0)
|
25
27
|
claide-plugins (>= 0.9.2)
|
26
28
|
colored2 (~> 3.1)
|
27
29
|
cork (~> 0.1)
|
28
|
-
faraday (>= 0.9.0, <
|
30
|
+
faraday (>= 0.9.0, < 3.0)
|
29
31
|
faraday-http-cache (~> 2.0)
|
30
|
-
git (~> 1.
|
32
|
+
git (~> 1.13)
|
31
33
|
kramdown (~> 2.3)
|
32
34
|
kramdown-parser-gfm (~> 1.0)
|
33
|
-
|
34
|
-
|
35
|
+
octokit (>= 4.0)
|
36
|
+
pstore (~> 0.1)
|
35
37
|
terminal-table (>= 1, < 4)
|
36
38
|
danger-plugin-api (1.0.0)
|
37
39
|
danger (> 2.0)
|
38
|
-
diff-lcs (1.5.
|
39
|
-
faraday (
|
40
|
-
|
41
|
-
faraday-
|
42
|
-
faraday-excon (~> 1.1)
|
43
|
-
faraday-httpclient (~> 1.0)
|
44
|
-
faraday-multipart (~> 1.0)
|
45
|
-
faraday-net_http (~> 1.0)
|
46
|
-
faraday-net_http_persistent (~> 1.0)
|
47
|
-
faraday-patron (~> 1.0)
|
48
|
-
faraday-rack (~> 1.0)
|
49
|
-
faraday-retry (~> 1.0)
|
40
|
+
diff-lcs (1.5.1)
|
41
|
+
faraday (2.8.1)
|
42
|
+
base64
|
43
|
+
faraday-net_http (>= 2.0, < 3.1)
|
50
44
|
ruby2_keywords (>= 0.0.4)
|
51
|
-
faraday-
|
52
|
-
faraday-em_synchrony (1.0.0)
|
53
|
-
faraday-excon (1.1.0)
|
54
|
-
faraday-http-cache (2.4.1)
|
45
|
+
faraday-http-cache (2.5.1)
|
55
46
|
faraday (>= 0.8)
|
56
|
-
faraday-
|
57
|
-
|
58
|
-
multipart-post (~> 2)
|
59
|
-
faraday-net_http (1.0.1)
|
60
|
-
faraday-net_http_persistent (1.2.0)
|
61
|
-
faraday-patron (1.0.0)
|
62
|
-
faraday-rack (1.0.0)
|
63
|
-
faraday-retry (1.0.3)
|
64
|
-
ffi (1.15.5)
|
47
|
+
faraday-net_http (3.0.2)
|
48
|
+
ffi (1.17.0)
|
65
49
|
formatador (1.1.0)
|
66
|
-
git (1.
|
50
|
+
git (1.19.1)
|
67
51
|
addressable (~> 2.8)
|
68
52
|
rchardet (~> 1.8)
|
69
|
-
guard (2.
|
53
|
+
guard (2.19.0)
|
70
54
|
formatador (>= 0.2.4)
|
71
55
|
listen (>= 2.7, < 4.0)
|
72
56
|
lumberjack (>= 1.0.12, < 2.0)
|
@@ -80,75 +64,74 @@ GEM
|
|
80
64
|
guard (~> 2.1)
|
81
65
|
guard-compat (~> 1.1)
|
82
66
|
rspec (>= 2.99.0, < 4.0)
|
83
|
-
json (2.
|
67
|
+
json (2.8.1)
|
84
68
|
kramdown (2.4.0)
|
85
69
|
rexml
|
86
70
|
kramdown-parser-gfm (1.1.0)
|
87
71
|
kramdown (~> 2.0)
|
72
|
+
language_server-protocol (3.17.0.3)
|
88
73
|
listen (3.0.7)
|
89
74
|
rb-fsevent (>= 0.9.3)
|
90
75
|
rb-inotify (>= 0.9.7)
|
91
|
-
lumberjack (1.2.
|
92
|
-
method_source (1.
|
93
|
-
mini_portile2 (2.8.
|
94
|
-
multipart-post (2.2.3)
|
76
|
+
lumberjack (1.2.10)
|
77
|
+
method_source (1.1.0)
|
78
|
+
mini_portile2 (2.8.7)
|
95
79
|
nap (1.1.0)
|
96
80
|
nenv (0.3.0)
|
97
|
-
|
98
|
-
|
99
|
-
mini_portile2 (~> 2.8.0)
|
100
|
-
racc (~> 1.4)
|
101
|
-
nokogiri (1.13.10-arm64-darwin)
|
81
|
+
nokogiri (1.15.6)
|
82
|
+
mini_portile2 (~> 2.8.2)
|
102
83
|
racc (~> 1.4)
|
103
84
|
notiffany (0.1.3)
|
104
85
|
nenv (~> 0.1)
|
105
86
|
shellany (~> 0.0)
|
106
|
-
octokit (
|
87
|
+
octokit (9.2.0)
|
107
88
|
faraday (>= 1, < 3)
|
108
89
|
sawyer (~> 0.9)
|
109
90
|
open4 (1.3.4)
|
110
|
-
parallel (1.
|
111
|
-
parser (3.
|
91
|
+
parallel (1.26.3)
|
92
|
+
parser (3.3.6.0)
|
112
93
|
ast (~> 2.4.1)
|
113
|
-
|
94
|
+
racc
|
95
|
+
pry (0.14.2)
|
114
96
|
coderay (~> 1.1)
|
115
97
|
method_source (~> 1.0)
|
116
|
-
|
117
|
-
|
98
|
+
pstore (0.1.3)
|
99
|
+
public_suffix (5.1.1)
|
100
|
+
racc (1.8.1)
|
118
101
|
rainbow (3.1.1)
|
119
|
-
rake (13.
|
102
|
+
rake (13.2.1)
|
120
103
|
rb-fsevent (0.11.2)
|
121
|
-
rb-inotify (0.
|
104
|
+
rb-inotify (0.11.1)
|
122
105
|
ffi (~> 1.0)
|
123
106
|
rchardet (1.8.0)
|
124
|
-
regexp_parser (2.
|
125
|
-
rexml (3.
|
126
|
-
rspec (3.
|
127
|
-
rspec-core (~> 3.
|
128
|
-
rspec-expectations (~> 3.
|
129
|
-
rspec-mocks (~> 3.
|
130
|
-
rspec-core (3.
|
131
|
-
rspec-support (~> 3.
|
132
|
-
rspec-expectations (3.
|
107
|
+
regexp_parser (2.9.2)
|
108
|
+
rexml (3.3.9)
|
109
|
+
rspec (3.13.0)
|
110
|
+
rspec-core (~> 3.13.0)
|
111
|
+
rspec-expectations (~> 3.13.0)
|
112
|
+
rspec-mocks (~> 3.13.0)
|
113
|
+
rspec-core (3.13.2)
|
114
|
+
rspec-support (~> 3.13.0)
|
115
|
+
rspec-expectations (3.13.3)
|
133
116
|
diff-lcs (>= 1.2.0, < 2.0)
|
134
|
-
rspec-support (~> 3.
|
135
|
-
rspec-mocks (3.
|
117
|
+
rspec-support (~> 3.13.0)
|
118
|
+
rspec-mocks (3.13.2)
|
136
119
|
diff-lcs (>= 1.2.0, < 2.0)
|
137
|
-
rspec-support (~> 3.
|
138
|
-
rspec-support (3.
|
139
|
-
rubocop (1.
|
120
|
+
rspec-support (~> 3.13.0)
|
121
|
+
rspec-support (3.13.1)
|
122
|
+
rubocop (1.68.0)
|
140
123
|
json (~> 2.3)
|
124
|
+
language_server-protocol (>= 3.17.0)
|
141
125
|
parallel (~> 1.10)
|
142
|
-
parser (>= 3.
|
126
|
+
parser (>= 3.3.0.2)
|
143
127
|
rainbow (>= 2.2.2, < 4.0)
|
144
|
-
regexp_parser (>=
|
145
|
-
|
146
|
-
rubocop-ast (>= 1.23.0, < 2.0)
|
128
|
+
regexp_parser (>= 2.4, < 3.0)
|
129
|
+
rubocop-ast (>= 1.32.2, < 2.0)
|
147
130
|
ruby-progressbar (~> 1.7)
|
148
|
-
unicode-display_width (>=
|
149
|
-
rubocop-ast (1.
|
150
|
-
parser (>= 3.
|
151
|
-
ruby-progressbar (1.
|
131
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
132
|
+
rubocop-ast (1.36.1)
|
133
|
+
parser (>= 3.3.1.0)
|
134
|
+
ruby-progressbar (1.13.0)
|
152
135
|
ruby2_keywords (0.0.5)
|
153
136
|
sawyer (0.9.2)
|
154
137
|
addressable (>= 2.3.5)
|
@@ -156,11 +139,9 @@ GEM
|
|
156
139
|
shellany (0.0.1)
|
157
140
|
terminal-table (3.0.2)
|
158
141
|
unicode-display_width (>= 1.1.1, < 3)
|
159
|
-
thor (1.2
|
160
|
-
unicode-display_width (2.
|
161
|
-
|
162
|
-
yard (0.9.28)
|
163
|
-
webrick (~> 1.7.0)
|
142
|
+
thor (1.3.2)
|
143
|
+
unicode-display_width (2.6.0)
|
144
|
+
yard (0.9.37)
|
164
145
|
|
165
146
|
PLATFORMS
|
166
147
|
ruby
|
data/README.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
|
2
|
+
- [danger-shroud](#danger-shroud)
|
3
|
+
- [Installation](#installation)
|
4
|
+
- [Usage Kover](#usage-kover)
|
5
|
+
- [Parameters](#parameters)
|
6
|
+
- [Examples](#examples)
|
7
|
+
- [Usage Jacoco](#usage-jacoco)
|
8
|
+
- [Parameters](#parameters-1)
|
9
|
+
- [Examples](#examples-1)
|
10
|
+
- [Development](#development)
|
11
|
+
- [Versioning](#versioning)
|
12
|
+
|
1
13
|
# danger-shroud
|
2
14
|
|
3
15
|
A danger plugin for enforcing code coverage coverage via a Kover or Jacoco coverage report.
|
@@ -16,12 +28,28 @@ gem 'danger-shroud'
|
|
16
28
|
|
17
29
|
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.
|
18
30
|
|
31
|
+
### Parameters
|
32
|
+
|
33
|
+
You can use the following parameters to control how shroud operates:
|
34
|
+
|
35
|
+
| Param | Type | Description | Example |
|
36
|
+
|-----------------------------|---------|---------------------------------------------------------------------------------------------|------------------------------|
|
37
|
+
| moduleName | String | the display name of the project or module. | `'Module Name '` |
|
38
|
+
| file | String | file path to a Kover xml coverage report. | `'path/to/kover/report.xml'` |
|
39
|
+
| totalProjectThreshold | Integer | defines the required percentage of total project coverage for a passing build. | default `90` |
|
40
|
+
| modifiedFileThreshold | Integer | defines the required percentage of files modified in a PR for a passing build. | default `90` |
|
41
|
+
| failIfUnderProjectThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true` |
|
42
|
+
| failIfUnderFileThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true` |
|
43
|
+
| coverageType | enum | the type of coverage to use (:branch, :class, :instruction, :line, and :method). | default `:line` |
|
44
|
+
|
45
|
+
### Examples
|
46
|
+
|
19
47
|
Running shroud with default values:
|
20
48
|
|
21
49
|
```ruby
|
22
50
|
# Report coverage of modified files, fail if either total
|
23
51
|
# project coverage or any modified file's coverage is under 90%
|
24
|
-
shroud.reportKover 'Module Name', 'path/to/kover/report.xml'
|
52
|
+
shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml'
|
25
53
|
```
|
26
54
|
|
27
55
|
Running shroud with custom coverage thresholds:
|
@@ -29,20 +57,35 @@ Running shroud with custom coverage thresholds:
|
|
29
57
|
```ruby
|
30
58
|
# Report coverage of modified files, fail if total project coverage is under 80%,
|
31
59
|
# or if any modified file's coverage is under 95%
|
32
|
-
shroud.reportKover 'Module Name', 'path/to/kover/report.xml', 80, 95
|
60
|
+
shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95
|
33
61
|
```
|
34
62
|
|
35
63
|
Warn on builds instead of fail:
|
36
64
|
|
37
65
|
```ruby
|
38
66
|
# Report coverage of modified files the same as the above example, except the
|
39
|
-
# builds will only warn instead of fail if below thresholds
|
40
|
-
shroud.reportKover 'Module Name', 'path/to/kover/report.xml', 80, 95, false
|
67
|
+
# builds will only warn instead of fail if below project thresholds
|
68
|
+
shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
|
41
69
|
```
|
42
70
|
|
43
|
-
|
44
71
|
## Usage Jacoco
|
45
72
|
|
73
|
+
### Parameters
|
74
|
+
|
75
|
+
You can use the following parameters to control how shroud operates:
|
76
|
+
|
77
|
+
| Param | Type | Description | Example |
|
78
|
+
|-----------------------------|---------|---------------------------------------------------------------------------------------------|-------------------------------|
|
79
|
+
| moduleName | String | the display name of the project or module. | `'Module Name '` |
|
80
|
+
| file | String | file path to a Jacoco xml coverage report. | `'path/to/jacoco/report.xml'` |
|
81
|
+
| totalProjectThreshold | Integer | defines the required percentage of total project coverage for a passing build. | default `90` |
|
82
|
+
| modifiedFileThreshold | Integer | defines the required percentage of files modified in a PR for a passing build. | default `90` |
|
83
|
+
| failIfUnderProjectThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true` |
|
84
|
+
| failIfUnderFileThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true` |
|
85
|
+
| coverageType | enum | the type of coverage to use (:branch, :class, :instruction, :line, and :method). | default `:line` |
|
86
|
+
|
87
|
+
### Examples
|
88
|
+
|
46
89
|
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.
|
47
90
|
|
48
91
|
Running shroud with default values:
|
@@ -50,7 +93,7 @@ Running shroud with default values:
|
|
50
93
|
```ruby
|
51
94
|
# Report coverage of modified files, fail if either total
|
52
95
|
# project coverage or any modified file's coverage is under 90%
|
53
|
-
shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml'
|
96
|
+
shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml'
|
54
97
|
```
|
55
98
|
|
56
99
|
Running shroud with custom coverage thresholds:
|
@@ -58,7 +101,7 @@ Running shroud with custom coverage thresholds:
|
|
58
101
|
```ruby
|
59
102
|
# Report coverage of modified files, fail if total project coverage is under 80%,
|
60
103
|
# or if any modified file's coverage is under 95%
|
61
|
-
shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml', 80, 95
|
104
|
+
shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95
|
62
105
|
```
|
63
106
|
|
64
107
|
Warn on builds instead of fail:
|
@@ -66,16 +109,33 @@ Warn on builds instead of fail:
|
|
66
109
|
```ruby
|
67
110
|
# Report coverage of modified files the same as the above example, except the
|
68
111
|
# builds will only warn instead of fail if below thresholds
|
69
|
-
shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml', 80, 95, false
|
112
|
+
shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
|
70
113
|
```
|
71
114
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
115
|
## Development
|
76
116
|
|
77
117
|
1. Clone this repo
|
78
118
|
2. Run `bundle install` to setup dependencies.
|
79
119
|
3. Run `bundle exec rake spec` to run the tests.
|
80
120
|
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
81
|
-
5. Make your changes.
|
121
|
+
5. Make your changes.
|
122
|
+
|
123
|
+
## Versioning
|
124
|
+
|
125
|
+
This repository conforms to the semantic versioning convention:
|
126
|
+
|
127
|
+
```
|
128
|
+
v[MAJOR].[MINOR].[PATCH]
|
129
|
+
```
|
130
|
+
|
131
|
+
where
|
132
|
+
|
133
|
+
[MAJOR] is incremented when an incompatible API change is made or a major milestone that significantly changes the library is achieved.
|
134
|
+
|
135
|
+
[MINOR] is incremented when new functionality is introduced in a backward-compatible manner.
|
136
|
+
|
137
|
+
[PATCH] is incremented when a backward-compatible bug fix is introduced.
|
138
|
+
|
139
|
+
All updates should have a corresponding CHANGELOG.md entry that at a high-level describes what is being newly introduced in it.
|
140
|
+
|
141
|
+
When incrementing a level any lower-levels should always reset to 0.
|
data/lib/shroud/gem_version.rb
CHANGED
data/lib/shroud/plugin.rb
CHANGED
@@ -11,66 +11,59 @@ module Danger
|
|
11
11
|
#
|
12
12
|
# # Report coverage of modified files, fail if either total project coverage
|
13
13
|
# # or any modified file's coverage is under 90%
|
14
|
-
# shroud.reportKover 'Project Name', 'path/to/kover/report.xml'
|
14
|
+
# shroud.reportKover moduleName: 'Project Name', file: 'path/to/kover/report.xml'
|
15
15
|
#
|
16
16
|
# @example Running Shroud with custom coverage thresholds for Kover
|
17
17
|
#
|
18
18
|
# # Report coverage of modified files, fail if total project coverage is under 80%,
|
19
19
|
# # or if any modified file's coverage is under 95%
|
20
|
-
# shroud.reportKover 'Project Name', 'path/to/kover/report.xml', 80, 95
|
20
|
+
# shroud.reportKover moduleName: 'Project Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95
|
21
21
|
#
|
22
22
|
# @example Warn on builds instead of fail for Kover
|
23
23
|
#
|
24
24
|
# # Report coverage of modified files the same as the above example, except the
|
25
25
|
# # builds will only warn instead of fail if below thresholds
|
26
|
-
# shroud.reportKover 'Project Name', 'path/to/kover/report.xml', 80, 95, false
|
26
|
+
# shroud.reportKover moduleName: 'Project Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
|
27
27
|
#
|
28
28
|
# @example Running Shroud with default values for Jacoco
|
29
29
|
#
|
30
30
|
# # Report coverage of modified files, fail if either total project coverage
|
31
31
|
# # or any modified file's coverage is under 90%
|
32
|
-
# shroud.reportJacoco 'Project Name', 'path/to/jacoco/report.xml'
|
32
|
+
# shroud.reportJacoco moduleName: 'Project Name', file: 'path/to/jacoco/report.xml'
|
33
33
|
#
|
34
34
|
# @example Running Shroud with custom coverage thresholds for Jacoco
|
35
35
|
#
|
36
36
|
# # Report coverage of modified files, fail if total project coverage is under 80%,
|
37
37
|
# # or if any modified file's coverage is under 95%
|
38
|
-
# shroud.reportJacoco 'Project Name', 'path/to/jacoco/report.xml', 80, 95
|
38
|
+
# shroud.reportJacoco moduleName: 'Project Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95
|
39
39
|
#
|
40
40
|
# @example Warn on builds instead of fail for Jacoco
|
41
41
|
#
|
42
42
|
# # Report coverage of modified files the same as the above example, except the
|
43
43
|
# # builds will only warn instead of fail if below thresholds
|
44
|
-
# shroud.reportJacoco 'Project Name', 'path/to/jacoco/report.xml', 80, 95, false
|
44
|
+
# shroud.reportJacoco moduleName: 'Project Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
|
45
45
|
#
|
46
46
|
# @tags android, kover, jacoco, coverage
|
47
47
|
#
|
48
48
|
class DangerShroud < Plugin
|
49
49
|
|
50
|
-
#
|
50
|
+
# Defines the method of coverage to be used
|
51
51
|
#
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
#
|
56
|
-
#
|
57
|
-
# @param [Integer] totalProjectThreshold
|
58
|
-
# defines the required percentage of total project coverage for a passing build.
|
59
|
-
# default 90.
|
60
|
-
#
|
61
|
-
# @param [Integer] modifiedFileThreshold
|
62
|
-
# defines the required percentage of files modified in a PR for a passing build.
|
63
|
-
# default 90.
|
64
|
-
#
|
65
|
-
# @param [Boolean] failIfUnderThreshold
|
66
|
-
# if true, will fail builds that are under the provided thresholds. if false, will only warn.
|
67
|
-
# default true.
|
52
|
+
# * Branch
|
53
|
+
# * Class
|
54
|
+
# * Instruction
|
55
|
+
# * Line
|
56
|
+
# * Method
|
68
57
|
#
|
69
|
-
# @
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
58
|
+
# @example
|
59
|
+
# COVERAGE_TYPE[:line] #=> 'LINE'
|
60
|
+
COVERAGE_TYPE = {
|
61
|
+
branch: 'BRANCH',
|
62
|
+
class: 'CLASS',
|
63
|
+
instruction: 'INSTRUCTION',
|
64
|
+
line: 'LINE',
|
65
|
+
method: 'METHOD'
|
66
|
+
}.freeze
|
74
67
|
|
75
68
|
# Report coverage on diffed files, as well as overall coverage.
|
76
69
|
#
|
@@ -88,13 +81,38 @@ module Danger
|
|
88
81
|
# defines the required percentage of files modified in a PR for a passing build.
|
89
82
|
# default 90.
|
90
83
|
#
|
91
|
-
# @param [Boolean]
|
92
|
-
# if true, will fail builds that are under the provided thresholds.
|
84
|
+
# @param [Boolean] failIfUnderProjectThreshold
|
85
|
+
# if true, will fail builds that are under the provided thresholds for the overall project. If false, will only warn.
|
93
86
|
# default true.
|
94
87
|
#
|
88
|
+
# @param [Boolean] failIfUnderFileThreshold
|
89
|
+
# if true, will fail builds that are under the provided thresholds per file. If false, will only warn.
|
90
|
+
# default true.
|
91
|
+
#
|
92
|
+
# @param [Symbol] coverageType
|
93
|
+
# defines the type of coverage to use.
|
94
|
+
# default line.
|
95
|
+
#
|
95
96
|
# @return [void]
|
96
|
-
def reportJacoco(
|
97
|
-
|
97
|
+
def reportJacoco(
|
98
|
+
moduleName:,
|
99
|
+
file:,
|
100
|
+
totalProjectThreshold: 90,
|
101
|
+
modifiedFileThreshold: 90,
|
102
|
+
failIfUnderProjectThreshold: true,
|
103
|
+
failIfUnderFileThreshold: failIfUnderProjectThreshold,
|
104
|
+
coverageType: :line
|
105
|
+
)
|
106
|
+
internalReport(
|
107
|
+
reportType: 'Jacoco',
|
108
|
+
moduleName: moduleName,
|
109
|
+
file: file,
|
110
|
+
totalProjectThreshold: totalProjectThreshold,
|
111
|
+
modifiedFileThreshold: modifiedFileThreshold,
|
112
|
+
failIfUnderProjectThreshold: failIfUnderProjectThreshold,
|
113
|
+
failIfUnderFileThreshold: failIfUnderFileThreshold,
|
114
|
+
coverageType: coverageType
|
115
|
+
)
|
98
116
|
end
|
99
117
|
|
100
118
|
# Report coverage on diffed files, as well as overall coverage.
|
@@ -113,21 +131,57 @@ module Danger
|
|
113
131
|
# defines the required percentage of files modified in a PR for a passing build.
|
114
132
|
# default 90.
|
115
133
|
#
|
116
|
-
# @param [Boolean]
|
117
|
-
# if true, will fail builds that are under the provided thresholds.
|
134
|
+
# @param [Boolean] failIfUnderProjectThreshold
|
135
|
+
# if true, will fail builds that are under the provided thresholds for the overall project. If false, will only warn.
|
118
136
|
# default true.
|
119
137
|
#
|
138
|
+
# @param [Boolean] failIfUnderFileThreshold
|
139
|
+
# if true, will fail builds that are under the provided thresholds per file. If false, will only warn.
|
140
|
+
# default true.
|
141
|
+
#
|
142
|
+
# @param [Symbol] coverageType
|
143
|
+
# defines the type of coverage to use.
|
144
|
+
# default line.
|
145
|
+
#
|
120
146
|
# @return [void]
|
121
|
-
def reportKover(
|
122
|
-
|
147
|
+
def reportKover(
|
148
|
+
moduleName:,
|
149
|
+
file:,
|
150
|
+
totalProjectThreshold: 90,
|
151
|
+
modifiedFileThreshold: 90,
|
152
|
+
failIfUnderProjectThreshold: true,
|
153
|
+
failIfUnderFileThreshold: failIfUnderProjectThreshold,
|
154
|
+
coverageType: :line
|
155
|
+
)
|
156
|
+
internalReport(
|
157
|
+
reportType: 'Kover',
|
158
|
+
moduleName: moduleName,
|
159
|
+
file: file,
|
160
|
+
totalProjectThreshold: totalProjectThreshold,
|
161
|
+
modifiedFileThreshold: modifiedFileThreshold,
|
162
|
+
failIfUnderProjectThreshold: failIfUnderProjectThreshold,
|
163
|
+
failIfUnderFileThreshold: failIfUnderFileThreshold,
|
164
|
+
coverageType: coverageType
|
165
|
+
)
|
123
166
|
end
|
124
167
|
|
125
|
-
private def internalReport(
|
168
|
+
private def internalReport(
|
169
|
+
reportType:,
|
170
|
+
moduleName:,
|
171
|
+
file:,
|
172
|
+
totalProjectThreshold:,
|
173
|
+
modifiedFileThreshold:,
|
174
|
+
failIfUnderProjectThreshold:,
|
175
|
+
failIfUnderFileThreshold:,
|
176
|
+
coverageType:
|
177
|
+
)
|
126
178
|
raise "Please specify file name." if file.empty?
|
127
179
|
raise "No #{reportType} xml report found at #{file}" unless File.exist? file
|
180
|
+
coverageMethod = COVERAGE_TYPE[coverageType]
|
181
|
+
raise "Undefined coverage type" if coverageMethod.nil?
|
128
182
|
rawXml = File.read(file)
|
129
183
|
parsedXml = Nokogiri::XML.parse(rawXml)
|
130
|
-
totalInstructionCoverage = parsedXml.xpath("/report/counter[@type='
|
184
|
+
totalInstructionCoverage = parsedXml.xpath("/report/counter[@type='#{coverageMethod}']")
|
131
185
|
missed = totalInstructionCoverage.attr("missed").value.to_i
|
132
186
|
covered = totalInstructionCoverage.attr("covered").value.to_i
|
133
187
|
total = missed + covered
|
@@ -144,7 +198,7 @@ module Danger
|
|
144
198
|
touchedFilesHash = {}
|
145
199
|
|
146
200
|
touchedFileNames.each do |touchedFileName|
|
147
|
-
xmlForFileName = parsedXml.xpath("//class[@sourcefilename='#{touchedFileName}']/counter[@type='
|
201
|
+
xmlForFileName = parsedXml.xpath("//class[@sourcefilename='#{touchedFileName}']/counter[@type='#{coverageMethod}']")
|
148
202
|
|
149
203
|
if (xmlForFileName.length > 0)
|
150
204
|
missed = 0
|
@@ -177,7 +231,7 @@ module Danger
|
|
177
231
|
# warn or fail if under specified file threshold:
|
178
232
|
if (coveragePercent < modifiedFileThreshold)
|
179
233
|
warningMessage = "Uh oh! #{fileName} is under #{modifiedFileThreshold}% coverage!"
|
180
|
-
if (
|
234
|
+
if (failIfUnderFileThreshold)
|
181
235
|
fail warningMessage
|
182
236
|
else
|
183
237
|
warn warningMessage
|
@@ -196,7 +250,7 @@ module Danger
|
|
196
250
|
# warn or fail if total coverage is under specified threshold
|
197
251
|
if (coveragePercent < totalProjectThreshold)
|
198
252
|
totalCoverageWarning = "Uh oh! Your project is under #{totalProjectThreshold}% coverage!"
|
199
|
-
if (
|
253
|
+
if (failIfUnderProjectThreshold)
|
200
254
|
fail totalCoverageWarning
|
201
255
|
else
|
202
256
|
warn totalCoverageWarning
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-shroud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- andrewhaisting
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -176,6 +176,7 @@ files:
|
|
176
176
|
- ".github/workflows/publish.yml"
|
177
177
|
- ".gitignore"
|
178
178
|
- ".ruby-version"
|
179
|
+
- CHANGELOG.md
|
179
180
|
- Gemfile
|
180
181
|
- Gemfile.lock
|
181
182
|
- Guardfile
|
@@ -194,7 +195,7 @@ homepage: https://github.com/livefront/livefront-shroud-android
|
|
194
195
|
licenses:
|
195
196
|
- MIT
|
196
197
|
metadata: {}
|
197
|
-
post_install_message:
|
198
|
+
post_install_message:
|
198
199
|
rdoc_options: []
|
199
200
|
require_paths:
|
200
201
|
- lib
|
@@ -210,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
211
|
version: '0'
|
211
212
|
requirements: []
|
212
213
|
rubygems_version: 3.1.4
|
213
|
-
signing_key:
|
214
|
+
signing_key:
|
214
215
|
specification_version: 4
|
215
216
|
summary: A danger plugin for enforcing code coverage via a Jacoco coverage report.
|
216
217
|
test_files:
|