matrixeval-ruby 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff8434fd08a67fa951ee19e922ec6e4b19cfb6237a7f2fc17d993ab259319287
4
- data.tar.gz: 1aba3deac866ffd27dbf87afe5af59188871910b1c784a129e39ca449de04350
3
+ metadata.gz: b38c89479923e7c9b607eff588ef02e9b4af821899b45b3a55a995e5673c9a9f
4
+ data.tar.gz: d2984e75182192bf0c80fced8062a019754c6d1ef042b757074e014e2851c6bd
5
5
  SHA512:
6
- metadata.gz: 6599effee10ada71d4ec19eea49b9ae009500626c1b908d168215a9fdfc5f24a3a57cc6f8b9ede3d23ad5f4443e6ec589b48f37fa773f45f46e238d94c75fe99
7
- data.tar.gz: b521b93b8b4f0ea4161fa2b26d88b0aee008d1c340ea7ac3d7e4e383592fd28fa56b85f6fa80d87ba091a36c017fc9d69f93324be30b5f282eb073e8d9e8828e
6
+ metadata.gz: ec71cc460fe724eb580b95da0af5e42e9324a7f789ab951af5082871cf45a8e5906545a3ce60ec31993da95872d76ae8cdae5372ed58b5ecae603e6c4d42ced3
7
+ data.tar.gz: bf8be870710b0f433319e9be0360e69bdd23625d078661d288ef23b3b5c8cef61535e5baca49eff4013abf88a8769ab6030d7840a77f8f74fda92b452c480d7e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0] - 2022-02-27
4
+
5
+ - Refactor this gem as a plugin of matrixeval
6
+
3
7
  ## [0.3.1] - 2022-02-21
4
8
 
5
9
  - Add `.matrixeval/docker-compose` to `.gitignore`
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # matrixeval-ruby
2
2
 
3
- Test your ruby code against multiple versions of dependencies like Ruby, Rails, Env ...
3
+ It's a plugin of [matrixeval](https://github.com/MatrixEval/matrixeval-ruby) for Ruby. Test your ruby code against multiple versions of dependencies like Ruby, Rails, Env ...
4
4
 
