danger-xcode_summary 0.1.0

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
+ SHA1:
3
+ metadata.gz: 40f3d04704e9bb77f8327487287a2831656ce32e
4
+ data.tar.gz: 031bd83de379c5c9dad8b66fda4e1b1b45a412d7
5
+ SHA512:
6
+ metadata.gz: 2cc6e6288f4d3cac6436a8f8071eb89af94ebfdc02433b1da9e4de5279b20b0a4a658413009ceab9d2820dca84637d3e880e42e59f0fd493c2cae09916fe6abb
7
+ data.tar.gz: 7f0e85c16312e54fdbd791d08e7cdb76d05897359d2b537176a28f8f3431e8d378fdb19a320fbab1c4b8ca018155c252ee96ed9136afb09fa9587eaacdf01ec3
data/.gitignore ADDED
@@ -0,0 +1,3 @@
1
+ .DS_Store
2
+ pkg
3
+ .idea/
data/.rubocop.yml ADDED
@@ -0,0 +1,85 @@
1
+ # kind_of? is a good way to check a type
2
+ Style/ClassCheck:
3
+ EnforcedStyle: kind_of?
4
+
5
+ # It's better to be more explicit about the type
6
+ Style/BracesAroundHashParameters:
7
+ Enabled: false
8
+
9
+ # specs sometimes have useless assignments, which is fine
10
+ Lint/UselessAssignment:
11
+ Exclude:
12
+ - '**/spec/**/*'
13
+
14
+ # HoundCI doesn't like this rule
15
+ Style/DotPosition:
16
+ Enabled: false
17
+
18
+ # Cop supports --auto-correct.
19
+ Lint/UnusedBlockArgument:
20
+ Enabled: false
21
+
22
+ # We want to allow class Fastlane::Class
23
+ Style/ClassAndModuleChildren:
24
+ Enabled: false
25
+
26
+ Metrics/AbcSize:
27
+ Max: 60
28
+
29
+ # The %w might be confusing for new users
30
+ Style/WordArray:
31
+ MinSize: 19
32
+
33
+ # raise and fail are both okay
34
+ Style/SignalException:
35
+ Enabled: false
36
+
37
+ # Better too much 'return' than one missing
38
+ Style/RedundantReturn:
39
+ Enabled: false
40
+
41
+ # Having if in the same line might not always be good
42
+ Style/IfUnlessModifier:
43
+ Enabled: false
44
+
45
+ # Configuration parameters: CountComments.
46
+ Metrics/ClassLength:
47
+ Max: 320
48
+
49
+ Metrics/CyclomaticComplexity:
50
+ Max: 17
51
+
52
+ # Configuration parameters: AllowURI, URISchemes.
53
+ Metrics/LineLength:
54
+ Max: 120
55
+
56
+ # Configuration parameters: CountKeywordArgs.
57
+ Metrics/ParameterLists:
58
+ Max: 10
59
+
60
+ Metrics/PerceivedComplexity:
61
+ Max: 18
62
+
63
+ # Sometimes it's easier to read without guards
64
+ Style/GuardClause:
65
+ Enabled: false
66
+
67
+ # something = if something_else
68
+ # that's confusing
69
+ Style/ConditionalAssignment:
70
+ Enabled: false
71
+
72
+ # Better to have too much self than missing a self
73
+ Style/RedundantSelf:
74
+ Enabled: false
75
+
76
+ Metrics/MethodLength:
77
+ Max: 60
78
+
79
+ # We're not there yet
80
+ Style/Documentation:
81
+ Enabled: false
82
+
83
+ # Adds complexity
84
+ Style/IfInsideElse:
85
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.0
8
+ - 2.1.3
9
+ - 2.3.1
10
+
11
+ script:
12
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in danger-xcode_summary.gemspec
4
+ gemspec
5
+
6
+ gem 'danger'
7
+ gem 'yard'
8
+ gem 'rubocop'
data/Gemfile.lock ADDED
@@ -0,0 +1,139 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-xcode_summary (0.1.0)
5
+ danger-plugin-api (~> 1.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.4.0)
11
+ ast (2.3.0)
12
+ claide (1.0.0)
13
+ claide-plugins (0.9.1)
14
+ cork
15
+ nap
16
+ open4 (~> 1.3)
17
+ coderay (1.1.1)
18
+ colored (1.2)
19
+ cork (0.2.0)
20
+ colored (~> 1.2)
21
+ danger (3.0.3)
22
+ claide (~> 1.0)
23
+ claide-plugins (> 0.9.0)
24
+ colored (~> 1.2)
25
+ cork (~> 0.1)
26
+ faraday (~> 0.9)
27
+ faraday-http-cache (~> 1.0)
28
+ git (~> 1)
29
+ gitlab (~> 3.7.0)
30
+ kramdown (~> 1.5)
31
+ octokit (~> 4.2)
32
+ terminal-table (~> 1)
33
+ danger-plugin-api (1.0.0)
34
+ danger (> 2.0)
35
+ diff-lcs (1.2.5)
36
+ faraday (0.9.2)
37
+ multipart-post (>= 1.2, < 3)
38
+ faraday-http-cache (1.3.1)
39
+ faraday (~> 0.8)
40
+ ffi (1.9.14)
41
+ formatador (0.2.5)
42
+ git (1.3.0)
43
+ gitlab (3.7.0)
44
+ httparty (~> 0.13.0)
45
+ terminal-table
46
+ guard (2.14.0)
47
+ formatador (>= 0.2.4)
48
+ listen (>= 2.7, < 4.0)
49
+ lumberjack (~> 1.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.2)
57
+ guard (~> 2.1)
58
+ guard-compat (~> 1.1)
59
+ rspec (>= 2.99.0, < 4.0)
60
+ httparty (0.13.7)
61
+ json (~> 1.8)
62
+ multi_xml (>= 0.5.2)
63
+ json (1.8.3)
64
+ kramdown (1.12.0)
65
+ listen (3.0.7)
66
+ rb-fsevent (>= 0.9.3)
67
+ rb-inotify (>= 0.9.7)
68
+ lumberjack (1.0.10)
69
+ method_source (0.8.2)
70
+ multi_xml (0.5.5)
71
+ multipart-post (2.0.0)
72
+ nap (1.1.0)
73
+ nenv (0.3.0)
74
+ notiffany (0.1.0)
75
+ nenv (~> 0.1)
76
+ shellany (~> 0.0)
77
+ octokit (4.3.0)
78
+ sawyer (~> 0.7.0, >= 0.5.3)
79
+ open4 (1.3.4)
80
+ parser (2.3.1.2)
81
+ ast (~> 2.2)
82
+ powerpack (0.1.1)
83
+ pry (0.10.4)
84
+ coderay (~> 1.1.0)
85
+ method_source (~> 0.8.1)
86
+ slop (~> 3.4)
87
+ rainbow (2.1.0)
88
+ rake (10.5.0)
89
+ rb-fsevent (0.9.7)
90
+ rb-inotify (0.9.7)
91
+ ffi (>= 0.5.0)
92
+ rspec (3.5.0)
93
+ rspec-core (~> 3.5.0)
94
+ rspec-expectations (~> 3.5.0)
95
+ rspec-mocks (~> 3.5.0)
96
+ rspec-core (3.5.1)
97
+ rspec-support (~> 3.5.0)
98
+ rspec-expectations (3.5.0)
99
+ diff-lcs (>= 1.2.0, < 2.0)
100
+ rspec-support (~> 3.5.0)
101
+ rspec-mocks (3.5.0)
102
+ diff-lcs (>= 1.2.0, < 2.0)
103
+ rspec-support (~> 3.5.0)
104
+ rspec-support (3.5.0)
105
+ rubocop (0.41.2)
106
+ parser (>= 2.3.1.1, < 3.0)
107
+ powerpack (~> 0.1)
108
+ rainbow (>= 1.99.1, < 3.0)
109
+ ruby-progressbar (~> 1.7)
110
+ unicode-display_width (~> 1.0, >= 1.0.1)
111
+ ruby-progressbar (1.8.1)
112
+ sawyer (0.7.0)
113
+ addressable (>= 2.3.5, < 2.5)
114
+ faraday (~> 0.8, < 0.10)
115
+ shellany (0.0.1)
116
+ slop (3.6.0)
117
+ terminal-table (1.6.0)
118
+ thor (0.19.1)
119
+ unicode-display_width (1.1.0)
120
+ yard (0.9.1)
121
+
122
+ PLATFORMS
123
+ ruby
124
+
125
+ DEPENDENCIES
126
+ bundler (~> 1.3)
127
+ danger
128
+ danger-xcode_summary!
129
+ guard (~> 2.14)
130
+ guard-rspec (~> 4.7)
131
+ listen (= 3.0.7)
132
+ pry
133
+ rake (~> 10.0)
134
+ rspec (~> 3.4)
135
+ rubocop
136
+ yard
137
+
138
+ BUNDLED WITH
139
+ 1.13.1
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.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Diogo Tridapalli <me@diogot.com> and Marcelo Fabri <me@marcelofabri.com>
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # danger-xcode_summary
2
+
3
+ [![License](http://img.shields.io/badge/license-MIT-green.svg?style=flat)](LICENSE.txt)
4
+ [![Gem](https://img.shields.io/gem/v/danger-xcode_summary?style=flat)](http://rubygems.org/gems/danger-xcode_summary)
5
+ [![Build Status](https://travis-ci.org/diogot/danger-xcode_summary.svg?branch=master)](https://travis-ci.org/diogot/danger-xcode_summary)
6
+
7
+ A [Danger](http://danger.systems) plugin that shows all build errors, warnings and unit tests results generated from `xcodebuild`.
8
+
9
+ You need to use [xcpretty](https://github.com/supermarin/xcpretty) with
10
+ [xcpretty-json-formatter](https://github.com/marcelofabri/xcpretty-json-formatter)
11
+ to generate a JSON file that this plugin can read.
12
+
13
+ ## How does it look?
14
+
15
+ <table>
16
+ <thead>
17
+ <tr>
18
+ <th width="50"></th>
19
+ <th width="100%">
20
+ 1 Error
21
+ </th>
22
+ </tr>
23
+ </thead>
24
+ <tbody>
25
+ <tr>
26
+ <td><g-emoji alias="no_entry_sign" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f6ab.png">🚫</g-emoji></td>
27
+ <td>
28
+ <strong>MyWeightTests.MyWeightTests</strong>: testError, failed - :w: <br> <a href="https://github.com/Invariante/MyWeight/blob/0101261efd67cd1fb0d682d88476fdee3d17cf86/MyWeightTests/MyWeightTests.swift#L26">MyWeightTests/MyWeightTests.swift#L26</a>
29
+ </td>
30
+ </tr>
31
+ </tbody>
32
+ </table>
33
+
34
+ <table>
35
+ <thead>
36
+ <tr>
37
+ <th width="50"></th>
38
+ <th width="100%">
39
+ 2 Warnings
40
+ </th>
41
+ </tr>
42
+ </thead>
43
+ <tbody>
44
+
45
+ <tr>
46
+ <td><g-emoji alias="warning" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png">⚠️</g-emoji></td>
47
+ <td>
48
+ <strong><a href="https://github.com/Invariante/MyWeight/blob/0101261efd67cd1fb0d682d88476fdee3d17cf86/MyWeight/ViewController.swift#L35">MyWeight/ViewController.swift#L35</a></strong>: initialization of immutable value ‘bla’ was never used; consider replacing with assignment to ‘_’ or removing it <br><code>
49
+ let bla = "unused variable"
50
+ </code>
51
+ </td>
52
+ </tr>
53
+ <tr>
54
+ <td><g-emoji alias="warning" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/26a0.png">⚠️</g-emoji></td>
55
+ <td>
56
+ <strong><a href="https://github.com/Invariante/MyWeight/blob/0101261efd67cd1fb0d682d88476fdee3d17cf86/Bla.m#L32">Bla.m#L32</a></strong>: Value stored to ‘theme’ is never read <br><code>
57
+ theme = *ptr++;
58
+ </code>
59
+ </td>
60
+ </tr>
61
+ </tbody>
62
+ </table>
63
+
64
+ <table>
65
+ <thead>
66
+ <tr>
67
+ <th width="50"></th>
68
+ <th width="100%">
69
+ 1 Message
70
+ </th>
71
+ </tr>
72
+ </thead>
73
+ <tbody>
74
+
75
+ <tr>
76
+ <td><g-emoji alias="book" fallback-src="https://assets-cdn.github.com/images/icons/emoji/unicode/1f4d6.png">📖</g-emoji></td>
77
+ <td>Executed 5 tests, with 1 failure (0 unexpected) in 0.032 (0.065) seconds</td>
78
+ </tr>
79
+ </tr>
80
+ </tbody>
81
+ </table>
82
+
83
+ ## Installation
84
+
85
+ Add this line to your Gemfile:
86
+
87
+ ```ruby
88
+ gem 'danger-xcode_summary'
89
+ ```
90
+
91
+ ## Usage
92
+
93
+ Just add this line to your `Dangerfile`:
94
+
95
+ ```ruby
96
+ xcode_summary.report 'xcodebuild.json'
97
+ ```
98
+
99
+ You can also ignore warnings from certain files by setting `ignored_files`:
100
+
101
+ ```ruby
102
+ # Ignoring warnings from Pods
103
+ xcode_summary.ignored_files = '**/Pods/**'
104
+ xcode_summary.report 'xcodebuild.json'
105
+ ```
106
+
107
+ ## License
108
+
109
+ danger-xcode_summary is released under the MIT license. See [LICENSE.txt](LICENSE.txt) for details.
110
+
111
+ ## Development
112
+
113
+ 1. Clone this repo
114
+ 2. Run `bundle install` to setup dependencies.
115
+ 3. Run `bundle exec rake spec` to run the tests.
116
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
117
+ 5. Make your changes.
data/Rakefile ADDED
@@ -0,0 +1,23 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:specs)
6
+
7
+ task default: :specs
8
+
9
+ task :spec do
10
+ Rake::Task['specs'].invoke
11
+ Rake::Task['rubocop'].invoke
12
+ Rake::Task['spec_docs'].invoke
13
+ end
14
+
15
+ desc 'Run RuboCop on the lib/specs directory'
16
+ RuboCop::RakeTask.new(:rubocop) do |task|
17
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
18
+ end
19
+
20
+ desc 'Ensure that the plugin passes `danger plugins lint`'
21
+ task :spec_docs do
22
+ sh 'bundle exec danger plugins lint'
23
+ end
@@ -0,0 +1,43 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'xcode_summary/gem_version.rb'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'danger-xcode_summary'
8
+ spec.version = XcodeSummary::VERSION
9
+ spec.authors = ['Diogo Tridapalli', 'Marcelo Fabri']
10
+ spec.email = ['me@diogot.com', 'me@marcelofabri.com']
11
+ spec.description = 'Show formatted xcodebuild output in your PRs.'
12
+ spec.summary = 'A [Danger](http://danger.systems) plugin that shows all build errors, ' \
13
+ 'warnings and unit tests results generated from `xcodebuild`.'
14
+ spec.homepage = 'https://github.com/diogot/danger-xcode_summary'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_runtime_dependency 'danger-plugin-api', '~> 1.0'
23
+
24
+ # General ruby development
25
+ spec.add_development_dependency 'bundler', '~> 1.3'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+
28
+ # Testing support
29
+ spec.add_development_dependency 'rspec', '~> 3.4'
30
+
31
+ # Makes testing easy via `bundle exec guard`
32
+ spec.add_development_dependency 'guard', '~> 2.14'
33
+ spec.add_development_dependency 'guard-rspec', '~> 4.7'
34
+
35
+ # If you want to work on older builds of ruby
36
+ spec.add_development_dependency 'listen', '3.0.7'
37
+
38
+ # This gives you the chance to run a REPL inside your test
39
+ # via
40
+ # binding.pry
41
+ # This will stop test execution and let you inspect the results
42
+ spec.add_development_dependency 'pry'
43
+ end
@@ -0,0 +1 @@
1
+ require 'xcode_summary/plugin'
@@ -0,0 +1 @@
1
+ require 'xcode_summary/gem_version'
@@ -0,0 +1,3 @@
1
+ module XcodeSummary
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,167 @@
1
+ require 'json'
2
+
3
+ module Danger
4
+ # Shows all build errors, warnings and unit tests results generated from `xcodebuild`.
5
+ # You need to use [xcpretty](https://github.com/supermarin/xcpretty)
6
+ # with [xcpretty-json-formatter](https://github.com/marcelofabri/xcpretty-json-formatter)
7
+ # to generate a JSON file that this plugin can read.
8
+ # @example Showing summary
9
+ #
10
+ # xcode_summary.report 'xcodebuild.json'
11
+ #
12
+ # @example Filtering warnings in Pods
13
+ #
14
+ # xcode_summary.ignored_files = '**/Pods/**'
15
+ # xcode_summary.report 'xcodebuild.json'
16
+ #
17
+ # @see diogot/danger-xcode_summary
18
+ # @tags xcode, xcodebuild, format
19
+ #
20
+ class DangerXcodeSummary < Plugin
21
+ # The project root, which will be used to make the paths relative.
22
+ # Defaults to `pwd`.
23
+ # @param [String] value
24
+ # @return [String]
25
+ attr_accessor :project_root
26
+
27
+ # A globbed string or array of strings which should match the files
28
+ # that you want to ignore warnings on. Defaults to nil.
29
+ # An example would be `'**/Pods/**'` to ignore warnings in Pods that your project uses.
30
+ #
31
+ # @param [String or [String]] value
32
+ # @return [[String]]
33
+ attr_accessor :ignored_files
34
+
35
+ # Defines if the test summary will be sticky or not.
36
+ # Defaults to `false`.
37
+ # @param [Boolean] value
38
+ # @return [Boolean]
39
+ attr_accessor :sticky_summary
40
+
41
+ def project_root
42
+ root = @project_root || Dir.pwd
43
+ root += '/' unless root.end_with? '/'
44
+ root
45
+ end
46
+
47
+ def ignored_files
48
+ [@ignored_files].flatten.compact
49
+ end
50
+
51
+ def sticky_summary
52
+ @sticky_summary || false
53
+ end
54
+
55
+ # Reads a file with JSON Xcode summary and reports it.
56
+ #
57
+ # @param [String] file_path Path for Xcode summary in JSON format.
58
+ # @return [void]
59
+ def report(file_path)
60
+ if File.file?(file_path)
61
+ xcode_summary = JSON.parse(File.read(file_path), symbolize_names: true)
62
+ format_summary(xcode_summary)
63
+ else
64
+ fail 'summary file not found'
65
+ end
66
+ end
67
+
68
+ private
69
+
70
+ def format_summary(xcode_summary)
71
+ messages(xcode_summary).each { |s| message(s, sticky: sticky_summary) }
72
+ warnings(xcode_summary).each { |s| warn(s, sticky: false) }
73
+ errors(xcode_summary).each { |s| fail(s, sticky: false) }
74
+ end
75
+
76
+ def messages(xcode_summary)
77
+ [
78
+ xcode_summary[:tests_summary_messages]
79
+ ].flatten.uniq.compact.map(&:strip)
80
+ end
81
+
82
+ def warnings(xcode_summary)
83
+ [
84
+ xcode_summary[:warnings],
85
+ xcode_summary[:ld_warnings],
86
+ xcode_summary.fetch(:compile_warnings, {}).map { |s| format_compile_warning(s) }
87
+ ].flatten.uniq.compact
88
+ end
89
+
90
+ def errors(xcode_summary)
91
+ [
92
+ xcode_summary[:errors],
93
+ xcode_summary.fetch(:compile_errors, {}).map { |s| format_compile_warning(s) },
94
+ xcode_summary.fetch(:file_missing_errors, {}).map { |s| format_format_file_missing_error(s) },
95
+ xcode_summary.fetch(:undefined_symbols_errors, {}).map { |s| format_undefined_symbols(s) },
96
+ xcode_summary.fetch(:duplicate_symbols_errors, {}).map { |s| format_duplicate_symbols(s) },
97
+ xcode_summary.fetch(:tests_failures, {}).map { |k, v| format_test_failure(k, v) }.flatten
98
+ ].flatten.uniq.compact
99
+ end
100
+
101
+ def format_path(path)
102
+ clean_path, line = parse_filename(path)
103
+ path = clean_path + '#L' + line if clean_path && line
104
+
105
+ github.html_link(path)
106
+ end
107
+
108
+ def parse_filename(path)
109
+ regex = /^(.*?):(\d*):?\d*$/
110
+ match = path.match(regex)
111
+ if match
112
+ match.captures
113
+ end
114
+ end
115
+
116
+ def relative_path(path)
117
+ return nil if project_root.nil?
118
+ path.gsub(project_root, '')
119
+ end
120
+
121
+ def should_ignore_warning?(path)
122
+ parsed = parse_filename(path)
123
+ path = parsed.first || path
124
+ ignored_files.any? { |pattern| File.fnmatch(pattern, path) }
125
+ end
126
+
127
+ def escape_reason(reason)
128
+ reason.gsub('>', '\>').gsub('<', '\<')
129
+ end
130
+
131
+ def format_compile_warning(h)
132
+ path = relative_path(h[:file_path])
133
+ return nil if should_ignore_warning?(path)
134
+
135
+ path_link = format_path(path)
136
+ "**#{path_link}**: #{escape_reason(h[:reason])} <br />" \
137
+ "```\n" \
138
+ "#{h[:line]}\n" \
139
+ '```'
140
+ end
141
+
142
+ def format_format_file_missing_error(h)
143
+ path = relative_path(h[:file_path])
144
+ path_link = format_path(path)
145
+ "**#{escape_reason(h[:reason])}**: #{path_link}"
146
+ end
147
+
148
+ def format_undefined_symbols(h)
149
+ "#{h[:message]} <br />" \
150
+ "> Symbol: #{h[:symbol]} <br />" \
151
+ "> Referenced from: #{h[:reference]}"
152
+ end
153
+
154
+ def format_duplicate_symbols(h)
155
+ "#{h[:message]} <br />" \
156
+ "> #{h[:file_paths].map { |path| path.split('/').last }.join('<br /> ')}"
157
+ end
158
+
159
+ def format_test_failure(suite_name, failures)
160
+ failures.map do |f|
161
+ path = relative_path(f[:file_path])
162
+ path_link = format_path(path)
163
+ "**#{suite_name}**: #{f[:test_case]}, #{escape_reason(f[:reason])} <br /> #{path_link}"
164
+ end
165
+ end
166
+ end
167
+ end
@@ -0,0 +1,44 @@
1
+ {
2
+ "warnings": [
3
+
4
+ ],
5
+ "ld_warnings": [
6
+
7
+ ],
8
+ "compile_warnings": [
9
+ {
10
+ "file_name": "Bla.m",
11
+ "file_path": "/Users/diogo/src/MyWeight/MyWeight/Bla.m:32:13",
12
+ "reason": "Value stored to 'theme' is never read",
13
+ "line": " theme = *ptr++;",
14
+ "cursor": " ^ ~~~~~~"
15
+ },
16
+ {
17
+ "file_name": "ISO8601DateFormatter.m",
18
+ "file_path": "/Users/diogo/src/MyWeight/MyWeight/Pods/ISO8601DateFormatter/ISO8601DateFormatter.m:176:19",
19
+ "reason": "'NSUndefinedDateComponent' is deprecated: first deprecated in iOS 8.0 - Use NSDateComponentUndefined instead [-Wdeprecated-declarations]",
20
+ "line": " month_or_week = NSUndefinedDateComponent,",
21
+ "cursor": " ^"
22
+ }
23
+ ],
24
+ "errors": [
25
+
26
+ ],
27
+ "compile_errors": [
28
+
29
+ ],
30
+ "file_missing_errors": [
31
+
32
+ ],
33
+ "undefined_symbols_errors": [
34
+
35
+ ],
36
+ "duplicate_symbols_errors": [
37
+
38
+ ],
39
+ "tests_failures": {
40
+ },
41
+ "tests_summary_messages": [
42
+ "\t Executed 4 tests, with 0 failures (0 unexpected) in 0.012 (0.017) seconds\n"
43
+ ]
44
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "tests_summary_messages": [
3
+ "\t Executed 4 tests, with 0 failures (0 unexpected) in 0.012 (0.017) seconds\n"
4
+ ]
5
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "tests_failures": {
3
+ "MyWeight.MyWeightSpec": [
4
+ {
5
+ "file_path": "/Users/diogo/src/MyWeight/MyWeight/MyWeightTests/Tests.swift:86",
6
+ "reason": "expected to eventually not be nil, got <nil>",
7
+ "test_case": "works_with_success"
8
+ }
9
+ ]
10
+ }
11
+ }
@@ -0,0 +1,59 @@
1
+ require 'pathname'
2
+ ROOT = Pathname.new(File.expand_path('../../', __FILE__))
3
+ $LOAD_PATH.unshift((ROOT + 'lib').to_s)
4
+ $LOAD_PATH.unshift((ROOT + 'spec').to_s)
5
+
6
+ require 'bundler/setup'
7
+ require 'pry'
8
+
9
+ require 'rspec'
10
+ require 'danger'
11
+
12
+ require 'danger_plugin'
13
+
14
+ # Use coloured output, it's the best.
15
+ RSpec.configure do |config|
16
+ config.filter_gems_from_backtrace 'bundler'
17
+ config.color = true
18
+ config.tty = true
19
+ end
20
+
21
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
22
+ # If you are expanding these files, see if it's already been done ^.
23
+
24
+ # A silent version of the user interface,
25
+ # it comes with an extra function `.string` which will
26
+ # strip all ANSI colours from the string.
27
+
28
+ # rubocop:disable Lint/NestedMethodDefinition
29
+ def testing_ui
30
+ @output = StringIO.new
31
+ def @output.winsize
32
+ [20, 9999]
33
+ end
34
+
35
+ cork = Cork::Board.new(out: @output)
36
+ def cork.string
37
+ out.string.gsub(/\e\[([;\d]+)?m/, '')
38
+ end
39
+ cork
40
+ end
41
+ # rubocop:enable Lint/NestedMethodDefinition
42
+
43
+ # Example environment (ENV) that would come from
44
+ # running a PR on TravisCI
45
+ def testing_env
46
+ {
47
+ 'HAS_JOSH_K_SEAL_OF_APPROVAL' => 'true',
48
+ 'TRAVIS_PULL_REQUEST' => '800',
49
+ 'TRAVIS_REPO_SLUG' => 'artsy/eigen',
50
+ 'TRAVIS_COMMIT_RANGE' => '759adcbd0d8f...13c4dc8bb61d',
51
+ 'DANGER_GITHUB_API_TOKEN' => '123sbdq54erfsd3422gdfio'
52
+ }
53
+ end
54
+
55
+ # A stubbed out Dangerfile for use in tests
56
+ def testing_dangerfile
57
+ env = Danger::EnvironmentManager.new(testing_env)
58
+ Danger::Dangerfile.new(env, testing_ui)
59
+ end
@@ -0,0 +1,82 @@
1
+ require File.expand_path('../spec_helper', __FILE__)
2
+
3
+ module Danger
4
+ describe Danger::DangerXcodeSummary do
5
+ it 'should be a plugin' do
6
+ expect(Danger::DangerXcodeSummary.new(nil)).to be_a Danger::Plugin
7
+ end
8
+
9
+ #
10
+ # You should test your custom attributes and methods here
11
+ #
12
+ describe 'with Dangerfile' do
13
+ before do
14
+ @dangerfile = testing_dangerfile
15
+ @xcode_summary = @dangerfile.xcode_summary
16
+ @xcode_summary.env.request_source.pr_json = {
17
+ head: {
18
+ repo: {
19
+ html_url: 'https://github.com/diogot/danger-xcode_summary'
20
+ },
21
+ sha: '129jef029jf029fj2039fj203f92'
22
+ }
23
+ }
24
+ @xcode_summary.project_root = '/Users/diogo/src/MyWeight'
25
+ end
26
+
27
+ it 'sets sticky_summary to false as default' do
28
+ expect(@xcode_summary.sticky_summary).to eq false
29
+ end
30
+
31
+ it 'fail if file does not exist' do
32
+ @xcode_summary.report('spec/fixtures/inexistent_file.json')
33
+ expect(@dangerfile.status_report[:errors]).to eq ['summary file not found']
34
+ end
35
+
36
+ describe 'summary' do
37
+ it 'formats summary messages' do
38
+ @xcode_summary.report('spec/fixtures/summary_messages.json')
39
+ expect(@dangerfile.status_report[:messages]).to eq [
40
+ 'Executed 4 tests, with 0 failures (0 unexpected) in 0.012 (0.017) seconds'
41
+ ]
42
+ end
43
+
44
+ it 'formats compile warnings' do
45
+ @xcode_summary.report('spec/fixtures/summary.json')
46
+ expect(@dangerfile.status_report[:warnings]).to eq [
47
+ # rubocop:disable LineLength
48
+ "**<a href='https://github.com/diogot/danger-xcode_summary/blob/129jef029jf029fj2039fj203f92/MyWeight/Bla.m#L32'>MyWeight/Bla.m#L32</a>**: Value stored to 'theme' is never read <br />```\n theme = *ptr++;\n```",
49
+ "**<a href='https://github.com/diogot/danger-xcode_summary/blob/129jef029jf029fj2039fj203f92/MyWeight/Pods/ISO8601DateFormatter/ISO8601DateFormatter.m#L176'>MyWeight/Pods/ISO8601DateFormatter/ISO8601DateFormatter.m#L176</a>**: 'NSUndefinedDateComponent' is deprecated: first deprecated in iOS 8.0 - Use NSDateComponentUndefined instead [-Wdeprecated-declarations] <br />```\n month_or_week = NSUndefinedDateComponent,\n```"
50
+ # rubocop:enable LineLength
51
+ ]
52
+ end
53
+
54
+ it 'ignores file when ignored_files matches' do
55
+ @xcode_summary.ignored_files = '**/Pods/**'
56
+ @xcode_summary.report('spec/fixtures/summary.json')
57
+ expect(@dangerfile.status_report[:warnings]).to eq [
58
+ # rubocop:disable LineLength
59
+ "**<a href='https://github.com/diogot/danger-xcode_summary/blob/129jef029jf029fj2039fj203f92/MyWeight/Bla.m#L32'>MyWeight/Bla.m#L32</a>**: Value stored to 'theme' is never read <br />```\n theme = *ptr++;\n```",
60
+ # rubocop:enable LineLength
61
+ ]
62
+ end
63
+
64
+ it 'ignores file when ignored_files is an array and matches' do
65
+ @xcode_summary.ignored_files = ['**/Pods/**', '*.m']
66
+ @xcode_summary.report('spec/fixtures/summary.json')
67
+ expect(@dangerfile.status_report[:warnings]).to eq []
68
+ end
69
+
70
+ it 'formats test errors' do
71
+ @xcode_summary.report('spec/fixtures/test_errors.json')
72
+ expect(@dangerfile.status_report[:errors]).to eq [
73
+ # rubocop:disable LineLength
74
+ '**MyWeight.MyWeightSpec**: works_with_success, expected to eventually not be nil, got \<nil\> <br /> ' \
75
+ "<a href='https://github.com/diogot/danger-xcode_summary/blob/129jef029jf029fj2039fj203f92/MyWeight/MyWeightTests/Tests.swift#L86'>MyWeight/MyWeightTests/Tests.swift#L86</a>",
76
+ # rubocop:enable LineLength
77
+ ]
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
metadata ADDED
@@ -0,0 +1,183 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-xcode_summary
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Diogo Tridapalli
8
+ - Marcelo Fabri
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-09-30 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: '1.3'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.3'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '10.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '10.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: '3.4'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '3.4'
70
+ - !ruby/object:Gem::Dependency
71
+ name: guard
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '2.14'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '2.14'
84
+ - !ruby/object:Gem::Dependency
85
+ name: guard-rspec
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '4.7'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '4.7'
98
+ - !ruby/object:Gem::Dependency
99
+ name: listen
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '='
103
+ - !ruby/object:Gem::Version
104
+ version: 3.0.7
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '='
110
+ - !ruby/object:Gem::Version
111
+ version: 3.0.7
112
+ - !ruby/object:Gem::Dependency
113
+ name: pry
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
+ description: Show formatted xcodebuild output in your PRs.
127
+ email:
128
+ - me@diogot.com
129
+ - me@marcelofabri.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - ".gitignore"
135
+ - ".rubocop.yml"
136
+ - ".travis.yml"
137
+ - Gemfile
138
+ - Gemfile.lock
139
+ - Guardfile
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - danger-xcode_summary.gemspec
144
+ - lib/danger_plugin.rb
145
+ - lib/danger_xcode_summary.rb
146
+ - lib/xcode_summary/gem_version.rb
147
+ - lib/xcode_summary/plugin.rb
148
+ - spec/fixtures/summary.json
149
+ - spec/fixtures/summary_messages.json
150
+ - spec/fixtures/test_errors.json
151
+ - spec/spec_helper.rb
152
+ - spec/xcode_summary_spec.rb
153
+ homepage: https://github.com/diogot/danger-xcode_summary
154
+ licenses:
155
+ - MIT
156
+ metadata: {}
157
+ post_install_message:
158
+ rdoc_options: []
159
+ require_paths:
160
+ - lib
161
+ required_ruby_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ required_rubygems_version: !ruby/object:Gem::Requirement
167
+ requirements:
168
+ - - ">="
169
+ - !ruby/object:Gem::Version
170
+ version: '0'
171
+ requirements: []
172
+ rubyforge_project:
173
+ rubygems_version: 2.6.0
174
+ signing_key:
175
+ specification_version: 4
176
+ summary: A [Danger](http://danger.systems) plugin that shows all build errors, warnings
177
+ and unit tests results generated from `xcodebuild`.
178
+ test_files:
179
+ - spec/fixtures/summary.json
180
+ - spec/fixtures/summary_messages.json
181
+ - spec/fixtures/test_errors.json
182
+ - spec/spec_helper.rb
183
+ - spec/xcode_summary_spec.rb