matrixeval-ruby 0.2.2 → 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/CHANGELOG.md +5 -0
- data/README.md +85 -0
- data/lib/matrixeval/ruby/command_line.rb +5 -1
- data/lib/matrixeval/ruby/config.rb +38 -0
- data/lib/matrixeval/ruby/context/build_docker_compose_extend.rb +43 -0
- data/lib/matrixeval/ruby/context.rb +10 -1
- data/lib/matrixeval/ruby/docker_compose/extend.rb +21 -0
- data/lib/matrixeval/ruby/docker_compose/extend_raw.rb +19 -0
- data/lib/matrixeval/ruby/docker_compose/file.rb +135 -0
- data/lib/matrixeval/ruby/docker_compose.rb +35 -20
- data/lib/matrixeval/ruby/extra_mount_files.rb +23 -0
- data/lib/matrixeval/ruby/gemfile_locks.rb +3 -3
- data/lib/matrixeval/ruby/gitignore.rb +1 -1
- data/lib/matrixeval/ruby/runner.rb +4 -3
- data/lib/matrixeval/ruby/templates/matrixeval.yml +7 -4
- data/lib/matrixeval/ruby/variant.rb +2 -1
- data/lib/matrixeval/ruby/vector.rb +1 -2
- data/lib/matrixeval/ruby/version.rb +1 -1
- data/lib/matrixeval/ruby.rb +1 -0
- metadata +7 -3
- data/lib/matrixeval/ruby/docker_compose/yaml.rb +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 526b698efa76d623a97a48ec4f9ed2d365ed9c05f2d6ea8230d7778997173dd9
|
4
|
+
data.tar.gz: fcb6eb6971632aaf115e00390c7b0230e903e4ef57421e9e0d3a192535b645b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc21ef4da660bddffb12d523559c7609b6d8b232c2b38409184c9e67260b37d5acf23a0d2456afe977076f09ccf436b0b138502caf3b3db90b4d330a0050d2dd
|
7
|
+
data.tar.gz: 35085fc143ce553458ebbab452aec1a062f1faed2915098c6d9753115ca906cd19d2f335bbf5def2310f18bddd380bf43351ad23f00191d3401035892580ba0f
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# matrixeval-ruby
|
2
2
|
|
3
3
|
Test your ruby code against multiple versions of dependencies like Ruby, Rails, Env ...
|
4
|
+
|
5
|
+

