danger-xcprofiler 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/danger-xcprofiler.gemspec +2 -2
- data/lib/xcprofiler/danger_reporter.rb +8 -1
- data/lib/xcprofiler/gem_version.rb +1 -1
- data/lib/xcprofiler/plugin.rb +17 -3
- data/spec/spec_helper.rb +1 -1
- data/spec/xcprofiler_spec.rb +23 -2
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 98d8b6553f16e8366ff699fadb2a2353f9bb8f6813f3e20a223cba72474cbe5c
|
4
|
+
data.tar.gz: bbb1c70e6efaeffd593cbf7b59d760143493e8cc578dcf16098888905c9c4959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd7cdd61911169a68b9b0ce7ec7e34da47bfe43ec3e455330623fcaf60a167bb55c64c5f68f78f8df41970a071779381730769dc2d404e11ff04c159dbf5e810
|
7
|
+
data.tar.gz: 22b2ae376946f27b8a13ed8eece85dc81812ab0f304e4f1cb0ecb0794cb9b0d0424fbfc5b4bd12a230b451904a0b9da5c80bc3673ba9787ec77781840abe271b
|
data/danger-xcprofiler.gemspec
CHANGED
@@ -33,8 +33,8 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency 'coveralls'
|
34
34
|
|
35
35
|
# Linting code and docs
|
36
|
-
spec.add_development_dependency 'rubocop'
|
37
|
-
spec.add_development_dependency 'yard'
|
36
|
+
spec.add_development_dependency 'rubocop'
|
37
|
+
spec.add_development_dependency 'yard'
|
38
38
|
|
39
39
|
# Makes testing easy via `bundle exec guard`
|
40
40
|
spec.add_development_dependency 'guard', '~> 2.14'
|
@@ -3,15 +3,18 @@ require 'pathname'
|
|
3
3
|
|
4
4
|
module Danger
|
5
5
|
class DangerReporter < Xcprofiler::AbstractReporter
|
6
|
-
def initialize(dangerfile, thresholds, inline_mode, working_dir)
|
6
|
+
def initialize(dangerfile, thresholds, inline_mode, working_dir, ignored_files)
|
7
7
|
super({})
|
8
8
|
@dangerfile = dangerfile
|
9
9
|
@thresholds = thresholds
|
10
10
|
@inline_mode = inline_mode
|
11
11
|
@working_dir = working_dir
|
12
|
+
@ignored_files = ignored_files
|
12
13
|
end
|
13
14
|
|
14
15
|
def report!(executions)
|
16
|
+
executions.reject! { |execution| ignored_files.any? { |pattern| File.fnmatch(pattern, execution.path) } }
|
17
|
+
|
15
18
|
if @inline_mode
|
16
19
|
inline_report(executions)
|
17
20
|
else
|
@@ -69,5 +72,9 @@ module Danger
|
|
69
72
|
|
70
73
|
message
|
71
74
|
end
|
75
|
+
|
76
|
+
def ignored_files
|
77
|
+
[@ignored_files].flatten.compact
|
78
|
+
end
|
72
79
|
end
|
73
80
|
end
|
data/lib/xcprofiler/plugin.rb
CHANGED
@@ -12,6 +12,10 @@ module Danger
|
|
12
12
|
# xcprofiler.thresholds = { warn: 100, fail: 500 }
|
13
13
|
# xcprofiler.report 'MyApp'
|
14
14
|
#
|
15
|
+
# @example Specify a custom DerivedData directory
|
16
|
+
#
|
17
|
+
# xcprofiler.report 'MyApp' './DerivedData'
|
18
|
+
#
|
15
19
|
# @see giginet/danger-xcprofiler
|
16
20
|
# @tags xcode, ios, danger
|
17
21
|
class DangerXcprofiler < Plugin
|
@@ -33,13 +37,22 @@ module Danger
|
|
33
37
|
# @return [Boolean]
|
34
38
|
attr_accessor :inline_mode
|
35
39
|
|
40
|
+
# A globbed string or array of strings which should match the files
|
41
|
+
# that you want to ignore warnings on. Defaults to nil.
|
42
|
+
# An example would be `'**/Pods/**'` to ignore warnings in Pods that your project uses.
|
43
|
+
#
|
44
|
+
# @param [String or [String]] value
|
45
|
+
# @return [[String]]
|
46
|
+
attr_accessor :ignored_files
|
47
|
+
|
36
48
|
# Search the latest .xcactivitylog by the passing product_name and profile compilation time
|
37
49
|
# @param [String] product_name Product name for the target project.
|
50
|
+
# @param [String] derived_data_path Path to the directory containing the DerivedData.
|
38
51
|
# @return [void]
|
39
|
-
def report(product_name)
|
40
|
-
profiler = Xcprofiler::Profiler.by_product_name(product_name)
|
52
|
+
def report(product_name, derived_data_path = nil)
|
53
|
+
profiler = Xcprofiler::Profiler.by_product_name(product_name, derived_data_path)
|
41
54
|
profiler.reporters = [
|
42
|
-
DangerReporter.new(@dangerfile, thresholds, inline_mode, working_dir)
|
55
|
+
DangerReporter.new(@dangerfile, thresholds, inline_mode, working_dir, ignored_files)
|
43
56
|
]
|
44
57
|
profiler.report!
|
45
58
|
rescue Xcprofiler::DerivedDataNotFound, Xcprofiler::BuildFlagIsNotEnabled => e
|
@@ -58,6 +71,7 @@ module Danger
|
|
58
71
|
|
59
72
|
def inline_mode
|
60
73
|
return true if @inline_mode.nil?
|
74
|
+
|
61
75
|
!!@inline_mode
|
62
76
|
end
|
63
77
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/xcprofiler_spec.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
require File.expand_path('
|
1
|
+
require File.expand_path('spec_helper', __dir__)
|
2
2
|
require 'xcprofiler'
|
3
3
|
|
4
|
+
# rubocop:disable Metrics/ModuleLength
|
4
5
|
module Danger
|
5
6
|
describe Danger::DangerXcprofiler do
|
6
7
|
it 'should be a plugin' do
|
@@ -25,7 +26,7 @@ module Danger
|
|
25
26
|
allow(@dangerfile).to receive(:warn)
|
26
27
|
allow(@dangerfile).to receive(:fail)
|
27
28
|
allow(@dangerfile).to receive(:markdown)
|
28
|
-
allow(Xcprofiler::Profiler).to receive(:by_product_name).with(product_name).and_return(profiler)
|
29
|
+
allow(Xcprofiler::Profiler).to receive(:by_product_name).with(product_name, nil).and_return(profiler)
|
29
30
|
allow(derived_data).to receive(:flag_enabled?).and_return(true)
|
30
31
|
allow(derived_data).to receive(:executions).and_return([execution0, execution1])
|
31
32
|
[execution0, execution1].each do |execution|
|
@@ -34,6 +35,25 @@ module Danger
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
38
|
+
context 'with ignored files' do
|
39
|
+
let(:time0) { 49.9 }
|
40
|
+
let(:time1) { 50 }
|
41
|
+
it 'skips matching warning' do
|
42
|
+
@xcprofiler.ignored_files = ['path/**']
|
43
|
+
@xcprofiler.report(product_name)
|
44
|
+
expect(@dangerfile).to_not have_received(:warn).with('`doSomething()` takes 50.0 ms to build',
|
45
|
+
file: 'path/to/Source.swift',
|
46
|
+
line: 20)
|
47
|
+
end
|
48
|
+
it 'includes non-matching warning' do
|
49
|
+
@xcprofiler.ignored_files = ['other/path/**']
|
50
|
+
@xcprofiler.report(product_name)
|
51
|
+
expect(@dangerfile).to have_received(:warn).with('`doSomething()` takes 50.0 ms to build',
|
52
|
+
file: 'path/to/Source.swift',
|
53
|
+
line: 20)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
37
57
|
context 'with slow execution' do
|
38
58
|
let(:time0) { 49.9 }
|
39
59
|
let(:time1) { 50 }
|
@@ -119,3 +139,4 @@ module Danger
|
|
119
139
|
end
|
120
140
|
end
|
121
141
|
end
|
142
|
+
# rubocop:enable Metrics/ModuleLength
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-xcprofiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- giginet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcprofiler
|
@@ -98,30 +98,30 @@ dependencies:
|
|
98
98
|
name: rubocop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
110
|
+
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: yard
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '0
|
117
|
+
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '0
|
124
|
+
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: guard
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -223,7 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
223
|
version: '0'
|
224
224
|
requirements: []
|
225
225
|
rubyforge_project:
|
226
|
-
rubygems_version: 2.
|
226
|
+
rubygems_version: 2.7.6
|
227
227
|
signing_key:
|
228
228
|
specification_version: 4
|
229
229
|
summary: danger plugin for asserting Swift compilation time.
|