5
5
  ![](https://raw.githubusercontent.com/MatrixEval/assets/main/screenshots/summary.png)
6
6
 
@@ -31,7 +31,7 @@ Or install it yourself as:
31
31
  Initialize
32
32
 
33
33
  ```bash
34
- matrixeval init
34
+ matrixeval init -t ruby
35
35
  ```
36
36
 
37
37
  Customize `matrixeval.yml` file and run commands like:
@@ -52,9 +52,9 @@ Run `matrixeval --help` for more details
52
52
  Here is the configuration file `matrixeval.yml` which will auto created by `matrixeval init`
53
53
 
54
54
  ```yaml
55
- version: 0.3
56
- project_name: REPLACE_ME
55
+ version: 0.4
57
56
  target: ruby
57
+ project_name: REPLACE_ME
58
58
  parallel_workers: number_of_processors
59
59
  # commands:
60
60
  # - ps
@@ -107,6 +107,21 @@ exclude:
107
107
  # rails: 4.2
108
108
  # - ruby: jruby-9.3
109
109
  # rails: 7.0
110
+
111
+ docker-compose-extend:
112
+ # services:
113
+ # postgres:
114
+ # image: postgres:12.8
115
+ # volumes:
116
+ # - postgres12:/var/lib/postgresql/data
117
+ # environment:
118
+ # POSTGRES_HOST_AUTH_METHOD: trust
119
+
120
+ # redis:
121
+ # image: redis:6.2-alpine
122
+
123
+ # volumes:
124
+ # postgres12:
110
125
  ```
111
126
 
112
127
  ### Gemfile configuration example
@@ -0,0 +1,87 @@
1
+ module Matrixeval
2
+ module Ruby
3
+ class Target < Matrixeval::Target
4
+
5
+ def version
6
+ Matrixeval::Ruby::VERSION
7
+ end
8
+
9
+ def matrixeval_yml_template_path
10
+ Matrixeval::Ruby.root.join("lib/matrixeval/ruby/templates/matrixeval.yml")
11
+ end
12
+
13
+ def vector_key
14
+ "ruby"
15
+ end
16
+
17
+ def env(context)
18
+ {
19
+ "BUNDLE_PATH" => "/bundle",
20
+ "GEM_HOME" => "/bundle",
21
+ "BUNDLE_APP_CONFIG" => "/bundle",
22
+ "BUNDLE_BIN" => "/bundle/bin",
23
+ "PATH" => "/app/bin:/bundle/bin:$PATH"
24
+ }
25
+ end
26
+
27
+ def mounts(context)
28
+ bundle_volume = bundle_volume(context)
29
+
30
+ [
31
+ "#{bundle_volume}:/bundle",
32
+ "../gemfile_locks/#{context.id}:/app/Gemfile.lock"
33
+ ]
34
+ end
35
+
36
+ def volumes(context)
37
+ bundle_volume = bundle_volume(context)
38
+
39
+ {
40
+ bundle_volume => {
41
+ "name" => bundle_volume
42
+ }
43
+ }
44
+ end
45
+
46
+ def gitignore_paths
47
+ [
48
+ ".matrixeval/gemfile_locks"
49
+ ]
50
+ end
51
+
52
+ def support_commands
53
+ [
54
+ 'ruby', 'rake', 'rails', 'rspec', 'bundle',
55
+ 'bin/rake', 'bin/rails', 'bin/rspec', 'bin/test'
56
+ ]
57
+ end
58
+
59
+ def cli_example_lines
60
+ [
61
+ "",
62
+ "Example:",
63
+ " matrixeval --all bundle install",
64
+ " matrixeval --ruby 3.0 rspec a_spec.rb",
65
+ " matrixeval --ruby 3.1 --active_model 7.0 rake test",
66
+ " matrixeval bash"
67
+ ]
68
+ end
69
+
70
+ def create_files
71
+ gemfile_lock_folder = Matrixeval.working_dir.join(".matrixeval/gemfile_locks")
72
+ FileUtils.mkdir_p gemfile_lock_folder
73
+
74
+ Context.all.each do |context|
75
+ FileUtils.touch gemfile_lock_folder.join(context.id)
76
+ end
77
+ end
78
+
79
+ private
80
+
81
+ def bundle_volume(context)
82
+ docker_image = context.main_variant.container.image
83
+ "bundle_#{docker_image.gsub(/[^A-Za-z0-9]/,'_')}"
84
+ end
85
+ end
86
+ end
87
+ end
@@ -1,6 +1,6 @@
1
- version: 0.3
2
- project_name: REPLACE_ME
1
+ version: 0.4
3
2
  target: ruby
3
+ project_name: REPLACE_ME
4
4
  parallel_workers: number_of_processors
5
5
  # commands:
6
6
  # - ps
@@ -53,3 +53,18 @@ exclude:
53
53
  # rails: 4.2
54
54
  # - ruby: jruby-9.3
55
55
  # rails: 7.0
56
+
57
+ docker-compose-extend:
58
+ # services:
59
+ # postgres:
60
+ # image: postgres:12.8
61
+ # volumes:
62
+ # - postgres12:/var/lib/postgresql/data
63
+ # environment:
64
+ # POSTGRES_HOST_AUTH_METHOD: trust
65
+
66
+ # redis:
67
+ # image: redis:6.2-alpine
68
+
69
+ # volumes:
70
+ # postgres12:
@@ -1,7 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
1
  module Matrixeval
4
2
  module Ruby
5
- VERSION = "0.3.1"
3
+ VERSION = '0.4.0'
6
4
  end
7
5
  end
@@ -1,30 +1,14 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "ruby/version"
4
- require 'rainbow'
5
- require 'matrixeval/ruby/docker_compose'
6
- require 'matrixeval/ruby/context'
7
- require 'matrixeval/ruby/gemfile_locks'
8
- require 'matrixeval/ruby/extra_mount_files'
9
- require 'matrixeval/ruby/runner'
10
- require 'matrixeval/ruby/gitignore'
1
+ require 'matrixeval'
2
+ require_relative 'ruby/version'
3
+ require_relative 'ruby/target'
11
4
 
12
5
  module Matrixeval
13
6
  module Ruby
14
- class Error < StandardError; end
15
-
16
7
  module_function
17
8
  def root
18
9
  Pathname.new("#{__dir__}/../..")
19
10
  end
20
11
  end
21
-
22
- module_function
23
- def start(argv)
24
- Ruby::Runner.start(argv)
25
- end
26
-
27
- def working_dir
28
- Pathname.new(Dir.getwd)
29
- end
30
12
  end
13
+
14
+ Matrixeval.register_target(:ruby, Matrixeval::Ruby::Target)
metadata CHANGED
@@ -1,63 +1,33 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: matrixeval-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hopper Gee
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-20 00:00:00.000000000 Z
11
+ date: 2022-02-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rainbow
14
+ name: matrixeval
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '3.1'
19
+ version: 0.4.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '3.1'
27
- - !ruby/object:Gem::Dependency
28
- name: concurrent-ruby
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: terminal-table
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'
26
+ version: 0.4.2
55
27
  description: MatrixEval-Ruby
56
28
  email:
57
29
  - hopper.gee@hey.com
58
- executables:
59
- - matrixeval
60
- - meval
30
+ executables: []
61
31
  extensions: []
62
32
  extra_rdoc_files: []
63
33
  files:
@@ -70,28 +40,9 @@ files:
70
40
  - bin/console
71
41
  - bin/setup
72
42
  - bin/test
73
- - exe/matrixeval
74
- - exe/meval
75
43
  - lib/matrixeval/ruby.rb
76
- - lib/matrixeval/ruby/command_line.rb
77
- - lib/matrixeval/ruby/command_line/parse_context_arguments.rb
78
- - lib/matrixeval/ruby/config.rb
79
- - lib/matrixeval/ruby/config/yaml.rb
80
- - lib/matrixeval/ruby/container.rb
81
- - lib/matrixeval/ruby/context.rb
82
- - lib/matrixeval/ruby/context/build_docker_compose_extend.rb
83
- - lib/matrixeval/ruby/context/find_by_command_options.rb
84
- - lib/matrixeval/ruby/docker_compose.rb
85
- - lib/matrixeval/ruby/docker_compose/extend.rb
86
- - lib/matrixeval/ruby/docker_compose/extend_raw.rb
87
- - lib/matrixeval/ruby/docker_compose/file.rb
88
- - lib/matrixeval/ruby/extra_mount_files.rb
89
- - lib/matrixeval/ruby/gemfile_locks.rb
90
- - lib/matrixeval/ruby/gitignore.rb
91
- - lib/matrixeval/ruby/runner.rb
44
+ - lib/matrixeval/ruby/target.rb
92
45
  - lib/matrixeval/ruby/templates/matrixeval.yml
93
- - lib/matrixeval/ruby/variant.rb
94
- - lib/matrixeval/ruby/vector.rb
95
46
  - lib/matrixeval/ruby/version.rb
96
47
  homepage: https://github.com/MatrixEval/matrixeval-ruby
97
48
  licenses:
data/exe/matrixeval DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'matrixeval/ruby'
4
-
5
- Matrixeval.start(ARGV)
data/exe/meval DELETED
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'matrixeval/ruby'
4
-
5
- Matrixeval.start(ARGV)
@@ -1,85 +0,0 @@
1
- module Matrixeval
2
- module Ruby
3
- class CommandLine
4
- class ParseContextArguments
5
- class << self
6
- def call(context_arguments)
7
- new(context_arguments).call
8
- end
9
- end
10
-
11
- attr_reader :context_arguments, :options
12
-
13
- def initialize(context_arguments)
14
- @context_arguments = context_arguments
15
- @options = {}
16
- end
17
-
18
- def call
19
- parse!
20
- options
21
- end
22
-
23
- private
24
-
25
- def parse!
26
- OptionParser.new do |opts|
27
- opts.version = Matrixeval::Ruby::VERSION
28
- opts.program_name = ""
29
- opts.banner = <<~USAGE
30
- Usage:
31
- matrixeval(meval) [OPTIONS] COMMAND
32
- USAGE
33
-
34
- opts.separator ""
35
- opts.separator "Options:"
36
-
37
- opts.on "-a", "--all", "# Run the COMMAND against all matrix combinations"
38
-
39
- Config.vectors.each do |vector|
40
- # short = "-#{vector.short_key}"
41
- long = "--#{vector.key} [VERSION]"
42
- desc = [
43
- "# Run the COMMAND against a specific #{vector.key} version",
44
- "# Options: #{vector.variants.map(&:key).join("/")}",
45
- "# Default: #{vector.default_variant.key}",
46
- "# Customizable"
47
- ]
48
- opts.separator ""
49
- opts.on(long, *desc)
50
- end
51
-
52
- opts.separator ""
53
- opts.separator "Commands: #{Config.commands.join("/")} (Customizable)"
54
-
55
- opts.separator ""
56
- opts.separator "MatrixEval Options:"
57
-
58
- opts.on("-h", "--help", "# Show help") do
59
- puts opts.help
60
- exit
61
- end
62
-
63
- opts.on("-v", "--version", "# Show version") do
64
- puts opts.version
65
- exit
66
- end
67
-
68
- opts.separator ""
69
- opts.separator "Customizations:"
70
- opts.separator " You can customize all options in matrixeval.yml"
71
-
72
- opts.separator ""
73
- opts.separator "Example:"
74
- opts.separator " matrixeval --all bundle install"
75
- opts.separator " matrixeval --ruby 3.0 rspec a_spec.rb"
76
- opts.separator " matrixeval --ruby 3.1 --active_model 7.0 rake test"
77
- opts.separator " matrixeval bash"
78
-
79
- end.parse!(context_arguments, into: options)
80
- end
81
-
82
- end
83
- end
84
- end
85
- end
@@ -1,57 +0,0 @@
1
- require_relative "./command_line/parse_context_arguments"
2
-
3
- module Matrixeval
4
- module Ruby
5
- COMMANDS = [
6
- 'ruby', 'rake', 'rails', 'rspec', 'bundle',
7
- 'bin/rake', 'bin/rails', 'bin/rspec', 'bin/test',
8
- 'bash', 'dash', 'sh', 'zsh'
9
- ]
10
-
11
- class CommandLine
12
-
13
- attr_reader :argv
14
-
15
- def initialize(argv)
16
- @argv = argv
17
- end
18
-
19
- def valid?
20
- init? ||
21
- !context_options.empty? ||
22
- !seperator_index.nil?
23
- end
24
-
25
- def init?
26
- @argv[0] == 'init'
27
- end
28
-
29
- def all?
30
- context_options[:all]
31
- end
32
-
33
- def context_options
34
- @context_options ||= ParseContextArguments.call(context_arguments)
35
- end
36
-
37
- def context_arguments
38
- arguments = @argv[0...seperator_index]
39
- arguments << "-h" if @argv.empty?
40
- arguments
41
- end
42
-
43
- def rest_arguments
44
- @argv[seperator_index..-1]
45
- end
46
-
47
- private
48
-
49
- def seperator_index
50
- @argv.index do |argument|
51
- Config.commands.include?(argument)
52
- end
53
- end
54
-
55
- end
56
- end
57
- end
@@ -1,40 +0,0 @@
1
- module Matrixeval
2
- module Ruby
3
- class Config
4
- class YAML
5
-
6
- class MissingError < StandardError; end
7
-
8
- class << self
9
-
10
- def create
11
- return if File.exist?(path)
12
-
13
- FileUtils.cp(template_path, path)
14
- end
15
-
16
- def template_path
17
- Matrixeval::Ruby.root.join(
18
- "lib/matrixeval/ruby/templates/matrixeval.yml"
19
- )
20
- end
21
-
22
- def path
23
- Matrixeval.working_dir.join("matrixeval.yml")
24
- end
25
-
26
- def [](key)
27
- yaml[key]
28
- end
29
-
30
- def yaml
31
- raise MissingError unless File.exist?(path)
32
-
33
- ::YAML.load File.read(path)
34
- end
35
-
36
- end
37
- end
38
- end
39
- end
40
- end
@@ -1,98 +0,0 @@
1
- require 'yaml'
2
- require_relative "./vector"
3
- require_relative "./config/yaml"
4
- require_relative "./docker_compose/extend_raw"
5
- require_relative "./docker_compose/extend"
6
-
7
- module Matrixeval
8
- module Ruby
9
- class Config
10
- class << self
11
-
12
- def version
13
- YAML["version"]
14
- end
15
-
16
- def target
17
- YAML["target"]
18
- end
19
-
20
- def project_name
21
- name = YAML["project_name"]
22
-
23
- if name.nil? || name.strip.empty?
24
- raise Error.new('missing project_name')
25
- end
26
-
27
- name
28
- end
29
-
30
- def vectors
31
- @vectors = YAML["matrix"].map do |key, vector_config|
32
- Vector.new(key, vector_config)
33
- end
34
- end
35
-
36
- def main_vector
37
- vectors.find(&:main?)
38
- end
39
-
40
- def rest_vectors
41
- vectors.reject(&:main?)
42
- end
43
-
44
- def variant_combinations
45
- main_vector_variants.product(*rest_vector_variants_matrix)
46
- end
47
-
48
- def main_vector_variants
49
- main_vector.variants
50
- end
51
-
52
- def rest_vector_variants_matrix
53
- rest_vectors.map(&:variants)
54
- end
55
-
56
- def exclusions
57
- YAML["exclude"] || []
58
- end
59
-
60
- def parallel_workers
61
- YAML["parallel_workers"] || "number_of_processors"
62
- end
63
-
64
- def commands
65
- cmds = YAML["commands"] || []
66
- COMMANDS + cmds
67
- end
68
-
69
- def docker_compose_extend_raw
70
- DockerCompose::ExtendRaw.new(
71
- YAML["docker-compose-extend"] || {}
72
- )
73
- end
74
-
75
- def env
76
- YAML["env"] || {}
77
- end
78
-
79
- def mounts
80
- YAML["mounts"] || []
81
- end
82
-
83
- def all_mounts
84
- mounts + all_variant_mounts
85
- end
86
-
87
- private
88
-
89
- def all_variant_mounts
90
- Config.vectors
91
- .map(&:variants).flatten
92
- .map(&:mounts).flatten
93
- end
94
-
95
- end
96
- end
97
- end
98
- end
@@ -1,15 +0,0 @@
1
- module Matrixeval
2
- module Ruby
3
- class Container
4
-
5
- attr_reader :image, :env
6
-
7
- def initialize(options)
8
- options ||= {}
9
- @image = options["image"]
10
- @env = options["env"] || {}
11
- end
12
-
13
- end
14
- end
15
- end
@@ -1,43 +0,0 @@
1
- require 'erb'
2
- require 'json'
3
-
4
- module Matrixeval
5
- module Ruby
6
- class Context
7
- class BuildDockerComposeExtend
8
- class << self
9
- def call(context)
10
- new(context).call
11
- end
12
- end
13
-
14
- attr_reader :context
15
-
16
- def initialize(context)
17
- @context = context
18
- end
19
-
20
- def matrix_combination_id
21
- context.id
22
- end
23
-
24
- def call
25
- DockerCompose::Extend.new(docker_compose_extend)
26
- end
27
-
28
- private
29
-
30
- def docker_compose_extend
31
- JSON.parse(render_erb)
32
- end
33
-
34
- def render_erb
35
- ERB.new(
36
- Config.docker_compose_extend_raw.content
37
- ).result(binding)
38
- end
39
-
40
- end
41
- end
42
- end
43
- end