danger-compose_compiler_metrics 0.0.1 → 0.0.2

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: 0a4e4fdbd974ca9e26bf31a9d9d458a24701fba13e2cf50294ae0787573931f4
4
- data.tar.gz: 88b1ab8dacfa22cb954b930ffa589e8a3066e949d66c2275f93391a1bf829b44
3
+ metadata.gz: 5174bc2092a2c48fa3a84c6cb7006b0836fc9ccdc55f647efad88cc3fbd52e65
4
+ data.tar.gz: de4c9958f624409b65e36aa49d5b001de6f474e79c43afe51a42011f1150ac91
5
5
  SHA512:
6
- metadata.gz: bba795ff85c82cd20464458c407375dfbeeca2bcdc0f42b54cdf1842d3fb6b60507ff24e8b1ae796d753a83eab882b90d7f5e742bddd3d65187675099484c63f
7
- data.tar.gz: 53b535436b8654a60e2cbb43a42fa4aec95bae0a8cf684627e6ef40b8a063b14145e18d1560b22ef05e350efa99291a4af2d9e0f5bfb14ba7a5f4d050d00e9e3
6
+ metadata.gz: 4543a2ecc312efe6d7357acaf70e19bf84d4f2938cc525b9c33db740f04aee929acc7c2cdd17a98c5cb112bb3d3595654ac92498d3bf5de665e246608ea7e3b3
7
+ data.tar.gz: 77d0f263a40a8286b3b36cc6a3dc2bf6b3dff3370e91717d5bdefd4ed824ddecb067c8f14a9c70c1e8d000a35867817e66895f16701d9f653cef050f86fb251b
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ComposeCompilerMetrics
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
@@ -45,4 +45,8 @@ module Helper
45
45
  </details>
46
46
  HTML
47
47
  end
48
+
49
+ def installed?(command)
50
+ system("which #{command} > /dev/null")
51
+ end
48
52
  end
@@ -10,89 +10,64 @@ module Danger
10
10
  include Helper
11
11
 
12
12
  def report_difference(metrics_dir, base_metrics_dir)
13
- markdown('# Compose Compiler Metrics Difference Report')
13
+ unless installed?("diff")
14
+ error "diff command not found. Please install diff command."
15
+ return
16
+ end
17
+
18
+ markdown("# Compose Compiler Metrics Difference Report")
14
19
  build_variants(metrics_dir).each do |module_name, build_variant|
15
20
  markdown("## #{module_name} - #{build_variant}")
16
21
 
17
22
  # Metrics Report
18
23
  metrics_path = File.join(metrics_dir, metrics_filename(module_name, build_variant))
19
24
  base_metrics_path = File.join(base_metrics_dir, metrics_filename(module_name, build_variant))
20
- report = `diff -u #{base_metrics_path} #{metrics_path}`
21
-
22
- markdown(
23
- folding(
24
- '### Metrics',
25
- if report.empty?
26
- 'No difference found.'
27
- else
28
- <<~MARKDOWN
29
- ```diff
30
- #{report}
31
- ```
32
- MARKDOWN
33
- end
34
- )
35
- )
25
+ report_file_difference("Metrics", metrics_path, base_metrics_path)
36
26
 
37
27
  # Composable Stats Report
38
28
  composable_stats_report_path = File.join(metrics_dir, composable_stats_report_path(module_name, build_variant))
39
29
  base_composable_stats_report_path = File.join(base_metrics_dir, composable_stats_report_path(module_name, build_variant))
40
- report = `diff -u #{base_composable_stats_report_path} #{composable_stats_report_path}`
41
-
42
- markdown(
43
- folding(
44
- '### Composable Stats Report',
45
- if report.empty?
46
- 'No difference found.'
47
- else
48
- <<~MARKDOWN
49
- ```diff
50
- #{report}
51
- ```
52
- MARKDOWN
53
- end
54
- )
55
- )
30
+ report_file_difference("Composable Stats Report", composable_stats_report_path, base_composable_stats_report_path)
56
31
 
57
32
  # Composable Report
58
33
  composable_report_path = File.join(metrics_dir, composable_report_path(module_name, build_variant))
59
34
  base_composable_report_path = File.join(base_metrics_dir, composable_report_path(module_name, build_variant))
60
- report = `diff -u #{base_composable_report_path} #{composable_report_path}`
61
-
62
- markdown(
63
- folding(
64
- '### Composable Report',
65
- if report.empty?
66
- 'No difference found.'
67
- else
68
- <<~MARKDOWN
69
- ```diff
70
- #{report}
71
- ```
72
- MARKDOWN
73
- end
74
- )
75
- )
35
+ report_file_difference("Composable Report", composable_report_path, base_composable_report_path)
76
36
 
77
37
  # Class Report
78
38
  class_report_path = File.join(metrics_dir, class_report_path(module_name, build_variant))
79
39
  base_class_report_path = File.join(base_metrics_dir, class_report_path(module_name, build_variant))
80
- report = `diff -u #{base_class_report_path} #{class_report_path}`
81
- markdown(
82
- folding(
83
- '### Class Report',
84
- if report.empty?
85
- 'No difference found.'
86
- else
87
- <<~MARKDOWN
88
- ```diff
89
- #{report}
90
- ```
91
- MARKDOWN
92
- end
93
- )
94
- )
40
+ report_file_difference("Composable Report", class_report_path, base_class_report_path)
41
+ end
42
+ end
43
+
44
+ def report_file_difference(title, metrics_path, base_metrics_path)
45
+ unless File.exist?(metrics_path)
46
+ warn "DangerComposeCompilerMetrics: new file not found at #{metrics_path}. Skipping file difference report."
47
+ return
48
+ end
49
+
50
+ unless File.exist?(base_metrics_path)
51
+ warn "DangerComposeCompilerMetrics: reference file not found at #{base_metrics_path}. Skipping file difference report."
52
+ return
95
53
  end
54
+
55
+ report = `diff -u #{base_metrics_path} #{metrics_path}`
56
+
57
+ markdown(
58
+ folding(
59
+ "### #{title}",
60
+ if report.empty?
61
+ "No difference found."
62
+ else
63
+ <<~MARKDOWN
64
+ ```diff
65
+ #{report}
66
+ ```
67
+ MARKDOWN
68
+ end
69
+ )
70
+ )
96
71
  end
97
72
 
98
73
  def report(metrics_dir)
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.1
4
+ version: 0.0.2
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-02-08 00:00:00.000000000 Z
11
+ date: 2024-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: danger-plugin-api