|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
- Parallel test your ruby code against multiple versions of dependencies combinations.
|
10
|
+
- Test your ruby code against a specific dependencies combination.
|
11
|
+
- Choose any docker image you like for each job.
|
12
|
+
- Easy to use CLI to speed up your development efficiency
|
4
13
|
## Installation
|
5
14
|
|
6
15
|
Add this line to your application's Gemfile:
|
@@ -36,6 +45,82 @@ matrixeval bash
|
|
36
45
|
```
|
37
46
|
Run `matrixeval --help` for more details
|
38
47
|
|
48
|
+

|
49
|
+
|
50
|
+
### Configuration Example
|
51
|
+
|
52
|
+
Here is the configuration file `matrixeval.yml` which will auto created by `matrixeval init`
|
53
|
+
|
54
|
+
```yaml
|
55
|
+
version: 0.3
|
56
|
+
project_name: REPLACE_ME
|
57
|
+
target: ruby
|
58
|
+
parallel_workers: number_of_processors
|
59
|
+
# commands:
|
60
|
+
# - ps
|
61
|
+
# - top
|
62
|
+
# - an_additional_command
|
63
|
+
# mounts:
|
64
|
+
# - /a/path/need/to/mount:/a/path/mount/to
|
65
|
+
matrix:
|
66
|
+
ruby:
|
67
|
+
variants:
|
68
|
+
- key: 2.7
|
69
|
+
container:
|
70
|
+
image: ruby:2.7.1
|
71
|
+
- key: 3.0
|
72
|
+
default: true
|
73
|
+
container:
|
74
|
+
image: ruby:3.0.0
|
75
|
+
- key: 3.1
|
76
|
+
container:
|
77
|
+
image: ruby:3.1.0
|
78
|
+
# - key: jruby-9.3
|
79
|
+
# container:
|
80
|
+
# image: jruby:9.3
|
81
|
+
# env:
|
82
|
+
# PATH: "/opt/jruby/bin:/app/bin:/bundle/bin:$PATH"
|
83
|
+
# mounts:
|
84
|
+
# - /a/path/need/to/mount:/a/path/mount/to
|
85
|
+
|
86
|
+
# rails:
|
87
|
+
# variants:
|
88
|
+
# - key: 6.1
|
89
|
+
# default: true
|
90
|
+
# env:
|
91
|
+
# RAILS_VERSION: "~> 6.1.0"
|
92
|
+
# - key: 7.0
|
93
|
+
# env:
|
94
|
+
# RAILS_VERSION: "~> 7.0.0"
|
95
|
+
# another:
|
96
|
+
# variants:
|
97
|
+
# - key: key1
|
98
|
+
# default: true
|
99
|
+
# env:
|
100
|
+
# ENV_KEY: 1
|
101
|
+
# - key: key2
|
102
|
+
# env:
|
103
|
+
# ENV_KEY: 2
|
104
|
+
|
105
|
+
exclude:
|
106
|
+
# - ruby: 3.0
|
107
|
+
# rails: 4.2
|
108
|
+
# - ruby: jruby-9.3
|
109
|
+
# rails: 7.0
|
110
|
+
```
|
111
|
+
|
112
|
+
### Gemfile configuration example
|
113
|
+
|
114
|
+
Here is an example from [ruby-trello](https://github.com/jeremytregunna/ruby-trello)
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
if active_model_version = ENV['ACTIVE_MODEL_VERSION']
|
118
|
+
gem 'activemodel', active_model_version
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
122
|
+
You can also check its corresponding [`matrixeval.yml`](https://github.com/jeremytregunna/ruby-trello/blob/master/matrixeval.yml)
|
123
|
+
|
39
124
|
## Development
|
40
125
|
|
41
126
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -2,7 +2,11 @@ require_relative "./command_line/parse_context_arguments"
|
|
2
2
|
|
3
3
|
module Matrixeval
|
4
4
|
module Ruby
|
5
|
-
COMMANDS = [
|
5
|
+
COMMANDS = [
|
6
|
+
'ruby', 'rake', 'rails', 'rspec', 'bundle',
|
7
|
+
'bin/rake', 'bin/rails', 'bin/rspec', 'bin/test',
|
8
|
+
'bash', 'dash', 'sh', 'zsh'
|
9
|
+
]
|
6
10
|
|
7
11
|
class CommandLine
|
8
12
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require_relative "./vector"
|
3
3
|
require_relative "./config/yaml"
|
4
|
+
require_relative "./docker_compose/extend_raw"
|
5
|
+
require_relative "./docker_compose/extend"
|
4
6
|
|
5
7
|
module Matrixeval
|
6
8
|
module Ruby
|
@@ -15,6 +17,16 @@ module Matrixeval
|
|
15
17
|
YAML["target"]
|
16
18
|
end
|
17
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
|
+
|
18
30
|
def vectors
|
19
31
|
@vectors = YAML["matrix"].map do |key, vector_config|
|
20
32
|
Vector.new(key, vector_config)
|
@@ -54,6 +66,32 @@ module Matrixeval
|
|
54
66
|
COMMANDS + cmds
|
55
67
|
end
|
56
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
|
+
|
57
95
|
end
|
58
96
|
end
|
59
97
|
end
|
@@ -0,0 +1,43 @@
|
|
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
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative "./context/find_by_command_options"
|
2
|
+
require_relative "./context/build_docker_compose_extend"
|
2
3
|
|
3
4
|
module Matrixeval
|
4
5
|
module Ruby
|
@@ -52,7 +53,11 @@ module Matrixeval
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def gemfile_lock_path
|
55
|
-
Matrixeval.working_dir.join(".matrixeval/
|
56
|
+
Matrixeval.working_dir.join(".matrixeval/gemfile_locks/#{id}")
|
57
|
+
end
|
58
|
+
|
59
|
+
def docker_compose_file_path
|
60
|
+
Matrixeval.working_dir.join(".matrixeval/docker-compose/#{id}.yml")
|
56
61
|
end
|
57
62
|
|
58
63
|
def variants
|
@@ -72,6 +77,10 @@ module Matrixeval
|
|
72
77
|
end
|
73
78
|
end
|
74
79
|
|
80
|
+
def docker_compose_extend
|
81
|
+
BuildDockerComposeExtend.call(self)
|
82
|
+
end
|
83
|
+
|
75
84
|
end
|
76
85
|
end
|
77
86
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Matrixeval
|
2
|
+
module Ruby
|
3
|
+
class DockerCompose
|
4
|
+
class Extend
|
5
|
+
|
6
|
+
def initialize(config)
|
7
|
+
@config = config || {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def volumes
|
11
|
+
@config["volumes"] || {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def services
|
15
|
+
@config["services"] || {}
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,135 @@
|
|
1
|
+
require "erb"
|
2
|
+
|
3
|
+
module Matrixeval
|
4
|
+
module Ruby
|
5
|
+
class DockerCompose
|
6
|
+
class File
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def create_all
|
10
|
+
FileUtils.mkdir_p folder
|
11
|
+
|
12
|
+
Context.all.each do |context|
|
13
|
+
new(context).create
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def folder
|
20
|
+
Matrixeval.working_dir.join(".matrixeval/docker-compose")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
attr_reader :context
|
25
|
+
|
26
|
+
def initialize(context)
|
27
|
+
@context = context
|
28
|
+
end
|
29
|
+
|
30
|
+
def create
|
31
|
+
::File.open(docker_compose_file_path, 'w+') do |file|
|
32
|
+
file.puts build_content
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def docker_compose_file_path
|
39
|
+
context.docker_compose_file_path
|
40
|
+
end
|
41
|
+
|
42
|
+
def build_content
|
43
|
+
{
|
44
|
+
"version" => "3",
|
45
|
+
"services" => services_json,
|
46
|
+
"volumes" => volumes_json
|
47
|
+
}.to_yaml.sub(/---\n/, "")
|
48
|
+
end
|
49
|
+
|
50
|
+
def services_json
|
51
|
+
services = {}
|
52
|
+
|
53
|
+
services[main_variant.docker_compose_service_name] = {
|
54
|
+
"image" => main_variant.container.image,
|
55
|
+
"volumes" => mounts(main_variant),
|
56
|
+
"environment" => {
|
57
|
+
"BUNDLE_PATH" => "/bundle",
|
58
|
+
"GEM_HOME" => "/bundle",
|
59
|
+
"BUNDLE_APP_CONFIG" => "/bundle",
|
60
|
+
"BUNDLE_BIN" => "/bundle/bin",
|
61
|
+
"PATH" => "/app/bin:/bundle/bin:$PATH"
|
62
|
+
}.merge(extra_env),
|
63
|
+
"working_dir" => "/app"
|
64
|
+
}.merge(depends_on)
|
65
|
+
|
66
|
+
services.merge(docker_compose_extend.services)
|
67
|
+
end
|
68
|
+
|
69
|
+
def volumes_json
|
70
|
+
{
|
71
|
+
bundle_volume => {
|
72
|
+
"name" => bundle_volume
|
73
|
+
}
|
74
|
+
}.merge(docker_compose_extend.volumes)
|
75
|
+
end
|
76
|
+
|
77
|
+
def depends_on
|
78
|
+
if docker_compose_extend.services.keys.empty?
|
79
|
+
{}
|
80
|
+
else
|
81
|
+
{ "depends_on" => docker_compose_extend.services.keys }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def extra_env
|
86
|
+
Config.env.merge(context.env)
|
87
|
+
.merge(main_variant.container.env)
|
88
|
+
end
|
89
|
+
|
90
|
+
def main_variant
|
91
|
+
context.main_variant
|
92
|
+
end
|
93
|
+
|
94
|
+
def bundle_volume
|
95
|
+
main_variant.bundle_volume_name
|
96
|
+
end
|
97
|
+
|
98
|
+
def mounts(variant)
|
99
|
+
[
|
100
|
+
"../..:/app:cached",
|
101
|
+
"#{variant.bundle_volume_name}:/bundle",
|
102
|
+
"../gemfile_locks/#{context.id}:/app/Gemfile.lock"
|
103
|
+
] + extra_mounts
|
104
|
+
end
|
105
|
+
|
106
|
+
def extra_mounts
|
107
|
+
mounts = Config.mounts + context.variants.map(&:mounts).flatten
|
108
|
+
mounts.map do |mount|
|
109
|
+
local_path, in_docker_path = mount.split(':')
|
110
|
+
next mount if Pathname.new(local_path).absolute?
|
111
|
+
|
112
|
+
local_path = Matrixeval.working_dir.join(local_path)
|
113
|
+
docker_compose_folder_path = Matrixeval.working_dir.join(".matrixeval/docker-compose")
|
114
|
+
local_path = local_path.relative_path_from docker_compose_folder_path
|
115
|
+
|
116
|
+
"#{local_path}:#{in_docker_path}"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def docker_compose_extend
|
121
|
+
@docker_compose_extend ||= context.docker_compose_extend
|
122
|
+
end
|
123
|
+
|
124
|
+
def working_dir_name
|
125
|
+
Matrixeval.working_dir.basename
|
126
|
+
end
|
127
|
+
|
128
|
+
def project_name
|
129
|
+
Config.project_name.gsub(/[^A-Za-z0-9-]/,'_').downcase
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
@@ -1,16 +1,10 @@
|
|
1
1
|
|
2
|
-
require_relative "./docker_compose/
|
2
|
+
require_relative "./docker_compose/file"
|
3
3
|
|
4
4
|
module Matrixeval
|
5
5
|
module Ruby
|
6
6
|
class DockerCompose
|
7
7
|
|
8
|
-
class << self
|
9
|
-
def clean_containers
|
10
|
-
system("docker compose -f .matrixeval/docker-compose.yml rm --all -f >> /dev/null 2>&1")
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
8
|
attr_reader :context
|
15
9
|
|
16
10
|
def initialize(context)
|
@@ -18,34 +12,55 @@ module Matrixeval
|
|
18
12
|
end
|
19
13
|
|
20
14
|
def run(arguments)
|
21
|
-
forward_arguments = arguments.
|
15
|
+
forward_arguments = arguments.map do |arg|
|
16
|
+
arg.match(/\s/) ? "\"#{arg}\"" : arg
|
17
|
+
end.join(" ")
|
18
|
+
|
19
|
+
no_tty = %w[bash sh zsh dash].include?(arguments[0]) ? '' : '--no-TTY'
|
22
20
|
|
23
21
|
system(
|
24
22
|
<<~DOCKER_COMPOSE_COMMAND
|
25
|
-
|
23
|
+
#{docker_compose} \
|
26
24
|
run --rm \
|
27
|
-
#{
|
28
|
-
#{
|
29
|
-
#{docker_compose_service_name} \
|
25
|
+
#{no_tty} \
|
26
|
+
#{context.docker_compose_service_name} \
|
30
27
|
#{forward_arguments}
|
31
28
|
DOCKER_COMPOSE_COMMAND
|
32
29
|
)
|
30
|
+
ensure
|
31
|
+
stop_containers
|
32
|
+
clean_containers_and_anonymous_volumes
|
33
|
+
turn_on_stty_opost
|
33
34
|
end
|
34
35
|
|
35
36
|
private
|
36
37
|
|
37
|
-
def
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
def stop_containers
|
39
|
+
system("#{docker_compose} stop >> /dev/null 2>&1")
|
40
|
+
end
|
41
|
+
|
42
|
+
def clean_containers_and_anonymous_volumes
|
43
|
+
system("#{docker_compose} rm -v -f >> /dev/null 2>&1")
|
44
|
+
end
|
45
|
+
|
46
|
+
def docker_compose
|
47
|
+
<<~DOCKER_COMPOSE_COMMAND.strip
|
48
|
+
docker --log-level error compose \
|
49
|
+
-f #{yaml_file} \
|
50
|
+
-p matrixeval-#{project_name}-#{context.id}
|
51
|
+
DOCKER_COMPOSE_COMMAND
|
52
|
+
end
|
53
|
+
|
54
|
+
def yaml_file
|
55
|
+
".matrixeval/docker-compose/#{context.id}.yml"
|
41
56
|
end
|
42
57
|
|
43
|
-
def
|
44
|
-
"
|
58
|
+
def turn_on_stty_opost
|
59
|
+
system("stty opost")
|
45
60
|
end
|
46
61
|
|
47
|
-
def
|
48
|
-
|
62
|
+
def project_name
|
63
|
+
Config.project_name.gsub(/[^A-Za-z0-9-]/,'_').downcase
|
49
64
|
end
|
50
65
|
|
51
66
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Matrixeval
|
2
|
+
module Ruby
|
3
|
+
class ExtraMountFiles
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def create
|
7
|
+
Config.all_mounts.each do |mount|
|
8
|
+
local_path, _ = mount.split(':')
|
9
|
+
next mount if Pathname.new(local_path).absolute?
|
10
|
+
|
11
|
+
local_path = Matrixeval.working_dir.join(local_path)
|
12
|
+
next if local_path.extname.empty?
|
13
|
+
next if local_path.ascend.none? { |path| path == Matrixeval.working_dir }
|
14
|
+
|
15
|
+
FileUtils.mkdir_p local_path.dirname
|
16
|
+
FileUtils.touch local_path
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -4,7 +4,7 @@ module Matrixeval
|
|
4
4
|
class << self
|
5
5
|
|
6
6
|
def create
|
7
|
-
FileUtils.mkdir_p
|
7
|
+
FileUtils.mkdir_p gemfile_lock_folder
|
8
8
|
|
9
9
|
Context.all.each do |context|
|
10
10
|
FileUtils.touch context.gemfile_lock_path
|
@@ -13,8 +13,8 @@ module Matrixeval
|
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def
|
17
|
-
Matrixeval.working_dir.join(".matrixeval")
|
16
|
+
def gemfile_lock_folder
|
17
|
+
Matrixeval.working_dir.join(".matrixeval/gemfile_locks")
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -45,7 +45,6 @@ module Matrixeval
|
|
45
45
|
exit
|
46
46
|
ensure
|
47
47
|
turn_on_stty_opost
|
48
|
-
DockerCompose.clean_containers
|
49
48
|
end
|
50
49
|
|
51
50
|
private
|
@@ -67,9 +66,10 @@ module Matrixeval
|
|
67
66
|
|
68
67
|
def run_all_contexts
|
69
68
|
Config::YAML.create
|
70
|
-
DockerCompose::
|
69
|
+
DockerCompose::File.create_all
|
71
70
|
GemfileLocks.create
|
72
71
|
Gitignore.update
|
72
|
+
ExtraMountFiles.create
|
73
73
|
|
74
74
|
pull_all_images
|
75
75
|
|
@@ -111,9 +111,10 @@ module Matrixeval
|
|
111
111
|
|
112
112
|
def run_a_specific_context
|
113
113
|
Config::YAML.create
|
114
|
-
DockerCompose::
|
114
|
+
DockerCompose::File.create_all
|
115
115
|
GemfileLocks.create
|
116
116
|
Gitignore.update
|
117
|
+
ExtraMountFiles.create
|
117
118
|
|
118
119
|
context = Context.find_by_command_options!(command.context_options)
|
119
120
|
|
@@ -1,14 +1,15 @@
|
|
1
|
-
version: 0.
|
1
|
+
version: 0.3
|
2
|
+
project_name: REPLACE_ME
|
2
3
|
target: ruby
|
3
4
|
parallel_workers: number_of_processors
|
4
5
|
# commands:
|
5
6
|
# - ps
|
6
7
|
# - top
|
7
8
|
# - an_additional_command
|
9
|
+
# mounts:
|
10
|
+
# - /a/path/need/to/mount:/a/path/mount/to
|
8
11
|
matrix:
|
9
12
|
ruby:
|
10
|
-
# mounts:
|
11
|
-
# - /a/path/need/to/mount:/a/path/mount/to
|
12
13
|
variants:
|
13
14
|
- key: 2.7
|
14
15
|
container:
|
@@ -23,8 +24,10 @@ matrix:
|
|
23
24
|
# - key: jruby-9.3
|
24
25
|
# container:
|
25
26
|
# image: jruby:9.3
|
26
|
-
#
|
27
|
+
# env:
|
27
28
|
# PATH: "/opt/jruby/bin:/app/bin:/bundle/bin:$PATH"
|
29
|
+
# mounts:
|
30
|
+
# - /a/path/need/to/mount:/a/path/mount/to
|
28
31
|
|
29
32
|
# rails:
|
30
33
|
# variants:
|
@@ -9,7 +9,7 @@ module Matrixeval
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
-
attr_reader :key, :env, :vector, :default, :container
|
12
|
+
attr_reader :key, :env, :vector, :default, :container, :mounts
|
13
13
|
|
14
14
|
def initialize(config = {}, vector)
|
15
15
|
raise Error.new("Variant#key is missing") if config["key"].nil?
|
@@ -19,6 +19,7 @@ module Matrixeval
|
|
19
19
|
@container = Container.new(config["container"])
|
20
20
|
@env = config["env"] || {}
|
21
21
|
@default = config["default"] || false
|
22
|
+
@mounts = config["mounts"] || []
|
22
23
|
end
|
23
24
|
|
24
25
|
def name
|
@@ -3,11 +3,10 @@ require_relative "./variant"
|
|
3
3
|
module Matrixeval
|
4
4
|
module Ruby
|
5
5
|
class Vector
|
6
|
-
attr_reader :key, :variants
|
6
|
+
attr_reader :key, :variants
|
7
7
|
|
8
8
|
def initialize(key, config)
|
9
9
|
@key = key.to_s
|
10
|
-
@mounts = config["mounts"] || []
|
11
10
|
@variants = (config["variants"] || []).map do |variant_config|
|
12
11
|
config = if variant_config.is_a?(Hash)
|
13
12
|
variant_config
|
data/lib/matrixeval/ruby.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: matrixeval-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hopper Gee
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-02-
|
11
|
+
date: 2022-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rainbow
|
@@ -79,9 +79,13 @@ files:
|
|
79
79
|
- lib/matrixeval/ruby/config/yaml.rb
|
80
80
|
- lib/matrixeval/ruby/container.rb
|
81
81
|
- lib/matrixeval/ruby/context.rb
|
82
|
+
- lib/matrixeval/ruby/context/build_docker_compose_extend.rb
|
82
83
|
- lib/matrixeval/ruby/context/find_by_command_options.rb
|
83
84
|
- lib/matrixeval/ruby/docker_compose.rb
|
84
|
-
- lib/matrixeval/ruby/docker_compose/
|
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
|
85
89
|
- lib/matrixeval/ruby/gemfile_locks.rb
|
86
90
|
- lib/matrixeval/ruby/gitignore.rb
|
87
91
|
- lib/matrixeval/ruby/runner.rb
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require "erb"
|
2
|
-
|
3
|
-
module Matrixeval
|
4
|
-
module Ruby
|
5
|
-
class DockerCompose
|
6
|
-
class YAML
|
7
|
-
class << self
|
8
|
-
|
9
|
-
def create
|
10
|
-
FileUtils.mkdir_p dot_matrixeval_folder
|
11
|
-
|
12
|
-
File.open(path, 'w+') do |file|
|
13
|
-
file.puts build_content
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def build_content
|
20
|
-
{
|
21
|
-
"version" => "3",
|
22
|
-
"services" => services_json,
|
23
|
-
"volumes" => volumes_json
|
24
|
-
}.to_yaml.sub(/---\n/, "")
|
25
|
-
end
|
26
|
-
|
27
|
-
def services_json
|
28
|
-
services = {}
|
29
|
-
|
30
|
-
Config.main_vector_variants.map do |variant|
|
31
|
-
services[variant.docker_compose_service_name] = {
|
32
|
-
"image" => variant.container.image,
|
33
|
-
"volumes" => mounts(variant),
|
34
|
-
"environment" => {
|
35
|
-
"BUNDLE_PATH" => "/bundle",
|
36
|
-
"GEM_HOME" => "/bundle",
|
37
|
-
"BUNDLE_APP_CONFIG" => "/bundle",
|
38
|
-
"BUNDLE_BIN" => "/bundle/bin",
|
39
|
-
"PATH" => "/app/bin:/bundle/bin:$PATH"
|
40
|
-
}.merge(variant.container.env),
|
41
|
-
"working_dir" => "/app"
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
services
|
46
|
-
end
|
47
|
-
|
48
|
-
def volumes_json
|
49
|
-
bundle_volumes.map do |volume|
|
50
|
-
[volume, {"name" => volume}]
|
51
|
-
end.to_h
|
52
|
-
end
|
53
|
-
|
54
|
-
def bundle_volumes
|
55
|
-
Config.main_vector_variants.map(&:bundle_volume_name)
|
56
|
-
end
|
57
|
-
|
58
|
-
def mounts(variant)
|
59
|
-
[
|
60
|
-
"..:/app:cached",
|
61
|
-
"#{variant.bundle_volume_name}:/bundle",
|
62
|
-
] + Config.main_vector.mounts
|
63
|
-
end
|
64
|
-
|
65
|
-
def path
|
66
|
-
dot_matrixeval_folder.join("docker-compose.yml")
|
67
|
-
end
|
68
|
-
|
69
|
-
def dot_matrixeval_folder
|
70
|
-
Matrixeval.working_dir.join(".matrixeval")
|
71
|
-
end
|
72
|
-
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|