vx-builder 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.travis.yml +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +40 -0
- data/lib/vx/builder/configuration.rb +20 -0
- data/lib/vx/builder/helper/config.rb +14 -0
- data/lib/vx/builder/helper/logger.rb +14 -0
- data/lib/vx/builder/helper/trace_sh_command.rb +16 -0
- data/lib/vx/builder/script/env.rb +21 -0
- data/lib/vx/builder/script/prepare.rb +59 -0
- data/lib/vx/builder/script/ruby.rb +59 -0
- data/lib/vx/builder/script/script.rb +22 -0
- data/lib/vx/builder/script/services.rb +25 -0
- data/lib/vx/builder/script/webdav_cache.rb +83 -0
- data/lib/vx/builder/script.rb +98 -0
- data/lib/vx/builder/source/constants.rb +11 -0
- data/lib/vx/builder/source/matrix.rb +113 -0
- data/lib/vx/builder/source/serializable.rb +43 -0
- data/lib/vx/builder/source.rb +106 -0
- data/lib/vx/builder/task.rb +27 -0
- data/lib/vx/builder/version.rb +5 -0
- data/lib/vx/builder.rb +38 -0
- data/spec/fixtures/travis.yml +5 -0
- data/spec/fixtures/travis_bug_1.yml +13 -0
- data/spec/fixtures/travis_bug_2.yml +18 -0
- data/spec/lib/builder/configuration_spec.rb +7 -0
- data/spec/lib/builder/script_spec.rb +29 -0
- data/spec/lib/builder/source_matrix_spec.rb +215 -0
- data/spec/lib/builder/source_spec.rb +183 -0
- data/spec/lib/builder/task_spec.rb +25 -0
- data/spec/lib/builder_spec.rb +17 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/support/create.rb +14 -0
- data/spec/support/fixture.rb +7 -0
- data/vx-builder.gemspec +29 -0
- metadata +192 -0
@@ -0,0 +1,183 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vx::Builder::Source do
|
4
|
+
let(:content) { YAML.load fixture('travis.yml') }
|
5
|
+
let(:config) { described_class.from_attributes content }
|
6
|
+
subject { config }
|
7
|
+
|
8
|
+
its(:attributes) { should be }
|
9
|
+
its(:rvm) { should eq %w{ 2.0.0 } }
|
10
|
+
its(:before_script) { should eq ["echo before_script"] }
|
11
|
+
its(:script) { should eq ["RAILS_ENV=test ls -1 && echo DONE!"] }
|
12
|
+
|
13
|
+
context "merge" do
|
14
|
+
let(:new_attrs) { { rvm: "replaced" } }
|
15
|
+
subject{ config.merge new_attrs }
|
16
|
+
|
17
|
+
it "should build a new BuildConfiguration instance" do
|
18
|
+
expect(subject).to be_an_instance_of(described_class)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should replace attributes" do
|
22
|
+
expect(subject.attributes["rvm"]).to eq %w{ replaced }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context "(serialization)" do
|
27
|
+
|
28
|
+
context "build new instance" do
|
29
|
+
let(:expected) { {
|
30
|
+
"rvm" => ["2.0.0"],
|
31
|
+
"before_script" => ["echo before_script"],
|
32
|
+
"script" => ["RAILS_ENV=test ls -1 && echo DONE!"],
|
33
|
+
"env" => {
|
34
|
+
"matrix" => [],
|
35
|
+
"global" => []
|
36
|
+
}
|
37
|
+
} }
|
38
|
+
|
39
|
+
context "from_yaml" do
|
40
|
+
subject { described_class.from_yaml(fixture('travis.yml')).attributes }
|
41
|
+
it { should eq expected }
|
42
|
+
end
|
43
|
+
|
44
|
+
context "form_file" do
|
45
|
+
subject { described_class.from_file('spec/fixtures/travis.yml').attributes }
|
46
|
+
it { should eq expected }
|
47
|
+
end
|
48
|
+
|
49
|
+
context "from_attributes" do
|
50
|
+
let(:attrs) {{
|
51
|
+
rvm: "2.0.0",
|
52
|
+
before_script: "echo before_script",
|
53
|
+
script: "RAILS_ENV=test ls -1 && echo DONE!"
|
54
|
+
}}
|
55
|
+
subject { described_class.from_attributes(attrs).attributes }
|
56
|
+
it { should eq expected }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context ".to_yaml" do
|
61
|
+
subject { config.to_yaml }
|
62
|
+
it { should eq config.attributes.to_yaml }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "to_matrix_s" do
|
67
|
+
subject { config.to_matrix_s }
|
68
|
+
it { should eq 'rvm:2.0.0' }
|
69
|
+
|
70
|
+
context "when many items" do
|
71
|
+
before do
|
72
|
+
mock(config).rvm { %w{ 1.9.3 2.0.0 } }
|
73
|
+
mock(config).scala { %w{ 2.10.1 } }
|
74
|
+
end
|
75
|
+
it { should eq "rvm:1.9.3, scala:2.10.1" }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
context "matrix_keys" do
|
80
|
+
subject { config.matrix_keys }
|
81
|
+
it { should eq("rvm" => "2.0.0") }
|
82
|
+
|
83
|
+
context "when many items" do
|
84
|
+
before do
|
85
|
+
mock(config).rvm { %w{ 1.9.3 2.0.0 } }
|
86
|
+
mock(config).scala { %w{ 2.10.1 } }
|
87
|
+
end
|
88
|
+
it { should eq({"rvm"=>"1.9.3", "scala"=>"2.10.1"}) }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
it "empty attributes must be empty Array" do
|
94
|
+
expect(config.scala).to eq([])
|
95
|
+
end
|
96
|
+
|
97
|
+
context "normalize_attributes" do
|
98
|
+
described_class::AS_ARRAY.each do |m|
|
99
|
+
context "convert #{m} attribute to Array" do
|
100
|
+
let(:content) { { m => m } }
|
101
|
+
subject { config.__send__(m) }
|
102
|
+
it { should eq([m]) }
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "convert hash keys to strings" do
|
107
|
+
let(:content) { { rvm: "rvm" } }
|
108
|
+
subject { config.attributes }
|
109
|
+
it { should include("rvm" => %w{rvm}) }
|
110
|
+
end
|
111
|
+
|
112
|
+
context "build env hash" do
|
113
|
+
subject { config.attributes["env"] }
|
114
|
+
|
115
|
+
context "from String" do
|
116
|
+
let(:content) { { env: "FOO" } }
|
117
|
+
it { should eq( "global" => [], "matrix" => %w{ FOO } ) }
|
118
|
+
end
|
119
|
+
|
120
|
+
context "from Array" do
|
121
|
+
let(:content) { { env: %w{ FOO BAR } } }
|
122
|
+
it { should eq( 'global' => [], 'matrix' => %w{ FOO BAR } ) }
|
123
|
+
end
|
124
|
+
|
125
|
+
context "from empty Hash" do
|
126
|
+
let(:content) { { env: {} } }
|
127
|
+
it { should eq( 'global' => [], 'matrix' => [] ) }
|
128
|
+
end
|
129
|
+
|
130
|
+
context "from Hash" do
|
131
|
+
let(:content) { { env: { "global" => "1", 'matrix' => '2' } } }
|
132
|
+
it { should eq( 'global' => %w{1}, 'matrix' => %w{2} ) }
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
context "env" do
|
138
|
+
let(:content) { { env: env } }
|
139
|
+
subject { config.env }
|
140
|
+
|
141
|
+
context "when attributes[env] is Array" do
|
142
|
+
let(:env) { %w{ FOO=1 BAR=2 } }
|
143
|
+
it { should eq("matrix"=>["FOO=1", "BAR=2"], "global"=>[]) }
|
144
|
+
end
|
145
|
+
|
146
|
+
context "when attributes[env] is Hash" do
|
147
|
+
let(:env) { { "matrix" => %w{ BAZ=1 } } }
|
148
|
+
it { should eq("matrix"=>["BAZ=1"], "global"=>[]) }
|
149
|
+
end
|
150
|
+
|
151
|
+
context "when attributes[env] is empty" do
|
152
|
+
let(:env) { {} }
|
153
|
+
it { should eq("matrix"=>[], "global"=>[]) }
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
context "global_env" do
|
158
|
+
let(:content) { { env: env } }
|
159
|
+
subject { config.global_env }
|
160
|
+
|
161
|
+
context "when attributes[env] is Array" do
|
162
|
+
let(:env) { %w{ FOO=1 } }
|
163
|
+
it { should eq([]) }
|
164
|
+
end
|
165
|
+
|
166
|
+
context "when attributes[env] is Hash" do
|
167
|
+
let(:env) { { "global" => %w{ FOO=1 } } }
|
168
|
+
it { should eq %w{ FOO=1 } }
|
169
|
+
end
|
170
|
+
|
171
|
+
context "when attributes[env] is empty" do
|
172
|
+
let(:env) { {} }
|
173
|
+
it { should eq([]) }
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
context "services" do
|
178
|
+
subject { config.services }
|
179
|
+
let(:content) { { services: 'service' } }
|
180
|
+
it { should eq ['service'] }
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vx/common'
|
3
|
+
|
4
|
+
describe Vx::Builder::Task do
|
5
|
+
let(:task) {
|
6
|
+
described_class.new(
|
7
|
+
'name',
|
8
|
+
'source',
|
9
|
+
'sha',
|
10
|
+
deploy_key: 'deploy_key',
|
11
|
+
pull_request_id: '1'
|
12
|
+
)
|
13
|
+
}
|
14
|
+
|
15
|
+
subject { task }
|
16
|
+
|
17
|
+
context "just created" do
|
18
|
+
let(:name) { should eq 'name' }
|
19
|
+
let(:source) { should eq 'source' }
|
20
|
+
let(:sha) { should eq 'sha' }
|
21
|
+
let(:deploy_key) { should eq 'deploy_key' }
|
22
|
+
let(:pull_request_id) { should eq '1' }
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vx::Builder do
|
4
|
+
subject { described_class }
|
5
|
+
|
6
|
+
its(:logger) { should be }
|
7
|
+
its(:config) { should be }
|
8
|
+
|
9
|
+
context ".configure" do
|
10
|
+
it "should change configuration" do
|
11
|
+
subject.configure do |c|
|
12
|
+
c.casher_ruby = 'ruby'
|
13
|
+
end
|
14
|
+
expect(subject.config.casher_ruby).to eq 'ruby'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.expand_path '../../lib/vx/builder', __FILE__
|
2
|
+
|
3
|
+
Bundler.require(:test)
|
4
|
+
require 'rspec/autorun'
|
5
|
+
require 'vx/message/testing'
|
6
|
+
|
7
|
+
Dir[File.expand_path("../..", __FILE__) + "/spec/support/**/*.rb"].each {|f| require f}
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.mock_with :rr
|
11
|
+
|
12
|
+
config.before(:each) do
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
data/vx-builder.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'vx/builder/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "vx-builder"
|
8
|
+
spec.version = Vx::Builder::VERSION
|
9
|
+
spec.authors = ["Dmitry Galinsky"]
|
10
|
+
spec.email = ["dima.exe@gmail.com"]
|
11
|
+
spec.description = %q{ Write a gem description}
|
12
|
+
spec.summary = %q{ Write a gem summary}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency 'vx-common'
|
22
|
+
spec.add_runtime_dependency 'vx-message'
|
23
|
+
spec.add_runtime_dependency 'hashr'
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "rspec"
|
28
|
+
spec.add_development_dependency "rr"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,192 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: vx-builder
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dmitry Galinsky
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: vx-common
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: vx-message
|
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: hashr
|
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: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '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: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rr
|
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
|
+
description: ' Write a gem description'
|
112
|
+
email:
|
113
|
+
- dima.exe@gmail.com
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- .rspec
|
120
|
+
- .travis.yml
|
121
|
+
- Gemfile
|
122
|
+
- LICENSE.txt
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- lib/vx/builder.rb
|
126
|
+
- lib/vx/builder/configuration.rb
|
127
|
+
- lib/vx/builder/helper/config.rb
|
128
|
+
- lib/vx/builder/helper/logger.rb
|
129
|
+
- lib/vx/builder/helper/trace_sh_command.rb
|
130
|
+
- lib/vx/builder/script.rb
|
131
|
+
- lib/vx/builder/script/env.rb
|
132
|
+
- lib/vx/builder/script/prepare.rb
|
133
|
+
- lib/vx/builder/script/ruby.rb
|
134
|
+
- lib/vx/builder/script/script.rb
|
135
|
+
- lib/vx/builder/script/services.rb
|
136
|
+
- lib/vx/builder/script/webdav_cache.rb
|
137
|
+
- lib/vx/builder/source.rb
|
138
|
+
- lib/vx/builder/source/constants.rb
|
139
|
+
- lib/vx/builder/source/matrix.rb
|
140
|
+
- lib/vx/builder/source/serializable.rb
|
141
|
+
- lib/vx/builder/task.rb
|
142
|
+
- lib/vx/builder/version.rb
|
143
|
+
- spec/fixtures/travis.yml
|
144
|
+
- spec/fixtures/travis_bug_1.yml
|
145
|
+
- spec/fixtures/travis_bug_2.yml
|
146
|
+
- spec/lib/builder/configuration_spec.rb
|
147
|
+
- spec/lib/builder/script_spec.rb
|
148
|
+
- spec/lib/builder/source_matrix_spec.rb
|
149
|
+
- spec/lib/builder/source_spec.rb
|
150
|
+
- spec/lib/builder/task_spec.rb
|
151
|
+
- spec/lib/builder_spec.rb
|
152
|
+
- spec/spec_helper.rb
|
153
|
+
- spec/support/create.rb
|
154
|
+
- spec/support/fixture.rb
|
155
|
+
- vx-builder.gemspec
|
156
|
+
homepage: ''
|
157
|
+
licenses:
|
158
|
+
- MIT
|
159
|
+
metadata: {}
|
160
|
+
post_install_message:
|
161
|
+
rdoc_options: []
|
162
|
+
require_paths:
|
163
|
+
- lib
|
164
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - '>='
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - '>='
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
requirements: []
|
175
|
+
rubyforge_project:
|
176
|
+
rubygems_version: 2.0.14
|
177
|
+
signing_key:
|
178
|
+
specification_version: 4
|
179
|
+
summary: Write a gem summary
|
180
|
+
test_files:
|
181
|
+
- spec/fixtures/travis.yml
|
182
|
+
- spec/fixtures/travis_bug_1.yml
|
183
|
+
- spec/fixtures/travis_bug_2.yml
|
184
|
+
- spec/lib/builder/configuration_spec.rb
|
185
|
+
- spec/lib/builder/script_spec.rb
|
186
|
+
- spec/lib/builder/source_matrix_spec.rb
|
187
|
+
- spec/lib/builder/source_spec.rb
|
188
|
+
- spec/lib/builder/task_spec.rb
|
189
|
+
- spec/lib/builder_spec.rb
|
190
|
+
- spec/spec_helper.rb
|
191
|
+
- spec/support/create.rb
|
192
|
+
- spec/support/fixture.rb
|