vx-builder 0.5.5 → 0.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vx/builder/build_configuration.rb +4 -1
- data/lib/vx/builder/build_configuration/matrix.rb +39 -0
- data/lib/vx/builder/matrix_builder.rb +27 -1
- data/lib/vx/builder/version.rb +1 -1
- data/spec/fixtures/travis.yml +4 -0
- data/spec/lib/builder/build_configuration/matrix_spec.rb +52 -0
- data/spec/lib/builder/build_configuration_spec.rb +2 -1
- data/spec/lib/builder/matrix_builder_spec.rb +20 -0
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce0dadf1e545f6b25be85c1bc67f77eb50462166
|
4
|
+
data.tar.gz: 674500ec89d62b497ef1096a0aa80718d84731bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2d17b508d3ba8861ddcbfc5480c51b6177a696f2fb057a627223517eed62e42acbb4a31a6465d2c37b1d33d8cf3ffc56ab87246b59c7fe5726006dd73e8034f
|
7
|
+
data.tar.gz: e2e2c103a1594b81c02f3bd2bc5cc652d47695b7f3b3c19fec333863aa5a93d57b7e1965808ee4b5b04f9c021c39f702c3f3461c77c4d399fcdab46423a414a9
|
@@ -57,7 +57,8 @@ module Vx
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
attr_reader :env, :cache, :deploy, :attributes, :deploy_modules, :vexor
|
60
|
+
attr_reader :env, :cache, :deploy, :attributes, :deploy_modules, :vexor,
|
61
|
+
:matrix
|
61
62
|
|
62
63
|
def initialize(new_attributes = {}, matrix_attributes = {})
|
63
64
|
new_attributes = {} unless new_attributes.is_a?(Hash)
|
@@ -65,6 +66,7 @@ module Vx
|
|
65
66
|
@env = Env.new new_attributes.delete("env")
|
66
67
|
@cache = Cache.new new_attributes.delete("cache")
|
67
68
|
@vexor = Vexor.new new_attributes.delete("vexor")
|
69
|
+
@matrix = Matrix.new new_attributes.delete("matrix")
|
68
70
|
|
69
71
|
@deploy = Deploy.new new_attributes.delete("deploy")
|
70
72
|
@deploy_modules = new_attributes.delete("deploy_modules") || []
|
@@ -117,6 +119,7 @@ module Vx
|
|
117
119
|
"env" => env.attributes,
|
118
120
|
"cache" => cache.attributes,
|
119
121
|
"vexor" => vexor.attributes,
|
122
|
+
"matrix" => matrix.attributes,
|
120
123
|
"deploy" => deploy.attributes,
|
121
124
|
"deploy_modules" => deploy_modules.map(&:to_hash)
|
122
125
|
)
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Vx
|
2
|
+
module Builder
|
3
|
+
class BuildConfiguration
|
4
|
+
class Matrix
|
5
|
+
|
6
|
+
attr_reader :attributes
|
7
|
+
|
8
|
+
def initialize(new_env)
|
9
|
+
normalize_attributes(new_env)
|
10
|
+
end
|
11
|
+
|
12
|
+
def exclude
|
13
|
+
@attributes["exclude"] || []
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def normalize_attributes(new_env)
|
19
|
+
@attributes = {}
|
20
|
+
|
21
|
+
if new_env.is_a?(Hash)
|
22
|
+
exclude = extract_exclude(new_env)
|
23
|
+
@attributes.merge!("exclude" => exclude) if exclude
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def extract_exclude(env)
|
28
|
+
case env['exclude']
|
29
|
+
when Hash
|
30
|
+
[env['exclude']]
|
31
|
+
when Array
|
32
|
+
env['exclude'].select{|i| i.is_a?(Hash) }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -9,6 +9,7 @@ module Vx
|
|
9
9
|
jdk
|
10
10
|
go
|
11
11
|
node_js
|
12
|
+
rust
|
12
13
|
|
13
14
|
image
|
14
15
|
env_matrix:env
|
@@ -27,7 +28,12 @@ module Vx
|
|
27
28
|
matrix_attributes
|
28
29
|
)
|
29
30
|
end
|
30
|
-
|
31
|
+
filter_not_empty(
|
32
|
+
filter_exclude(
|
33
|
+
build_configuration.matrix.exclude,
|
34
|
+
build_configurations
|
35
|
+
)
|
36
|
+
)
|
31
37
|
end
|
32
38
|
end
|
33
39
|
|
@@ -90,6 +96,26 @@ module Vx
|
|
90
96
|
|
91
97
|
private
|
92
98
|
|
99
|
+
def filter_not_empty(configurations)
|
100
|
+
configurations.select{|c| c.any? }
|
101
|
+
end
|
102
|
+
|
103
|
+
def filter_exclude(exclude, configurations)
|
104
|
+
configurations.select do |c|
|
105
|
+
!exclude.any? do |pair|
|
106
|
+
pair.all? do |k,v|
|
107
|
+
if k == 'env'
|
108
|
+
k = 'env_matrix'
|
109
|
+
end
|
110
|
+
|
111
|
+
c.respond_to?(k) &&
|
112
|
+
c.public_send(k).is_a?(Array) &&
|
113
|
+
c.public_send(k).include?(v)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
93
119
|
def not_matrix?(pairs)
|
94
120
|
pairs.all?{|i| i.size == 1 }
|
95
121
|
end
|
data/lib/vx/builder/version.rb
CHANGED
data/spec/fixtures/travis.yml
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vx::Builder::BuildConfiguration::Matrix do
|
4
|
+
let(:params) { { 'matrix' => ['a', 'b'], 'global' => ['c', 'd'] } }
|
5
|
+
let(:env) { described_class.new params }
|
6
|
+
subject { env }
|
7
|
+
|
8
|
+
it "should succeefuly work without matrix" do
|
9
|
+
matrix = described_class.new(nil)
|
10
|
+
expect(matrix.attributes).to be_empty
|
11
|
+
|
12
|
+
matrix = described_class.new({})
|
13
|
+
expect(matrix.attributes).to be_empty
|
14
|
+
|
15
|
+
matrix = described_class.new({"foo" => "bar"})
|
16
|
+
expect(matrix.attributes).to be_empty
|
17
|
+
|
18
|
+
matrix = described_class.new(%w{1})
|
19
|
+
expect(matrix.attributes).to be_empty
|
20
|
+
|
21
|
+
matrix = described_class.new('string')
|
22
|
+
expect(matrix.attributes).to be_empty
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should build exclude attribute from Hash" do
|
26
|
+
attrs = {
|
27
|
+
"exclude" => {
|
28
|
+
"rvm" => "2.1"
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
matrix = described_class.new attrs
|
33
|
+
expect(matrix.attributes).to eq({
|
34
|
+
"exclude"=> [{"rvm" => "2.1"}]
|
35
|
+
})
|
36
|
+
expect(matrix.exclude).to eq([{'rvm' => '2.1'}])
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should build exclude attribute from Array" do
|
40
|
+
attrs = {
|
41
|
+
"exclude" => [
|
42
|
+
{"rvm" => "2.1"},
|
43
|
+
'ignore'
|
44
|
+
]
|
45
|
+
}
|
46
|
+
matrix = described_class.new attrs
|
47
|
+
expect(matrix.attributes).to eq({
|
48
|
+
"exclude"=> [{"rvm" => "2.1"}]
|
49
|
+
})
|
50
|
+
expect(matrix.exclude).to eq([{'rvm' => '2.1'}])
|
51
|
+
end
|
52
|
+
end
|
@@ -52,7 +52,8 @@ describe Vx::Builder::BuildConfiguration do
|
|
52
52
|
"deploy_modules" => [],
|
53
53
|
"bundler_args" => ["--without development"],
|
54
54
|
"before_deploy" => ["echo before deploy"],
|
55
|
-
"after_deploy" => ["echo after deploy"]
|
55
|
+
"after_deploy" => ["echo after deploy"],
|
56
|
+
"matrix" => {"exclude"=>[{"rvm"=>2.1}]}
|
56
57
|
}
|
57
58
|
) }
|
58
59
|
end
|
@@ -40,6 +40,25 @@ describe Vx::Builder::MatrixBuilder do
|
|
40
40
|
).build
|
41
41
|
end
|
42
42
|
|
43
|
+
it "should exclude configurations" do
|
44
|
+
yaml = YAML.load %{
|
45
|
+
env:
|
46
|
+
- B=frontend
|
47
|
+
- B=backend
|
48
|
+
rvm:
|
49
|
+
- 2.0
|
50
|
+
- 2.1
|
51
|
+
matrix:
|
52
|
+
exclude:
|
53
|
+
- rvm: 2.1
|
54
|
+
env: B=frontend
|
55
|
+
}
|
56
|
+
configurations = create_matrix(yaml)
|
57
|
+
expect(configurations).to have(3).items
|
58
|
+
expect(configurations.map(&:rvm)).to eq [[2.0], [2.0], [2.1]]
|
59
|
+
expect(configurations.map(&:env_matrix)).to eq [["B=backend"], ["B=frontend"], ["B=backend"]]
|
60
|
+
end
|
61
|
+
|
43
62
|
it "should generate 12 configurations" do
|
44
63
|
expect(create_matrix).to have(12).items
|
45
64
|
end
|
@@ -151,6 +170,7 @@ describe Vx::Builder::MatrixBuilder do
|
|
151
170
|
it { should eq ['rvm:2.0.0'] }
|
152
171
|
end
|
153
172
|
end
|
173
|
+
|
154
174
|
end
|
155
175
|
|
156
176
|
context "attributes_for_new_confgurations_with_merged_env" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vx-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dmitry Galinsky
|
@@ -129,6 +129,7 @@ files:
|
|
129
129
|
- lib/vx/builder/build_configuration/deploy/base.rb
|
130
130
|
- lib/vx/builder/build_configuration/deploy/shell.rb
|
131
131
|
- lib/vx/builder/build_configuration/env.rb
|
132
|
+
- lib/vx/builder/build_configuration/matrix.rb
|
132
133
|
- lib/vx/builder/build_configuration/vexor.rb
|
133
134
|
- lib/vx/builder/configuration.rb
|
134
135
|
- lib/vx/builder/deploy_builder.rb
|
@@ -194,6 +195,7 @@ files:
|
|
194
195
|
- spec/lib/builder/build_configuration/deploy/shell_spec.rb
|
195
196
|
- spec/lib/builder/build_configuration/deploy_spec.rb
|
196
197
|
- spec/lib/builder/build_configuration/env_spec.rb
|
198
|
+
- spec/lib/builder/build_configuration/matrix_spec.rb
|
197
199
|
- spec/lib/builder/build_configuration/vexor_spec.rb
|
198
200
|
- spec/lib/builder/build_configuration_spec.rb
|
199
201
|
- spec/lib/builder/configuration_spec.rb
|
@@ -278,6 +280,7 @@ test_files:
|
|
278
280
|
- spec/lib/builder/build_configuration/deploy/shell_spec.rb
|
279
281
|
- spec/lib/builder/build_configuration/deploy_spec.rb
|
280
282
|
- spec/lib/builder/build_configuration/env_spec.rb
|
283
|
+
- spec/lib/builder/build_configuration/matrix_spec.rb
|
281
284
|
- spec/lib/builder/build_configuration/vexor_spec.rb
|
282
285
|
- spec/lib/builder/build_configuration_spec.rb
|
283
286
|
- spec/lib/builder/configuration_spec.rb
|