danger-jacoco-instacart 0.1.12.SNAPSHOT.1 → 0.1.13

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: b68f00cbed8e16eb566459431cfb6d296b84b2fec8b87f5e07cb40e513b08b1c
4
- data.tar.gz: a14e683220953972e2ee3fa84ff6f4fd795c60701c8108d187a24f710b10eced
3
+ metadata.gz: 04b74ccc5974fdd122bb8909a71b541891e760d99f7cfd120c06d71c133c2b32
4
+ data.tar.gz: 9f8e75aa5cf7611307255edb1ae2119e81f5c7010700d324d1b7041cd7d5d275
5
5
  SHA512:
6
- metadata.gz: 0a8ed5dfd7cf494b6e1ceb45f87d06d8666e6f92ec1e31b73a75bdf00a2cc209c67854d3d0eee1eb367b4311ac280a22115fb075d904538f611ccb44ac94d5e7
7
- data.tar.gz: 6c2cc47baf7fea31de40f60b531a442a5daad3460b2ecf6360dc6e1860077a4888fff6e9e071c0d4775c87224533e66edf1483586418220953762ed76621399a
6
+ metadata.gz: da2bc98c6c2693be43e96012f0ac3b2000911fca7610fba47387046f908797eb49a4b2f04d505af4ddd359cae44703725c1216bf9716bb0cf62c58b20636dca5
7
+ data.tar.gz: 9f768d669d1eb720bf898ab9fbdfd6deb8fd68994a67ae490938eee2fd4c693dcfb0a06314b466fef6c9109424f037738171e77113546579986a1ca6dfce4266
data/.yardoc/checksums CHANGED
@@ -1,6 +1,6 @@
1
1
  /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/danger_jacoco.rb 38229d934b3315bb2a5a4eec18eb65f3c54d304f
2
- /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/gem_version.rb 4109fe221b49a7d872a2d1bebf772583ed7c4437
3
- /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/plugin.rb 17233d007f6187a47676390d6499ab5c7cb3a2b8
2
+ /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/gem_version.rb 1c81f68cb95296bfd592c1b57e0f2e6341f56b55
3
+ /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/plugin.rb e99030c6a408c1bc77962b844d74c324daecad40
4
4
  /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/sax_parser.rb 370e2799f8dbdf7d642c820214e6ea84c30c9cb0
5
5
  /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/counter.rb 368f4a9811617b7a174ddf837a8fac49a4bc32a6
6
6
  /Users/alexanderbezverhni/workspace/junk/danger-jacoco/lib/jacoco/model/report.rb 7cf45ee71ff347a130320f6190ddb25525c7095d
data/.yardoc/object_types CHANGED
Binary file
Binary file
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Jacoco
4
- VERSION = '0.1.12.SNAPSHOT.1'
4
+ VERSION = '0.1.13'
5
5
  end
data/lib/jacoco/plugin.rb CHANGED
@@ -23,7 +23,7 @@ module Danger
23
23
  attr_accessor :minimum_project_coverage_percentage, :minimum_class_coverage_percentage,
24
24
  :minimum_composable_class_coverage_percentage, :only_check_new_files, :files_extension,
25
25
  :minimum_package_coverage_map, :minimum_class_coverage_map, :fail_no_coverage_data_found,
26
- :title, :class_column_title, :subtitle_success, :subtitle_failure
26
+ :title, :class_column_title, :subtitle_success, :subtitle_failure, :file_to_create_on_failure
27
27
 
28
28
  # Initialize the plugin with configured parameters or defaults
29
29
  def setup
@@ -31,6 +31,7 @@ module Danger
31
31
  setup_texts
32
32
  @only_check_new_files = false unless only_check_new_files
33
33
  @files_extension = ['.kt', '.java'] unless files_extension
34
+ @file_to_create_on_failure = 'danger_jacoco_failure_status_file.txt' unless file_to_create_on_failure
34
35
  end
35
36
 
36
37
  # Initialize the plugin with configured optional texts
@@ -227,29 +228,28 @@ module Danger
227
228
 
228
229
  # rubocop:disable Style/SignalException
229
230
  def report_fails(class_coverage_above_minimum, total_covered)
230
- total_failure_message = ''
231
231
  if total_covered[:covered] < minimum_project_coverage_percentage
232
232
  # fail danger if total coverage is smaller than minimum_project_coverage_percentage
233
233
  covered = total_covered[:covered]
234
- total_failure_message = "Total coverage of #{covered}%." \
235
- " Improve this to at least #{minimum_project_coverage_percentage}%"
236
- fail(total_failure_message)
237
- # rubocop:disable Lint/UnreachableCode (rubocop mistakenly thinks that raise is unreachable since priorly called "fail" raises by itself, but in fact "fail" is caught and handled)
238
- raise CoverageRequirementsNotMetError, total_failure_message if class_coverage_above_minimum
234
+ fail("Total coverage of #{covered}%. Improve this to at least #{minimum_project_coverage_percentage}%")
235
+ # rubocop:disable Lint/UnreachableCode (rubocop mistakenly thinks that this line is unreachable since priorly called "fail" raises an error, but in fact "fail" is caught and handled)
236
+ create_status_file_on_failure if class_coverage_above_minimum
239
237
  # rubocop:enable Lint/UnreachableCode
