danger-jacoco 0.1.5 → 0.1.6
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.yaml +1 -0
- data/.github/workflows/release.yaml +2 -1
- data/danger-jacoco.gemspec +3 -3
- data/lib/jacoco/gem_version.rb +1 -1
- data/lib/jacoco/plugin.rb +32 -12
- data/spec/fixtures/output_b.xml +34 -0
- data/spec/jacoco_spec.rb +38 -1
- data/spec/spec_helper.rb +2 -0
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98c57cc2ececdda3470143782f1c87943a3f0a08f2931c0aa634444da0d90c69
|
4
|
+
data.tar.gz: 4de9109e706b7fa0f33a3906261535fe6c40e4d6b1580951af6cc1a1d6597e01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 021aa093d7763cef129b9b3ee73ddb23ca1e29d6565d6b8c74e24ee4071ea55ea8de5452dd16fea5b2aef97fefdb67ce9fd82a20d22b248af58bd37c51df11fa
|
7
|
+
data.tar.gz: 527c5b390bae29e370215cec242586c41adeb16ccd25932a7ab41a03ffd81afaaaf756acf36dd0168f0f86423237ecdfe6a715941a3943a0c514ddab63b5841c
|
data/.github/workflows/ci.yaml
CHANGED
@@ -10,13 +10,14 @@ jobs:
|
|
10
10
|
- uses: actions/setup-ruby@v1
|
11
11
|
with:
|
12
12
|
ruby-version: '2.6.x'
|
13
|
+
- run: gem install bundler
|
13
14
|
- run: bundle install
|
14
15
|
- run: bundle exec rake spec
|
15
16
|
- name: setup credentials
|
16
17
|
env:
|
17
18
|
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
18
19
|
run: |
|
19
|
-
mkdir ~/.gem
|
20
|
+
mkdir -p ~/.gem
|
20
21
|
echo -e "---\r\n:rubygems_api_key: $RUBYGEMS_API_KEY" > ~/.gem/credentials
|
21
22
|
chmod 0600 ~/.gem/credentials
|
22
23
|
- run: bundle exec rake release
|
data/danger-jacoco.gemspec
CHANGED
@@ -22,8 +22,8 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency 'nokogiri-happymapper', '~> 0.6'
|
23
23
|
|
24
24
|
# General ruby development
|
25
|
-
spec.add_development_dependency 'bundler', '~>
|
26
|
-
spec.add_development_dependency 'rake', '~>
|
25
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
26
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
27
27
|
|
28
28
|
# Testing support
|
29
29
|
spec.add_development_dependency 'rspec', '~> 3.7'
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_development_dependency 'guard-rspec', '~> 4.7'
|
38
38
|
|
39
39
|
# If you want to work on older builds of ruby
|
40
|
-
spec.add_development_dependency 'listen', '3.1
|
40
|
+
spec.add_development_dependency 'listen', '3.2.1'
|
41
41
|
|
42
42
|
# This gives you the chance to run a REPL inside your tests
|
43
43
|
# via:
|
data/lib/jacoco/gem_version.rb
CHANGED
data/lib/jacoco/plugin.rb
CHANGED
@@ -25,6 +25,7 @@ module Danger
|
|
25
25
|
attr_accessor :files_extension
|
26
26
|
attr_accessor :minimum_package_coverage_map
|
27
27
|
attr_accessor :minimum_class_coverage_map
|
28
|
+
attr_accessor :fail_no_coverage_data_found
|
28
29
|
|
29
30
|
# Initialize the plugin with configured parameters or defaults
|
30
31
|
def setup
|
@@ -61,7 +62,9 @@ module Danger
|
|
61
62
|
# Java => blah/blah/java/slashed_package/Source.java
|
62
63
|
# Kotlin => blah/blah/kotlin/slashed_package/Source.kt
|
63
64
|
#
|
64
|
-
def report(path, report_url = '', delimiter = %r{\/java\/|\/kotlin\/})
|
65
|
+
def report(path, report_url = '', delimiter = %r{\/java\/|\/kotlin\/}, fail_no_coverage_data_found: true)
|
66
|
+
@fail_no_coverage_data_found = fail_no_coverage_data_found
|
67
|
+
|
65
68
|
setup
|
66
69
|
classes = classes(delimiter)
|
67
70
|
|
@@ -89,18 +92,28 @@ module Danger
|
|
89
92
|
|
90
93
|
# It returns a specific class code coverage and an emoji status as well
|
91
94
|
def report_class(jacoco_class)
|
95
|
+
report_result = {
|
96
|
+
covered: 'No coverage data found : -',
|
97
|
+
status: ':black_joker:',
|
98
|
+
required_coverage_percentage: 'No coverage data found : -'
|
99
|
+
}
|
100
|
+
|
92
101
|
counter = coverage_counter(jacoco_class)
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
102
|
+
unless counter.nil?
|
103
|
+
coverage = (counter.covered.fdiv(counter.covered + counter.missed) * 100).floor
|
104
|
+
required_coverage = minimum_class_coverage_map[jacoco_class.name]
|
105
|
+
required_coverage = package_coverage(jacoco_class.name) if required_coverage.nil?
|
106
|
+
required_coverage = minimum_class_coverage_percentage if required_coverage.nil?
|
107
|
+
status = coverage_status(coverage, required_coverage)
|
108
|
+
|
109
|
+
report_result = {
|
110
|
+
covered: coverage,
|
111
|
+
status: status,
|
112
|
+
required_coverage_percentage: required_coverage
|
113
|
+
}
|
114
|
+
end
|
98
115
|
|
99
|
-
|
100
|
-
covered: coverage,
|
101
|
-
status: status,
|
102
|
-
required_coverage_percentage: required_coverage
|
103
|
-
}
|
116
|
+
report_result
|
104
117
|
end
|
105
118
|
|
106
119
|
# it returns the most suitable coverage by package name to class or nil
|
@@ -149,7 +162,14 @@ module Danger
|
|
149
162
|
branch_counter = counters.detect { |e| e.type.eql? 'BRANCH' }
|
150
163
|
line_counter = counters.detect { |e| e.type.eql? 'LINE' }
|
151
164
|
counter = branch_counter.nil? ? line_counter : branch_counter
|
152
|
-
|
165
|
+
|
166
|
+
if counter.nil?
|
167
|
+
no_coverage_data_found_message = "No coverage data found for #{jacoco_class.name}"
|
168
|
+
|
169
|
+
raise no_coverage_data_found_message if @fail_no_coverage_data_found.class == TrueClass
|
170
|
+
|
171
|
+
warn no_coverage_data_found_message
|
172
|
+
end
|
153
173
|
|
154
174
|
counter
|
155
175
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.0//EN"
|
2
|
+
"report.dtd">
|
3
|
+
<report name="test_report">
|
4
|
+
<sessioninfo id="test-id" start="1480057517395" dump="1480057526412"/>
|
5
|
+
<package name="com/example">
|
6
|
+
<class name="com/example/CachedRepository">
|
7
|
+
<method name="<init>" desc="()V" line="17">
|
8
|
+
<counter type="INSTRUCTION" missed="0" covered="11"/>
|
9
|
+
<counter type="COMPLEXITY" missed="0" covered="1"/>
|
10
|
+
<counter type="METHOD" missed="0" covered="1"/>
|
11
|
+
</method>
|
12
|
+
<counter type="INSTRUCTION" missed="0" covered="46"/>
|
13
|
+
<counter type="COMPLEXITY" missed="5" covered="7"/>
|
14
|
+
<counter type="METHOD" missed="0" covered="7"/>
|
15
|
+
<counter type="CLASS" missed="0" covered="1"/>
|
16
|
+
</class>
|
17
|
+
<sourcefile name="CachedRepository.java">
|
18
|
+
<line nr="16" mi="0" ci="2" mb="0" cb="0"/>
|
19
|
+
<line nr="17" mi="0" ci="3" mb="0" cb="0"/>
|
20
|
+
<counter type="INSTRUCTION" missed="2" covered="98"/>
|
21
|
+
<counter type="COMPLEXITY" missed="2" covered="11"/>
|
22
|
+
<counter type="METHOD" missed="2" covered="11"/>
|
23
|
+
<counter type="CLASS" missed="2" covered="4"/>
|
24
|
+
</sourcefile>
|
25
|
+
<counter type="INSTRUCTION" missed="80" covered="324"/>
|
26
|
+
<counter type="COMPLEXITY" missed="11" covered="39"/>
|
27
|
+
<counter type="METHOD" missed="9" covered="37"/>
|
28
|
+
<counter type="CLASS" missed="2" covered="10"/>
|
29
|
+
</package>
|
30
|
+
<counter type="INSTRUCTION" missed="39399" covered="19321"/>
|
31
|
+
<counter type="COMPLEXITY" missed="5517" covered="1444"/>
|
32
|
+
<counter type="METHOD" missed="3382" covered="1120"/>
|
33
|
+
<counter type="CLASS" missed="491" covered="370"/>
|
34
|
+
</report>
|
data/spec/jacoco_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# rubocop:disable LineLength
|
4
|
-
|
4
|
+
# rubocop:disable ModuleLength
|
5
5
|
# rubocop:disable BlockLength
|
6
6
|
|
7
7
|
require File.expand_path('spec_helper', __dir__)
|
@@ -122,9 +122,46 @@ module Danger
|
|
122
122
|
|
123
123
|
expect(@dangerfile.status_report[:markdowns][0].message).to include('| [`com/example/CachedRepository`](http://test.com/com.example/CachedRepository.html) | 50% | 80% | :warning: |')
|
124
124
|
end
|
125
|
+
|
126
|
+
it 'When option "fail_no_coverage_data_found" is set to optionally fail, it doesn\'t fail the execution' do
|
127
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_a.xml"
|
128
|
+
|
129
|
+
@my_plugin.minimum_class_coverage_percentage = 80
|
130
|
+
@my_plugin.minimum_project_coverage_percentage = 50
|
131
|
+
|
132
|
+
expect { @my_plugin.report(path_a, fail_no_coverage_data_found: true) }.to_not raise_error(RuntimeError)
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'When option "fail_no_coverage_data_found" is not set, the execution fails on empty data' do
|
136
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_b.xml"
|
137
|
+
|
138
|
+
@my_plugin.minimum_class_coverage_percentage = 80
|
139
|
+
@my_plugin.minimum_project_coverage_percentage = 50
|
140
|
+
|
141
|
+
expect { @my_plugin.report path_a }.to raise_error(RuntimeError)
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'When option "fail_no_coverage_data_found" is set to optionally fail, the execution fails on empty data' do
|
145
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_b.xml"
|
146
|
+
|
147
|
+
@my_plugin.minimum_class_coverage_percentage = 80
|
148
|
+
@my_plugin.minimum_project_coverage_percentage = 50
|
149
|
+
|
150
|
+
expect { @my_plugin.report path_a, fail_no_coverage_data_found: true }.to raise_error(RuntimeError)
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'When option "fail_no_coverage_data_found" is set to optionally warn (not fail), the execution doesn\'t fail on empty data' do
|
154
|
+
path_a = "#{File.dirname(__FILE__)}/fixtures/output_b.xml"
|
155
|
+
|
156
|
+
@my_plugin.minimum_class_coverage_percentage = 80
|
157
|
+
@my_plugin.minimum_project_coverage_percentage = 50
|
158
|
+
|
159
|
+
expect { @my_plugin.report path_a, fail_no_coverage_data_found: false }.to_not raise_error(RuntimeError)
|
160
|
+
end
|
125
161
|
end
|
126
162
|
end
|
127
163
|
end
|
128
164
|
|
129
165
|
# rubocop:enable LineLength
|
166
|
+
# rubocop:enable ModuleLength
|
130
167
|
# rubocop:enable BlockLength
|
data/spec/spec_helper.rb
CHANGED
@@ -18,6 +18,8 @@ RSpec.configure do |config|
|
|
18
18
|
config.tty = true
|
19
19
|
end
|
20
20
|
|
21
|
+
RSpec::Expectations.configuration.on_potential_false_positives = :nothing
|
22
|
+
|
21
23
|
require 'danger_plugin'
|
22
24
|
|
23
25
|
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-jacoco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Malinskiy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: danger-plugin-api
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '13.0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '13.0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 3.1
|
145
|
+
version: 3.2.1
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 3.1
|
152
|
+
version: 3.2.1
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: pry
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- lib/jacoco/plugin.rb
|
199
199
|
- lib/jacoco/sax_parser.rb
|
200
200
|
- spec/fixtures/output_a.xml
|
201
|
+
- spec/fixtures/output_b.xml
|
201
202
|
- spec/jacoco_spec.rb
|
202
203
|
- spec/spec_helper.rb
|
203
204
|
homepage: https://github.com/Malinskiy/danger-jacoco
|
@@ -225,5 +226,6 @@ specification_version: 4
|
|
225
226
|
summary: A longer description of danger-jacoco.
|
226
227
|
test_files:
|
227
228
|
- spec/fixtures/output_a.xml
|
229
|
+
- spec/fixtures/output_b.xml
|
228
230
|
- spec/jacoco_spec.rb
|
229
231
|
- spec/spec_helper.rb
|