danger-shroud 0.0.7 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/.github/workflows/publish.yml +1 -1
- data/.ruby-version +1 -1
- data/CHANGELOG.md +42 -0
- data/Gemfile.lock +79 -62
- data/README.md +46 -23
- data/lib/shroud/gem_version.rb +1 -1
- data/lib/shroud/plugin.rb +81 -39
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9dc7c91737f9342eb62d48933887ac740b95cdb422497c7329a5a1e51214e59
|
4
|
+
data.tar.gz: e0e5805f272abc2dbc075871face1e3cb6cbf46a48a38f45f4823cc514c045d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f77902e316f4d2b96a2e27254586eeebf2bef8863a2893e0faa3246a064a5ed7072b3ae10f1420d916074c422ff931d8fb6eecc917d90c73ffd88ddf13d238d
|
7
|
+
data.tar.gz: 62890a17e53b620a7648e654d09b3c7a838cf6920d42ab40c61ba9d887ad2d9afc888e6a9e2d70cf3fe90c44ab28f7f4fdf307c78e66728d980ee5e9fd2fa57a
|
data/.github/workflows/ci.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
3.1.0
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
Change Log
|
2
|
+
==========
|
3
|
+
|
4
|
+
Version Next
|
5
|
+
----------------------------
|
6
|
+
|
7
|
+
Version 2.0.0
|
8
|
+
----------------------------
|
9
|
+
* Upgrade to Ruby 3.1.0
|
10
|
+
|
11
|
+
Version 1.0.0
|
12
|
+
----------------------------
|
13
|
+
|
14
|
+
* Add 'coverageType' property and set default to ':line' instead of ':instruction'. (API Change)
|
15
|
+
* Add Named Parameters for all functions; users must now specify the name of each parameter being passed in. (Breaking Change)
|
16
|
+
* Remove 'report' function; users must now use 'reportKover' or 'reportJacoco' directly. (Breaking Change)
|
17
|
+
|
18
|
+
Version 0.0.7
|
19
|
+
----------------------------
|
20
|
+
|
21
|
+
* Add separate variables for the 'failIfUnderProjectThreshold' and 'failIfUnderFileThreshold'.
|
22
|
+
|
23
|
+
Version 0.0.6
|
24
|
+
----------------------------
|
25
|
+
|
26
|
+
* Target Ruby 2.7.2.
|
27
|
+
* Update publishing logic.
|
28
|
+
|
29
|
+
Version 0.0.5
|
30
|
+
----------------------------
|
31
|
+
|
32
|
+
* Add support for Kover test reports.
|
33
|
+
|
34
|
+
Version 0.0.4
|
35
|
+
----------------------------
|
36
|
+
|
37
|
+
* Migrate to Github Actions.
|
38
|
+
|
39
|
+
Version 0.0.3
|
40
|
+
----------------------------
|
41
|
+
|
42
|
+
* 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 (2.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, <
|
13
|
-
ast (2.4.
|
11
|
+
addressable (2.8.7)
|
12
|
+
public_suffix (>= 2.0.2, < 7.0)
|
13
|
+
ast (2.4.3)
|
14
|
+
base64 (0.2.0)
|
14
15
|
claide (1.1.0)
|
15
16
|
claide-plugins (0.9.2)
|
16
17
|
cork
|
@@ -20,39 +21,44 @@ GEM
|
|
20
21
|
colored2 (3.1.2)
|
21
22
|
cork (0.3.0)
|
22
23
|
colored2 (~> 3.1)
|
23
|
-
danger (9.
|
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
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.
|
39
|
-
faraday (2.
|
40
|
-
faraday-net_http (>= 2.0, < 3.
|
41
|
-
|
42
|
-
|
40
|
+
diff-lcs (1.6.1)
|
41
|
+
faraday (2.12.2)
|
42
|
+
faraday-net_http (>= 2.0, < 3.5)
|
43
|
+
json
|
44
|
+
logger
|
45
|
+
faraday-http-cache (2.5.1)
|
43
46
|
faraday (>= 0.8)
|
44
|
-
faraday-net_http (3.0
|
45
|
-
|
47
|
+
faraday-net_http (3.4.0)
|
48
|
+
net-http (>= 0.5.0)
|
49
|
+
ffi (1.17.1)
|
46
50
|
formatador (1.1.0)
|
47
|
-
git (1.
|
51
|
+
git (1.19.1)
|
48
52
|
addressable (~> 2.8)
|
49
53
|
rchardet (~> 1.8)
|
50
|
-
guard (2.
|
54
|
+
guard (2.19.1)
|
51
55
|
formatador (>= 0.2.4)
|
52
56
|
listen (>= 2.7, < 4.0)
|
57
|
+
logger (~> 1.6)
|
53
58
|
lumberjack (>= 1.0.12, < 2.0)
|
54
59
|
nenv (~> 0.1)
|
55
60
|
notiffany (~> 0.0)
|
61
|
+
ostruct (~> 0.6)
|
56
62
|
pry (>= 0.13.0)
|
57
63
|
shellany (~> 0.0)
|
58
64
|
thor (>= 0.18.1)
|
@@ -61,82 +67,93 @@ GEM
|
|
61
67
|
guard (~> 2.1)
|
62
68
|
guard-compat (~> 1.1)
|
63
69
|
rspec (>= 2.99.0, < 4.0)
|
64
|
-
json (2.
|
65
|
-
kramdown (2.
|
66
|
-
rexml
|
70
|
+
json (2.10.2)
|
71
|
+
kramdown (2.5.1)
|
72
|
+
rexml (>= 3.3.9)
|
67
73
|
kramdown-parser-gfm (1.1.0)
|
68
74
|
kramdown (~> 2.0)
|
75
|
+
language_server-protocol (3.17.0.4)
|
76
|
+
lint_roller (1.1.0)
|
69
77
|
listen (3.0.7)
|
70
78
|
rb-fsevent (>= 0.9.3)
|
71
79
|
rb-inotify (>= 0.9.7)
|
72
|
-
|
73
|
-
|
74
|
-
|
80
|
+
logger (1.6.6)
|
81
|
+
lumberjack (1.2.10)
|
82
|
+
method_source (1.1.0)
|
83
|
+
mini_portile2 (2.8.8)
|
75
84
|
nap (1.1.0)
|
76
85
|
nenv (0.3.0)
|
77
|
-
|
78
|
-
|
79
|
-
|
86
|
+
net-http (0.6.0)
|
87
|
+
uri
|
88
|
+
nokogiri (1.18.6)
|
89
|
+
mini_portile2 (~> 2.8.2)
|
80
90
|
racc (~> 1.4)
|
81
91
|
notiffany (0.1.3)
|
82
92
|
nenv (~> 0.1)
|
83
93
|
shellany (~> 0.0)
|
84
|
-
octokit (
|
94
|
+
octokit (9.2.0)
|
85
95
|
faraday (>= 1, < 3)
|
86
96
|
sawyer (~> 0.9)
|
87
97
|
open4 (1.3.4)
|
88
|
-
|
89
|
-
|
98
|
+
ostruct (0.6.1)
|
99
|
+
parallel (1.26.3)
|
100
|
+
parser (3.3.7.2)
|
90
101
|
ast (~> 2.4.1)
|
91
|
-
|
102
|
+
racc
|
103
|
+
prism (1.4.0)
|
104
|
+
pry (0.15.2)
|
92
105
|
coderay (~> 1.1)
|
93
106
|
method_source (~> 1.0)
|
94
|
-
|
95
|
-
|
107
|
+
pstore (0.2.0)
|
108
|
+
public_suffix (6.0.1)
|
109
|
+
racc (1.8.1)
|
96
110
|
rainbow (3.1.1)
|
97
|
-
rake (13.
|
111
|
+
rake (13.2.1)
|
98
112
|
rb-fsevent (0.11.2)
|
99
|
-
rb-inotify (0.
|
113
|
+
rb-inotify (0.11.1)
|
100
114
|
ffi (~> 1.0)
|
101
|
-
rchardet (1.
|
102
|
-
regexp_parser (2.
|
103
|
-
rexml (3.
|
104
|
-
rspec (3.
|
105
|
-
rspec-core (~> 3.
|
106
|
-
rspec-expectations (~> 3.
|
107
|
-
rspec-mocks (~> 3.
|
108
|
-
rspec-core (3.
|
109
|
-
rspec-support (~> 3.
|
110
|
-
rspec-expectations (3.
|
115
|
+
rchardet (1.9.0)
|
116
|
+
regexp_parser (2.10.0)
|
117
|
+
rexml (3.4.1)
|
118
|
+
rspec (3.13.0)
|
119
|
+
rspec-core (~> 3.13.0)
|
120
|
+
rspec-expectations (~> 3.13.0)
|
121
|
+
rspec-mocks (~> 3.13.0)
|
122
|
+
rspec-core (3.13.3)
|
123
|
+
rspec-support (~> 3.13.0)
|
124
|
+
rspec-expectations (3.13.3)
|
111
125
|
diff-lcs (>= 1.2.0, < 2.0)
|
112
|
-
rspec-support (~> 3.
|
113
|
-
rspec-mocks (3.
|
126
|
+
rspec-support (~> 3.13.0)
|
127
|
+
rspec-mocks (3.13.2)
|
114
128
|
diff-lcs (>= 1.2.0, < 2.0)
|
115
|
-
rspec-support (~> 3.
|
116
|
-
rspec-support (3.
|
117
|
-
rubocop (1.
|
129
|
+
rspec-support (~> 3.13.0)
|
130
|
+
rspec-support (3.13.2)
|
131
|
+
rubocop (1.74.0)
|
118
132
|
json (~> 2.3)
|
133
|
+
language_server-protocol (~> 3.17.0.2)
|
134
|
+
lint_roller (~> 1.1.0)
|
119
135
|
parallel (~> 1.10)
|
120
|
-
parser (>= 3.
|
136
|
+
parser (>= 3.3.0.2)
|
121
137
|
rainbow (>= 2.2.2, < 4.0)
|
122
|
-
regexp_parser (>=
|
123
|
-
|
124
|
-
rubocop-ast (>= 1.28.0, < 2.0)
|
138
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
139
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
125
140
|
ruby-progressbar (~> 1.7)
|
126
|
-
unicode-display_width (>= 2.4.0, <
|
127
|
-
rubocop-ast (1.
|
128
|
-
parser (>= 3.
|
141
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
142
|
+
rubocop-ast (1.43.0)
|
143
|
+
parser (>= 3.3.7.2)
|
144
|
+
prism (~> 1.4)
|
129
145
|
ruby-progressbar (1.13.0)
|
130
|
-
ruby2_keywords (0.0.5)
|
131
146
|
sawyer (0.9.2)
|
132
147
|
addressable (>= 2.3.5)
|
133
148
|
faraday (>= 0.17.3, < 3)
|
134
149
|
shellany (0.0.1)
|
135
|
-
terminal-table (
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
150
|
+
terminal-table (1.6.0)
|
151
|
+
thor (1.3.2)
|
152
|
+
unicode-display_width (3.1.4)
|
153
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
154
|
+
unicode-emoji (4.0.4)
|
155
|
+
uri (1.0.3)
|
156
|
+
yard (0.9.37)
|
140
157
|
|
141
158
|
PLATFORMS
|
142
159
|
ruby
|
data/README.md
CHANGED
@@ -8,6 +8,7 @@
|
|
8
8
|
- [Parameters](#parameters-1)
|
9
9
|
- [Examples](#examples-1)
|
10
10
|
- [Development](#development)
|
11
|
+
- [Versioning](#versioning)
|
11
12
|
|
12
13
|
# danger-shroud
|
13
14
|
|
@@ -31,14 +32,15 @@ Shroud depends on having a Kover coverage report generated for your project. For
|
|
31
32
|
|
32
33
|
You can use the following parameters to control how shroud operates:
|
33
34
|
|
34
|
-
Param
|
35
|
-
|
36
|
-
moduleName
|
37
|
-
file
|
38
|
-
totalProjectThreshold
|
39
|
-
modifiedFileThreshold
|
40
|
-
failIfUnderProjectThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true`
|
41
|
-
failIfUnderFileThreshold
|
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` |
|
42
44
|
|
43
45
|
### Examples
|
44
46
|
|
@@ -47,7 +49,7 @@ Running shroud with default values:
|
|
47
49
|
```ruby
|
48
50
|
# Report coverage of modified files, fail if either total
|
49
51
|
# project coverage or any modified file's coverage is under 90%
|
50
|
-
shroud.reportKover 'Module Name', 'path/to/kover/report.xml'
|
52
|
+
shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml'
|
51
53
|
```
|
52
54
|
|
53
55
|
Running shroud with custom coverage thresholds:
|
@@ -55,7 +57,7 @@ Running shroud with custom coverage thresholds:
|
|
55
57
|
```ruby
|
56
58
|
# Report coverage of modified files, fail if total project coverage is under 80%,
|
57
59
|
# or if any modified file's coverage is under 95%
|
58
|
-
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
|
59
61
|
```
|
60
62
|
|
61
63
|
Warn on builds instead of fail:
|
@@ -63,7 +65,7 @@ Warn on builds instead of fail:
|
|
63
65
|
```ruby
|
64
66
|
# Report coverage of modified files the same as the above example, except the
|
65
67
|
# builds will only warn instead of fail if below project thresholds
|
66
|
-
shroud.reportKover 'Module Name', 'path/to/kover/report.xml', 80, 95, false, false
|
68
|
+
shroud.reportKover moduleName: 'Module Name', file: 'path/to/kover/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
|
67
69
|
```
|
68
70
|
|
69
71
|
## Usage Jacoco
|
@@ -72,14 +74,15 @@ shroud.reportKover 'Module Name', 'path/to/kover/report.xml', 80, 95, false, fal
|
|
72
74
|
|
73
75
|
You can use the following parameters to control how shroud operates:
|
74
76
|
|
75
|
-
Param
|
76
|
-
|
77
|
-
moduleName
|
78
|
-
file
|
79
|
-
totalProjectThreshold
|
80
|
-
modifiedFileThreshold
|
81
|
-
failIfUnderProjectThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true`
|
82
|
-
failIfUnderFileThreshold
|
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` |
|
83
86
|
|
84
87
|
### Examples
|
85
88
|
|
@@ -90,7 +93,7 @@ Running shroud with default values:
|
|
90
93
|
```ruby
|
91
94
|
# Report coverage of modified files, fail if either total
|
92
95
|
# project coverage or any modified file's coverage is under 90%
|
93
|
-
shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml'
|
96
|
+
shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml'
|
94
97
|
```
|
95
98
|
|
96
99
|
Running shroud with custom coverage thresholds:
|
@@ -98,7 +101,7 @@ Running shroud with custom coverage thresholds:
|
|
98
101
|
```ruby
|
99
102
|
# Report coverage of modified files, fail if total project coverage is under 80%,
|
100
103
|
# or if any modified file's coverage is under 95%
|
101
|
-
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
|
102
105
|
```
|
103
106
|
|
104
107
|
Warn on builds instead of fail:
|
@@ -106,7 +109,7 @@ Warn on builds instead of fail:
|
|
106
109
|
```ruby
|
107
110
|
# Report coverage of modified files the same as the above example, except the
|
108
111
|
# builds will only warn instead of fail if below thresholds
|
109
|
-
shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml', 80, 95, false, false
|
112
|
+
shroud.reportJacoco moduleName: 'Module Name', file: 'path/to/jacoco/report.xml', totalProjectThreshold: 80, modifiedFileThreshold: 95, failIfUnderProjectThreshold: false, failIfUnderFileThreshold: false
|
110
113
|
```
|
111
114
|
|
112
115
|
## Development
|
@@ -115,4 +118,24 @@ shroud.reportJacoco 'Module Name', 'path/to/jacoco/report.xml', 80, 95, false, f
|
|
115
118
|
2. Run `bundle install` to setup dependencies.
|
116
119
|
3. Run `bundle exec rake spec` to run the tests.
|
117
120
|
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
118
|
-
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,70 +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, 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, 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.
|
52
|
+
# * Branch
|
53
|
+
# * Class
|
54
|
+
# * Instruction
|
55
|
+
# * Line
|
56
|
+
# * Method
|
64
57
|
#
|
65
|
-
# @
|
66
|
-
#
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
def report(file, totalProjectThreshold = 90, modifiedFileThreshold = 90, failIfUnderProjectThreshold = true, failIfUnderFileThreshold = failIfUnderProjectThreshold)
|
75
|
-
warn "[DEPRECATION] `report` is deprecated. Please use `reportJacoco` or `reportKover` instead."
|
76
|
-
reportJacoco('Project', file, totalProjectThreshold = 90, modifiedFileThreshold = 90, failIfUnderProjectThreshold, failIfUnderFileThreshold)
|
77
|
-
end
|
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
|
78
67
|
|
79
68
|
# Report coverage on diffed files, as well as overall coverage.
|
80
69
|
#
|
@@ -100,9 +89,30 @@ module Danger
|
|
100
89
|
# if true, will fail builds that are under the provided thresholds per file. If false, will only warn.
|
101
90
|
# default true.
|
102
91
|
#
|
92
|
+
# @param [Symbol] coverageType
|
93
|
+
# defines the type of coverage to use.
|
94
|
+
# default line.
|
95
|
+
#
|
103
96
|
# @return [void]
|
104
|
-
def reportJacoco(
|
105
|
-
|
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
|
+
)
|
106
116
|
end
|
107
117
|
|
108
118
|
# Report coverage on diffed files, as well as overall coverage.
|
@@ -129,17 +139,49 @@ module Danger
|
|
129
139
|
# if true, will fail builds that are under the provided thresholds per file. If false, will only warn.
|
130
140
|
# default true.
|
131
141
|
#
|
142
|
+
# @param [Symbol] coverageType
|
143
|
+
# defines the type of coverage to use.
|
144
|
+
# default line.
|
145
|
+
#
|
132
146
|
# @return [void]
|
133
|
-
def reportKover(
|
134
|
-
|
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
|
+
)
|
135
166
|
end
|
136
167
|
|
137
|
-
private def internalReport(
|
168
|
+
private def internalReport(
|
169
|
+
reportType:,
|
170
|
+
moduleName:,
|
171
|
+
file:,
|
172
|
+
totalProjectThreshold:,
|
173
|
+
modifiedFileThreshold:,
|
174
|
+
failIfUnderProjectThreshold:,
|
175
|
+
failIfUnderFileThreshold:,
|
176
|
+
coverageType:
|
177
|
+
)
|
138
178
|
raise "Please specify file name." if file.empty?
|
139
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?
|
140
182
|
rawXml = File.read(file)
|
141
183
|
parsedXml = Nokogiri::XML.parse(rawXml)
|
142
|
-
totalInstructionCoverage = parsedXml.xpath("/report/counter[@type='
|
184
|
+
totalInstructionCoverage = parsedXml.xpath("/report/counter[@type='#{coverageMethod}']")
|
143
185
|
missed = totalInstructionCoverage.attr("missed").value.to_i
|
144
186
|
covered = totalInstructionCoverage.attr("covered").value.to_i
|
145
187
|
total = missed + covered
|
@@ -156,7 +198,7 @@ module Danger
|
|
156
198
|
touchedFilesHash = {}
|
157
199
|
|
158
200
|
touchedFileNames.each do |touchedFileName|
|
159
|
-
xmlForFileName = parsedXml.xpath("//class[@sourcefilename='#{touchedFileName}']/counter[@type='
|
201
|
+
xmlForFileName = parsedXml.xpath("//class[@sourcefilename='#{touchedFileName}']/counter[@type='#{coverageMethod}']")
|
160
202
|
|
161
203
|
if (xmlForFileName.length > 0)
|
162
204
|
missed = 0
|
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: 2.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-03-26 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
|
@@ -209,8 +210,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
210
|
- !ruby/object:Gem::Version
|
210
211
|
version: '0'
|
211
212
|
requirements: []
|
212
|
-
rubygems_version: 3.
|
213
|
-
signing_key:
|
213
|
+
rubygems_version: 3.3.3
|
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:
|