vx-builder 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/lib/vx/builder.rb +15 -2
- data/lib/vx/builder/build_configuration.rb +12 -13
- data/lib/vx/builder/build_configuration/deploy.rb +10 -17
- data/lib/vx/builder/build_configuration/deploy/base.rb +64 -0
- data/lib/vx/builder/build_configuration/deploy/shell.rb +21 -0
- data/lib/vx/builder/build_configuration/env.rb +11 -4
- data/lib/vx/builder/deploy_builder.rb +59 -0
- data/lib/vx/builder/{matrix.rb → matrix_builder.rb} +8 -20
- data/lib/vx/builder/script_builder.rb +127 -0
- data/lib/vx/builder/script_builder/base.rb +59 -0
- data/lib/vx/builder/{script/base.rb → script_builder/base.rb-e} +13 -10
- data/lib/vx/builder/{script/artifacts.rb → script_builder/cache.rb} +13 -30
- data/lib/vx/builder/{script/cache.rb → script_builder/cache.rb-e} +0 -0
- data/lib/vx/builder/script_builder/clojure.rb +34 -0
- data/lib/vx/builder/{script/clojure.rb → script_builder/clojure.rb-e} +0 -0
- data/lib/vx/builder/script_builder/deploy.rb +34 -0
- data/lib/vx/builder/script_builder/deploy.rb-e +34 -0
- data/lib/vx/builder/script_builder/env.rb +39 -0
- data/lib/vx/builder/{script/env.rb → script_builder/env.rb-e} +0 -0
- data/lib/vx/builder/script_builder/java.rb +31 -0
- data/lib/vx/builder/{script/java.rb → script_builder/java.rb-e} +0 -0
- data/lib/vx/builder/script_builder/prepare.rb +72 -0
- data/lib/vx/builder/{script/prepare.rb → script_builder/prepare.rb-e} +0 -0
- data/lib/vx/builder/script_builder/ruby.rb +80 -0
- data/lib/vx/builder/{script/ruby.rb → script_builder/ruby.rb-e} +0 -0
- data/lib/vx/builder/script_builder/scala.rb +50 -0
- data/lib/vx/builder/{script/scala.rb → script_builder/scala.rb-e} +0 -0
- data/lib/vx/builder/script_builder/script.rb +32 -0
- data/lib/vx/builder/script_builder/script.rb-e +32 -0
- data/lib/vx/builder/script_builder/services.rb +26 -0
- data/lib/vx/builder/{script/services.rb → script_builder/services.rb-e} +0 -0
- data/lib/vx/builder/task.rb +1 -7
- data/lib/vx/builder/version.rb +1 -1
- data/spec/fixtures/integration/ruby/deploy/config.yml +6 -2
- data/spec/fixtures/integration/ruby/deploy/d.after_script.sh +1 -1
- data/spec/fixtures/integration/ruby/deploy/d.before_script.sh +3 -1
- data/spec/fixtures/integration/ruby/deploy/d.script.sh +6 -2
- data/spec/fixtures/integration/ruby/matrix/config.yml +4 -1
- data/spec/fixtures/integration/ruby/matrix/d.after_script.sh +1 -1
- data/spec/fixtures/integration/ruby/matrix/d.before_script.sh +1 -1
- data/spec/fixtures/integration/ruby/matrix/d.script.sh +6 -2
- data/spec/fixtures/travis.yml +2 -7
- data/spec/integration/ruby_spec.rb +14 -19
- data/spec/lib/builder/build_configuration/cache_spec.rb +35 -0
- data/spec/lib/builder/build_configuration/deploy/base_spec.rb +33 -0
- data/spec/lib/builder/build_configuration/deploy/shell_spec.rb +61 -0
- data/spec/lib/builder/build_configuration/deploy_spec.rb +50 -0
- data/spec/lib/builder/build_configuration/env_spec.rb +43 -0
- data/spec/lib/builder/build_configuration_spec.rb +4 -124
- data/spec/lib/builder/deploy_builder_spec.rb +82 -0
- data/spec/lib/builder/{matrix_spec.rb → matrix_builder_spec.rb} +9 -67
- data/spec/lib/builder/{script → script_builder}/cache_spec.rb +1 -1
- data/spec/lib/builder/{script → script_builder}/clojure_spec.rb +1 -1
- data/spec/lib/builder/{script → script_builder}/env_spec.rb +1 -1
- data/spec/lib/builder/{script → script_builder}/java_spec.rb +1 -1
- data/spec/lib/builder/{script → script_builder}/prepare_spec.rb +2 -2
- data/spec/lib/builder/{script → script_builder}/ruby_spec.rb +1 -1
- data/spec/lib/builder/{script → script_builder}/scala_spec.rb +1 -1
- data/spec/lib/builder/{script_spec.rb → script_builder_spec.rb} +1 -1
- data/spec/lib/builder/task_spec.rb +0 -2
- data/spec/support/create.rb +24 -11
- metadata +59 -38
- data/lib/vx/builder/build_configuration/artifacts.rb +0 -68
- data/lib/vx/builder/build_configuration/deploy/provider.rb +0 -58
- data/lib/vx/builder/script.rb +0 -145
- data/lib/vx/builder/script/deploy.rb +0 -40
- data/lib/vx/builder/script/script.rb +0 -39
- data/spec/lib/builder/script/artifacts_spec.rb +0 -18
File without changes
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Vx
|
2
|
+
module Builder
|
3
|
+
class ScriptBuilder
|
4
|
+
|
5
|
+
class Scala < Base
|
6
|
+
|
7
|
+
DEFAULT_SCALA = '2.10.3'
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
if enabled?(env)
|
11
|
+
do_cache_key(env) do |i|
|
12
|
+
i << "scala-#{scala env}"
|
13
|
+
end
|
14
|
+
|
15
|
+
do_announce(env) do |i|
|
16
|
+
i << trace_sh_command("export SCALA_VERSION=#{scala env}")
|
17
|
+
end
|
18
|
+
|
19
|
+
do_install(env) do |i|
|
20
|
+
i << "if [[ -d project || -f build.sbt ]] ; then #{trace_sh_command "sbt ++#{scala env} update"} ; fi"
|
21
|
+
end
|
22
|
+
|
23
|
+
do_script(env) do |i|
|
24
|
+
i << "if [[ -d project || -f build.sbt ]] ; then #{trace_sh_command "sbt ++#{scala env} test"} ; fi"
|
25
|
+
end
|
26
|
+
|
27
|
+
do_cached_directories(env) do |i|
|
28
|
+
i << "~/.sbt"
|
29
|
+
i << "~/.ivy2"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
app.call(env)
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def enabled?(env)
|
39
|
+
env.source.scala.first || env.source.language == 'scala'
|
40
|
+
end
|
41
|
+
|
42
|
+
def scala(env)
|
43
|
+
env.source.scala.first || DEFAULT_SCALA
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Vx
|
2
|
+
module Builder
|
3
|
+
class ScriptBuilder
|
4
|
+
|
5
|
+
Script = Struct.new(:app) do
|
6
|
+
|
7
|
+
include Helper::TraceShCommand
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env.source.before_install.each do |c|
|
11
|
+
env.before_install << trace_sh_command(c)
|
12
|
+
end
|
13
|
+
|
14
|
+
env.source.before_script.each do |c|
|
15
|
+
env.before_script << trace_sh_command(c)
|
16
|
+
end
|
17
|
+
|
18
|
+
env.source.script.each do |c|
|
19
|
+
env.script << trace_sh_command(c)
|
20
|
+
end
|
21
|
+
|
22
|
+
env.source.after_success.each do |c|
|
23
|
+
env.after_success << trace_sh_command(c)
|
24
|
+
end
|
25
|
+
|
26
|
+
app.call(env)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Vx
|
2
|
+
module Builder
|
3
|
+
class Script
|
4
|
+
|
5
|
+
Script = Struct.new(:app) do
|
6
|
+
|
7
|
+
include Helper::TraceShCommand
|
8
|
+
|
9
|
+
def call(env)
|
10
|
+
env.source.before_install.each do |c|
|
11
|
+
env.before_install << trace_sh_command(c)
|
12
|
+
end
|
13
|
+
|
14
|
+
env.source.before_script.each do |c|
|
15
|
+
env.before_script << trace_sh_command(c)
|
16
|
+
end
|
17
|
+
|
18
|
+
env.source.script.each do |c|
|
19
|
+
env.script << trace_sh_command(c)
|
20
|
+
end
|
21
|
+
|
22
|
+
env.source.after_success.each do |c|
|
23
|
+
env.after_success << trace_sh_command(c)
|
24
|
+
end
|
25
|
+
|
26
|
+
app.call(env)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Vx
|
2
|
+
module Builder
|
3
|
+
class ScriptBuilder
|
4
|
+
|
5
|
+
class Services < Base
|
6
|
+
|
7
|
+
ALIASES = {
|
8
|
+
'rabbitmq' => 'rabbitmq-server'
|
9
|
+
}
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
env.source.services.each do |srv|
|
13
|
+
srv = ALIASES[srv] || srv
|
14
|
+
env.init << trace_sh_command("sudo service #{srv} start")
|
15
|
+
end
|
16
|
+
unless env.source.services.empty?
|
17
|
+
env.init << trace_sh_command("sleep 3")
|
18
|
+
end
|
19
|
+
|
20
|
+
app.call(env)
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
File without changes
|
data/lib/vx/builder/task.rb
CHANGED
@@ -3,7 +3,7 @@ module Vx
|
|
3
3
|
class Task
|
4
4
|
|
5
5
|
attr_reader :name, :src, :sha, :deploy_key, :branch, :pull_request_id,
|
6
|
-
:cache_url_prefix, :
|
6
|
+
:cache_url_prefix, :job_id, :build_id
|
7
7
|
|
8
8
|
def initialize(options = {})
|
9
9
|
@name = options[:name]
|
@@ -15,16 +15,10 @@ module Vx
|
|
15
15
|
@branch = options[:branch]
|
16
16
|
@pull_request_id = options[:pull_request_id]
|
17
17
|
@cache_url_prefix = options[:cache_url_prefix]
|
18
|
-
@artifacts_url_prefix = options[:artifacts_url_prefix]
|
19
|
-
@deploy = !!options[:deploy]
|
20
18
|
|
21
19
|
validate!
|
22
20
|
end
|
23
21
|
|
24
|
-
def deploy?
|
25
|
-
@deploy
|
26
|
-
end
|
27
|
-
|
28
22
|
private
|
29
23
|
|
30
24
|
def validate!
|
data/lib/vx/builder/version.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
1
|
language: ruby
|
2
2
|
|
3
|
+
env:
|
4
|
+
global: "FOO"
|
5
|
+
matrix: "BAR"
|
6
|
+
|
3
7
|
deploy:
|
4
8
|
|
5
|
-
-
|
9
|
+
- shell: cap staging deploy
|
6
10
|
branch: master
|
7
11
|
|
8
|
-
-
|
12
|
+
- shell: cap producation deploy
|
9
13
|
branch: production
|
10
14
|
|
11
15
|
after_deploy: echo after deploy
|
@@ -7,6 +7,8 @@ export DEBIAN_FRONTEND=noninteractive
|
|
7
7
|
export CI_JOB_ID=1
|
8
8
|
export CI_BUILD_ID=12
|
9
9
|
export CI_BRANCH=master
|
10
|
+
echo \$\ export\ FOO
|
11
|
+
export FOO
|
10
12
|
export VX_ROOT=$(pwd)
|
11
13
|
mkdir -p ${VX_ROOT}/data/name
|
12
14
|
mkdir -p ${VX_ROOT}/code/name
|
@@ -52,6 +54,6 @@ bundle install
|
|
52
54
|
echo \$\ bundle\ clean\ --force
|
53
55
|
bundle clean --force
|
54
56
|
|
55
|
-
# before
|
57
|
+
# before script
|
56
58
|
echo \$\ echo\ before\ deploy
|
57
59
|
echo before deploy
|
data/spec/fixtures/travis.yml
CHANGED
@@ -30,13 +30,8 @@ cache:
|
|
30
30
|
directories:
|
31
31
|
- ~/.cache
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
- /app/*.txt
|
36
|
-
- app/
|
37
|
-
- prefix: $CI_JOB_ID/
|
38
|
-
|
39
|
-
deploy: "cap deploy production"
|
33
|
+
deploy:
|
34
|
+
shell: "cap deploy production"
|
40
35
|
|
41
36
|
after_deploy: echo after deploy
|
42
37
|
before_deploy: echo before deploy
|
@@ -4,9 +4,9 @@ describe "(integration) ruby" do
|
|
4
4
|
let(:build_configuration) {
|
5
5
|
Vx::Builder::BuildConfiguration.from_yaml(config)
|
6
6
|
}
|
7
|
-
let(:matrix) { Vx::Builder
|
7
|
+
let(:matrix) { Vx::Builder.matrix build_configuration }
|
8
8
|
let(:task) { create :task }
|
9
|
-
let(:script) { Vx::Builder
|
9
|
+
let(:script) { Vx::Builder.script(task, source) }
|
10
10
|
subject { matrix }
|
11
11
|
|
12
12
|
def write_script_to_filter(prefix)
|
@@ -26,18 +26,17 @@ describe "(integration) ruby" do
|
|
26
26
|
context "language" do
|
27
27
|
let(:config) { fixture("integration/ruby/language/config.yml") }
|
28
28
|
|
29
|
-
its(:
|
29
|
+
its(:build) { should have(1).item }
|
30
30
|
|
31
31
|
context "first configuration" do
|
32
|
-
let(:source) { matrix.
|
32
|
+
let(:source) { matrix.build.first }
|
33
33
|
subject { script }
|
34
34
|
|
35
35
|
before { write_script_to_filter "language/" }
|
36
36
|
|
37
|
-
it { should_not be_deploy }
|
38
37
|
its(:to_before_script) { should eq fixture("integration/ruby/language/before_script.sh") }
|
39
|
-
its(:to_script)
|
40
|
-
its(:to_after_script)
|
38
|
+
its(:to_script) { should eq fixture("integration/ruby/language/script.sh") }
|
39
|
+
its(:to_after_script) { should eq fixture("integration/ruby/language/after_script.sh") }
|
41
40
|
end
|
42
41
|
end
|
43
42
|
|
@@ -46,7 +45,7 @@ describe "(integration) ruby" do
|
|
46
45
|
|
47
46
|
context "configuration" do
|
48
47
|
let(:task) { create :task, deploy: true }
|
49
|
-
let(:source) {
|
48
|
+
let(:source) { Vx::Builder.deploy(matrix, branch: "master").build }
|
50
49
|
subject { script }
|
51
50
|
|
52
51
|
before { write_script_to_filter "deploy/d." }
|
@@ -55,45 +54,42 @@ describe "(integration) ruby" do
|
|
55
54
|
expect(source).to be
|
56
55
|
end
|
57
56
|
|
58
|
-
it { should be_deploy }
|
59
57
|
its(:to_before_script) { should eq fixture("integration/ruby/deploy/d.before_script.sh") }
|
60
|
-
its(:to_script)
|
61
|
-
its(:to_after_script)
|
58
|
+
its(:to_script) { should eq fixture("integration/ruby/deploy/d.script.sh") }
|
59
|
+
its(:to_after_script) { should eq fixture("integration/ruby/deploy/d.after_script.sh") }
|
62
60
|
end
|
63
61
|
end
|
64
62
|
|
65
63
|
context "matrix" do
|
66
64
|
let(:config) { fixture("integration/ruby/matrix/config.yml") }
|
67
65
|
|
68
|
-
its(:
|
66
|
+
its(:build) { should have(2).item }
|
69
67
|
|
70
68
|
context "0th configuration" do
|
71
|
-
let(:source) { matrix.
|
69
|
+
let(:source) { matrix.build[0] }
|
72
70
|
subject { script }
|
73
71
|
|
74
72
|
before { write_script_to_filter "matrix/0." }
|
75
73
|
|
76
|
-
it { should_not be_deploy }
|
77
74
|
its(:to_before_script) { should eq fixture("integration/ruby/matrix/0.before_script.sh") }
|
78
75
|
its(:to_script) { should eq fixture("integration/ruby/matrix/0.script.sh") }
|
79
76
|
its(:to_after_script) { should eq fixture("integration/ruby/matrix/0.after_script.sh") }
|
80
77
|
end
|
81
78
|
|
82
79
|
context "1th configuration" do
|
83
|
-
let(:source) { matrix.
|
80
|
+
let(:source) { matrix.build[1] }
|
84
81
|
subject { script }
|
85
82
|
|
86
83
|
before { write_script_to_filter "matrix/1." }
|
87
84
|
|
88
|
-
it { should_not be_deploy }
|
89
85
|
its(:to_before_script) { should eq fixture("integration/ruby/matrix/1.before_script.sh") }
|
90
86
|
its(:to_script) { should eq fixture("integration/ruby/matrix/1.script.sh") }
|
91
87
|
its(:to_after_script) { should eq fixture("integration/ruby/matrix/1.after_script.sh") }
|
92
88
|
end
|
93
89
|
|
94
90
|
context "deploy configuration" do
|
95
|
-
let(:task) { create :task
|
96
|
-
let(:source) {
|
91
|
+
let(:task) { create :task }
|
92
|
+
let(:source) { Vx::Builder.deploy(matrix, branch: "master").build }
|
97
93
|
subject { script }
|
98
94
|
|
99
95
|
before { write_script_to_filter "matrix/d." }
|
@@ -102,7 +98,6 @@ describe "(integration) ruby" do
|
|
102
98
|
expect(source).to be
|
103
99
|
end
|
104
100
|
|
105
|
-
it { should be_deploy }
|
106
101
|
its(:to_before_script) { should eq fixture("integration/ruby/matrix/d.before_script.sh") }
|
107
102
|
its(:to_script) { should eq fixture("integration/ruby/matrix/d.script.sh") }
|
108
103
|
its(:to_after_script) { should eq fixture("integration/ruby/matrix/d.after_script.sh") }
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vx::Builder::BuildConfiguration::Cache do
|
4
|
+
let(:params) { { "directories" => ['/a', '/b'] } }
|
5
|
+
let(:env) { described_class.new params }
|
6
|
+
subject { env }
|
7
|
+
|
8
|
+
its(:attributes) { should eq("directories"=>["/a", "/b"], "enabled"=>true) }
|
9
|
+
|
10
|
+
context "attributes" do
|
11
|
+
context "when cache is valid hash" do
|
12
|
+
let(:params) { {"directories" => ['/a']} }
|
13
|
+
it { should be_enabled }
|
14
|
+
its(:directories) { should eq ['/a'] }
|
15
|
+
end
|
16
|
+
|
17
|
+
context "when cache is invalid hash" do
|
18
|
+
let(:params) { {"key" => ['/a']} }
|
19
|
+
it { should be_enabled }
|
20
|
+
its(:directories) { should eq [] }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when is nil" do
|
24
|
+
let(:params) { nil }
|
25
|
+
it { should be_enabled }
|
26
|
+
its(:directories) { should eq [] }
|
27
|
+
end
|
28
|
+
|
29
|
+
context "when is false value" do
|
30
|
+
let(:params) { false }
|
31
|
+
it { should_not be_enabled }
|
32
|
+
its(:directories){ should eq [] }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vx::Builder::BuildConfiguration::Deploy::Base do
|
4
|
+
let(:params) { {
|
5
|
+
"shell" => "echo true",
|
6
|
+
"branch" => "master"
|
7
|
+
} }
|
8
|
+
subject { described_class.new params }
|
9
|
+
|
10
|
+
context "#branch" do
|
11
|
+
it "should be empty if key 'branch' is not exists" do
|
12
|
+
expect(get_branch nil).to eq []
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be if string" do
|
16
|
+
expect(get_branch "master").to eq ['master']
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should be if array" do
|
20
|
+
expect(get_branch [:master, :staging]).to eq %w{ master staging }
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_branch(branch)
|
24
|
+
described_class.new(params.merge("branch" => branch)).branch
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context ".loaded" do
|
29
|
+
subject { described_class.loaded }
|
30
|
+
it { should have(1).items }
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|