danger-compose_compiler_metrics 0.0.1

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
+ SHA256:
3
+ metadata.gz: 0a4e4fdbd974ca9e26bf31a9d9d458a24701fba13e2cf50294ae0787573931f4
4
+ data.tar.gz: 88b1ab8dacfa22cb954b930ffa589e8a3066e949d66c2275f93391a1bf829b44
5
+ SHA512:
6
+ metadata.gz: bba795ff85c82cd20464458c407375dfbeeca2bcdc0f42b54cdf1842d3fb6b60507ff24e8b1ae796d753a83eab882b90d7f5e742bddd3d65187675099484c63f
7
+ data.tar.gz: 53b535436b8654a60e2cbb43a42fa4aec95bae0a8cf684627e6ef40b8a063b14145e18d1560b22ef05e350efa99291a4af2d9e0f5bfb14ba7a5f4d050d00e9e3
data/.gitignore ADDED
@@ -0,0 +1,125 @@
1
+ ### Generated by gibo (https://github.com/simonwhitaker/gibo)
2
+ ### https://raw.github.com/github/gitignore/4488915eec0b3a45b5c63ead28f286819c0917de/Global/macOS.gitignore
3
+
4
+ # General
5
+ .DS_Store
6
+ .AppleDouble
7
+ .LSOverride
8
+
9
+ # Icon must end with two \r
10
+ Icon
11
+
12
+ # Thumbnails
13
+ ._*
14
+
15
+ # Files that might appear in the root of a volume
16
+ .DocumentRevisions-V100
17
+ .fseventsd
18
+ .Spotlight-V100
19
+ .TemporaryItems
20
+ .Trashes
21
+ .VolumeIcon.icns
22
+ .com.apple.timemachine.donotpresent
23
+
24
+ # Directories potentially created on remote AFP share
25
+ .AppleDB
26
+ .AppleDesktop
27
+ Network Trash Folder
28
+ Temporary Items
29
+ .apdisk
30
+ ### Generated by gibo (https://github.com/simonwhitaker/gibo)
31
+ ### https://raw.github.com/github/gitignore/4488915eec0b3a45b5c63ead28f286819c0917de/Ruby.gitignore
32
+
33
+ *.gem
34
+ *.rbc
35
+ /.config
36
+ /coverage/
37
+ /InstalledFiles
38
+ /pkg/
39
+ /spec/reports/
40
+ /spec/examples.txt
41
+ /test/tmp/
42
+ /test/version_tmp/
43
+ /tmp/
44
+
45
+ # Used by dotenv library to load environment variables.
46
+ # .env
47
+
48
+ # Ignore Byebug command history file.
49
+ .byebug_history
50
+
51
+ ## Specific to RubyMotion:
52
+ .dat*
53
+ .repl_history
54
+ build/
55
+ *.bridgesupport
56
+ build-iPhoneOS/
57
+ build-iPhoneSimulator/
58
+
59
+ ## Specific to RubyMotion (use of CocoaPods):
60
+ #
61
+ # We recommend against adding the Pods directory to your .gitignore. However
62
+ # you should judge for yourself, the pros and cons are mentioned at:
63
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
64
+ #
65
+ # vendor/Pods/
66
+
67
+ ## Documentation cache and generated files:
68
+ /.yardoc/
69
+ /_yardoc/
70
+ /doc/
71
+ /rdoc/
72
+
73
+ ## Environment normalization:
74
+ /.bundle/
75
+ /vendor/bundle
76
+ /lib/bundler/man/
77
+
78
+ # for a library or gem, you might want to ignore these files since the code is
79
+ # intended to run in multiple environments; otherwise, check them in:
80
+ # Gemfile.lock
81
+ # .ruby-version
82
+ # .ruby-gemset
83
+
84
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
85
+ .rvmrc
86
+
87
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
88
+ # .rubocop-https?--*
89
+ ### Generated by gibo (https://github.com/simonwhitaker/gibo)
90
+ ### https://raw.github.com/github/gitignore/4488915eec0b3a45b5c63ead28f286819c0917de/Global/VisualStudioCode.gitignore
91
+
92
+ .vscode/*
93
+ !.vscode/settings.json
94
+ !.vscode/tasks.json
95
+ !.vscode/launch.json
96
+ !.vscode/extensions.json
97
+ !.vscode/*.code-snippets
98
+
99
+ # Local History for Visual Studio Code
100
+ .history/
101
+
102
+ # Built Visual Studio Code Extensions
103
+ *.vsix
104
+ ### Generated by gibo (https://github.com/simonwhitaker/gibo)
105
+ ### https://raw.github.com/github/gitignore/4488915eec0b3a45b5c63ead28f286819c0917de/Global/Vim.gitignore
106
+
107
+ # Swap
108
+ [._]*.s[a-v][a-z]
109
+ !*.svg # comment out if you don't need vector files
110
+ [._]*.sw[a-p]
111
+ [._]s[a-rt-v][a-z]
112
+ [._]ss[a-gi-z]
113
+ [._]sw[a-p]
114
+
115
+ # Session
116
+ Session.vim
117
+ Sessionx.vim
118
+
119
+ # Temporary
120
+ .netrwhist
121
+ *~
122
+ # Auto-generated tag files
123
+ tags
124
+ # Persistent undo
125
+ [._]*.un~
data/.rubocop.yml ADDED
@@ -0,0 +1,148 @@
1
+ # Defaults can be found here: https://github.com/bbatsov/rubocop/blob/master/config/default.yml
2
+
3
+ # If you don't like these settings, just delete this file :)
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.7
7
+
8
+ Style/StringLiterals:
9
+ EnforcedStyle: double_quotes
10
+ Enabled: true
11
+
12
+ # kind_of? is a good way to check a type
13
+ Style/ClassCheck:
14
+ EnforcedStyle: kind_of?
15
+
16
+ # specs sometimes have useless assignments, which is fine
17
+ Lint/UselessAssignment:
18
+ Exclude:
19
+ - '**/spec/**/*'
20
+
21
+ # We could potentially enable the 2 below:
22
+ Layout/FirstHashElementIndentation:
23
+ Enabled: false
24
+
25
+ Layout/HashAlignment:
26
+ Enabled: false
27
+
28
+ # HoundCI doesn't like this rule
29
+ Layout/DotPosition:
30
+ Enabled: false
31
+
32
+ # We allow !! as it's an easy way to convert ot boolean
33
+ Style/DoubleNegation:
34
+ Enabled: false
35
+
36
+ # Cop supports --auto-correct.
37
+ Lint/UnusedBlockArgument:
38
+ Enabled: false
39
+
40
+ # We want to allow class Fastlane::Class
41
+ Style/ClassAndModuleChildren:
42
+ Enabled: false
43
+
44
+ Metrics/AbcSize:
45
+ Max: 60
46
+
47
+ # The %w might be confusing for new users
48
+ Style/WordArray:
49
+ MinSize: 19
50
+
51
+ # raise and fail are both okay
52
+ Style/SignalException:
53
+ Enabled: false
54
+
55
+ # Better too much 'return' than one missing
56
+ Style/RedundantReturn:
57
+ Enabled: false
58
+
59
+ # Having if in the same line might not always be good
60
+ Style/IfUnlessModifier:
61
+ Enabled: false
62
+
63
+ # and and or is okay
64
+ Style/AndOr:
65
+ Enabled: false
66
+
67
+ # Configuration parameters: CountComments.
68
+ Metrics/ClassLength:
69
+ Max: 350
70
+
71
+ Metrics/CyclomaticComplexity:
72
+ Max: 17
73
+
74
+ # Configuration parameters: AllowURI, URISchemes.
75
+ Layout/LineLength:
76
+ Max: 370
77
+
78
+ # Configuration parameters: CountKeywordArgs.
79
+ Metrics/ParameterLists:
80
+ Max: 10
81
+
82
+ Metrics/PerceivedComplexity:
83
+ Max: 18
84
+
85
+ # Sometimes it's easier to read without guards
86
+ Style/GuardClause:
87
+ Enabled: false
88
+
89
+ # something = if something_else
90
+ # that's confusing
91
+ Style/ConditionalAssignment:
92
+ Enabled: false
93
+
94
+ # Better to have too much self than missing a self
95
+ Style/RedundantSelf:
96
+ Enabled: false
97
+
98
+ Metrics/MethodLength:
99
+ Max: 60
100
+
101
+ # We're not there yet
102
+ Style/Documentation:
103
+ Enabled: false
104
+
105
+ # Adds complexity
106
+ Style/IfInsideElse:
107
+ Enabled: false
108
+
109
+ # danger specific
110
+
111
+ Style/BlockComments:
112
+ Enabled: false
113
+
114
+ Layout/MultilineMethodCallIndentation:
115
+ EnforcedStyle: indented
116
+
117
+ # FIXME: 25
118
+ Metrics/BlockLength:
119
+ Max: 345
120
+ Exclude:
121
+ - "**/*_spec.rb"
122
+
123
+ Style/MixinGrouping:
124
+ Enabled: false
125
+
126
+ Naming/FileName:
127
+ Enabled: false
128
+
129
+ Layout/HeredocIndentation:
130
+ Enabled: false
131
+
132
+ Style/SpecialGlobalVars:
133
+ Enabled: false
134
+
135
+ Style/PercentLiteralDelimiters:
136
+ PreferredDelimiters:
137
+ "%": ()
138
+ "%i": ()
139
+ "%q": ()
140
+ "%Q": ()
141
+ "%r": "{}"
142
+ "%s": ()
143
+ "%w": ()
144
+ "%W": ()
145
+ "%x": ()
146
+
147
+ Security/YAMLLoad:
148
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ cache:
3
+ directories:
4
+ - bundle
5
+
6
+ rvm:
7
+ - 2.7
8
+
9
+ script:
10
+ - bundle exec rake spec
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in danger-compose_compiler_metrics.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,163 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ danger-compose_compiler_metrics (0.0.1)
5
+ csv
6
+ danger-plugin-api (~> 1.0)
7
+ json
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.8.6)
13
+ public_suffix (>= 2.0.2, < 6.0)
14
+ ast (2.4.2)
15
+ base64 (0.2.0)
16
+ claide (1.1.0)
17
+ claide-plugins (0.9.2)
18
+ cork
19
+ nap
20
+ open4 (~> 1.3)
21
+ coderay (1.1.3)
22
+ colored2 (3.1.2)
23
+ cork (0.3.0)
24
+ colored2 (~> 3.1)
25
+ csv (3.2.8)
26
+ danger (9.4.3)
27
+ claide (~> 1.0)
28
+ claide-plugins (>= 0.9.2)
29
+ colored2 (~> 3.1)
30
+ cork (~> 0.1)
31
+ faraday (>= 0.9.0, < 3.0)
32
+ faraday-http-cache (~> 2.0)
33
+ git (~> 1.13)
34
+ kramdown (~> 2.3)
35
+ kramdown-parser-gfm (~> 1.0)
36
+ no_proxy_fix
37
+ octokit (>= 4.0)
38
+ terminal-table (>= 1, < 4)
39
+ danger-plugin-api (1.0.0)
40
+ danger (> 2.0)
41
+ diff-lcs (1.5.1)
42
+ faraday (2.9.0)
43
+ faraday-net_http (>= 2.0, < 3.2)
44
+ faraday-http-cache (2.5.1)
45
+ faraday (>= 0.8)
46
+ faraday-net_http (3.1.0)
47
+ net-http
48
+ ffi (1.16.3)
49
+ formatador (1.1.0)
50
+ git (1.19.1)
51
+ addressable (~> 2.8)
52
+ rchardet (~> 1.8)
53
+ guard (2.18.1)
54
+ formatador (>= 0.2.4)
55
+ listen (>= 2.7, < 4.0)
56
+ lumberjack (>= 1.0.12, < 2.0)
57
+ nenv (~> 0.1)
58
+ notiffany (~> 0.0)
59
+ pry (>= 0.13.0)
60
+ shellany (~> 0.0)
61
+ thor (>= 0.18.1)
62
+ guard-compat (1.2.1)
63
+ guard-rspec (4.7.3)
64
+ guard (~> 2.1)
65
+ guard-compat (~> 1.1)
66
+ rspec (>= 2.99.0, < 4.0)
67
+ json (2.7.1)
68
+ kramdown (2.4.0)
69
+ rexml
70
+ kramdown-parser-gfm (1.1.0)
71
+ kramdown (~> 2.0)
72
+ language_server-protocol (3.17.0.3)
73
+ listen (3.0.7)
74
+ rb-fsevent (>= 0.9.3)
75
+ rb-inotify (>= 0.9.7)
76
+ lumberjack (1.2.10)
77
+ method_source (1.0.0)
78
+ nap (1.1.0)
79
+ nenv (0.3.0)
80
+ net-http (0.4.1)
81
+ uri
82
+ no_proxy_fix (0.1.2)
83
+ notiffany (0.1.3)
84
+ nenv (~> 0.1)
85
+ shellany (~> 0.0)
86
+ octokit (8.1.0)
87
+ base64
88
+ faraday (>= 1, < 3)
89
+ sawyer (~> 0.9)
90
+ open4 (1.3.4)
91
+ parallel (1.24.0)
92
+ parser (3.3.0.5)
93
+ ast (~> 2.4.1)
94
+ racc
95
+ pry (0.14.2)
96
+ coderay (~> 1.1)
97
+ method_source (~> 1.0)
98
+ public_suffix (5.0.4)
99
+ racc (1.7.3)
100
+ rainbow (3.1.1)
101
+ rake (10.5.0)
102
+ rb-fsevent (0.11.2)
103
+ rb-inotify (0.10.1)
104
+ ffi (~> 1.0)
105
+ rchardet (1.8.0)
106
+ regexp_parser (2.9.0)
107
+ rexml (3.2.6)
108
+ rspec (3.13.0)
109
+ rspec-core (~> 3.13.0)
110
+ rspec-expectations (~> 3.13.0)
111
+ rspec-mocks (~> 3.13.0)
112
+ rspec-core (3.13.0)
113
+ rspec-support (~> 3.13.0)
114
+ rspec-expectations (3.13.0)
115
+ diff-lcs (>= 1.2.0, < 2.0)
116
+ rspec-support (~> 3.13.0)
117
+ rspec-mocks (3.13.0)
118
+ diff-lcs (>= 1.2.0, < 2.0)
119
+ rspec-support (~> 3.13.0)
120
+ rspec-support (3.13.0)
121
+ rubocop (1.60.2)
122
+ json (~> 2.3)
123
+ language_server-protocol (>= 3.17.0)
124
+ parallel (~> 1.10)
125
+ parser (>= 3.3.0.2)
126
+ rainbow (>= 2.2.2, < 4.0)
127
+ regexp_parser (>= 1.8, < 3.0)
128
+ rexml (>= 3.2.5, < 4.0)
129
+ rubocop-ast (>= 1.30.0, < 2.0)
130
+ ruby-progressbar (~> 1.7)
131
+ unicode-display_width (>= 2.4.0, < 3.0)
132
+ rubocop-ast (1.30.0)
133
+ parser (>= 3.2.1.0)
134
+ ruby-progressbar (1.13.0)
135
+ sawyer (0.9.2)
136
+ addressable (>= 2.3.5)
137
+ faraday (>= 0.17.3, < 3)
138
+ shellany (0.0.1)
139
+ terminal-table (3.0.2)
140
+ unicode-display_width (>= 1.1.1, < 3)
141
+ thor (1.3.0)
142
+ unicode-display_width (2.5.0)
143
+ uri (0.13.0)
144
+ yard (0.9.34)
145
+
146
+ PLATFORMS
147
+ arm64-darwin-23
148
+ ruby
149
+
150
+ DEPENDENCIES
151
+ bundler (~> 2.0)
152
+ danger-compose_compiler_metrics!
153
+ guard (~> 2.14)
154
+ guard-rspec (~> 4.7)
155
+ listen (= 3.0.7)
156
+ pry
157
+ rake (~> 10.0)
158
+ rspec (~> 3.4)
159
+ rubocop
160
+ yard
161
+
162
+ BUNDLED WITH
163
+ 2.5.3
data/Guardfile ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # A guardfile for making Danger Plugins
4
+ # For more info see https://github.com/guard/guard#readme
5
+
6
+ # To run, use `bundle exec guard`.
7
+
8
+ guard :rspec, cmd: "bundle exec rspec" do
9
+ require "guard/rspec/dsl"
10
+ dsl = Guard::RSpec::Dsl.new(self)
11
+
12
+ # RSpec files
13
+ rspec = dsl.rspec
14
+ watch(rspec.spec_helper) { rspec.spec_dir }
15
+ watch(rspec.spec_support) { rspec.spec_dir }
16
+ watch(rspec.spec_files)
17
+
18
+ # Ruby files
19
+ ruby = dsl.ruby
20
+ dsl.watch_spec_files_for(ruby.lib_files)
21
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2024 Tomoki Yamashita <tomorrowkey@gmail.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,20 @@
1
+ # danger-compose_compiler_metrics
2
+
3
+ A description of danger-compose_compiler_metrics.
4
+
5
+ ## Installation
6
+
7
+ $ gem install danger-compose_compiler_metrics
8
+
9
+ ## Usage
10
+
11
+ Methods and attributes from this plugin are available in
12
+ your `Dangerfile` under the `compose_compiler_metrics` namespace.
13
+
14
+ ## Development
15
+
16
+ 1. Clone this repo
17
+ 2. Run `bundle install` to setup dependencies.
18
+ 3. Run `bundle exec rake spec` to run the tests.
19
+ 4. Use `bundle exec guard` to automatically have tests run as you make changes.
20
+ 5. Make your changes.
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "rubocop/rake_task"
6
+
7
+ RSpec::Core::RakeTask.new(:specs)
8
+
9
+ task default: :specs
10
+
11
+ task :spec do
12
+ Rake::Task["specs"].invoke
13
+ Rake::Task["rubocop"].invoke
14
+ Rake::Task["spec_docs"].invoke
15
+ end
16
+
17
+ desc "Run RuboCop on the lib/specs directory"
18
+ RuboCop::RakeTask.new(:rubocop) do |task|
19
+ task.patterns = ["lib/**/*.rb", "spec/**/*.rb"]
20
+ end
21
+
22
+ desc "Ensure that the plugin passes `danger plugins lint`"
23
+ task :spec_docs do
24
+ sh "bundle exec danger plugins lint"
25
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require "compose_compiler_metrics/gem_version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "danger-compose_compiler_metrics"
9
+ spec.version = ComposeCompilerMetrics::VERSION
10
+ spec.authors = ["Tomoki Yamashita"]
11
+ spec.email = ["tomorrowkey@gmail.com"]
12
+ spec.description = "Report compose compiler metrics"
13
+ spec.summary = "Report compose compiler metrics"
14
+ spec.homepage = "https://github.com/tomorrowkey/danger-compose_compiler_metrics"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
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
+ spec.add_runtime_dependency "json"
24
+ spec.add_runtime_dependency "csv"
25
+
26
+ # General ruby development
27
+ spec.add_development_dependency "bundler", "~> 2.0"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+
30
+ # Testing support
31
+ spec.add_development_dependency "rspec", "~> 3.4"
32
+
33
+ # Linting code and docs
34
+ spec.add_development_dependency "rubocop"
35
+ spec.add_development_dependency "yard"
36
+
37
+ # Makes testing easy via `bundle exec guard`
38
+ spec.add_development_dependency "guard", "~> 2.14"
39
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
40
+
41
+ # If you want to work on older builds of ruby
42
+ spec.add_development_dependency "listen", "3.0.7"
43
+
44
+ # This gives you the chance to run a REPL inside your tests
45
+ # via:
46
+ #
47
+ # require 'pry'
48
+ # binding.pry
49
+ #
50
+ # This will stop test execution and let you inspect the results
51
+ spec.add_development_dependency "pry"
52
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ComposeCompilerMetrics
4
+ VERSION = "0.0.1"
5
+ end
@@ -0,0 +1,48 @@
1
+ module Helper
2
+ def build_variants(dir)
3
+ Dir.glob("#{dir}/*").
4
+ map { |s| File.basename(s).split(/[_\-]/).take(2) }.
5
+ uniq
6
+ end
7
+
8
+ def metrics_filename(module_name, build_variant)
9
+ "#{module_name}_#{build_variant}-module.json"
10
+ end
11
+
12
+ def composable_stats_report_path(module_name, build_variant)
13
+ "#{module_name}_#{build_variant}-composables.csv"
14
+ end
15
+
16
+ def composable_report_path(module_name, build_variant)
17
+ "#{module_name}_#{build_variant}-composables.txt"
18
+ end
19
+
20
+ def class_report_path(module_name, build_variant)
21
+ "#{module_name}_#{build_variant}-classes.txt"
22
+ end
23
+
24
+ def build_markdown_table(headers, rows)
25
+ [].tap do |table|
26
+ table << "| #{headers.join(' | ')} |"
27
+ table << "| #{headers.map { |h| '---' }.join(' | ')} |"
28
+ rows.each do |row|
29
+ table << "| #{row.join(' | ')} |"
30
+ end
31
+ end.join("\n")
32
+ end
33
+
34
+ def folding(summary, details)
35
+ <<~HTML
36
+ <details>
37
+ <summary>
38
+
39
+ #{summary}
40
+
41
+ </summary>
42
+
43
+ #{details}
44
+
45
+ </details>
46
+ HTML
47
+ end
48
+ end
@@ -0,0 +1,154 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'csv'
5
+
6
+ require_relative './helper'
7
+
8
+ module Danger
9
+ class DangerComposeCompilerMetrics < Plugin
10
+ include Helper
11
+
12
+ def report_difference(metrics_dir, base_metrics_dir)
13
+ markdown('# Compose Compiler Metrics Difference Report')
14
+ build_variants(metrics_dir).each do |module_name, build_variant|
15
+ markdown("## #{module_name} - #{build_variant}")
16
+
17
+ # Metrics Report
18
+ metrics_path = File.join(metrics_dir, metrics_filename(module_name, build_variant))
19
+ 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
+ )
36
+
37
+ # Composable Stats Report
38
+ composable_stats_report_path = File.join(metrics_dir, composable_stats_report_path(module_name, build_variant))
39
+ 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
+ )
56
+
57
+ # Composable Report
58
+ composable_report_path = File.join(metrics_dir, composable_report_path(module_name, build_variant))
59
+ 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
+ )
76
+
77
+ # Class Report
78
+ class_report_path = File.join(metrics_dir, class_report_path(module_name, build_variant))
79
+ 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
+ )
95
+ end
96
+ end
97
+
98
+ def report(metrics_dir)
99
+ markdown('# Compose Compiler Metrics Report')
100
+ build_variants(metrics_dir).each do |module_name, build_variant|
101
+ markdown("## #{module_name} - #{build_variant}")
102
+
103
+ # Metrics Report
104
+ metrics_path = File.join(metrics_dir, metrics_filename(module_name, build_variant))
105
+ table_headers = %w[name value]
106
+ table_rows = JSON.load_file(metrics_path).to_a
107
+
108
+ markdown(
109
+ folding(
110
+ '### Metrics',
111
+ build_markdown_table(table_headers, table_rows)
112
+ )
113
+ )
114
+
115
+ # Composable Stats Report
116
+ composable_stats_report_path = File.join(metrics_dir, composable_stats_report_path(module_name, build_variant))
117
+ csv = CSV.read(composable_stats_report_path, headers: true)
118
+
119
+ markdown(
120
+ folding(
121
+ '### Composable Stats Report',
122
+ build_markdown_table(csv.headers, csv.map(&:fields))
123
+ )
124
+ )
125
+
126
+ # Composable Report
127
+ composable_report_path = File.join(metrics_dir, composable_report_path(module_name, build_variant))
128
+ markdown(
129
+ folding(
130
+ '### Composable Report',
131
+ <<~MARKDOWN
132
+ ```kotlin
133
+ #{File.read(composable_report_path)}
134
+ ```
135
+ MARKDOWN
136
+ )
137
+ )
138
+
139
+ # Class Report
140
+ class_report_path = File.join(metrics_dir, class_report_path(module_name, build_variant))
141
+ markdown(
142
+ folding(
143
+ '### Class Report',
144
+ <<~MARKDOWN
145
+ ```kotlin
146
+ #{File.read(class_report_path)}
147
+ ```
148
+ MARKDOWN
149
+ )
150
+ )
151
+ end
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "compose_compiler_metrics/gem_version"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "compose_compiler_metrics/plugin"
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require File.expand_path("spec_helper", __dir__)
4
+
5
+ module Danger
6
+ describe Danger::DangerComposeCompilerMetrics do
7
+ it "should be a plugin" do
8
+ expect(Danger::DangerComposeCompilerMetrics.new(nil)).to be_a Danger::Plugin
9
+ end
10
+
11
+ #
12
+ # You should test your custom attributes and methods here
13
+ #
14
+ describe "with Dangerfile" do
15
+ before do
16
+ @dangerfile = testing_dangerfile
17
+ @my_plugin = @dangerfile.compose_compiler_metrics
18
+
19
+ # mock the PR data
20
+ # you can then use this, eg. github.pr_author, later in the spec
21
+ json = File.read("#{File.dirname(__FILE__)}/support/fixtures/github_pr.json") # example json: `curl https://api.github.com/repos/danger/danger-plugin-template/pulls/18 > github_pr.json`
22
+ allow(@my_plugin.github).to receive(:pr_json).and_return(json)
23
+ end
24
+
25
+ # Some examples for writing tests
26
+ # You should replace these with your own.
27
+
28
+ xit "Warns on a monday" do
29
+ monday_date = Date.parse("2016-07-11")
30
+ allow(Date).to receive(:today).and_return monday_date
31
+
32
+ @my_plugin.warn_on_mondays
33
+
34
+ expect(@dangerfile.status_report[:warnings]).to eq(["Trying to merge code on a Monday"])
35
+ end
36
+
37
+ xit "Does nothing on a tuesday" do
38
+ monday_date = Date.parse("2016-07-12")
39
+ allow(Date).to receive(:today).and_return monday_date
40
+
41
+ @my_plugin.warn_on_mondays
42
+
43
+ expect(@dangerfile.status_report[:warnings]).to eq([])
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pathname"
4
+ ROOT = Pathname.new(File.expand_path("..", __dir__))
5
+ $:.unshift("#{ROOT}lib".to_s)
6
+ $:.unshift("#{ROOT}spec".to_s)
7
+
8
+ require "bundler/setup"
9
+ require "pry"
10
+
11
+ require "rspec"
12
+ require "danger"
13
+
14
+ if `git remote -v` == ""
15
+ puts "You cannot run tests without setting a local git remote on this repo"
16
+ puts "It's a weird side-effect of Danger's internals."
17
+ exit(0)
18
+ end
19
+
20
+ # Use coloured output, it's the best.
21
+ RSpec.configure do |config|
22
+ config.filter_gems_from_backtrace "bundler"
23
+ config.color = true
24
+ config.tty = true
25
+ end
26
+
27
+ require "danger_plugin"
28
+
29
+ # These functions are a subset of https://github.com/danger/danger/blob/master/spec/spec_helper.rb
30
+ # If you are expanding these files, see if it's already been done ^.
31
+
32
+ # A silent version of the user interface,
33
+ # it comes with an extra function `.string` which will
34
+ # strip all ANSI colours from the string.
35
+
36
+ # rubocop:disable Lint/NestedMethodDefinition
37
+ def testing_ui
38
+ @output = StringIO.new
39
+ def @output.winsize
40
+ [20, 9999]
41
+ end
42
+
43
+ cork = Cork::Board.new(out: @output)
44
+ def cork.string
45
+ out.string.gsub(/\e\[([;\d]+)?m/, "")
46
+ end
47
+ cork
48
+ end
49
+ # rubocop:enable Lint/NestedMethodDefinition
50
+
51
+ # Example environment (ENV) that would come from
52
+ # running a PR on TravisCI
53
+ def testing_env
54
+ {
55
+ "HAS_JOSH_K_SEAL_OF_APPROVAL" => "true",
56
+ "TRAVIS_PULL_REQUEST" => "800",
57
+ "TRAVIS_REPO_SLUG" => "artsy/eigen",
58
+ "TRAVIS_COMMIT_RANGE" => "759adcbd0d8f...13c4dc8bb61d",
59
+ "DANGER_GITHUB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
60
+ }
61
+ end
62
+
63
+ # A stubbed out Dangerfile for use in tests
64
+ def testing_dangerfile
65
+ env = Danger::EnvironmentManager.new(testing_env)
66
+ Danger::Dangerfile.new(env, testing_ui)
67
+ end
metadata ADDED
@@ -0,0 +1,230 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: danger-compose_compiler_metrics
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tomoki Yamashita
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-02-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: danger-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: csv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.4'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: yard
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: guard
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.14'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.14'
139
+ - !ruby/object:Gem::Dependency
140
+ name: guard-rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '4.7'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '4.7'
153
+ - !ruby/object:Gem::Dependency
154
+ name: listen
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 3.0.7
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 3.0.7
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ description: Report compose compiler metrics
182
+ email:
183
+ - tomorrowkey@gmail.com
184
+ executables: []
185
+ extensions: []
186
+ extra_rdoc_files: []
187
+ files:
188
+ - ".gitignore"
189
+ - ".rubocop.yml"
190
+ - ".travis.yml"
191
+ - Gemfile
192
+ - Gemfile.lock
193
+ - Guardfile
194
+ - LICENSE.txt
195
+ - README.md
196
+ - Rakefile
197
+ - danger-compose_compiler_metrics.gemspec
198
+ - lib/compose_compiler_metrics/gem_version.rb
199
+ - lib/compose_compiler_metrics/helper.rb
200
+ - lib/compose_compiler_metrics/plugin.rb
201
+ - lib/danger_compose_compiler_metrics.rb
202
+ - lib/danger_plugin.rb
203
+ - spec/compose_compiler_metrics_spec.rb
204
+ - spec/spec_helper.rb
205
+ homepage: https://github.com/tomorrowkey/danger-compose_compiler_metrics
206
+ licenses:
207
+ - MIT
208
+ metadata: {}
209
+ post_install_message:
210
+ rdoc_options: []
211
+ require_paths:
212
+ - lib
213
+ required_ruby_version: !ruby/object:Gem::Requirement
214
+ requirements:
215
+ - - ">="
216
+ - !ruby/object:Gem::Version
217
+ version: '0'
218
+ required_rubygems_version: !ruby/object:Gem::Requirement
219
+ requirements:
220
+ - - ">="
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
223
+ requirements: []
224
+ rubygems_version: 3.5.3
225
+ signing_key:
226
+ specification_version: 4
227
+ summary: Report compose compiler metrics
228
+ test_files:
229
+ - spec/compose_compiler_metrics_spec.rb
230
+ - spec/spec_helper.rb