danger-xcprofiler 0.2.0 → 0.3.0
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 +4 -4
- data/.rubocop.yml +5 -1
- data/.travis.yml +0 -1
- data/lib/xcprofiler/danger_reporter.rb +39 -10
- data/lib/xcprofiler/gem_version.rb +1 -1
- data/spec/xcprofiler_spec.rb +13 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d53c2adc425beb4ac13b96c331b14aae3778cc8f
|
4
|
+
data.tar.gz: c2b35bcfbafdb557ff76b38e5a11b6037c3540c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c520d168973faa82f5cfb25988dcbb390c6ecb68b91fff925d49f92a00252aaf53bde9504c8f95858d1df72a2dc018ad57f2b0e0d9ed7c44c315e9feabab00b8
|
7
|
+
data.tar.gz: 1b0470efd3c6da2002ab7d4362c52df4a555067aa34665b83b6fedda9ead81d02923cd9c5427947f782616de930b6039a65a833aec52dfb25de7306947e79584
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -12,13 +12,21 @@ module Danger
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def report!(executions)
|
15
|
+
if @inline_mode
|
16
|
+
inline_report(executions)
|
17
|
+
else
|
18
|
+
markdown_report(executions)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def inline_report(executions)
|
15
25
|
executions.each do |execution|
|
16
26
|
options = {}
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
message = message(execution)
|
27
|
+
options[:file] = relative_path(execution.path)
|
28
|
+
options[:line] = execution.line
|
29
|
+
message = "`#{execution.method_name}` takes #{execution.time} ms to build"
|
22
30
|
|
23
31
|
if execution.time >= @thresholds[:fail]
|
24
32
|
@dangerfile.fail(message, options)
|
@@ -28,17 +36,38 @@ module Danger
|
|
28
36
|
end
|
29
37
|
end
|
30
38
|
|
31
|
-
|
39
|
+
def markdown_report(executions)
|
40
|
+
warning_executions = executions.select do |e|
|
41
|
+
e.time >= @thresholds[:warn] && e.time < @thresholds[:fail]
|
42
|
+
end
|
43
|
+
error_executions = executions.select do |e|
|
44
|
+
e.time >= @thresholds[:fail]
|
45
|
+
end
|
46
|
+
|
47
|
+
return if warning_executions.empty? && error_executions.empty?
|
32
48
|
|
33
|
-
|
34
|
-
message
|
35
|
-
|
36
|
-
|
49
|
+
message = "### Xcprofiler found issues\n\n"
|
50
|
+
message << markdown_issues(warning_executions, 'Warnings') unless warning_executions.empty?
|
51
|
+
message << markdown_issues(error_executions, 'Errors') unless error_executions.empty?
|
52
|
+
@dangerfile.markdown(message, {})
|
37
53
|
end
|
38
54
|
|
39
55
|
def relative_path(path)
|
40
56
|
working_dir = Pathname.new(@working_dir)
|
41
57
|
Pathname.new(path).relative_path_from(working_dir).to_s
|
42
58
|
end
|
59
|
+
|
60
|
+
def markdown_issues(executions, heading)
|
61
|
+
message = "#### #{heading}\n\n"
|
62
|
+
|
63
|
+
message << "| File | Line | Method Name | Build Time (ms) |\n"
|
64
|
+
message << "| ---- | ---- | ----------- | --------------- |\n"
|
65
|
+
|
66
|
+
executions.each do |e|
|
67
|
+
message << "| #{e.filename} | #{e.line} | #{e.method_name} | #{e.time} |\n"
|
68
|
+
end
|
69
|
+
|
70
|
+
message
|
71
|
+
end
|
43
72
|
end
|
44
73
|
end
|
data/spec/xcprofiler_spec.rb
CHANGED
@@ -24,6 +24,7 @@ module Danger
|
|
24
24
|
@xcprofiler.working_dir = ''
|
25
25
|
allow(@dangerfile).to receive(:warn)
|
26
26
|
allow(@dangerfile).to receive(:fail)
|
27
|
+
allow(@dangerfile).to receive(:markdown)
|
27
28
|
allow(Xcprofiler::Profiler).to receive(:by_product_name).with(product_name).and_return(profiler)
|
28
29
|
allow(derived_data).to receive(:flag_enabled?).and_return(true)
|
29
30
|
allow(derived_data).to receive(:executions).and_return([execution0, execution1])
|
@@ -92,18 +93,26 @@ module Danger
|
|
92
93
|
context 'with slow execution' do
|
93
94
|
let(:time0) { 49.9 }
|
94
95
|
let(:time1) { 50 }
|
96
|
+
message = "### Xcprofiler found issues\n\n"
|
97
|
+
message << "#### Warnings\n\n"
|
98
|
+
message << "| File | Line | Method Name | Build Time (ms) |\n"
|
99
|
+
message << "| ---- | ---- | ----------- | --------------- |\n"
|
100
|
+
message << "| Source.swift | 20 | doSomething() | 50.0 |\n"
|
95
101
|
it 'asserts warning' do
|
96
102
|
@xcprofiler.report(product_name)
|
97
|
-
expect(@dangerfile).to have_received(:
|
98
|
-
.with('[Source.swift] `doSomething()` takes 50.0 ms to build', {})
|
103
|
+
expect(@dangerfile).to have_received(:markdown).with(message, {})
|
99
104
|
end
|
100
105
|
end
|
101
106
|
|
102
107
|
context 'with very slow execution' do
|
108
|
+
message = "### Xcprofiler found issues\n\n"
|
109
|
+
message << "#### Errors\n\n"
|
110
|
+
message << "| File | Line | Method Name | Build Time (ms) |\n"
|
111
|
+
message << "| ---- | ---- | ----------- | --------------- |\n"
|
112
|
+
message << "| Source.swift | 20 | doSomething() | 100.0 |\n"
|
103
113
|
it 'asserts failure' do
|
104
114
|
@xcprofiler.report(product_name)
|
105
|
-
expect(@dangerfile).to have_received(:
|
106
|
-
.with('[Source.swift] `doSomething()` takes 100.0 ms to build', {})
|
115
|
+
expect(@dangerfile).to have_received(:markdown).with(message, {})
|
107
116
|
end
|
108
117
|
end
|
109
118
|
end
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- giginet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xcprofiler
|