240
238
  end
241
239
 
242
240
  return if class_coverage_above_minimum
243
241
 
244
- class_failure_message = 'Class coverage is below minimum.' \
245
- " Improve to at least #{minimum_class_coverage_percentage}%"
246
- fail(class_failure_message)
247
- # rubocop:disable Lint/UnreachableCode (rubocop mistakenly thinks that raise is unreachable since priorly called "fail" raises by itself, but in fact "fail" is caught and handled)
248
- raise CoverageRequirementsNotMetError, "#{total_failure_message}. #{class_failure_message}"
242
+ fail("Class coverage is below minimum. Improve to at least #{minimum_class_coverage_percentage}%")
243
+ # rubocop:disable Lint/UnreachableCode (rubocop mistakenly thinks that this line is unreachable since priorly called "fail" raises an error, but in fact "fail" is caught and handled)
244
+ create_status_file_on_failure
249
245
  # rubocop:enable Lint/UnreachableCode
250
246
  end
251
247
  # rubocop:enable Style/SignalException
252
248
 
249
+ def create_status_file_on_failure
250
+ File.open(file_to_create_on_failure, 'w') {}
251
+ end
252
+
253
253
  def markdown_class(parser, report_markdown, report_url, class_to_file_path_hash)
254
254
  class_coverage_above_minimum = true
255
255
  parser.classes.each do |jacoco_class| # Check metrics for each classes
@@ -275,10 +275,3 @@ module Danger
275
275
  end
276
276
  end
277
277
  end
278
-
279
- # Exception that is being thrown when any of the coverage requirements aren't met
280
- class CoverageRequirementsNotMetError < StandardError
281
- def initialize(msg = 'Coverage requirements not met')
282
- super
283
- end
284
- end
data/spec/jacoco_spec.rb CHANGED
@@ -25,6 +25,7 @@ module Danger
25
25
 
26
26
  allow(@dangerfile.git).to receive(:modified_files).and_return(modified_files)
27
27
  allow(@dangerfile.git).to receive(:added_files).and_return(added_files)
28
+ allow(File).to receive(:open).and_call_original
28
29
  end
29
30
 
30
31
  it :report do
@@ -33,7 +34,7 @@ module Danger
33
34
  @my_plugin.minimum_project_coverage_percentage = 50
34
35
  @my_plugin.minimum_class_coverage_map = { 'com/example/CachedRepository' => 100 }
35
36
 
36
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%. Class coverage is below minimum. Improve to at least 0%/)
37
+ @my_plugin.report path_a
37
38
 
38
39
  expect(@dangerfile.status_report[:errors]).to eq(['Total coverage of 32.9%. Improve this to at least 50%',
39
40
  'Class coverage is below minimum. Improve to at least 0%'])
@@ -43,13 +44,44 @@ module Danger
43
44
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 100% | :warning: |')
44
45
  end
45
46
 
47
+ it 'creates supplied status file upon failure' do
48
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
49
+
50
+ @my_plugin.minimum_project_coverage_percentage = 100
51
+ @my_plugin.minimum_class_coverage_percentage = 60
52
+ @my_plugin.file_to_create_on_failure = 'kmm.txt'
53
+
54
+ expect(File).to receive(:open).with('kmm.txt', 'w')
55
+ @my_plugin.report path_a
56
+ end
57
+
58
+ it 'creates default status file upon failure' do
59
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
60
+
61
+ @my_plugin.minimum_class_coverage_percentage = 60
62
+
63
+ expect(File).to receive(:open).with('danger_jacoco_failure_status_file.txt', 'w')
64
+ @my_plugin.report path_a
65
+ end
66
+
67
+ it 'does _not_ create status file upon success' do
68
+ path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
69
+
70
+ @my_plugin.minimum_class_coverage_percentage = 40
71
+ @my_plugin.file_to_create_on_failure = 'kmm.txt'
72
+
73
+ expect(File).to_not receive(:open).with('kmm.txt', 'w')
74
+ @my_plugin.report path_a
75
+ end
76
+
46
77
  it 'test regex class coverage' do
47
78
  path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
48
79
 
49
80
  @my_plugin.minimum_project_coverage_percentage = 50
50
81
  @my_plugin.minimum_class_coverage_map = { '.*Repository' => 60 }
51
82
 
52
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%. Class coverage is below minimum. Improve to at least 0%/)
83
+ @my_plugin.report path_a
84
+
53
85
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 60% | :warning: |')
54
86
  end
55
87
 
@@ -59,7 +91,8 @@ module Danger
59
91
  @my_plugin.minimum_project_coverage_percentage = 50
60
92
  @my_plugin.minimum_package_coverage_map = { 'com/example/' => 70 }
61
93
 
62
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%/)
94
+ @my_plugin.report path_a
95
+
63
96
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 70% | :warning: |')
64
97
  end
