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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 234c6bbce9b759a9a8b744c477e5b0f90ab40d742830635a6ff284f85b1b1015
4
- data.tar.gz: 21e54c40b94bdd7d4989516d5287279427888f07efc48475e6f754908f0b72c8
3
+ metadata.gz: c9dc7c91737f9342eb62d48933887ac740b95cdb422497c7329a5a1e51214e59
4
+ data.tar.gz: e0e5805f272abc2dbc075871face1e3cb6cbf46a48a38f45f4823cc514c045d7
5
5
  SHA512:
6
- metadata.gz: 4ad01b61dfe54625578c9e8b8b26f0520cffcee3d63e5f7275a1a45c332e503f4c2d0d254fb6619e35e9d20d51fc982d917e370be23668ed82f3293343b77fa5
7
- data.tar.gz: c5403ff85b292d6ad451ae73998e9fff69e76c462e260bf4dd8d918bc519fb88ff1fc38bde541421b25145eabbf70e96a04ceb4b1f26559b91f2f7fb53d30ef4
6
+ metadata.gz: 2f77902e316f4d2b96a2e27254586eeebf2bef8863a2893e0faa3246a064a5ed7072b3ae10f1420d916074c422ff931d8fb6eecc917d90c73ffd88ddf13d238d
7
+ data.tar.gz: 62890a17e53b620a7648e654d09b3c7a838cf6920d42ab40c61ba9d887ad2d9afc888e6a9e2d70cf3fe90c44ab28f7f4fdf307c78e66728d980ee5e9fd2fa57a
@@ -5,7 +5,7 @@ on:
5
5
  pull_request:
6
6
 
7
7
  env:
8
- RUBY_VERSION: 2.7.2
8
+ RUBY_VERSION: 3.1.0
9
9
 
10
10
  jobs:
11
11
  test:
@@ -5,7 +5,7 @@ on:
5
5
  branches: [ "master" ]
6
6
 
7
7
  env:
8
- RUBY_VERSION: 2.7.2
8
+ RUBY_VERSION: 3.1.0
9
9
 
10
10
  jobs:
11
11
  build:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.7.2
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.7)
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.4)
12
- public_suffix (>= 2.0.2, < 6.0)
13
- ast (2.4.2)
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.2.0)
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.7)
32
+ git (~> 1.13)
31
33
  kramdown (~> 2.3)
32
34
  kramdown-parser-gfm (~> 1.0)
33
- no_proxy_fix
34
- octokit (~> 5.0)
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.0)
39
- faraday (2.7.4)
40
- faraday-net_http (>= 2.0, < 3.1)
41
- ruby2_keywords (>= 0.0.4)
42
- faraday-http-cache (2.4.1)
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.2)
45
- ffi (1.15.5)
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.18.0)
51
+ git (1.19.1)
48
52
  addressable (~> 2.8)
49
53
  rchardet (~> 1.8)
50
- guard (2.18.0)
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.6.3)
65
- kramdown (2.4.0)
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
- lumberjack (1.2.8)
73
- method_source (1.0.0)
74
- mini_portile2 (2.8.1)
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
- no_proxy_fix (0.1.2)
78
- nokogiri (1.14.3)
79
- mini_portile2 (~> 2.8.0)
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 (5.6.1)
94
+ octokit (9.2.0)
85
95
  faraday (>= 1, < 3)
86
96
  sawyer (~> 0.9)
87
97
  open4 (1.3.4)
88
- parallel (1.22.1)
89
- parser (3.2.2.0)
98
+ ostruct (0.6.1)
99
+ parallel (1.26.3)
100
+ parser (3.3.7.2)
90
101
  ast (~> 2.4.1)
91
- pry (0.14.2)
102
+ racc
103
+ prism (1.4.0)
104
+ pry (0.15.2)
92
105
  coderay (~> 1.1)
93
106
  method_source (~> 1.0)
94
- public_suffix (5.0.1)
95
- racc (1.6.2)
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.0.6)
111
+ rake (13.2.1)
98
112
  rb-fsevent (0.11.2)
99
- rb-inotify (0.10.1)
113
+ rb-inotify (0.11.1)
100
114
  ffi (~> 1.0)
