danger-compose_compiler_metrics 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8b9f0973e51bb4416bad39bb523c7d0b9e81828aa750c435fbdfe2b471857a48
|
4
|
+
data.tar.gz: cffa918441edcfa7bbd58e0d994a508c32abb22679194af550836e5edd5cb294
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c171857c7292b8b335c143721da0bc3cf8b38dd28de677b33bf210d49346908ebde5ae5e073151c7c47f1016d5d79f34c799aa1a077ee476312033a2d2b08862
|
7
|
+
data.tar.gz: 2b4451fb0c7150296ab5c71ead7711584816412349afc8195631016121a2c2cab87bc6eb423b3ee8f681a19d3064492420f13a91578888cff648059ae4ff6ddc
|
data/Gemfile.lock
CHANGED
@@ -33,9 +33,11 @@ module Helper
|
|
33
33
|
end.join("\n")
|
34
34
|
end
|
35
35
|
|
36
|
-
def folding(summary, details)
|
36
|
+
def folding(summary, details, open)
|
37
|
+
open_attribute = open == :open ? "open" : ""
|
38
|
+
|
37
39
|
<<~HTML
|
38
|
-
<details>
|
40
|
+
<details #{open_attribute}>
|
39
41
|
<summary>
|
40
42
|
|
41
43
|
#{summary}
|
@@ -10,7 +10,7 @@ module Danger
|
|
10
10
|
class DangerComposeCompilerMetrics < Plugin
|
11
11
|
include Helper
|
12
12
|
|
13
|
-
def report_difference(metrics_dir, reference_metrics_dir)
|
13
|
+
def report_difference(metrics_dir, reference_metrics_dir, options = {})
|
14
14
|
unless installed?("diff")
|
15
15
|
failure "diff command not found. Please install diff command."
|
16
16
|
return
|
@@ -24,27 +24,30 @@ module Danger
|
|
24
24
|
metrics_path = File.join(metrics_dir, metrics_filename(module_name, build_variant))
|
25
25
|
reference_metrics_path = File.join(reference_metrics_dir, metrics_filename(module_name, build_variant))
|
26
26
|
|
27
|
-
report_metrics_report("Metrics Summary", metrics_path, reference_metrics_path)
|
28
|
-
report_file_difference("Metrics", metrics_path, reference_metrics_path)
|
27
|
+
report_metrics_report("Metrics Summary", metrics_path, reference_metrics_path, options[:metrics_summary])
|
28
|
+
report_file_difference("Metrics", metrics_path, reference_metrics_path, options[:metrics])
|
29
29
|
|
30
30
|
# Composable Stats Report
|
31
31
|
composable_stats_report_path = File.join(metrics_dir, composable_stats_report_path(module_name, build_variant))
|
32
32
|
reference_composable_stats_report_path = File.join(reference_metrics_dir, composable_stats_report_path(module_name, build_variant))
|
33
|
-
report_file_difference("Composable Stats Report", composable_stats_report_path, reference_composable_stats_report_path)
|
33
|
+
report_file_difference("Composable Stats Report", composable_stats_report_path, reference_composable_stats_report_path, options[:composable_stats])
|
34
34
|
|
35
35
|
# Composable Report
|
36
36
|
composable_report_path = File.join(metrics_dir, composable_report_path(module_name, build_variant))
|
37
37
|
reference_composable_report_path = File.join(reference_metrics_dir, composable_report_path(module_name, build_variant))
|
38
|
-
report_file_difference("Composable Report", composable_report_path, reference_composable_report_path)
|
38
|
+
report_file_difference("Composable Report", composable_report_path, reference_composable_report_path, options[:composable_report])
|
39
39
|
|
40
40
|
# Class Report
|
41
41
|
class_report_path = File.join(metrics_dir, class_report_path(module_name, build_variant))
|
42
42
|
reference_class_report_path = File.join(reference_metrics_dir, class_report_path(module_name, build_variant))
|
43
|
-
report_file_difference("Class Report", class_report_path, reference_class_report_path)
|
43
|
+
report_file_difference("Class Report", class_report_path, reference_class_report_path, options[:class_report])
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def report_metrics_report(title, metrics_path, reference_metrics_path)
|
47
|
+
def report_metrics_report(title, metrics_path, reference_metrics_path, open)
|
48
|
+
open ||= :close
|
49
|
+
return if open == :disabled
|
50
|
+
|
48
51
|
unless File.exist?(metrics_path)
|
49
52
|
warn "DangerComposeCompilerMetrics: new file not found at #{metrics_path}. Skipping file difference report."
|
50
53
|
return
|
@@ -85,12 +88,16 @@ module Danger
|
|
85
88
|
markdown(
|
86
89
|
folding(
|
87
90
|
"### #{title}",
|
88
|
-
tables.join("\n\n")
|
91
|
+
tables.join("\n\n"),
|
92
|
+
open
|
89
93
|
)
|
90
94
|
)
|
91
95
|
end
|
92
96
|
|
93
|
-
def report_file_difference(title, metrics_path, reference_metrics_path)
|
97
|
+
def report_file_difference(title, metrics_path, reference_metrics_path, open)
|
98
|
+
open ||= :close
|
99
|
+
return if open == :disabled
|
100
|
+
|
94
101
|
unless File.exist?(metrics_path)
|
95
102
|
warn "DangerComposeCompilerMetrics: new file not found at #{metrics_path}. Skipping file difference report."
|
96
103
|
return
|
@@ -114,12 +121,13 @@ module Danger
|
|
114
121
|
#{report}
|
115
122
|
```
|
116
123
|
MARKDOWN
|
117
|
-
end
|
124
|
+
end,
|
125
|
+
open
|
118
126
|
)
|
119
127
|
)
|
120
128
|
end
|
121
129
|
|
122
|
-
def report(metrics_dir)
|
130
|
+
def report(metrics_dir, options = {})
|
123
131
|
markdown("# Compose Compiler Metrics Report")
|
124
132
|
build_variants(metrics_dir).each do |module_name, build_variant|
|
125
133
|
markdown("## #{module_name} - #{build_variant}")
|
@@ -128,51 +136,49 @@ module Danger
|
|
128
136
|
metrics_path = File.join(metrics_dir, metrics_filename(module_name, build_variant))
|
129
137
|
table_headers = %w(name value)
|
130
138
|
table_rows = JSON.load_file(metrics_path).to_a
|
131
|
-
|
132
|
-
markdown(
|
133
|
-
folding(
|
134
|
-
"### Metrics",
|
135
|
-
build_markdown_table(table_headers, table_rows)
|
136
|
-
)
|
137
|
-
)
|
139
|
+
report_table("Metrics", table_headers, table_rows, options[:metrics])
|
138
140
|
|
139
141
|
# Composable Stats Report
|
140
142
|
composable_stats_report_path = File.join(metrics_dir, composable_stats_report_path(module_name, build_variant))
|
141
143
|
csv = CSV.read(composable_stats_report_path, headers: true)
|
142
|
-
|
143
|
-
markdown(
|
144
|
-
folding(
|
145
|
-
"### Composable Stats Report",
|
146
|
-
build_markdown_table(csv.headers, csv.map(&:fields))
|
147
|
-
)
|
148
|
-
)
|
144
|
+
report_table("Composable Stats Report", csv.headers, csv.map(&:fields), options[:composable_stats])
|
149
145
|
|
150
146
|
# Composable Report
|
151
147
|
composable_report_path = File.join(metrics_dir, composable_report_path(module_name, build_variant))
|
152
|
-
|
153
|
-
folding(
|
154
|
-
"### Composable Report",
|
155
|
-
<<~MARKDOWN
|
156
|
-
```kotlin
|
157
|
-
#{File.read(composable_report_path)}
|
158
|
-
```
|
159
|
-
MARKDOWN
|
160
|
-
)
|
161
|
-
)
|
148
|
+
report_code_block("Composable Report", "kotlin", File.read(composable_report_path), options[:composable_report])
|
162
149
|
|
163
150
|
# Class Report
|
164
151
|
class_report_path = File.join(metrics_dir, class_report_path(module_name, build_variant))
|
165
|
-
|
166
|
-
folding(
|
167
|
-
"### Class Report",
|
168
|
-
<<~MARKDOWN
|
169
|
-
```kotlin
|
170
|
-
#{File.read(class_report_path)}
|
171
|
-
```
|
172
|
-
MARKDOWN
|
173
|
-
)
|
174
|
-
)
|
152
|
+
report_code_block("Class Report", "kotlin", File.read(class_report_path), options[:class_report])
|
175
153
|
end
|
176
154
|
end
|
155
|
+
|
156
|
+
def report_table(title, headers, rows, open)
|
157
|
+
return if open == :disabled
|
158
|
+
|
159
|
+
markdown(
|
160
|
+
folding(
|
161
|
+
"### #{title}",
|
162
|
+
build_markdown_table(headers, rows),
|
163
|
+
open
|
164
|
+
)
|
165
|
+
)
|
166
|
+
end
|
167
|
+
|
168
|
+
def report_code_block(title, language, code, open)
|
169
|
+
return if open == :disabled
|
170
|
+
|
171
|
+
markdown(
|
172
|
+
folding(
|
173
|
+
"### #{title}",
|
174
|
+
<<~MARKDOWN,
|
175
|
+
```#{language}
|
176
|
+
#{code}
|
177
|
+
```
|
178
|
+
MARKDOWN
|
179
|
+
open
|
180
|
+
)
|
181
|
+
)
|
182
|
+
end
|
177
183
|
end
|
178
184
|
end
|
@@ -13,11 +13,12 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe "#report_difference" do
|
16
|
-
subject { plugin.report_difference(metrics_path, reference_metrics_path) }
|
16
|
+
subject { plugin.report_difference(metrics_path, reference_metrics_path, options) }
|
17
17
|
|
18
18
|
let(:file_timestamp) { Time.new(2024, 1, 1, 0, 0, 0) }
|
19
19
|
let(:metrics_path) { "#{File.dirname(__FILE__)}/support/fixtures/compose_compiler_metrics" }
|
20
20
|
let(:reference_metrics_path) { "#{File.dirname(__FILE__)}/support/fixtures/compose_compiler_metrics_baseline" }
|
21
|
+
let(:options) { {} }
|
21
22
|
|
22
23
|
before do
|
23
24
|
[
|
@@ -35,7 +36,7 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
35
36
|
"# Compose Compiler Metrics Difference Report",
|
36
37
|
"## app - debug",
|
37
38
|
<<~MARKDOWN,
|
38
|
-
<details>
|
39
|
+
<details >
|
39
40
|
<summary>
|
40
41
|
|
41
42
|
### Metrics Summary
|
@@ -95,7 +96,7 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
95
96
|
</details>
|
96
97
|
MARKDOWN
|
97
98
|
<<~MARKDOWN,
|
98
|
-
<details>
|
99
|
+
<details >
|
99
100
|
<summary>
|
100
101
|
|
101
102
|
### Metrics
|
@@ -153,7 +154,7 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
153
154
|
</details>
|
154
155
|
MARKDOWN
|
155
156
|
<<~MARKDOWN,
|
156
|
-
<details>
|
157
|
+
<details >
|
157
158
|
<summary>
|
158
159
|
|
159
160
|
### Composable Stats Report
|
@@ -178,7 +179,7 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
178
179
|
</details>
|
179
180
|
MARKDOWN
|
180
181
|
<<~MARKDOWN,
|
181
|
-
<details>
|
182
|
+
<details >
|
182
183
|
<summary>
|
183
184
|
|
184
185
|
### Composable Report
|
@@ -216,7 +217,7 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
216
217
|
</details>
|
217
218
|
MARKDOWN
|
218
219
|
<<~MARKDOWN
|
219
|
-
<details>
|
220
|
+
<details >
|
220
221
|
<summary>
|
221
222
|
|
222
223
|
### Class Report
|
@@ -290,18 +291,45 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
290
291
|
)
|
291
292
|
end
|
292
293
|
end
|
294
|
+
|
295
|
+
context "when metrics option is disabled" do
|
296
|
+
let(:options) { { metrics: :disabled } }
|
297
|
+
|
298
|
+
it do
|
299
|
+
within_block_is_expected.to change {
|
300
|
+
dangerfile.status_report[:markdowns].map(&:message)
|
301
|
+
}.from(
|
302
|
+
be_empty
|
303
|
+
).to(
|
304
|
+
expect_report_list.reject.with_index { |_, i| i == 3 }
|
305
|
+
)
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
context "when metrics option is open" do
|
310
|
+
let(:options) { { metrics: :open } }
|
311
|
+
|
312
|
+
it do
|
313
|
+
subject
|
314
|
+
|
315
|
+
expect(dangerfile.status_report[:markdowns][3].message).to eq(
|
316
|
+
expect_report_list[3].gsub("<details >", "<details open>")
|
317
|
+
)
|
318
|
+
end
|
319
|
+
end
|
293
320
|
end
|
294
321
|
|
295
322
|
describe "#report" do
|
296
|
-
subject { plugin.report(metrics_path) }
|
323
|
+
subject { plugin.report(metrics_path, options) }
|
297
324
|
|
298
325
|
let(:metrics_path) { "#{File.dirname(__FILE__)}/support/fixtures/compose_compiler_metrics" }
|
326
|
+
let(:options) { {} }
|
299
327
|
let(:expect_report_list) do
|
300
328
|
[
|
301
329
|
"# Compose Compiler Metrics Report",
|
302
330
|
"## app - debug",
|
303
331
|
<<~MARKDOWN,
|
304
|
-
<details>
|
332
|
+
<details >
|
305
333
|
<summary>
|
306
334
|
|
307
335
|
### Metrics
|
@@ -337,7 +365,7 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
337
365
|
</details>
|
338
366
|
MARKDOWN
|
339
367
|
<<~MARKDOWN,
|
340
|
-
<details>
|
368
|
+
<details >
|
341
369
|
<summary>
|
342
370
|
|
343
371
|
### Composable Stats Report
|
@@ -353,7 +381,7 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
353
381
|
</details>
|
354
382
|
MARKDOWN
|
355
383
|
<<~MARKDOWN,
|
356
|
-
<details>
|
384
|
+
<details >
|
357
385
|
<summary>
|
358
386
|
|
359
387
|
### Composable Report
|
@@ -379,7 +407,7 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
379
407
|
</details>
|
380
408
|
MARKDOWN
|
381
409
|
<<~MARKDOWN
|
382
|
-
<details>
|
410
|
+
<details >
|
383
411
|
<summary>
|
384
412
|
|
385
413
|
### Class Report
|
@@ -404,11 +432,39 @@ describe Danger::DangerComposeCompilerMetrics do
|
|
404
432
|
]
|
405
433
|
end
|
406
434
|
|
407
|
-
it
|
408
|
-
|
435
|
+
it do
|
436
|
+
within_block_is_expected.to change {
|
437
|
+
dangerfile.status_report[:markdowns].map(&:message)
|
438
|
+
}.from(
|
439
|
+
be_empty
|
440
|
+
).to(
|
441
|
+
expect_report_list
|
442
|
+
)
|
443
|
+
end
|
409
444
|
|
410
|
-
|
411
|
-
|
445
|
+
context "when metrics option is disabled" do
|
446
|
+
let(:options) { { metrics: :disabled } }
|
447
|
+
|
448
|
+
it do
|
449
|
+
within_block_is_expected.to change {
|
450
|
+
dangerfile.status_report[:markdowns].map(&:message)
|
451
|
+
}.from(
|
452
|
+
be_empty
|
453
|
+
).to(
|
454
|
+
expect_report_list.reject.with_index { |_, i| i == 2 }
|
455
|
+
)
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
context "when metrics option is open" do
|
460
|
+
let(:options) { { metrics: :open } }
|
461
|
+
|
462
|
+
it do
|
463
|
+
subject
|
464
|
+
|
465
|
+
expect(dangerfile.status_report[:markdowns][2].message).to eq(
|
466
|
+
expect_report_list[2].gsub("<details >", "<details open>")
|
467
|
+
)
|
412
468
|
end
|
413
469
|
end
|
414
470
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: danger-compose_compiler_metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomoki Yamashita
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: csv
|