matrixeval-ruby 0.2.0 → 0.3.1
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 +17 -0
- data/README.md +85 -0
- data/lib/matrixeval/ruby/command_line.rb +11 -7
- 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 -14
- 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 +5 -5
- data/lib/matrixeval/ruby/runner.rb +12 -11
- 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 -4
- data/Gemfile.lock +0 -37
- 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: ff8434fd08a67fa951ee19e922ec6e4b19cfb6237a7f2fc17d993ab259319287
|
4
|
+
data.tar.gz: 1aba3deac866ffd27dbf87afe5af59188871910b1c784a129e39ca449de04350
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6599effee10ada71d4ec19eea49b9ae009500626c1b908d168215a9fdfc5f24a3a57cc6f8b9ede3d23ad5f4443e6ec589b48f37fa773f45f46e238d94c75fe99
|
7
|
+
data.tar.gz: b521b93b8b4f0ea4161fa2b26d88b0aee008d1c340ea7ac3d7e4e383592fd28fa56b85f6fa80d87ba091a36c017fc9d69f93324be30b5f282eb073e8d9e8828e
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.1] - 2022-02-21
|
4
|
+
|
5
|
+
- Add `.matrixeval/docker-compose` to `.gitignore`
|
6
|
+
|
7
|
+
## [0.3.0] - 2022-02-21
|
8
|
+
|
9
|
+
- Support add extra docker compose services and volumes
|
10
|
+
- Isolate each job with docker compose project name and network
|
11
|
+
|
12
|
+
## [0.2.2] - 2022-02-11
|
13
|
+
|
14
|
+
- Auto remove containers
|
15
|
+
|
16
|
+
## [0.2.1] - 2022-02-11
|
17
|
+
|
18
|
+
- Fix a assignment method issue
|
19
|
+
|
3
20
|
## [0.2.0] - 2022-02-10
|
4
21
|
|
5
22
|
- Change config format from 0.1 to 0.2
|
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,11 +2,15 @@ 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
|
|
9
|
-
|
13
|
+
attr_reader :argv
|
10
14
|
|
11
15
|
def initialize(argv)
|
12
16
|
@argv = argv
|
@@ -19,7 +23,7 @@ module Matrixeval
|
|
19
23
|
end
|
20
24
|
|
21
25
|
def init?
|
22
|
-
argv[0] == 'init'
|
26
|
+
@argv[0] == 'init'
|
23
27
|
end
|
24
28
|
|
25
29
|
def all?
|
@@ -31,19 +35,19 @@ module Matrixeval
|
|
31
35
|
end
|
32
36
|
|
33
37
|
def context_arguments
|
34
|
-
arguments = argv[0...seperator_index]
|
35
|
-
arguments << "-h" if argv.empty?
|
38
|
+
arguments = @argv[0...seperator_index]
|
39
|
+
arguments << "-h" if @argv.empty?
|
36
40
|
arguments
|
37
41
|
end
|
38
42
|
|
39
43
|
def rest_arguments
|
40
|
-
argv[seperator_index..-1]
|
44
|
+
@argv[seperator_index..-1]
|
41
45
|
end
|
42
46
|
|
43
47
|
private
|
44
48
|
|
45
49
|
def seperator_index
|
46
|
-
argv.index do |argument|
|
50
|
+
@argv.index do |argument|
|
47
51
|
Config.commands.include?(argument)
|
48
52
|
end
|
49
53
|
end
|
@@ -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,5 +1,5 @@
|
|
1
1
|
|
2
|
-
require_relative "./docker_compose/
|
2
|
+
require_relative "./docker_compose/file"
|
3
3
|
|
4
4
|
module Matrixeval
|
5
5
|
module Ruby
|
@@ -12,34 +12,55 @@ module Matrixeval
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def run(arguments)
|
15
|
-
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'
|
16
20
|
|
17
21
|
system(
|
18
22
|
<<~DOCKER_COMPOSE_COMMAND
|
19
|
-
|
23
|
+
#{docker_compose} \
|
20
24
|
run --rm \
|
21
|
-
#{
|
22
|
-
#{
|
23
|
-
#{docker_compose_service_name} \
|
25
|
+
#{no_tty} \
|
26
|
+
#{context.docker_compose_service_name} \
|
24
27
|
#{forward_arguments}
|
25
28
|
DOCKER_COMPOSE_COMMAND
|
26
29
|
)
|
30
|
+
ensure
|
31
|
+
stop_containers
|
32
|
+
clean_containers_and_anonymous_volumes
|
33
|
+
turn_on_stty_opost
|
27
34
|
end
|
28
35
|
|
29
36
|
private
|
30
37
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
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"
|
35
56
|
end
|
36
57
|
|
37
|
-
def
|
38
|
-
"
|
58
|
+
def turn_on_stty_opost
|
59
|
+
system("stty opost")
|
39
60
|
end
|
40
61
|
|
41
|
-
def
|
42
|
-
|
62
|
+
def project_name
|
63
|
+
Config.project_name.gsub(/[^A-Za-z0-9-]/,'_').downcase
|
43
64
|
end
|
44
65
|
|
45
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
|
@@ -14,7 +14,7 @@ module Matrixeval
|
|
14
14
|
return if docker_compose_included?
|
15
15
|
|
16
16
|
File.open(gitignore_path, 'a+') do |file|
|
17
|
-
file.puts
|
17
|
+
file.puts docker_compose
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -28,7 +28,7 @@ module Matrixeval
|
|
28
28
|
|
29
29
|
def docker_compose_included?
|
30
30
|
File.exist?(gitignore_path) &&
|
31
|
-
File.read(gitignore_path).include?(
|
31
|
+
File.read(gitignore_path).include?(docker_compose)
|
32
32
|
end
|
33
33
|
|
34
34
|
def gemfile_locks_included?
|
@@ -36,12 +36,12 @@ module Matrixeval
|
|
36
36
|
File.read(gitignore_path).include?(gemfile_locks)
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
".matrixeval/docker-compose
|
39
|
+
def docker_compose
|
40
|
+
".matrixeval/docker-compose"
|
41
41
|
end
|
42
42
|
|
43
43
|
def gemfile_locks
|
44
|
-
".matrixeval/
|
44
|
+
".matrixeval/gemfile_locks"
|
45
45
|
end
|
46
46
|
|
47
47
|
def gitignore_path
|
@@ -16,7 +16,6 @@ module Matrixeval
|
|
16
16
|
end
|
17
17
|
|
18
18
|
attr_reader :argv, :command
|
19
|
-
attr_accessor :threads, :matrixeval_results
|
20
19
|
|
21
20
|
def initialize(argv)
|
22
21
|
@argv = argv
|
@@ -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
|
|
@@ -88,7 +88,7 @@ module Matrixeval
|
|
88
88
|
docker_compose = DockerCompose.new(context)
|
89
89
|
success = docker_compose.run(command.rest_arguments)
|
90
90
|
|
91
|
-
|
91
|
+
@matrixeval_results << [context, !!success]
|
92
92
|
end
|
93
93
|
|
94
94
|
report
|
@@ -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
|
|
@@ -145,7 +146,7 @@ module Matrixeval
|
|
145
146
|
table.add_row headers.map { |value| { value: value, alignment: :center } }
|
146
147
|
table.add_separator
|
147
148
|
|
148
|
-
matrixeval_results.each do |context, success|
|
149
|
+
@matrixeval_results.each do |context, success|
|
149
150
|
success_cell = [success ? Rainbow('Success').green : Rainbow('Failed').red]
|
150
151
|
row = (context.variants.map(&:key) + success_cell).map do |value|
|
151
152
|
{ value: value, alignment: :center }
|
@@ -160,19 +161,19 @@ module Matrixeval
|
|
160
161
|
end
|
161
162
|
|
162
163
|
def parallel(collection)
|
163
|
-
threads = [] unless threads.empty?
|
164
|
-
matrixeval_results = [] unless matrixeval_results.empty?
|
164
|
+
@threads = [] unless @threads.empty?
|
165
|
+
@matrixeval_results = [] unless @matrixeval_results.empty?
|
165
166
|
|
166
167
|
collection.each_slice(per_worker_contexts_count) do |sub_collection|
|
167
|
-
threads << Thread.new do
|
168
|
+
@threads << Thread.new do
|
168
169
|
yield sub_collection
|
169
170
|
end
|
170
171
|
end
|
171
172
|
|
172
|
-
threads.each(&:join)
|
173
|
+
@threads.each(&:join)
|
173
174
|
|
174
|
-
threads.each do |thread|
|
175
|
-
|
175
|
+
@threads.each do |thread|
|
176
|
+
@matrixeval_results += (thread[:matrixeval_results] || [])
|
176
177
|
end
|
177
178
|
end
|
178
179
|
|
@@ -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.1
|
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
|
@@ -64,7 +64,6 @@ files:
|
|
64
64
|
- CHANGELOG.md
|
65
65
|
- CODE_OF_CONDUCT.md
|
66
66
|
- Gemfile
|
67
|
-
- Gemfile.lock
|
68
67
|
- LICENSE.txt
|
69
68
|
- README.md
|
70
69
|
- Rakefile
|
@@ -80,9 +79,13 @@ files:
|
|
80
79
|
- lib/matrixeval/ruby/config/yaml.rb
|
81
80
|
- lib/matrixeval/ruby/container.rb
|
82
81
|
- lib/matrixeval/ruby/context.rb
|
82
|
+
- lib/matrixeval/ruby/context/build_docker_compose_extend.rb
|
83
83
|
- lib/matrixeval/ruby/context/find_by_command_options.rb
|
84
84
|
- lib/matrixeval/ruby/docker_compose.rb
|
85
|
-
- 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
|
86
89
|
- lib/matrixeval/ruby/gemfile_locks.rb
|
87
90
|
- lib/matrixeval/ruby/gitignore.rb
|
88
91
|
- lib/matrixeval/ruby/runner.rb
|
data/Gemfile.lock
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
matrixeval-ruby (0.1.1)
|
5
|
-
concurrent-ruby
|
6
|
-
rainbow (~> 3.1)
|
7
|
-
terminal-table
|
8
|
-
|
9
|
-
GEM
|
10
|
-
remote: https://rubygems.org/
|
11
|
-
specs:
|
12
|
-
byebug (11.1.3)
|
13
|
-
concurrent-ruby (1.1.9)
|
14
|
-
minitest (5.15.0)
|
15
|
-
minitest-focus (1.3.1)
|
16
|
-
minitest (>= 4, < 6)
|
17
|
-
mocha (1.13.0)
|
18
|
-
rainbow (3.1.1)
|
19
|
-
rake (13.0.6)
|
20
|
-
terminal-table (3.0.2)
|
21
|
-
unicode-display_width (>= 1.1.1, < 3)
|
22
|
-
unicode-display_width (2.1.0)
|
23
|
-
|
24
|
-
PLATFORMS
|
25
|
-
x86_64-darwin-19
|
26
|
-
x86_64-linux
|
27
|
-
|
28
|
-
DEPENDENCIES
|
29
|
-
byebug
|
30
|
-
matrixeval-ruby!
|
31
|
-
minitest (~> 5.0)
|
32
|
-
minitest-focus
|
33
|
-
mocha
|
34
|
-
rake (~> 13.0)
|
35
|
-
|
36
|
-
BUNDLED WITH
|
37
|
-
2.2.32
|
@@ -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
|