danger-undercover 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/ISSUE_TEMPLATE/bug_template.md +20 -0
- data/.github/ISSUE_TEMPLATE/feature_template.md +14 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +13 -0
- data/.github/workflows/test.yml +44 -0
- data/.gitignore +5 -0
- data/.rubocop.yml +6 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +146 -0
- data/Guardfile +21 -0
- data/LICENSE +19 -0
- data/README.md +57 -0
- data/Rakefile +25 -0
- data/danger-undercover.gemspec +51 -0
- data/lib/danger_plugin.rb +3 -0
- data/lib/danger_undercover.rb +3 -0
- data/lib/undercover/gem_version.rb +5 -0
- data/lib/undercover/plugin.rb +47 -0
- data/spec/fixtures/undercover_failed.txt +17 -0
- data/spec/fixtures/undercover_passed.txt +2 -0
- data/spec/spec_helper.rb +66 -0
- data/spec/undercover_spec.rb +40 -0
- metadata +210 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cb04717e10cd473267cb307eb0d4b4d0fcd4301fc9e5aa49addf8167cc7b8dbe
|
4
|
+
data.tar.gz: be57b82ff15f6808c4cb4c7ec835c347e1907d4f152a0e2ba8ffc56a83f71cbb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 826db9606d9cdb7bd8baf9b2090654b03412a00bdae6921bb662aee6267730c4c6c5fabc85b04f3380e9ce6b38d5487c1b81e74d4eefbeaeab93740d9d6bdfdf
|
7
|
+
data.tar.gz: bbed20bc346d9118d268d042c18427c1e856f973f9afbabb58dcbccb8ebe66a08fe8d66152fc479e4e602ead77647465db25c685dcfe56f84a16f39d4bfbcb16
|
@@ -0,0 +1,20 @@
|
|
1
|
+
---
|
2
|
+
name: "Bug Report"
|
3
|
+
about: "You found something that is not working. Report it so that it can be fixed. 👷"
|
4
|
+
title: "Fix: "
|
5
|
+
labels: "type : bug"
|
6
|
+
---
|
7
|
+
|
8
|
+
## Issue
|
9
|
+
|
10
|
+
Describe the issue you are facing. Show us the implementation: screenshots, gif, etc.
|
11
|
+
|
12
|
+
## Expected
|
13
|
+
|
14
|
+
Describe what should be the correct behaviour.
|
15
|
+
|
16
|
+
## Steps to reproduce
|
17
|
+
|
18
|
+
1.
|
19
|
+
2.
|
20
|
+
3.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
name: "Feature"
|
3
|
+
about: "Open a feature issue to add new functionalities."
|
4
|
+
title: "Add "
|
5
|
+
labels: "type : feature"
|
6
|
+
---
|
7
|
+
|
8
|
+
## Why
|
9
|
+
|
10
|
+
Describe the big picture of the feature and why it's needed.
|
11
|
+
|
12
|
+
## Who Benefits?
|
13
|
+
|
14
|
+
Describe who will be the beneficiaries e.g. everyone, specific chapters, clients...
|
@@ -0,0 +1,13 @@
|
|
1
|
+
https://github.com/nimblehq/git-template/issues/??
|
2
|
+
|
3
|
+
## What happened 👀
|
4
|
+
|
5
|
+
Describe the big picture of your changes here to communicate to the team why we should accept this pull request.
|
6
|
+
|
7
|
+
## Insight 📝
|
8
|
+
|
9
|
+
Describe in details how to test the changes, which solution you tried but did not go with, referenced documentation is welcome as well.
|
10
|
+
|
11
|
+
## Proof Of Work 📹
|
12
|
+
|
13
|
+
Show us the implementation: screenshots, gif, etc.
|
@@ -0,0 +1,44 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
- development
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build-and-test:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby: [ '2.5', '2.6', '2.7.1' ]
|
17
|
+
|
18
|
+
name: Ruby ${{ matrix.ruby }}
|
19
|
+
|
20
|
+
steps:
|
21
|
+
- uses: actions/checkout@v2
|
22
|
+
|
23
|
+
- uses: actions/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
ruby-version: ${{ matrix.ruby }}
|
26
|
+
|
27
|
+
- name: Cache gems
|
28
|
+
uses: actions/cache@v1
|
29
|
+
with:
|
30
|
+
path: vendor/bundle
|
31
|
+
key: bundle-use-ruby-${{ runner.os }}-${{ matrix.ruby }}-${{ hashFiles('**/Gemfile.lock') }}
|
32
|
+
restore-keys: |
|
33
|
+
bundle-use-ruby-${{ runner.os }}-${{ matrix.ruby }}-
|
34
|
+
|
35
|
+
- name: Install bundler
|
36
|
+
run: gem install bundler
|
37
|
+
|
38
|
+
- name: Bundle install
|
39
|
+
run: |
|
40
|
+
bundle config path vendor/bundle
|
41
|
+
bundle install --jobs 4 --retry 3
|
42
|
+
|
43
|
+
- name: Run specs
|
44
|
+
run: bundle exec rake spec
|
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
danger-undercover (1.0.0)
|
5
|
+
danger-plugin-api (~> 1.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
ast (2.4.1)
|
13
|
+
claide (1.0.3)
|
14
|
+
claide-plugins (0.9.2)
|
15
|
+
cork
|
16
|
+
nap
|
17
|
+
open4 (~> 1.3)
|
18
|
+
coderay (1.1.3)
|
19
|
+
colored2 (3.1.2)
|
20
|
+
cork (0.3.0)
|
21
|
+
colored2 (~> 3.1)
|
22
|
+
danger (8.0.6)
|
23
|
+
claide (~> 1.0)
|
24
|
+
claide-plugins (>= 0.9.2)
|
25
|
+
colored2 (~> 3.1)
|
26
|
+
cork (~> 0.1)
|
27
|
+
faraday (>= 0.9.0, < 2.0)
|
28
|
+
faraday-http-cache (~> 2.0)
|
29
|
+
git (~> 1.7)
|
30
|
+
kramdown (~> 2.3)
|
31
|
+
kramdown-parser-gfm (~> 1.0)
|
32
|
+
no_proxy_fix
|
33
|
+
octokit (~> 4.7)
|
34
|
+
terminal-table (~> 1)
|
35
|
+
danger-plugin-api (1.0.0)
|
36
|
+
danger (> 2.0)
|
37
|
+
diff-lcs (1.4.4)
|
38
|
+
faraday (1.0.1)
|
39
|
+
multipart-post (>= 1.2, < 3)
|
40
|
+
faraday-http-cache (2.2.0)
|
41
|
+
faraday (>= 0.8)
|
42
|
+
ffi (1.13.1)
|
43
|
+
formatador (0.2.5)
|
44
|
+
git (1.7.0)
|
45
|
+
rchardet (~> 1.8)
|
46
|
+
guard (2.16.2)
|
47
|
+
formatador (>= 0.2.4)
|
48
|
+
listen (>= 2.7, < 4.0)
|
49
|
+
lumberjack (>= 1.0.12, < 2.0)
|
50
|
+
nenv (~> 0.1)
|
51
|
+
notiffany (~> 0.0)
|
52
|
+
pry (>= 0.9.12)
|
53
|
+
shellany (~> 0.0)
|
54
|
+
thor (>= 0.18.1)
|
55
|
+
guard-compat (1.2.1)
|
56
|
+
guard-rspec (4.7.3)
|
57
|
+
guard (~> 2.1)
|
58
|
+
guard-compat (~> 1.1)
|
59
|
+
rspec (>= 2.99.0, < 4.0)
|
60
|
+
kramdown (2.3.0)
|
61
|
+
rexml
|
62
|
+
kramdown-parser-gfm (1.1.0)
|
63
|
+
kramdown (~> 2.0)
|
64
|
+
listen (3.2.1)
|
65
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
66
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
67
|
+
lumberjack (1.2.8)
|
68
|
+
method_source (1.0.0)
|
69
|
+
multipart-post (2.1.1)
|
70
|
+
nap (1.1.0)
|
71
|
+
nenv (0.3.0)
|
72
|
+
no_proxy_fix (0.1.2)
|
73
|
+
notiffany (0.1.3)
|
74
|
+
nenv (~> 0.1)
|
75
|
+
shellany (~> 0.0)
|
76
|
+
octokit (4.18.0)
|
77
|
+
faraday (>= 0.9)
|
78
|
+
sawyer (~> 0.8.0, >= 0.5.3)
|
79
|
+
open4 (1.3.4)
|
80
|
+
parallel (1.19.2)
|
81
|
+
parser (2.7.2.0)
|
82
|
+
ast (~> 2.4.1)
|
83
|
+
pry (0.13.1)
|
84
|
+
coderay (~> 1.1)
|
85
|
+
method_source (~> 1.0)
|
86
|
+
public_suffix (4.0.6)
|
87
|
+
rainbow (3.0.0)
|
88
|
+
rake (13.0.1)
|
89
|
+
rb-fsevent (0.10.4)
|
90
|
+
rb-inotify (0.10.1)
|
91
|
+
ffi (~> 1.0)
|
92
|
+
rchardet (1.8.0)
|
93
|
+
regexp_parser (1.8.2)
|
94
|
+
rexml (3.2.4)
|
95
|
+
rspec (3.9.0)
|
96
|
+
rspec-core (~> 3.9.0)
|
97
|
+
rspec-expectations (~> 3.9.0)
|
98
|
+
rspec-mocks (~> 3.9.0)
|
99
|
+
rspec-core (3.9.3)
|
100
|
+
rspec-support (~> 3.9.3)
|
101
|
+
rspec-expectations (3.9.2)
|
102
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
103
|
+
rspec-support (~> 3.9.0)
|
104
|
+
rspec-mocks (3.9.1)
|
105
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
106
|
+
rspec-support (~> 3.9.0)
|
107
|
+
rspec-support (3.9.3)
|
108
|
+
rubocop (0.93.1)
|
109
|
+
parallel (~> 1.10)
|
110
|
+
parser (>= 2.7.1.5)
|
111
|
+
rainbow (>= 2.2.2, < 4.0)
|
112
|
+
regexp_parser (>= 1.8)
|
113
|
+
rexml
|
114
|
+
rubocop-ast (>= 0.6.0)
|
115
|
+
ruby-progressbar (~> 1.7)
|
116
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
117
|
+
rubocop-ast (0.7.1)
|
118
|
+
parser (>= 2.7.1.5)
|
119
|
+
ruby-progressbar (1.10.1)
|
120
|
+
sawyer (0.8.2)
|
121
|
+
addressable (>= 2.3.5)
|
122
|
+
faraday (> 0.8, < 2.0)
|
123
|
+
shellany (0.0.1)
|
124
|
+
terminal-table (1.8.0)
|
125
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
126
|
+
thor (1.0.1)
|
127
|
+
unicode-display_width (1.7.0)
|
128
|
+
yard (0.9.25)
|
129
|
+
|
130
|
+
PLATFORMS
|
131
|
+
ruby
|
132
|
+
|
133
|
+
DEPENDENCIES
|
134
|
+
bundler
|
135
|
+
danger-undercover!
|
136
|
+
guard
|
137
|
+
guard-rspec
|
138
|
+
listen
|
139
|
+
pry
|
140
|
+
rake
|
141
|
+
rspec
|
142
|
+
rubocop
|
143
|
+
yard
|
144
|
+
|
145
|
+
BUNDLED WITH
|
146
|
+
2.1.4
|
data/Guardfile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A guardfile for making Danger Plugins
|
4
|
+
# For more info see https://github.com/guard/guard#readme
|
5
|
+
|
6
|
+
# To run, use `bundle exec guard`.
|
7
|
+
|
8
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
9
|
+
require 'guard/rspec/dsl'
|
10
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
11
|
+
|
12
|
+
# RSpec files
|
13
|
+
rspec = dsl.rspec
|
14
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
15
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
16
|
+
watch(rspec.spec_files)
|
17
|
+
|
18
|
+
# Ruby files
|
19
|
+
ruby = dsl.ruby
|
20
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
21
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014-2020 Nimble.
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# danger-undercover
|
2
|
+
|
3
|
+
A [Danger](https://github.com/danger/danger) plugin to show [Undercover](https://github.com/grodowski/undercover) report.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ gem install danger-undercover
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
To use this gem all the instruction provided in [Undercover](https://github.com/grodowski/undercover) must be followed.
|
12
|
+
|
13
|
+
To know more about running undercover [visit here](https://github.com/grodowski/undercover#usage)
|
14
|
+
|
15
|
+
> Use the `-c --compare ref` flag to specify a git ref (commit hash, branch name, tag) to compare against.
|
16
|
+
**This is a recommended usage for CI/CD build environments**, as `undercover` will `exit 1` if there are any warnings.
|
17
|
+
|
18
|
+
Run the below command to output undercover report to a `txt` file which this plugin will use to geneate PR comments.
|
19
|
+
To use it on a CI server, run this command before running `Danger` so that the file is created beforehand.
|
20
|
+
|
21
|
+
$ undercover -c $compare_git_ref > coverage/undercover.txt
|
22
|
+
|
23
|
+
>Here $compare_git_ref as per undercover documentation, can be a commit hash, branch name, or tag. i.e. origin/master
|
24
|
+
, origin/development
|
25
|
+
|
26
|
+
|
27
|
+
Then in your `Dangerfile` add the following line with the output file
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
undercover.report 'coverage/undercover.txt'
|
31
|
+
```
|
32
|
+
|
33
|
+
## Development
|
34
|
+
|
35
|
+
1. Clone this repo
|
36
|
+
2. Run `bundle install` to setup dependencies.
|
37
|
+
3. Run `bundle exec rake spec` to run the tests.
|
38
|
+
4. Use `bundle exec guard` to automatically have tests run as you make changes.
|
39
|
+
5. Make your changes.
|
40
|
+
|
41
|
+
## License
|
42
|
+
|
43
|
+
It is free software, and may be redistributed under the terms specified in the [LICENSE] file.
|
44
|
+
|
45
|
+
[LICENSE]: /LICENSE
|
46
|
+
|
47
|
+
## About
|
48
|
+
|
49
|
+
![Nimble](https://assets.nimblehq.co/logo/dark/logo-dark-text-160.png)
|
50
|
+
|
51
|
+
This project is maintained and funded by Nimble.
|
52
|
+
|
53
|
+
We love open source and do our part in sharing our work with the community!
|
54
|
+
See [our other projects][community] or [hire our team][hire] to help build your product.
|
55
|
+
|
56
|
+
[community]: https://github.com/nimblehq
|
57
|
+
[hire]: https://nimblehq.co/
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new(:specs)
|
8
|
+
|
9
|
+
task default: :specs
|
10
|
+
|
11
|
+
task :spec do
|
12
|
+
Rake::Task['specs'].invoke
|
13
|
+
Rake::Task['rubocop'].invoke
|
14
|
+
Rake::Task['spec_docs'].invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Run RuboCop on the lib/specs directory'
|
18
|
+
RuboCop::RakeTask.new(:rubocop) do |task|
|
19
|
+
task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
|
20
|
+
end
|
21
|
+
|
22
|
+
desc 'Ensure that the plugin passes `danger plugins lint`'
|
23
|
+
task :spec_docs do
|
24
|
+
sh 'bundle exec danger plugins lint'
|
25
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'undercover/gem_version.rb'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'danger-undercover'
|
9
|
+
spec.version = Undercover::VERSION
|
10
|
+
spec.authors = %w[Nimble rafayet-monon]
|
11
|
+
spec.email = %w[dev@nimblehq.co rafayet@nimblehq.co]
|
12
|
+
spec.description = 'Show undercover report to PRs'
|
13
|
+
spec.summary = 'A Danger plugin for Undercover gem'
|
14
|
+
spec.homepage = 'https://github.com/nimblehq/danger-undercover'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.required_ruby_version = '~> 2.4'
|
18
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
|
24
|
+
|
25
|
+
# General ruby development
|
26
|
+
spec.add_development_dependency 'bundler'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
|
+
|
29
|
+
# Testing support
|
30
|
+
spec.add_development_dependency 'rspec'
|
31
|
+
|
32
|
+
# Linting code and docs
|
33
|
+
spec.add_development_dependency 'rubocop'
|
34
|
+
spec.add_development_dependency 'yard'
|
35
|
+
|
36
|
+
# Makes testing easy via `bundle exec guard`
|
37
|
+
spec.add_development_dependency 'guard'
|
38
|
+
spec.add_development_dependency 'guard-rspec'
|
39
|
+
|
40
|
+
# If you want to work on older builds of ruby
|
41
|
+
spec.add_development_dependency 'listen'
|
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
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Danger
|
4
|
+
# Report missing coverage report using undercover and danger-undercover
|
5
|
+
#
|
6
|
+
# You have to use [undercover](https://github.com/grodowski/undercover) to gather
|
7
|
+
# undercover report and send the report to this plugin so that danger-undercover
|
8
|
+
# can use it.
|
9
|
+
#
|
10
|
+
# @example Report missing coverage report
|
11
|
+
#
|
12
|
+
# undercover.report('coverage/undercover.txt')
|
13
|
+
#
|
14
|
+
# @see nimblehq/danger-undercover
|
15
|
+
# @tags ruby, code-coverage, simplecov, undercover, danger, simplecov-lcov
|
16
|
+
#
|
17
|
+
class DangerUndercover < Plugin
|
18
|
+
VALID_FILE_FORMAT = '.txt'
|
19
|
+
|
20
|
+
# Checks the file validity and warns if no file is found
|
21
|
+
# if a valid file is found then if there are no changes,
|
22
|
+
# shows the report as a message in Danger.
|
23
|
+
# If there are reports then it shows the report as a warning in danger.
|
24
|
+
# @return [void]
|
25
|
+
#
|
26
|
+
def report(undercover_path, sticky: true)
|
27
|
+
return fail('Undercover: coverage report cannot be found.') unless valid_file? undercover_path
|
28
|
+
|
29
|
+
report = File.open(undercover_path).read
|
30
|
+
|
31
|
+
if report.match(/No coverage is missing in latest changes/)
|
32
|
+
message(report, sticky: sticky)
|
33
|
+
else
|
34
|
+
warn(report, sticky: sticky)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
# Checks if the file exists and the file is valid
|
41
|
+
# @return [Boolean] File validity
|
42
|
+
#
|
43
|
+
def valid_file?(undercover_path)
|
44
|
+
File.exist?(undercover_path) && (File.extname(undercover_path) == VALID_FILE_FORMAT)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
undercover: 👮♂️ some methods have no test coverage! Please add specs for methods listed below
|
2
|
+
🚨 1) node `index3` type: instance method,
|
3
|
+
loc: app/controllers/v2/provinces_controller.rb:9:11, coverage: 0.0%
|
4
|
+
9: def index3 hits: n/a
|
5
|
+
10: render json: V2::ProvinceSerializer.new(provinces) hits: 0
|
6
|
+
11: end hits: n/a
|
7
|
+
🚨 2) node `index2` type: instance method,
|
8
|
+
loc: app/controllers/v2/sub_districts_controller.rb:9:11, coverage: 0.0%
|
9
|
+
9: def index2 hits: n/a
|
10
|
+
10: render json: V2::SubDistrictSerializer.new(sub_districts) hits: 0
|
11
|
+
11: end hits: n/a
|
12
|
+
🚨 3) node `index3` type: instance method,
|
13
|
+
loc: app/controllers/v2/sub_districts_controller.rb:13:15, coverage: 0.0%
|
14
|
+
13: def index3 hits: n/a
|
15
|
+
14: render json: V2::SubDistrictSerializer.new(sub_districts) hits: 0
|
16
|
+
15: end hits: n/a
|
17
|
+
Undercover finished in 0.9006s
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
ROOT = Pathname.new(File.expand_path('..', __dir__))
|
5
|
+
$LOAD_PATH.unshift("#{ROOT}lib")
|
6
|
+
$LOAD_PATH.unshift("#{ROOT}spec")
|
7
|
+
|
8
|
+
require 'bundler/setup'
|
9
|
+
require 'pry'
|
10
|
+
|
11
|
+
require 'rspec'
|
12
|
+
require 'danger'
|
13
|
+
|
14
|
+
if `git remote -v` == ''
|
15
|
+
puts 'You cannot run tests without setting a local git remote on this repo'
|
16
|
+
puts "It's a weird side-effect of Danger's internals."
|
17
|
+
exit(0)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Use coloured output, it's the best.
|
21
|
+
RSpec.configure do |config|
|
22
|
+
config.filter_gems_from_backtrace 'bundler'
|
23
|
+
config.color = true
|
24
|
+
config.tty = true
|
25
|
+
end
|
26
|
+
|
27
|
+
require 'danger_plugin'
|
28
|
+
|
29
|
+
# These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
|
30
|
+
# If you are expanding these files, see if it's already been done ^.
|
31
|
+
|
32
|
+
# A silent version of the user interface,
|
33
|
+
# it comes with an extra function `.string` which will
|
34
|
+
# strip all ANSI colours from the string.
|
35
|
+
|
36
|
+
# rubocop:disable Lint/NestedMethodDefinition
|
37
|
+
def testing_ui
|
38
|
+
@output = StringIO.new
|
39
|
+
def @output.winsize
|
40
|
+
[20, 9999]
|
41
|
+
end
|
42
|
+
|
43
|
+
cork = Cork::Board.new(out: @output)
|
44
|
+
def cork.string
|
45
|
+
out.string.gsub(/\e\[([;\d]+)?m/, '')
|
46
|
+
end
|
47
|
+
cork
|
48
|
+
end
|
49
|
+
# rubocop:enable Lint/NestedMethodDefinition
|
50
|
+
|
51
|
+
# Example environment (ENV) that would come from running a PR
|
52
|
+
def testing_env
|
53
|
+
{
|
54
|
+
'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
|
55
|
+
'PULL_REQUEST' => '800',
|
56
|
+
'REPO_SLUG' => 'artsy/eigen',
|
57
|
+
'COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
|
58
|
+
'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
# A stubbed out Dangerfile for use in tests
|
63
|
+
def testing_dangerfile
|
64
|
+
env = Danger::EnvironmentManager.new(testing_env)
|
65
|
+
Danger::Dangerfile.new(env, testing_ui)
|
66
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require File.expand_path('spec_helper', __dir__)
|
4
|
+
|
5
|
+
module Danger
|
6
|
+
describe Danger::DangerUndercover do
|
7
|
+
it 'is a Danger plugin' do
|
8
|
+
expect(Danger::DangerUndercover.new(nil)).to be_a Danger::Plugin
|
9
|
+
end
|
10
|
+
|
11
|
+
describe 'Dangerfile' do
|
12
|
+
before do
|
13
|
+
@dangerfile = testing_dangerfile
|
14
|
+
@undercover = @dangerfile.undercover
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'fails if file is not found' do
|
18
|
+
@undercover.report('spec/fixtures/missing_file.txt')
|
19
|
+
|
20
|
+
expect(@dangerfile.status_report[:errors]).to eq(['Undercover: coverage report cannot be found.'])
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'shows success message if nothing to report' do
|
24
|
+
report_path = 'spec/fixtures/undercover_passed.txt'
|
25
|
+
@undercover.report(report_path)
|
26
|
+
report = File.open(report_path).read
|
27
|
+
|
28
|
+
expect(@dangerfile.status_report[:messages]).to eq([report])
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'shows warnings if undercover has a report' do
|
32
|
+
report_path = 'spec/fixtures/undercover_failed.txt'
|
33
|
+
@undercover.report(report_path)
|
34
|
+
report = File.open(report_path).read
|
35
|
+
|
36
|
+
expect(@dangerfile.status_report[:warnings]).to eq([report])
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
ADDED
@@ -0,0 +1,210 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-undercover
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nimble
|
8
|
+
- rafayet-monon
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2020-10-15 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: danger-plugin-api
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '0'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rubocop
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: yard
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: guard
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: guard-rspec
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: listen
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
type: :development
|
134
|
+
prerelease: false
|
135
|
+
version_requirements: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: pry
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - ">="
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0'
|
154
|
+
description: Show undercover report to PRs
|
155
|
+
email:
|
156
|
+
- dev@nimblehq.co
|
157
|
+
- rafayet@nimblehq.co
|
158
|
+
executables: []
|
159
|
+
extensions: []
|
160
|
+
extra_rdoc_files: []
|
161
|
+
files:
|
162
|
+
- ".github/ISSUE_TEMPLATE/bug_template.md"
|
163
|
+
- ".github/ISSUE_TEMPLATE/feature_template.md"
|
164
|
+
- ".github/PULL_REQUEST_TEMPLATE.md"
|
165
|
+
- ".github/workflows/test.yml"
|
166
|
+
- ".gitignore"
|
167
|
+
- ".rubocop.yml"
|
168
|
+
- Gemfile
|
169
|
+
- Gemfile.lock
|
170
|
+
- Guardfile
|
171
|
+
- LICENSE
|
172
|
+
- README.md
|
173
|
+
- Rakefile
|
174
|
+
- danger-undercover.gemspec
|
175
|
+
- lib/danger_plugin.rb
|
176
|
+
- lib/danger_undercover.rb
|
177
|
+
- lib/undercover/gem_version.rb
|
178
|
+
- lib/undercover/plugin.rb
|
179
|
+
- spec/fixtures/undercover_failed.txt
|
180
|
+
- spec/fixtures/undercover_passed.txt
|
181
|
+
- spec/spec_helper.rb
|
182
|
+
- spec/undercover_spec.rb
|
183
|
+
homepage: https://github.com/nimblehq/danger-undercover
|
184
|
+
licenses:
|
185
|
+
- MIT
|
186
|
+
metadata: {}
|
187
|
+
post_install_message:
|
188
|
+
rdoc_options: []
|
189
|
+
require_paths:
|
190
|
+
- lib
|
191
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
192
|
+
requirements:
|
193
|
+
- - "~>"
|
194
|
+
- !ruby/object:Gem::Version
|
195
|
+
version: '2.4'
|
196
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - ">="
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '0'
|
201
|
+
requirements: []
|
202
|
+
rubygems_version: 3.1.4
|
203
|
+
signing_key:
|
204
|
+
specification_version: 4
|
205
|
+
summary: A Danger plugin for Undercover gem
|
206
|
+
test_files:
|
207
|
+
- spec/fixtures/undercover_failed.txt
|
208
|
+
- spec/fixtures/undercover_passed.txt
|
209
|
+
- spec/spec_helper.rb
|
210
|
+
- spec/undercover_spec.rb
|