65
98
 
@@ -72,7 +105,8 @@ module Danger
72
105
  'com/' => 90
73
106
  }
74
107
 
75
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%/)
108
+ @my_plugin.report path_a
109
+
76
110
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 70% | :warning: |')
77
111
  end
78
112
 
@@ -85,7 +119,8 @@ module Danger
85
119
  'com/' => 30
86
120
  }
87
121
 
88
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%/)
122
+ @my_plugin.report path_a
123
+
89
124
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 77% | :warning: |')
90
125
  end
91
126
 
@@ -99,7 +134,8 @@ module Danger
99
134
  }
100
135
  @my_plugin.minimum_class_coverage_map = { 'com/example/CachedRepository' => 100 }
101
136
 
102
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%/)
137
+ @my_plugin.report path_a
138
+
103
139
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 100% | :warning: |')
104
140
  end
105
141
 
@@ -113,7 +149,8 @@ module Danger
113
149
  }
114
150
  @my_plugin.minimum_class_coverage_map = { 'com/example/CachedRepository' => 80 }
115
151
 
116
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%/)
152
+ @my_plugin.report path_a
153
+
117
154
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 80% | :warning: |')
118
155
  end
119
156
 
@@ -150,7 +187,7 @@ module Danger
150
187
  @my_plugin.minimum_class_coverage_percentage = 70
151
188
  @my_plugin.only_check_new_files = true
152
189
 
153
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Class coverage is below minimum. Improve to at least 70%/)
190
+ @my_plugin.report path_a
154
191
 
155
192
  expect(@dangerfile.status_report[:markdowns][0].message).to include('### JaCoCo Code Coverage 55.59% :white_check_mark:')
156
193
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| Class | Covered | Required | Status |')
@@ -165,7 +202,8 @@ module Danger
165
202
  @my_plugin.minimum_class_coverage_percentage = 80
166
203
  @my_plugin.minimum_project_coverage_percentage = 50
167
204
 
168
- expect { @my_plugin.report(path_a, 'http://test.com/') }.to raise_error(CoverageRequirementsNotMetError, /Total coverage of 32.9%. Improve this to at least 50%. Class coverage is below minimum. Improve to at least 80%/)
205
+ @my_plugin.report(path_a, 'http://test.com/')
206
+
169
207
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| [`com/example/CachedRepository`](http://test.com/com.example/CachedRepository.html) | 50% | 80% | :warning: |')
170
208
  end
171
209
 
@@ -227,7 +265,7 @@ module Danger
227
265
  @my_plugin.minimum_project_coverage_percentage = 30
228
266
  @my_plugin.minimum_class_coverage_percentage = 60
229
267
 
230
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Class coverage is below minimum. Improve to at least 60%/)
268
+ @my_plugin.report path_a
231
269
 
232
270
  expected = "### JaCoCo Code Coverage 32.9% :white_check_mark:\n"
233
271
  expected += "#### There are classes that do not meet coverage requirement :warning:\n"
@@ -261,7 +299,7 @@ module Danger
261
299
  @my_plugin.minimum_class_coverage_percentage = 60
262
300
  @my_plugin.subtitle_failure = 'Too bad :('
263
301
 
264
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Class coverage is below minimum. Improve to at least 60%/)
302
+ @my_plugin.report path_a
265
303
 
266
304
  expected = "### JaCoCo Code Coverage 32.9% :white_check_mark:\n"
267
305
  expected += "#### Too bad :(\n"
@@ -304,7 +342,7 @@ module Danger
304
342
 
305
343
  @my_plugin.minimum_class_coverage_percentage = 50
306
344
 
307
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Class coverage is below minimum. Improve to at least 50%/)
345
+ @my_plugin.report path_a
308
346
 
309
347
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 42% | 50% | :warning: |')
310
348
  end
@@ -349,7 +387,7 @@ module Danger
349
387
  @my_plugin.minimum_class_coverage_percentage = 55
350
388
  @my_plugin.minimum_composable_class_coverage_percentage = 45
351
389
 
352
- expect { @my_plugin.report(path_a) }.to raise_error(CoverageRequirementsNotMetError, /Class coverage is below minimum. Improve to at least 55%/)
390
+ @my_plugin.report path_a
353
391
 
354
392
  expect(@dangerfile.status_report[:markdowns][0].message).to include('| `com/example/CachedRepository` | 50% | 55% | :warning: |')
355
393
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danger-jacoco-instacart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12.SNAPSHOT.1
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Malinskiy
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-09-08 00:00:00.000000000 Z
12
+ date: 2022-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: danger-plugin-api
@@ -228,9 +228,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
228
228
  version: '2.6'
229
229
  required_rubygems_version: !ruby/object:Gem::Requirement
230
230
  requirements:
231
- - - ">"
231
+ - - ">="
232
232
  - !ruby/object:Gem::Version
233
- version: 1.3.1
233
+ version: '0'
234
234
  requirements: []
235
235
  rubygems_version: 3.1.2
236
236
  signing_key: