danger-jacoco-instacart 0.1.14 → 0.1.15
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/lib/jacoco/gem_version.rb +1 -1
- data/lib/jacoco/plugin.rb +23 -9
- data/spec/jacoco_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dd4a48316de722878c9a9a93259094c27b8ac841391399eb11bfec956379fee
|
4
|
+
data.tar.gz: 8d0f4f5cdaa727efd0d6edcc119790661bc9c63b1e28a16d3fce4adc7f6239ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8eb83937c2a0cf5b1fad92fa98c160d9cc481793b3eeb51f1b8a71239ecc8cd0bcd4b5f6d32fc093c5b01a4cfba9e4bd119b66e13ebd58d797ca9486e3a3e72
|
7
|
+
data.tar.gz: 14567a96d7cb741c17a5dbaff165ee9bc6dd09b3e293319c644081938a20c7f6bcfe363cb34d9370f0a1b637fb8d89788f8d00632b2c164e628c510821330b3b
|
data/lib/jacoco/gem_version.rb
CHANGED
data/lib/jacoco/plugin.rb
CHANGED
@@ -31,7 +31,7 @@ module Danger
|
|
31
31
|
setup_texts
|
32
32
|
@files_to_check = [] unless files_to_check
|
33
33
|
@files_extension = ['.kt', '.java'] unless files_extension
|
34
|
-
@file_to_create_on_failure = 'danger_jacoco_failure_status_file.
|
34
|
+
@file_to_create_on_failure = 'danger_jacoco_failure_status_file.json' unless file_to_create_on_failure
|
35
35
|
end
|
36
36
|
|
37
37
|
# Initialize the plugin with configured optional texts
|
@@ -99,7 +99,7 @@ module Danger
|
|
99
99
|
report_markdown.insert(header.length, "#### #{subtitle}\n")
|
100
100
|
markdown(report_markdown)
|
101
101
|
|
102
|
-
report_fails(class_coverage_above_minimum, total_covered)
|
102
|
+
report_fails(parser, report_url, class_coverage_above_minimum, total_covered)
|
103
103
|
end
|
104
104
|
# rubocop:enable Style/AbcSize
|
105
105
|
|
@@ -223,13 +223,13 @@ module Danger
|
|
223
223
|
end
|
224
224
|
|
225
225
|
# rubocop:disable Style/SignalException
|
226
|
-
def report_fails(class_coverage_above_minimum, total_covered)
|
226
|
+
def report_fails(parser, report_url, class_coverage_above_minimum, total_covered)
|
227
227
|
if total_covered[:covered] < minimum_project_coverage_percentage
|
228
228
|
# fail danger if total coverage is smaller than minimum_project_coverage_percentage
|
229
229
|
covered = total_covered[:covered]
|
230
230
|
fail("Total coverage of #{covered}%. Improve this to at least #{minimum_project_coverage_percentage}%")
|
231
231
|
# 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)
|
232
|
-
create_status_file_on_failure if class_coverage_above_minimum
|
232
|
+
create_status_file_on_failure(parser, report_url) if class_coverage_above_minimum
|
233
233
|
# rubocop:enable Lint/UnreachableCode
|
234
234
|
end
|
235
235
|
|
@@ -237,13 +237,20 @@ module Danger
|
|
237
237
|
|
238
238
|
fail("Class coverage is below minimum. Improve to at least #{minimum_class_coverage_percentage}%")
|
239
239
|
# 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)
|
240
|
-
create_status_file_on_failure
|
240
|
+
create_status_file_on_failure(parser, report_url)
|
241
241
|
# rubocop:enable Lint/UnreachableCode
|
242
242
|
end
|
243
243
|
# rubocop:enable Style/SignalException
|
244
244
|
|
245
|
-
def create_status_file_on_failure
|
246
|
-
|
245
|
+
def create_status_file_on_failure(parser, report_url)
|
246
|
+
data = []
|
247
|
+
parser.classes.each do |jacoco_class|
|
248
|
+
data.push({ 'name' => jacoco_class.name, 'path' => report_filepath(jacoco_class.name, report_url) })
|
249
|
+
end
|
250
|
+
|
251
|
+
File.open(file_to_create_on_failure, 'w') do |f|
|
252
|
+
f.write({ 'failures' => data }.to_json)
|
253
|
+
end
|
247
254
|
end
|
248
255
|
|
249
256
|
def markdown_class(parser, report_markdown, report_url, class_to_file_path_hash)
|
@@ -265,8 +272,15 @@ module Danger
|
|
265
272
|
if report_url.empty?
|
266
273
|
"`#{class_name}`"
|
267
274
|
else
|
268
|
-
|
269
|
-
|
275
|
+
"[`#{class_name}`](#{report_url + report_filepath(class_name, report_url)})"
|
276
|
+
end
|
277
|
+
end
|
278
|
+
|
279
|
+
def report_filepath(class_name, report_url)
|
280
|
+
if report_url.empty?
|
281
|
+
class_name
|
282
|
+
else
|
283
|
+
"#{class_name.gsub(%r{/(?=[^/]*/.)}, '.')}.html"
|
270
284
|
end
|
271
285
|
end
|
272
286
|
end
|
data/spec/jacoco_spec.rb
CHANGED
@@ -58,7 +58,7 @@ module Danger
|
|
58
58
|
@my_plugin.files_to_check = ['src/java/com/example/CachedRepository.java', 'src/java/io/sample/UseCase.java']
|
59
59
|
@my_plugin.minimum_class_coverage_percentage = 60
|
60
60
|
|
61
|
-
expect(File).to receive(:open).with('danger_jacoco_failure_status_file.
|
61
|
+
expect(File).to receive(:open).with('danger_jacoco_failure_status_file.json', 'w')
|
62
62
|
@my_plugin.report path_a
|
63
63
|
end
|
64
64
|
|
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.
|
4
|
+
version: 0.1.15
|
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:
|
12
|
+
date: 2023-06-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: danger-plugin-api
|