danger-kover 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: df912d1ae056b291d3f6fea996bb8d61879ce0b9aa26abd50aa46cdc40a8b60e
4
+ data.tar.gz: 6942d6c7bad3e008f8b961b53d1fff3b85ad31a00f40279436b2c586f238e298
5
+ SHA512:
6
+ metadata.gz: 88312125ea11e7d9f22776eb8707c08c909fbe0a5c325f44ef89a5daeef7cf364fcf44f3dffdebeab21d030916374545f117f391554f1c7c8728d2913b3be337
7
+ data.tar.gz: fa0415298f378a97d57274d49a8a2b96af759f590c6efcd19618678dbb01ee6f9c2058e4bf8b6d20495864c594aa5034b7a46a2d9b9df393c595d48e7525aa13
@@ -0,0 +1,10 @@
1
+ version: 1
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
7
+ open-pull-requests-limit: 0
8
+ # Add/Remove reviewers here
9
+ reviewers:
10
+ - "JCarlosR"
@@ -0,0 +1,28 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ env:
8
+ RUBY_VERSION: 3.2.2
9
+
10
+ jobs:
11
+ test:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - name: Checkout
16
+ uses: actions/checkout@v2
17
+
18
+ - name: Configure Ruby
19
+ uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ env.RUBY_VERSION }}
22
+ bundler-cache: true
23
+
24
+ - name: Run Unit Tests
25
+ run: bundle exec rake spec
26
+
27
+ - name: Run Linter
28
+ run: bundle exec danger plugins lint
@@ -0,0 +1,34 @@
1
+ name: Ruby Gem
2
+
3
+ on:
4
+ push:
5
+ branches: [ "master" ]
6
+
7
+ env:
8
+ RUBY_VERSION: 2.7.2
9
+
10
+ jobs:
11
+ build:
12
+ name: Build + Publish
13
+ runs-on: ubuntu-latest
14
+ permissions:
15
+ contents: read
16
+ packages: write
17
+
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - name: Set up Ruby ${{ env.RUBY_VERSION }}
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ env.RUBY_VERSION }}
24
+
25
+ - name: Publish to RubyGems
26
+ run: |
27
+ mkdir -p $HOME/.gem
28
+ touch $HOME/.gem/credentials
29
+ chmod 0600 $HOME/.gem/credentials
30
+ printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
31
+ gem build *.gemspec
32
+ gem push *.gem
33
+ env:
34
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
4
+ .yardoc
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.2
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+ # Specify your gem's dependencies in danger-kover.gemspec
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,157 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-shroud (0.0.6)
5
+ danger-plugin-api (~> 1.0)
6
+ nokogiri
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ addressable (2.8.4)
12
+ public_suffix (>= 2.0.2, < 6.0)
13
+ ast (2.4.2)
14
+ claide (1.1.0)
15
+ claide-plugins (0.9.2)
16
+ cork
17
+ nap
18
+ open4 (~> 1.3)
19
+ coderay (1.1.3)
20
+ colored2 (3.1.2)
21
+ cork (0.3.0)
22
+ colored2 (~> 3.1)
23
+ danger (9.2.0)
24
+ claide (~> 1.0)
25
+ claide-plugins (>= 0.9.2)
26
+ colored2 (~> 3.1)
27
+ cork (~> 0.1)
28
+ faraday (>= 0.9.0, < 3.0)
29
+ faraday-http-cache (~> 2.0)
30
+ git (~> 1.7)
31
+ kramdown (~> 2.3)
32
+ kramdown-parser-gfm (~> 1.0)
33
+ no_proxy_fix
34
+ octokit (~> 5.0)
35
+ terminal-table (>= 1, < 4)
36
+ danger-plugin-api (1.0.0)
37
+ 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)
43
+ faraday (>= 0.8)
44
+ faraday-net_http (3.0.2)
45
+ ffi (1.15.5)
46
+ formatador (1.1.0)
47
+ git (1.18.0)
48
+ addressable (~> 2.8)
49
+ rchardet (~> 1.8)
50
+ guard (2.18.0)
51
+ formatador (>= 0.2.4)
52
+ listen (>= 2.7, < 4.0)
53
+ lumberjack (>= 1.0.12, < 2.0)
54
+ nenv (~> 0.1)
55
+ notiffany (~> 0.0)
56
+ pry (>= 0.13.0)
57
+ shellany (~> 0.0)
58
+ thor (>= 0.18.1)
59
+ guard-compat (1.2.1)
60
+ guard-rspec (4.7.3)
61
+ guard (~> 2.1)
62
+ guard-compat (~> 1.1)
63
+ rspec (>= 2.99.0, < 4.0)
64
+ json (2.6.3)
65
+ kramdown (2.4.0)
66
+ rexml
67
+ kramdown-parser-gfm (1.1.0)
68
+ kramdown (~> 2.0)
69
+ listen (3.0.7)
70
+ rb-fsevent (>= 0.9.3)
71
+ rb-inotify (>= 0.9.7)
72
+ lumberjack (1.2.8)
73
+ method_source (1.0.0)
74
+ mini_portile2 (2.8.1)
75
+ nap (1.1.0)
76
+ nenv (0.3.0)
77
+ no_proxy_fix (0.1.2)
78
+ nokogiri (1.14.3)
79
+ mini_portile2 (~> 2.8.0)
80
+ racc (~> 1.4)
81
+ notiffany (0.1.3)
82
+ nenv (~> 0.1)
83
+ shellany (~> 0.0)
84
+ octokit (5.6.1)
85
+ faraday (>= 1, < 3)
86
+ sawyer (~> 0.9)
87
+ open4 (1.3.4)
88
+ parallel (1.22.1)
89
+ parser (3.2.2.0)
90
+ ast (~> 2.4.1)
91
+ pry (0.14.2)
92
+ coderay (~> 1.1)
93
+ method_source (~> 1.0)
94
+ public_suffix (5.0.1)
95
+ racc (1.6.2)
96
+ rainbow (3.1.1)
97
+ rake (13.0.6)
98
+ rb-fsevent (0.11.2)
99
+ rb-inotify (0.10.1)
100
+ 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)
111
+ diff-lcs (>= 1.2.0, < 2.0)
112
+ rspec-support (~> 3.12.0)
113
+ rspec-mocks (3.12.5)
114
+ diff-lcs (>= 1.2.0, < 2.0)
115
+ rspec-support (~> 3.12.0)
116
+ rspec-support (3.12.0)
117
+ rubocop (1.50.2)
118
+ json (~> 2.3)
119
+ parallel (~> 1.10)
120
+ parser (>= 3.2.0.0)
121
+ 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)
125
+ 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)
129
+ ruby-progressbar (1.13.0)
130
+ ruby2_keywords (0.0.5)
131
+ sawyer (0.9.2)
132
+ addressable (>= 2.3.5)
133
+ faraday (>= 0.17.3, < 3)
134
+ 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)
140
+
141
+ PLATFORMS
142
+ ruby
143
+
144
+ DEPENDENCIES
145
+ bundler (~> 2.2)
146
+ danger-shroud!
147
+ guard (~> 2.14)
148
+ guard-rspec (~> 4.7)
149
+ listen (= 3.0.7)
150
+ pry
151
+ rake (~> 13.0)
152
+ rspec (~> 3.4)
153
+ rubocop
154
+ yard
155
+
156
+ BUNDLED WITH
157
+ 2.3.18
data/Guardfile ADDED
@@ -0,0 +1,19 @@
1
+ # A guardfile for making Danger Plugins
2
+ # For more info see https://github.com/guard/guard#readme
3
+
4
+ # To run, use `bundle exec guard`.
5
+
6
+ guard :rspec, cmd: 'bundle exec rspec' do
7
+ require 'guard/rspec/dsl'
8
+ dsl = Guard::RSpec::Dsl.new(self)
9
+
10
+ # RSpec files
11
+ rspec = dsl.rspec
12
+ watch(rspec.spec_helper) { rspec.spec_dir }
13
+ watch(rspec.spec_support) { rspec.spec_dir }
14
+ watch(rspec.spec_files)
15
+
16
+ # Ruby files
17
+ ruby = dsl.ruby
18
+ dsl.watch_spec_files_for(ruby.lib_files)
19
+ end
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2020 Andrew Haisting
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # danger-kover
2
+
3
+ A danger plugin for enforcing code coverage coverage based on a Kover coverage report.
4
+
5
+ ![Sample Banner Image](images/bannerImage.png)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'danger-kover'
13
+ ```
14
+
15
+ ## Danger Kover Plugin Usage
16
+
17
+ It depends on having a Kover coverage report generated for your project.
18
+
19
+ For Android projects, [kotlinx-kover](https://github.com/Kotlin/kotlinx-kover) works well.
20
+
21
+ Running with default values:
22
+
23
+ ```ruby
24
+ # Report coverage of modified files.
25
+ # Fail if either total project coverage or any modified file's coverage is under 70%.
26
+ kover.report 'Module Name', 'path/to/kover/report.xml'
27
+ ```
28
+
29
+ Running with custom attributes:
30
+
31
+ - Fail if total project coverage is under 70%.
32
+ - Or if any modified file's coverage is under 80%.
33
+
34
+ ```ruby
35
+ kover.total_threshold = 70
36
+ kover.file_threshold = 80
37
+ kover.report 'Module Name', 'path/to/kover/report.xml'
38
+ ```
39
+
40
+ Optional attribute to only warn instead of failing if below thresholds:
41
+
42
+ ```ruby
43
+ kover.fail_if_under_threshold false
44
+ ```
45
+
46
+ ## Development
47
+
48
+ 1. Clone this repo
49
+ 2. Run `bundle install` to setup dependencies.
50
+ 3. Run `bundle exec rake spec` to run the tests.
51
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
52
+ 5. Make your changes.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:specs)
5
+
6
+ task default: :specs
7
+
8
+ task :spec do
9
+ Rake::Task['specs'].invoke
10
+ Rake::Task['spec_docs'].invoke
11
+ end
12
+
13
+ desc 'Ensure that the plugin passes `danger plugins lint`'
14
+ task :spec_docs do
15
+ sh 'bundle exec danger plugins lint'
16
+ end
@@ -0,0 +1,51 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kover/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-kover'
8
+ spec.version = Kover::VERSION
9
+ spec.authors = ['andrewhaisting']
10
+ spec.email = ['ahaisting@gmail.com']
11
+ spec.description = %q{Enforce Kover code coverage on CI.}
12
+ spec.summary = %q{A danger plugin for enforcing code coverage via a Kover coverage report.}
13
+ spec.homepage = 'https://github.com/JCarlosR/danger-kover'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
22
+
23
+ # General ruby development
24
+ spec.add_development_dependency 'bundler', '~> 2.2'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
26
+
27
+ # Testing support
28
+ spec.add_development_dependency 'rspec', '~> 3.4'
29
+
30
+ # Linting code and docs
31
+ spec.add_development_dependency "rubocop"
32
+ spec.add_development_dependency "yard"
33
+
34
+ # Makes testing easy via `bundle exec guard`
35
+ spec.add_development_dependency 'guard', '~> 2.14'
36
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
37
+
38
+ # If you want to work on older builds of ruby
39
+ spec.add_development_dependency 'listen', '3.0.7'
40
+
41
+ spec.add_dependency 'nokogiri'
42
+
43
+ # This gives you the chance to run a REPL inside your tests
44
+ # via:
45
+ #
46
+ # require 'pry'
47
+ # binding.pry
48
+ #
49
+ # This will stop test execution and let you inspect the results
50
+ spec.add_development_dependency 'pry'
51
+ end
Binary file
@@ -0,0 +1 @@
1
+ require "kover/plugin"
@@ -0,0 +1 @@
1
+ require "kover/gem_version"
@@ -0,0 +1,3 @@
1
+ module Kover
2
+ VERSION = "0.0.1".freeze
3
+ end
@@ -0,0 +1,159 @@
1
+ require 'nokogiri'
2
+
3
+ module Danger
4
+
5
+ # Parse a Kover report to enforce code coverage on CI.
6
+ # Results are passed out as a table in markdown.
7
+ #
8
+ # It depends on having a Kover coverage report generated for your project.
9
+ #
10
+ #
11
+ # @example Running with default values for Kover
12
+ #
13
+ # # Report coverage of modified files, fail if either total project coverage
14
+ # # or any modified file's coverage is under 90%
15
+ # kover.report 'Project Name', 'path/to/kover/report.xml'
16
+ #
17
+ # @example Running with custom coverage thresholds for Kover
18
+ #
19
+ # # Report coverage of modified files, fail if total project coverage is under 80%,
20
+ # # or if any modified file's coverage is under 95%
21
+ # kover.report 'Project Name', 'path/to/kover/report.xml', 80, 95
22
+ #
23
+ # @example Warn on builds instead of failing for Kover
24
+ #
25
+ # # Report coverage of modified files the same as the above example, except the
26
+ # # builds will only warn instead of fail if below thresholds
27
+ # kover.report 'Project Name', 'path/to/kover/report.xml', 80, 95, false
28
+ #
29
+ # @tags android, kover, code coverage, coverage report
30
+ #
31
+ class DangerKover < Plugin
32
+
33
+ # Total project code coverage % threshold [0-100].
34
+ # @return [Integer]
35
+ attr_accessor :total_threshold
36
+
37
+ # A getter for `total_threshold`, returning 70% by default.
38
+ # @return [Integer]
39
+ def total_threshold
40
+ @total_threshold ||= 70
41
+ end
42
+
43
+ # Modified file code coverage % threshold [0-100].
44
+ # @return [Integer]
45
+ attr_accessor :file_threshold
46
+
47
+ # A getter for `file_threshold`, returning 70% by default.
48
+ # @return [Integer]
49
+ def file_threshold
50
+ @file_threshold ||= 70
51
+ end
52
+
53
+ # Fail if under threshould, just warn otherwise.
54
+ # @return [Boolean]
55
+ attr_accessor :fail_if_under_threshold
56
+
57
+ # A getter for `fail_if_under_threshold`, returning `true` by default.
58
+ # @return [Boolean]
59
+ def fail_if_under_threshold
60
+ @fail_if_under_threshold ||= true
61
+ end
62
+
63
+ # Report coverage on diffed files, as well as overall coverage.
64
+ #
65
+ # @param [String] moduleName
66
+ # the display name of the project or module
67
+ #
68
+ # @param [String] file
69
+ # file path to a Kover xml coverage report.
70
+ #
71
+ # @return [void]
72
+ def report(moduleName, file)
73
+ raise "Please specify file name." if file.empty?
74
+ raise "No Kover xml report found at #{file}" unless File.exist? file
75
+
76
+ rawXml = File.read(file)
77
+ parsedXml = Nokogiri::XML.parse(rawXml)
78
+ totalInstructionCoverage = parsedXml.xpath("/report/counter[@type='INSTRUCTION']")
79
+ missed = totalInstructionCoverage.attr("missed").value.to_i
80
+ covered = totalInstructionCoverage.attr("covered").value.to_i
81
+ total = missed + covered
82
+ coveragePercent = (covered / total.to_f) * 100
83
+
84
+ # get array of files names touched by this PR (modified + added)
85
+ touchedFileNames = @dangerfile.git.modified_files.map { |file| File.basename(file) }
86
+ touchedFileNames += @dangerfile.git.added_files.map { |file| File.basename(file) }
87
+
88
+ # used to later report files that were modified but not included in the report
89
+ fileNamesNotInReport = []
90
+
91
+ # hash for keeping track of coverage per filename: {filename => coverage percent}
92
+ touchedFilesHash = {}
93
+
94
+ touchedFileNames.each do |touchedFileName|
95
+ xmlForFileName = parsedXml.xpath("//class[@sourcefilename='#{touchedFileName}']/counter[@type='INSTRUCTION']")
96
+
97
+ if (xmlForFileName.length > 0)
98
+ missed = 0
99
+ covered = 0
100
+ xmlForFileName.each do |classCountXml|
101
+ missed += classCountXml.attr("missed").to_i
102
+ covered += classCountXml.attr("covered").to_i
103
+ end
104
+ touchedFilesHash[touchedFileName] = (covered.to_f / (missed + covered)) * 100
105
+ else
106
+ fileNamesNotInReport << touchedFileName
107
+ end
108
+ end
109
+
110
+ puts "Here are unreported files"
111
+ puts fileNamesNotInReport.to_s
112
+ puts "Here is the touched files coverage hash"
113
+ puts touchedFilesHash
114
+
115
+ output = "## 🎯 #{moduleName} Code Coverage: **`#{'%.2f' % coveragePercent}%`**\n"
116
+
117
+ if touchedFilesHash.empty?
118
+ output << "The new and modified files are not part of the coverage report."
119
+ else
120
+ output << "### Coverage of Modified Files:\n"
121
+ output << "File | Coverage\n"
122
+ output << ":-----|:-----:\n"
123
+ end
124
+
125
+ # go through each file:
126
+ touchedFilesHash.sort.each do |fileName, coveragePercent|
127
+ output << "`#{fileName}` | **`#{'%.2f' % coveragePercent}%`**\n"
128
+
129
+ # warn or fail if under specified file threshold:
130
+ if (coveragePercent < file_threshold)
131
+ warningMessage = "Uh oh! #{fileName} is under #{file_threshold}% coverage!"
132
+ if (fail_if_under_threshold)
133
+ fail warningMessage
134
+ else
135
+ warn warningMessage
136
+ end
137
+ end
138
+ end
139
+
140
+ output << "\n"
141
+ output << "Number of files not found in coverage report: #{fileNamesNotInReport.size}"
142
+ output << "\n"
143
+
144
+ output << 'Code coverage generated by [danger-kover](https://github.com/JCarlosR/danger-kover), based on [Shroud](https://github.com/livefront/danger-shroud)'
145
+ markdown output
146
+
147
+ # warn or fail if total coverage is under specified threshold
148
+ if (coveragePercent < total_threshold)
149
+ totalCoverageWarning = "Oops! The project codebase is under #{total_threshold}% coverage."
150
+
151
+ if (fail_if_under_threshold)
152
+ fail totalCoverageWarning
153
+ else
154
+ warn totalCoverageWarning
155
+ end
156
+ end
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path("../spec_helper", __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DangerKover do
5
+ it "should be a plugin" do
6
+ expect(Danger::DangerKover.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ #
10
+ # TODO test your custom attributes and methods here
11
+ #
12
+ end
13
+ end
@@ -0,0 +1,65 @@
1
+ require "pathname"
2
+ ROOT = Pathname.new(File.expand_path("../../", __FILE__))
3
+ $:.unshift((ROOT + "lib").to_s)
4
+ $:.unshift((ROOT + "spec").to_s)
5
+
6
+ require "bundler/setup"
7
+ require "pry"
8
+
9
+ require "rspec"
10
+ require "danger"
11
+
12
+ if `git remote -v` == ''
13
+ puts "You cannot run tests without setting a local git remote on this repo"
14
+ puts "It's a weird side-effect of Danger's internals."
15
+ exit(0)
16
+ end
17
+
18
+ # Use coloured output, it's the best.
19
+ RSpec.configure do |config|
20
+ config.filter_gems_from_backtrace "bundler"
21
+ config.color = true
22
+ config.tty = true
23
+ end
24
+
25
+ require "danger_plugin"
26
+
27
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
28
+ # If you are expanding these files, see if it's already been done ^.
29
+
30
+ # A silent version of the user interface,
31
+ # it comes with an extra function `.string` which will
32
+ # strip all ANSI colours from the string.
33
+
34
+ # rubocop:disable Lint/NestedMethodDefinition
35
+ def testing_ui
36
+ @output = StringIO.new
37
+ def @output.winsize
38
+ [20, 9999]
39
+ end
40
+
41
+ cork = Cork::Board.new(out: @output)
42
+ def cork.string
43
+ out.string.gsub(/\e\[([;\d]+)?m/, "")
44
+ end
45
+ cork
46
+ end
47
+ # rubocop:enable Lint/NestedMethodDefinition
48
+
49
+ # Example environment (ENV) that would come from
50
+ # running a PR on TravisCI
51
+ def testing_env
52
+ {
53
+ "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
54
+ "TRAVIS_PULL_REQUEST" => "800",
55
+ "TRAVIS_REPO_SLUG" => "artsy/eigen",
56
+ "TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
57
+ "DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
58
+ }
59
+ end
60
+
61
+ # A stubbed out Dangerfile for use in tests
62
+ def testing_dangerfile
63
+ env = Danger::EnvironmentManager.new(testing_env)
64
+ Danger::Dangerfile.new(env, testing_ui)
65
+ end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-kover
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - andrewhaisting
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: guard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '2.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '2.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: guard-rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '4.7'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '4.7'
125
+ - !ruby/object:Gem::Dependency
126
+ name: listen
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 3.0.7
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 3.0.7
139
+ - !ruby/object:Gem::Dependency
140
+ name: nokogiri
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: Enforce Kover code coverage on CI.
168
+ email:
169
+ - ahaisting@gmail.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".github/dependabot.yml"
175
+ - ".github/workflows/ci.yml"
176
+ - ".github/workflows/publish.yml"
177
+ - ".gitignore"
178
+ - ".ruby-version"
179
+ - Gemfile
180
+ - Gemfile.lock
181
+ - Guardfile
182
+ - LICENSE
183
+ - README.md
184
+ - Rakefile
185
+ - danger-kover.gemspec
186
+ - images/bannerImage.png
187
+ - lib/danger_plugin.rb
188
+ - lib/danger_shroud.rb
189
+ - lib/kover/gem_version.rb
190
+ - lib/kover/plugin.rb
191
+ - spec/shroud_spec.rb
192
+ - spec/spec_helper.rb
193
+ homepage: https://github.com/JCarlosR/danger-kover
194
+ licenses:
195
+ - MIT
196
+ metadata: {}
197
+ post_install_message:
198
+ rdoc_options: []
199
+ require_paths:
200
+ - lib
201
+ required_ruby_version: !ruby/object:Gem::Requirement
202
+ requirements:
203
+ - - ">="
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ required_rubygems_version: !ruby/object:Gem::Requirement
207
+ requirements:
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: '0'
211
+ requirements: []
212
+ rubygems_version: 3.4.19
213
+ signing_key:
214
+ specification_version: 4
215
+ summary: A danger plugin for enforcing code coverage via a Kover coverage report.
216
+ test_files:
217
+ - spec/shroud_spec.rb
218
+ - spec/spec_helper.rb