vx-builder 0.5.54 → 0.5.55

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.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -2
  3. data/lib/vx/builder/build_configuration.rb +2 -0
  4. data/lib/vx/builder/script_builder_v2/base.rb +67 -0
  5. data/lib/vx/builder/script_builder_v2/cache.rb +62 -0
  6. data/lib/vx/builder/script_builder_v2/clojure.rb +35 -0
  7. data/lib/vx/builder/script_builder_v2/clone.rb +43 -0
  8. data/lib/vx/builder/script_builder_v2/defaults.rb +44 -0
  9. data/lib/vx/builder/script_builder_v2/deploy.rb +40 -0
  10. data/lib/vx/builder/script_builder_v2/env.rb +65 -0
  11. data/lib/vx/builder/script_builder_v2/go.rb +64 -0
  12. data/lib/vx/builder/script_builder_v2/java.rb +36 -0
  13. data/lib/vx/builder/script_builder_v2/nodejs.rb +58 -0
  14. data/lib/vx/builder/script_builder_v2/python.rb +69 -0
  15. data/lib/vx/builder/script_builder_v2/ruby.rb +87 -0
  16. data/lib/vx/builder/script_builder_v2/rust.rb +48 -0
  17. data/lib/vx/builder/script_builder_v2/scala.rb +52 -0
  18. data/lib/vx/builder/script_builder_v2/services.rb +25 -0
  19. data/lib/vx/builder/script_builder_v2.rb +158 -0
  20. data/lib/vx/builder/templates/script_builder_v2/to_script.erb +29 -0
  21. data/lib/vx/builder/version.rb +1 -1
  22. data/lib/vx/builder.rb +5 -0
  23. data/spec/fixtures/script_builder_v2/simple.sh +15 -0
  24. data/spec/fixtures/script_builder_v2/simple.yml +89 -0
  25. data/spec/integration/script_builder_v2/clojure_spec.rb +41 -0
  26. data/spec/integration/script_builder_v2/go_spec.rb +54 -0
  27. data/spec/integration/script_builder_v2/nodejs_spec.rb +63 -0
  28. data/spec/integration/script_builder_v2/python_spec.rb +43 -0
  29. data/spec/integration/script_builder_v2/ruby_spec.rb +141 -0
  30. data/spec/integration/script_builder_v2/rust_spec.rb +41 -0
  31. data/spec/lib/builder/build_configuration_spec.rb +1 -0
  32. data/spec/lib/builder/script_builder_v2_spec.rb +52 -0
  33. data/spec/lib/builder/task_spec.rb +1 -1
  34. data/spec/support/create.rb +1 -1
  35. metadata +37 -2
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+ require 'yaml'
3
+ require 'tmpdir'
4
+ require 'fileutils'
5
+
6
+ describe "(integration v2) nodejs" do
7
+ let(:path) { Dir.tmpdir + "/vx-builder-test" }
8
+
9
+ before do
10
+ FileUtils.rm_rf(path)
11
+ FileUtils.mkdir_p(path)
12
+ end
13
+ after { FileUtils.rm_rf(path) }
14
+
15
+ def build(file, options = {})
16
+ config = Vx::Builder::BuildConfiguration.from_yaml(file)
17
+ matrix = Vx::Builder.matrix config
18
+ options[:task] ||= create(:task)
19
+ script = Vx::Builder.script_v2(options[:task], matrix.build.first)
20
+ OpenStruct.new script: script, matrix: matrix
21
+ end
22
+
23
+ it "should succesfuly run lang/nodejs", real: true do
24
+ file = {"language" => "node_js"}.to_yaml
25
+ task = create(
26
+ :task,
27
+ sha: "HEAD",
28
+ branch: "lang/nodejs"
29
+ )
30
+
31
+ b = build(file, task: task)
32
+ Dir.chdir(path) do
33
+ File.open("script.sh", "w") do |io|
34
+ io.write "set -e\n"
35
+ io.write b.script.to_script
36
+ end
37
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
38
+ expect($?.to_i).to eq 0
39
+ end
40
+ end
41
+
42
+ it "should succesfuly run lang/nodejs witn npm", real: true do
43
+ file = {
44
+ "language" => "node_js",
45
+ 'before_script' => "sudo npm install -g bower",
46
+ 'script' => 'bower --version' }.to_yaml
47
+ task = create(
48
+ :task,
49
+ sha: "HEAD",
50
+ branch: "lang/nodejs"
51
+ )
52
+
53
+ b = build(file, task: task)
54
+ Dir.chdir(path) do
55
+ File.open("script.sh", "w") do |io|
56
+ io.write "set -e\n"
57
+ io.write b.script.to_script
58
+ end
59
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
60
+ expect($?.to_i).to eq 0
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,43 @@
1
+ require 'spec_helper'
2
+ require 'yaml'
3
+ require 'tmpdir'
4
+ require 'fileutils'
5
+
6
+ describe "(integration v2) python" do
7
+ let(:path) { Dir.tmpdir + "/vx-builder-test" }
8
+
9
+ before do
10
+ FileUtils.rm_rf(path)
11
+ FileUtils.mkdir_p(path)
12
+ end
13
+ after do
14
+ system "sudo rm -rf #{path}"
15
+ end
16
+
17
+ def build(file, options = {})
18
+ config = Vx::Builder::BuildConfiguration.from_yaml(file)
19
+ matrix = Vx::Builder.matrix config
20
+ options[:task] ||= create(:task)
21
+ script = Vx::Builder.script_v2(options[:task], matrix.build.first)
22
+ OpenStruct.new script: script, matrix: matrix
23
+ end
24
+
25
+ it "should succesfuly run lang/python", real: true do
26
+ file = {"language" => "python"}.to_yaml
27
+ task = create(
28
+ :task,
29
+ sha: "HEAD",
30
+ branch: "lang/python"
31
+ )
32
+
33
+ b = build(file, task: task)
34
+ Dir.chdir(path) do
35
+ File.open("script.sh", "w") do |io|
36
+ io.write "set -e\n"
37
+ io.write b.script.to_script
38
+ end
39
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
40
+ expect($?.to_i).to eq 0
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,141 @@
1
+ require 'spec_helper'
2
+ require 'fileutils'
3
+ require 'tempfile'
4
+ require 'yaml'
5
+
6
+ describe "(integration v2) ruby" do
7
+ let(:path) { Dir.tmpdir + "/vx-builder-test" }
8
+
9
+ before do
10
+ FileUtils.rm_rf(path)
11
+ FileUtils.mkdir_p(path)
12
+ end
13
+
14
+ after { FileUtils.rm_rf(path) }
15
+
16
+ def build(file, options = {})
17
+ config = file ? Vx::Builder::BuildConfiguration.from_yaml(file) : Vx::Builder::BuildConfiguration.new(nil)
18
+ matrix = Vx::Builder.matrix config
19
+ options[:task] ||= create(:task)
20
+ rs = OpenStruct.new matrix: matrix, scripts: []
21
+ matrix.build.each do |b|
22
+ rs.scripts << Vx::Builder.script_v2(options[:task], b)
23
+ end
24
+ rs
25
+ end
26
+
27
+ it "should succesfuly run lang/ruby", real: true do
28
+ file = {"language" => "ruby"}.to_yaml
29
+ task = create(
30
+ :task,
31
+ sha: "HEAD",
32
+ branch: "lang/ruby"
33
+ )
34
+
35
+ b = build(file, task: task)
36
+ Dir.chdir(path) do
37
+ File.open("script.sh", "w") do |io|
38
+ io.write "set -e\n"
39
+ io.write b.scripts[0].to_script
40
+ end
41
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
42
+ expect($?.to_i).to eq 0
43
+ end
44
+ end
45
+
46
+ it "should fail to run lang/ruby", real: true do
47
+ file = {"language" => "ruby", "script" => "false"}.to_yaml
48
+ task = create(
49
+ :task,
50
+ sha: "HEAD",
51
+ branch: "lang/ruby"
52
+ )
53
+
54
+ b = build(file, task: task)
55
+ Dir.chdir(path) do
56
+ File.open("script.sh", "w") do |io|
57
+ io.write "set -e\n"
58
+ io.write b.scripts[0].to_script
59
+ end
60
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
61
+ expect($?.to_i).to_not eq 0
62
+ end
63
+ end
64
+
65
+ it "should succesfuly run lang/ruby with rvm key", real: true do
66
+ file = {"rvm" => "2.1"}.to_yaml
67
+ task = create(
68
+ :task,
69
+ sha: "HEAD",
70
+ branch: "lang/ruby"
71
+ )
72
+
73
+ b = build(file, task: task)
74
+ Dir.chdir(path) do
75
+ File.open("script.sh", "w") do |io|
76
+ io.write "set -e\n"
77
+ io.write b.scripts[0].to_script
78
+ end
79
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
80
+ expect($?.to_i).to eq 0
81
+ end
82
+ end
83
+
84
+ it "should succesfuly run lang/ruby with parallel_rspec", real: true do
85
+ file = {"language" => "ruby", "parallel" => 3, "script" => "parallel_rspec"}.to_yaml
86
+ task = create(
87
+ :task,
88
+ sha: "HEAD",
89
+ branch: "lang/ruby"
90
+ )
91
+
92
+ b = build(file, task: task)
93
+ Dir.chdir(path) do
94
+ File.open("script.sh", "w") do |io|
95
+ io.write "set -e\n"
96
+ io.write b.scripts[0].to_script
97
+ end
98
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
99
+ expect($?.to_i).to eq 0
100
+ end
101
+ end
102
+
103
+ it "should succesfuly run lang/ruby-rails-pg", real: true do
104
+ file = {"language" => "ruby"}.to_yaml
105
+ task = create(
106
+ :task,
107
+ sha: "HEAD",
108
+ branch: "lang/ruby-rails-pg"
109
+ )
110
+
111
+ b = build(file, task: task)
112
+ Dir.chdir(path) do
113
+ File.open("script.sh", "w") do |io|
114
+ io.write "set -e\n"
115
+ io.write b.scripts[0].to_script
116
+ end
117
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
118
+ expect($?.to_i).to eq 0
119
+ end
120
+ end
121
+
122
+ it "should succesfuly run lang/ruby-rails-mysql", real: true do
123
+ file = {"language" => "ruby"}.to_yaml
124
+ task = create(
125
+ :task,
126
+ sha: "HEAD",
127
+ branch: "lang/ruby-rails-mysql"
128
+ )
129
+
130
+ b = build(file, task: task)
131
+ Dir.chdir(path) do
132
+ File.open("script.sh", "w") do |io|
133
+ io.write "set -e\n"
134
+ io.write b.scripts[0].to_script
135
+ end
136
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
137
+ expect($?.to_i).to eq 0
138
+ end
139
+ end
140
+ end
141
+
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+ require 'yaml'
3
+ require 'tmpdir'
4
+ require 'fileutils'
5
+
6
+ describe "(integration v2) rust" do
7
+ let(:path) { Dir.tmpdir + "/vx-builder-test" }
8
+
9
+ before do
10
+ FileUtils.rm_rf(path)
11
+ FileUtils.mkdir_p(path)
12
+ end
13
+ after { FileUtils.rm_rf(path) }
14
+
15
+ def build(file, options = {})
16
+ config = Vx::Builder::BuildConfiguration.from_yaml(file)
17
+ matrix = Vx::Builder.matrix config
18
+ options[:task] ||= create(:task)
19
+ script = Vx::Builder.script_v2(options[:task], matrix.build.first)
20
+ OpenStruct.new script: script, matrix: matrix
21
+ end
22
+
23
+ it "should succesfuly run lang/rust", real: true do
24
+ file = {"language" => "rust"}.to_yaml
25
+ task = create(
26
+ :task,
27
+ sha: "HEAD",
28
+ branch: "lang/rust"
29
+ )
30
+
31
+ b = build(file, task: task)
32
+ Dir.chdir(path) do
33
+ File.open("script.sh", "w") do |io|
34
+ io.write "set -e\n"
35
+ io.write b.script.to_script
36
+ end
37
+ system("env", "-", "USER=$USER", "HOME=#{path}", "bash", "script.sh" )
38
+ expect($?.to_i).to eq 0
39
+ end
40
+ end
41
+ end
@@ -28,6 +28,7 @@ describe Vx::Builder::BuildConfiguration do
28
28
  "before_install" => ["echo before_install"],