101
- rchardet (1.8.0)
102
- regexp_parser (2.8.0)
103
- rexml (3.2.5)
104
- rspec (3.12.0)
105
- rspec-core (~> 3.12.0)
106
- rspec-expectations (~> 3.12.0)
107
- rspec-mocks (~> 3.12.0)
108
- rspec-core (3.12.1)
109
- rspec-support (~> 3.12.0)
110
- rspec-expectations (3.12.2)
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.12.0)
113
- rspec-mocks (3.12.5)
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.12.0)
116
- rspec-support (3.12.0)
117
- rubocop (1.50.2)
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.2.0.0)
136
+ parser (>= 3.3.0.2)
121
137
  rainbow (>= 2.2.2, < 4.0)
122
- regexp_parser (>= 1.8, < 3.0)
123
- rexml (>= 3.2.5, < 4.0)
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, < 3.0)
127
- rubocop-ast (1.28.0)
128
- parser (>= 3.2.1.0)
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 (3.0.2)
136
- unicode-display_width (>= 1.1.1, < 3)
137
- thor (1.2.1)
138
- unicode-display_width (2.4.2)
139
- yard (0.9.34)
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 | Type | Description | Example
35
- ---|---|---|---|
36
- moduleName | String | the display name of the project or module |`'Module Name '`
37
- file | String | file path to a Kover xml coverage report. | `'path/to/kover/report.xml'`
38
- totalProjectThreshold | Integer | defines the required percentage of total project coverage for a passing build. | default `90`
39
- modifiedFileThreshold | Integer | defines the required percentage of files modified in a PR for a passing build. | default `90`
40
- failIfUnderProjectThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true`
41
- failIfUnderFileThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true`
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 | Type | Description | Example
76
- ---|---|---|---|
77
- moduleName | String | the display name of the project or module |`'Module Name '`
78
- file | String | file path to a Kover xml coverage report. | `'path/to/jacoco/report.xml'`
79
- totalProjectThreshold | Integer | defines the required percentage of total project coverage for a passing build. | default `90`
80
- modifiedFileThreshold | Integer | defines the required percentage of files modified in a PR for a passing build. | default `90`
81
- failIfUnderProjectThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true`
82
- failIfUnderFileThreshold | Boolean | if true, will fail builds that are under the provided thresholds. if false, will only warn. | default `true`
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.
@@ -1,3 +1,3 @@
1
1
  module Shroud
2
- VERSION = "0.0.7".freeze
2
+ VERSION = "2.0.0".freeze
3
3
  end
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
- # <b>DEPRECATED:</b> Please use <tt>reportJacoco</tt> or <tt>reportKover</tt> instead.
50
+ # Defines the method of coverage to be used
51
51
  #
52
- # Report coverage on diffed files, as well as overall coverage.
53
- #
54
- # @param [String] file
55
- # file path to a Jacoco xml coverage report.
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
- # @param [Boolean] failIfUnderProjectThreshold
66
- # if true, will fail builds that are under the provided thresholds for the overall project. If false, will only warn.
67
- # default true.
68
- #
69
- # @param [Boolean] failIfUnderFileThreshold
70
- # if true, will fail builds that are under the provided thresholds per file. If false, will only warn.
71
- # default true.
72
- #
73
- # @return [void]
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(moduleName, file, totalProjectThreshold = 90, modifiedFileThreshold = 90, failIfUnderProjectThreshold = true, failIfUnderFileThreshold = false)
105
- internalReport('Jacoco', moduleName, file, totalProjectThreshold, modifiedFileThreshold, failIfUnderProjectThreshold, failIfUnderFileThreshold)
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(moduleName, file, totalProjectThreshold = 90, modifiedFileThreshold = 90, failIfUnderProjectThreshold = true, failIfUnderFileThreshold = failIfUnderProjectThreshold)
134
- internalReport('Kover', moduleName, file, totalProjectThreshold, modifiedFileThreshold, failIfUnderProjectThreshold, failIfUnderFileThreshold)
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(reportType, moduleName, file, totalProjectThreshold, modifiedFileThreshold, failIfUnderProjectThreshold, failIfUnderFileThreshold)
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='INSTRUCTION']")
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='INSTRUCTION']")
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.7
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: 2023-10-30 00:00:00.000000000 Z
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.1.4
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: