danger-xcov 0.1
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 +7 -0
- data/.gitignore +36 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +38 -0
- data/Rakefile +1 -0
- data/danger-xcov.gemspec +23 -0
- data/lib/danger_plugin.rb +90 -0
- data/lib/version.rb +4 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e009b2b109ebfa31c1a8cb709606a9a303603860
|
4
|
+
data.tar.gz: 771c6fb25fe8064a2f1c7da65fe4ef306f16c0ea
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3cc47d0dadb008030b5104da6e701172107f708e3db04e75aed2c07d23c37fdf7b8bf9ffcad6ef0b00b03091bb72f6ec5a26ffc09480df16c32a2e05158832d0
|
7
|
+
data.tar.gz: 2cfd0fb62db523b8c9c579896977e2c2ab6da75f043cf4ba09abd3af76d4273df52a00f7057f610a2bf3ac63d92ec1f6dde6ff35ac41d8aefb6467701820b84b
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/spec/examples.txt
|
9
|
+
/test/tmp/
|
10
|
+
/test/version_tmp/
|
11
|
+
/tmp/
|
12
|
+
|
13
|
+
## Specific to RubyMotion:
|
14
|
+
.dat*
|
15
|
+
.repl_history
|
16
|
+
build/
|
17
|
+
|
18
|
+
## Documentation cache and generated files:
|
19
|
+
/.yardoc/
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalization:
|
25
|
+
/.bundle/
|
26
|
+
/vendor/bundle
|
27
|
+
/lib/bundler/man/
|
28
|
+
|
29
|
+
# for a library or gem, you might want to ignore these files since the code is
|
30
|
+
# intended to run in multiple environments; otherwise, check them in:
|
31
|
+
# Gemfile.lock
|
32
|
+
# .ruby-version
|
33
|
+
# .ruby-gemset
|
34
|
+
|
35
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
36
|
+
.rvmrc
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Carlos Vidal
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+

|
2
|
+
-------
|
3
|
+
[](https://twitter.com/carlostify)
|
4
|
+
[](https://github.com/nakiostudio/xcov/blob/master/LICENSE)
|
5
|
+
[](http://rubygems.org/gems/danger-xcov)
|
6
|
+
[](http://rubygems.org/gems/danger-xcov)
|
7
|
+
|
8
|
+
**danger-xcov** is the [Danger](https://github.com/danger/danger) plugin of
|
9
|
+
[xcov](https://github.com/nakiostudio/xcov), a friendly visualizer for Xcode's
|
10
|
+
code coverage files.
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
```
|
15
|
+
sudo gem install danger-xcov
|
16
|
+
```
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
Simply add `xcov.report` to your `Dangerfile` passing those **xcov** parameters
|
21
|
+
you need. Click [here](https://github.com/nakiostudio/xcov#parameters-allowed) to
|
22
|
+
see the updated list of parameters allowed by **xcov**.
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
xcov.report(
|
26
|
+
scheme: 'EasyPeasy',
|
27
|
+
workspace: 'Example/EasyPeasy.xcworkspace',
|
28
|
+
exclude_targets: 'Demo.app',
|
29
|
+
minimum_coverage_percentage: 90
|
30
|
+
)
|
31
|
+
```
|
32
|
+
|
33
|
+
The result is as cool as follows:
|
34
|
+
|
35
|
+

|
36
|
+
|
37
|
+
## License
|
38
|
+
This project is licensed under the terms of the MIT license. See the LICENSE file.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/danger-xcov.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'danger-xcov'
|
8
|
+
spec.version = DangerXcov::VERSION
|
9
|
+
spec.authors = ['Carlos Vidal']
|
10
|
+
spec.email = ['nakioparkour@gmail.com']
|
11
|
+
spec.description = %q{Danger plugin to validate the code coverage of the files changed.}
|
12
|
+
spec.summary = %q{Danger plugin to validate the code coverage of the files changed}
|
13
|
+
spec.homepage = 'https://github.com/nakiostudio/danger-xcov'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_dependency 'danger'
|
20
|
+
spec.add_dependency 'xcov', '~> 0.9'
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Danger
|
2
|
+
class DangerXcov < Plugin
|
3
|
+
|
4
|
+
# Validates the code coverage of the files changed within a Pull Request.
|
5
|
+
# This method accepts the same arguments accepted by the xcov gem.
|
6
|
+
#
|
7
|
+
# @example Validating code coverage for EasyPeasy (easy-peasy.io)
|
8
|
+
#
|
9
|
+
# xcov.report(
|
10
|
+
# scheme: 'EasyPeasy',
|
11
|
+
# workspace: 'Example/EasyPeasy.xcworkspace',
|
12
|
+
# exclude_targets: 'Demo.app',
|
13
|
+
# minimum_coverage_percentage: 90
|
14
|
+
# )
|
15
|
+
#
|
16
|
+
# # Checks the coverage for the EasyPeasy scheme within the specified
|
17
|
+
# workspace, ignoring the target 'Demo.app' and setting a minimum
|
18
|
+
# coverage percentage of 90%.
|
19
|
+
# The result is sent to the pull request with a markdown format and
|
20
|
+
# notifies failure if the minimum coverage threshold is not reached.
|
21
|
+
#
|
22
|
+
# @see: https://github.com/nakiostudio/danger-xcov
|
23
|
+
# @tags: xcode, coverage, xccoverage, tests, ios, xcov
|
24
|
+
def report(*args)
|
25
|
+
# Check xcov availability, install it if needed
|
26
|
+
system "gem install xcov" unless xcov_available
|
27
|
+
unless xcov_available
|
28
|
+
puts "xcov is not available on this machine"
|
29
|
+
return
|
30
|
+
end
|
31
|
+
|
32
|
+
require "xcov"
|
33
|
+
|
34
|
+
# Init Xcov
|
35
|
+
config = args.first
|
36
|
+
Xcov.config = config
|
37
|
+
Xcov.ignore_handler = Xcov::IgnoreHandler.new
|
38
|
+
|
39
|
+
# Init project
|
40
|
+
FastlaneCore::Project.detect_projects(config)
|
41
|
+
Xcov.project = FastlaneCore::Project.new(config)
|
42
|
+
|
43
|
+
# Parse .xccoverage
|
44
|
+
report_json = Xcov::Runner.new.parse_xccoverage
|
45
|
+
|
46
|
+
# Map and process report
|
47
|
+
report = process_report(Xcov::Report.map(report_json))
|
48
|
+
|
49
|
+
# Create markdown
|
50
|
+
report_markdown = report.markdown_value
|
51
|
+
|
52
|
+
# Send markdown
|
53
|
+
markdown(report_markdown)
|
54
|
+
|
55
|
+
# Notify failure if minimum coverage hasn't been reached
|
56
|
+
threshold = config[:minimum_coverage_percentage].to_i
|
57
|
+
if !threshold.nil? && (report.coverage * 100) < threshold
|
58
|
+
fail("Code coverage under minimum of #{threshold}%")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Class methods
|
63
|
+
|
64
|
+
# Brief description of the plugin
|
65
|
+
# @return [String]
|
66
|
+
def self.description
|
67
|
+
"Danger plugin to validate the code coverage of the files changed"
|
68
|
+
end
|
69
|
+
|
70
|
+
# Aux methods
|
71
|
+
|
72
|
+
# Checks whether xcov is available
|
73
|
+
def xcov_available
|
74
|
+
`which xcov`.split("/").count > 1
|
75
|
+
end
|
76
|
+
|
77
|
+
# Filters the files that haven't been modified in the current PR
|
78
|
+
def process_report(report)
|
79
|
+
file_names = modified_files.map { |file| File.basename(file) }
|
80
|
+
report.targets.each do |target|
|
81
|
+
target.files = target.files.select { |file| file_names.include?(file.name) }
|
82
|
+
end
|
83
|
+
|
84
|
+
report
|
85
|
+
end
|
86
|
+
|
87
|
+
private :xcov_available, :process_report
|
88
|
+
|
89
|
+
end
|
90
|
+
end
|
data/lib/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: danger-xcov
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Carlos Vidal
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: danger
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: xcov
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.9'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Danger plugin to validate the code coverage of the files changed.
|
70
|
+
email:
|
71
|
+
- nakioparkour@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- danger-xcov.gemspec
|
82
|
+
- lib/danger_plugin.rb
|
83
|
+
- lib/version.rb
|
84
|
+
homepage: https://github.com/nakiostudio/danger-xcov
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.4.8
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Danger plugin to validate the code coverage of the files changed
|
108
|
+
test_files: []
|