29
29
  "install" => ["echo install"],
30
30
  "before_script" => ["echo before_script"],
31
+ "database" => [],
31
32
  "cache" => {
32
33
  "directories" => ["~/.cache"],
33
34
  "enabled" => true
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe Vx::Builder::ScriptBuilderV2 do
4
+ let(:task) { create :task }
5
+ let(:source) { create :source }
6
+ let(:script) { described_class.new task, source }
7
+ subject { script }
8
+
9
+ context "just created" do
10
+ its(:source) { should eq source }
11
+ its(:task) { should eq task }
12
+ end
13
+
14
+ it "should avaialble timeout and read_timeout attributes" do
15
+ expect(script.vexor.timeout).to eq 10
16
+ expect(script.vexor.read_timeout).to eq 20
17
+
18
+ simple_source = create :source, name: "simple.yml"
19
+ simple_script = described_class.new task, simple_source
20
+ expect(simple_script.vexor.timeout).to be_nil
21
+ expect(simple_script.vexor.read_timeout).to be_nil
22
+ end
23
+
24
+ it "should create parallel jobs" do
25
+ matrix = Vx::Builder::MatrixBuilder.new(source)
26
+ configurations = matrix.build
27
+ configuration = configurations[1]
28
+ expect(configuration.parallel).to eq 3
29
+ expect(configuration.parallel_job_number).to eq 1
30
+ parallel_script = described_class.new task, configuration
31
+
32
+ parallel_script.to_hash # call
33
+ stage = parallel_script.stage("init")
34
+ expect(stage.environment["CI_PARALLEL_JOBS"]).to eq 3
35
+ expect(stage.environment["CI_PARALLEL_JOB_NUMBER"]).to eq 1
36
+ end
37
+
38
+ it "should able to convert to yaml" do
39
+ yml = script.to_yaml
40
+ fixture = "spec/fixtures/script_builder_v2/simple.yml"
41
+ File.open(fixture, 'w') { |io| io.write yml }
42
+ expect(script.to_yaml).to eq File.read(fixture)
43
+ end
44
+
45
+ it "should able to convert to script" do
46
+ sh = script.to_script
47
+ fixture = "spec/fixtures/script_builder_v2/simple.sh"
48
+ File.open(fixture, 'w') { |io| io.write sh }
49
+ expect(script.to_script).to be
50
+ end
51
+
52
+ end
@@ -9,7 +9,7 @@ describe Vx::Builder::Task do
9
9
  its(:name) { should eq 'vexor/vx-test-repo' }
10
10
  its(:sha) { should eq '8f53c077072674972e21c82a286acc07fada91f5' }
11
11
  its(:deploy_key) { should be }
12
- its(:cache_url_prefix){ should eq 'http://example.com' }
12
+ its(:cache_url_prefix){ should eq 'http://localhost:3001' }
13
13
  its(:job_id) { should eq 1 }
14
14
  its(:build_id) { should eq 12 }
15
15
  its(:pull_request_id) { should eq 1 }
@@ -12,7 +12,7 @@ def create(name, options = {})
12
12
  sha: options[:sha] || "8f53c077072674972e21c82a286acc07fada91f5",
13
13
  deploy_key: fixture("vx_test_repo_insecure_key"),
14
14
  branch: options[:branch] || "test/pull-request",
15
- cache_url_prefix: "http://example.com",
15
+ cache_url_prefix: "http://localhost:3001",
16
16
  pull_request_id: options[:pull_request_id],
17
17
  job_number: 100,
18
18
  build_number: 101,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vx-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.54
4
+ version: 0.5.55
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dmitry Galinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-29 00:00:00.000000000 Z
11
+ date: 2014-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vx-common
@@ -163,7 +163,24 @@ files:
163
163
  - lib/vx/builder/script_builder/scala.rb
164
164
  - lib/vx/builder/script_builder/services.rb
165
165
  - lib/vx/builder/script_builder/timeouts.rb
166
+ - lib/vx/builder/script_builder_v2.rb
167
+ - lib/vx/builder/script_builder_v2/base.rb
168
+ - lib/vx/builder/script_builder_v2/cache.rb
169
+ - lib/vx/builder/script_builder_v2/clojure.rb
170
+ - lib/vx/builder/script_builder_v2/clone.rb
171
+ - lib/vx/builder/script_builder_v2/defaults.rb
172
+ - lib/vx/builder/script_builder_v2/deploy.rb
173
+ - lib/vx/builder/script_builder_v2/env.rb
174
+ - lib/vx/builder/script_builder_v2/go.rb
175
+ - lib/vx/builder/script_builder_v2/java.rb
176
+ - lib/vx/builder/script_builder_v2/nodejs.rb
177
+ - lib/vx/builder/script_builder_v2/python.rb
178
+ - lib/vx/builder/script_builder_v2/ruby.rb
179
+ - lib/vx/builder/script_builder_v2/rust.rb
180
+ - lib/vx/builder/script_builder_v2/scala.rb
181
+ - lib/vx/builder/script_builder_v2/services.rb
166
182
  - lib/vx/builder/task.rb
183
+ - lib/vx/builder/templates/script_builder_v2/to_script.erb
167
184
  - lib/vx/builder/version.rb
168
185
  - spec/fixtures/clojure.yml
169
186
  - spec/fixtures/integration/go/language/after_script.sh
@@ -190,6 +207,8 @@ files:
190
207
  - spec/fixtures/integration/ruby/matrix/d.script.sh
191
208
  - spec/fixtures/python.yml
192
209
  - spec/fixtures/scala.yml
210
+ - spec/fixtures/script_builder_v2/simple.sh
211
+ - spec/fixtures/script_builder_v2/simple.yml
193
212
  - spec/fixtures/simple.yml
194
213
  - spec/fixtures/travis.yml
195
214
  - spec/fixtures/travis_bug_1.yml
@@ -202,6 +221,12 @@ files:
202
221
  - spec/integration/python_spec.rb
203
222
  - spec/integration/ruby_spec.rb
204
223
  - spec/integration/rust_spec.rb
224
+ - spec/integration/script_builder_v2/clojure_spec.rb
225
+ - spec/integration/script_builder_v2/go_spec.rb
226
+ - spec/integration/script_builder_v2/nodejs_spec.rb
227
+ - spec/integration/script_builder_v2/python_spec.rb
228
+ - spec/integration/script_builder_v2/ruby_spec.rb
229
+ - spec/integration/script_builder_v2/rust_spec.rb
205
230
  - spec/lib/builder/build_configuration/cache_spec.rb
206
231
  - spec/lib/builder/build_configuration/deploy/base_spec.rb
207
232
  - spec/lib/builder/build_configuration/deploy/shell_spec.rb
@@ -222,6 +247,7 @@ files:
222
247
  - spec/lib/builder/script_builder/ruby_spec.rb
223
248
  - spec/lib/builder/script_builder/scala_spec.rb
224
249
  - spec/lib/builder/script_builder_spec.rb
250
+ - spec/lib/builder/script_builder_v2_spec.rb
225
251
  - spec/lib/builder/task_spec.rb
226
252
  - spec/lib/builder_spec.rb
227
253
  - spec/spec_helper.rb
@@ -278,6 +304,8 @@ test_files:
278
304
  - spec/fixtures/integration/ruby/matrix/d.script.sh
279
305
  - spec/fixtures/python.yml
280
306
  - spec/fixtures/scala.yml
307
+ - spec/fixtures/script_builder_v2/simple.sh
308
+ - spec/fixtures/script_builder_v2/simple.yml
281
309
  - spec/fixtures/simple.yml
282
310
  - spec/fixtures/travis.yml
283
311
  - spec/fixtures/travis_bug_1.yml
@@ -290,6 +318,12 @@ test_files:
290
318
  - spec/integration/python_spec.rb
291
319
  - spec/integration/ruby_spec.rb
292
320
  - spec/integration/rust_spec.rb
321
+ - spec/integration/script_builder_v2/clojure_spec.rb
322
+ - spec/integration/script_builder_v2/go_spec.rb
323
+ - spec/integration/script_builder_v2/nodejs_spec.rb
324
+ - spec/integration/script_builder_v2/python_spec.rb
325
+ - spec/integration/script_builder_v2/ruby_spec.rb
326
+ - spec/integration/script_builder_v2/rust_spec.rb
293
327
  - spec/lib/builder/build_configuration/cache_spec.rb
294
328
  - spec/lib/builder/build_configuration/deploy/base_spec.rb
295
329
  - spec/lib/builder/build_configuration/deploy/shell_spec.rb
@@ -310,6 +344,7 @@ test_files:
310
344
  - spec/lib/builder/script_builder/ruby_spec.rb
311
345
  - spec/lib/builder/script_builder/scala_spec.rb
312
346
  - spec/lib/builder/script_builder_spec.rb
347
+ - spec/lib/builder/script_builder_v2_spec.rb
313
348
  - spec/lib/builder/task_spec.rb
314
349
  - spec/lib/builder_spec.rb
315
350
  - spec/spec_helper.rb