vx-builder 0.3.3 → 0.3.4
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/build_configuration.rb +10 -5
- data/lib/vx/builder/deploy_builder.rb +10 -4
- data/lib/vx/builder/script_builder/base.rb +7 -3
- data/lib/vx/builder/script_builder/cache.rb +2 -2
- data/lib/vx/builder/version.rb +1 -1
- data/spec/fixtures/integration/ruby/deploy/d.after_script.sh +1 -2
- data/spec/fixtures/integration/ruby/matrix/d.after_script.sh +1 -2
- data/spec/lib/builder/deploy_builder_spec.rb +5 -0
- data/spec/lib/builder/matrix_builder_spec.rb +4 -0
- metadata +2 -13
- data/lib/vx/builder/script_builder/base.rb-e +0 -59
- data/lib/vx/builder/script_builder/cache.rb-e +0 -94
- data/lib/vx/builder/script_builder/clojure.rb-e +0 -34
- data/lib/vx/builder/script_builder/deploy.rb-e +0 -34
- data/lib/vx/builder/script_builder/env.rb-e +0 -36
- data/lib/vx/builder/script_builder/java.rb-e +0 -31
- data/lib/vx/builder/script_builder/prepare.rb-e +0 -72
- data/lib/vx/builder/script_builder/ruby.rb-e +0 -80
- data/lib/vx/builder/script_builder/scala.rb-e +0 -50
- data/lib/vx/builder/script_builder/script.rb-e +0 -32
- data/lib/vx/builder/script_builder/services.rb-e +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b01cd8a132faf22ac64d8ae7108b7f65e2cbe8e6
|
4
|
+
data.tar.gz: bb2d6983b7d3f3bdacf5317a85a9e81eb66874eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78f08dfcfa31ebe767d5f7920a31f062f16bbadffce7baffb51fb8fe493f00e33ed4aacf15c14fec916b8c5e21e736c8842fd2115ab1819fd8a28f84a981b9f7
|
7
|
+
data.tar.gz: a1436dace186cfa10a075cc7856e219dc05beeb4cd715f79a3201a441f90cfcb005aad2a937ca72c023f0752c04aaa443cb55114fe67437c7227be15005ab316
|
@@ -54,11 +54,11 @@ module Vx
|
|
54
54
|
def initialize(new_attributes = {}, matrix_attributes = {})
|
55
55
|
new_attributes = {} unless new_attributes.is_a?(Hash)
|
56
56
|
|
57
|
-
@env
|
58
|
-
@cache
|
59
|
-
@deploy
|
60
|
-
@deploy_modules
|
61
|
-
@deploy_modules
|
57
|
+
@env = Env.new new_attributes.delete("env")
|
58
|
+
@cache = Cache.new new_attributes.delete("cache")
|
59
|
+
@deploy = Deploy.new new_attributes.delete("deploy")
|
60
|
+
@deploy_modules = new_attributes.delete("deploy_modules") || []
|
61
|
+
@deploy_modules = Deploy.restore_modules(@deploy_modules)
|
62
62
|
|
63
63
|
@matrix_attributes = matrix_attributes
|
64
64
|
|
@@ -71,6 +71,11 @@ module Vx
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
+
# for deploy builder
|
75
|
+
def flat_matrix_attributes
|
76
|
+
@matrix_attributes
|
77
|
+
end
|
78
|
+
|
74
79
|
def matrix_attributes
|
75
80
|
@matrix_attributes.inject({}) do |a,pair|
|
76
81
|
k,v = pair
|
@@ -29,12 +29,18 @@ module Vx
|
|
29
29
|
end
|
30
30
|
|
31
31
|
hash["env"]["matrix"] = []
|
32
|
+
hash.merge!(
|
33
|
+
"deploy_modules" => deploy_modules.map(&:to_hash),
|
34
|
+
"deploy" => nil
|
35
|
+
)
|
36
|
+
|
37
|
+
matrix_hash = matrix_build_configuration.flat_matrix_attributes
|
38
|
+
(BLACK_LIST + %w{ env }).each do |key|
|
39
|
+
matrix_hash.delete(key)
|
40
|
+
end
|
32
41
|
|
33
42
|
build_configuration = BuildConfiguration.new(
|
34
|
-
hash
|
35
|
-
"deploy_modules" => deploy_modules.map(&:to_hash),
|
36
|
-
"deploy" => nil
|
37
|
-
)
|
43
|
+
hash, matrix_hash
|
38
44
|
)
|
39
45
|
[build_configuration]
|
40
46
|
end
|
@@ -35,23 +35,27 @@ module Vx
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def do_deploy_script(env)
|
38
|
-
if env
|
38
|
+
if deploy?(env)
|
39
39
|
yield env.script
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
def do_before_deploy(env)
|
44
|
-
if env
|
44
|
+
if deploy?(env)
|
45
45
|
yield env.before_script
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
def do_after_deploy(env)
|
50
|
-
if env
|
50
|
+
if deploy?(env)
|
51
51
|
yield env.after_success
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
def deploy?(env)
|
56
|
+
env.source.deploy_modules?
|
57
|
+
end
|
58
|
+
|
55
59
|
end
|
56
60
|
|
57
61
|
end
|
@@ -2,7 +2,7 @@ module Vx
|
|
2
2
|
module Builder
|
3
3
|
class ScriptBuilder
|
4
4
|
|
5
|
-
Cache
|
5
|
+
class Cache < Base
|
6
6
|
|
7
7
|
include Helper::Config
|
8
8
|
|
@@ -83,7 +83,7 @@ module Vx
|
|
83
83
|
end
|
84
84
|
|
85
85
|
def push(env)
|
86
|
-
if env.cache_push_url
|
86
|
+
if env.cache_push_url && !deploy?(env)
|
87
87
|
env.after_script << "#{casher_cmd} push #{env.cache_push_url}"
|
88
88
|
end
|
89
89
|
end
|
data/lib/vx/builder/version.rb
CHANGED
@@ -94,5 +94,10 @@ describe Vx::Builder::DeployBuilder do
|
|
94
94
|
expect(config.env.global).to eq(['1'])
|
95
95
|
expect(config.env.matrix).to eq([])
|
96
96
|
end
|
97
|
+
|
98
|
+
it "should assign matrix_attributes to configuration" do
|
99
|
+
config = deploy.build.first
|
100
|
+
expect(config.matrix_attributes).to eq("rvm"=>"1.8.7", "scala"=>"2.10.1")
|
101
|
+
end
|
97
102
|
end
|
98
103
|
end
|
@@ -48,6 +48,10 @@ describe Vx::Builder::MatrixBuilder do
|
|
48
48
|
expect(subject.map(&:before_install).flatten).to eq ["echo before_install"] * 12
|
49
49
|
end
|
50
50
|
|
51
|
+
it "should assign matrix_attributes" do
|
52
|
+
expect(subject.map(&:matrix_attributes).flatten).to have(12).items
|
53
|
+
end
|
54
|
+
|
51
55
|
context "when empty configuration" do
|
52
56
|
let(:attributes) { {
|
53
57
|
"deploy" => "value"
|
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.3.
|
4
|
+
version: 0.3.4
|
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-06-
|
11
|
+
date: 2014-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vx-common
|
@@ -136,27 +136,16 @@ files:
|
|
136
136
|
- lib/vx/builder/matrix_builder.rb
|
137
137
|
- lib/vx/builder/script_builder.rb
|
138
138
|
- lib/vx/builder/script_builder/base.rb
|
139
|
-
- lib/vx/builder/script_builder/base.rb-e
|
140
139
|
- lib/vx/builder/script_builder/cache.rb
|
141
|
-
- lib/vx/builder/script_builder/cache.rb-e
|
142
140
|
- lib/vx/builder/script_builder/clojure.rb
|
143
|
-
- lib/vx/builder/script_builder/clojure.rb-e
|
144
141
|
- lib/vx/builder/script_builder/deploy.rb
|
145
|
-
- lib/vx/builder/script_builder/deploy.rb-e
|
146
142
|
- lib/vx/builder/script_builder/env.rb
|
147
|
-
- lib/vx/builder/script_builder/env.rb-e
|
148
143
|
- lib/vx/builder/script_builder/java.rb
|
149
|
-
- lib/vx/builder/script_builder/java.rb-e
|
150
144
|
- lib/vx/builder/script_builder/prepare.rb
|
151
|
-
- lib/vx/builder/script_builder/prepare.rb-e
|
152
145
|
- lib/vx/builder/script_builder/ruby.rb
|
153
|
-
- lib/vx/builder/script_builder/ruby.rb-e
|
154
146
|
- lib/vx/builder/script_builder/scala.rb
|
155
|
-
- lib/vx/builder/script_builder/scala.rb-e
|
156
147
|
- lib/vx/builder/script_builder/script.rb
|
157
|
-
- lib/vx/builder/script_builder/script.rb-e
|
158
148
|
- lib/vx/builder/script_builder/services.rb
|
159
|
-
- lib/vx/builder/script_builder/services.rb-e
|
160
149
|
- lib/vx/builder/task.rb
|
161
150
|
- lib/vx/builder/version.rb
|
162
151
|
- spec/fixtures/clojure.yml
|
@@ -1,59 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module Builder
|
3
|
-
class Script
|
4
|
-
|
5
|
-
Base = Struct.new(:app) do
|
6
|
-
|
7
|
-
include Helper::TraceShCommand
|
8
|
-
|
9
|
-
def do_cache_key(env)
|
10
|
-
yield env.cache_key
|
11
|
-
end
|
12
|
-
|
13
|
-
def do_script(env)
|
14
|
-
if env.source.script.empty? && !env.source.deploy_modules?
|
15
|
-
yield env.script
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def do_cached_directories(env)
|
20
|
-
if env.source.cached_directories != false
|
21
|
-
yield env.cached_directories
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def do_announce(env)
|
26
|
-
yield env.announce
|
27
|
-
end
|
28
|
-
|
29
|
-
def do_before_install(env)
|
30
|
-
yield env.before_install
|
31
|
-
end
|
32
|
-
|
33
|
-
def do_install(env)
|
34
|
-
yield env.install
|
35
|
-
end
|
36
|
-
|
37
|
-
def do_deploy_script(env)
|
38
|
-
if env.source.deploy_modules?
|
39
|
-
yield env.script
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def do_before_deploy(env)
|
44
|
-
if env.source.deploy_modules?
|
45
|
-
yield env.before_script
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def do_after_deploy(env)
|
50
|
-
if env.source.deploy_modules?
|
51
|
-
yield env.after_success
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module Builder
|
3
|
-
class Script
|
4
|
-
|
5
|
-
Cache = Struct.new(:app) do
|
6
|
-
|
7
|
-
include Helper::Config
|
8
|
-
|
9
|
-
CASHER_URL = "https://raw2.github.com/dima-exe/casher/master/bin/casher"
|
10
|
-
CASHER_BIN = "$HOME/.casher/bin/casher"
|
11
|
-
|
12
|
-
def call(env)
|
13
|
-
rs = app.call env
|
14
|
-
|
15
|
-
if env.task.cache_url_prefix && enabled?(env)
|
16
|
-
assign_url_to_env(env)
|
17
|
-
prepare(env)
|
18
|
-
fetch(env)
|
19
|
-
add(env)
|
20
|
-
push(env)
|
21
|
-
end
|
22
|
-
|
23
|
-
rs
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def enabled?(env)
|
29
|
-
!env.cached_directories.empty?
|
30
|
-
end
|
31
|
-
|
32
|
-
def casher_cmd
|
33
|
-
"test -f #{CASHER_BIN} && #{config.casher_ruby} #{CASHER_BIN}"
|
34
|
-
end
|
35
|
-
|
36
|
-
def assign_url_to_env(env)
|
37
|
-
urls = []
|
38
|
-
branch = env.task.branch
|
39
|
-
if branch != 'master'
|
40
|
-
urls << url_for(env, branch)
|
41
|
-
end
|
42
|
-
urls << url_for(env, 'master')
|
43
|
-
|
44
|
-
env.cache_fetch_url = urls
|
45
|
-
env.cache_push_url = url_for(env, branch)
|
46
|
-
env
|
47
|
-
end
|
48
|
-
|
49
|
-
def url_for(env, branch)
|
50
|
-
name = branch
|
51
|
-
|
52
|
-
key =
|
53
|
-
if env.cache_key.empty?
|
54
|
-
"cache"
|
55
|
-
else
|
56
|
-
env.cache_key.join("-").downcase.gsub(/[^a-z0-9_\-.]/, '-')
|
57
|
-
end
|
58
|
-
|
59
|
-
"#{env.task.cache_url_prefix}/#{name}/#{key}.tgz"
|
60
|
-
end
|
61
|
-
|
62
|
-
def prepare(env)
|
63
|
-
cmd = %{
|
64
|
-
export CASHER_DIR=$HOME/.casher &&
|
65
|
-
( mkdir -p $CASHER_DIR/bin &&
|
66
|
-
/usr/bin/curl #{CASHER_URL} -s -o #{CASHER_BIN} &&
|
67
|
-
chmod +x #{CASHER_BIN} ) ||
|
68
|
-
true
|
69
|
-
}.gsub(/\n/, ' ').gsub(/ +/, ' ')
|
70
|
-
env.init << cmd
|
71
|
-
end
|
72
|
-
|
73
|
-
def fetch(env)
|
74
|
-
urls = env.cache_fetch_url.join(" ")
|
75
|
-
env.init << "#{casher_cmd} fetch #{urls} || true"
|
76
|
-
end
|
77
|
-
|
78
|
-
def add(env)
|
79
|
-
env.cached_directories.each do |d|
|
80
|
-
env.init << "#{casher_cmd} add #{d} || true"
|
81
|
-
end
|
82
|
-
env.init << "unset CASHER_DIR"
|
83
|
-
end
|
84
|
-
|
85
|
-
def push(env)
|
86
|
-
if env.cache_push_url
|
87
|
-
env.after_script << "#{casher_cmd} push #{env.cache_push_url}"
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module Builder
|
3
|
-
class Script
|
4
|
-
|
5
|
-
class Clojure < Base
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
if enabled?(env)
|
9
|
-
do_announce(env) do |i|
|
10
|
-
i << trace_sh_command("lein version")
|
11
|
-
end
|
12
|
-
|
13
|
-
do_install(env) do |i|
|
14
|
-
i << trace_sh_command("lein deps")
|
15
|
-
end
|
16
|
-
|
17
|
-
do_script(env) do |i|
|
18
|
-
i << trace_sh_command("lein test")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
app.call(env)
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def enabled?(env)
|
28
|
-
env.source.language == 'clojure'
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module Builder
|
3
|
-
class Script
|
4
|
-
|
5
|
-
class Deploy < Base
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
do_before_deploy(env) do |e|
|
9
|
-
env.source.before_deploy.each do |c|
|
10
|
-
e << trace_sh_command(c)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
do_deploy_script(env) do |e|
|
15
|
-
env.source.deploy_modules.each do |m|
|
16
|
-
m.to_commands.each do |c|
|
17
|
-
e << trace_sh_command(c)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
do_after_deploy(env) do |e|
|
23
|
-
env.source.after_deploy.each do |c|
|
24
|
-
e << trace_sh_command(c)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
app.call(env)
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module Builder
|
3
|
-
class Script
|
4
|
-
|
5
|
-
class Env < Base
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
env.init << "set -e"
|
9
|
-
env.init << "export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
10
|
-
env.init << 'export LC_ALL=en_US.UTF8'
|
11
|
-
env.init << 'export DEBIAN_FRONTEND=noninteractive'
|
12
|
-
|
13
|
-
export_vars(env, env.init)
|
14
|
-
export_vars(env, env.after_script_init)
|
15
|
-
|
16
|
-
env.source.env.global.each do |e|
|
17
|
-
env.init << trace_sh_command("export #{e}")
|
18
|
-
end
|
19
|
-
app.call(env)
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def export_vars(env, collection)
|
25
|
-
collection << "export CI_JOB_ID=#{env.task.job_id}"
|
26
|
-
collection << "export CI_BUILD_ID=#{env.task.build_id}"
|
27
|
-
|
28
|
-
if b = env.task.branch
|
29
|
-
collection << "export CI_BRANCH=#{b}"
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module Builder
|
3
|
-
class Script
|
4
|
-
|
5
|
-
class Java < Base
|
6
|
-
|
7
|
-
def call(env)
|
8
|
-
if java(env)
|
9
|
-
do_cache_key(env) do |i|
|
10
|
-
i << "jdk-#{java env}"
|
11
|
-
end
|
12
|
-
|
13
|
-
do_before_install(env) do |i|
|
14
|
-
i << "source $(which jdk_switcher.sh)"
|
15
|
-
i << trace_sh_command("jdk_switcher use #{java env}")
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
app.call(env)
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def java(env)
|
25
|
-
env.source.jdk.first
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
require 'vx/common'
|
2
|
-
|
3
|
-
module Vx
|
4
|
-
module Builder
|
5
|
-
class Script
|
6
|
-
|
7
|
-
Prepare = Struct.new(:app) do
|
8
|
-
|
9
|
-
include Helper::TraceShCommand
|
10
|
-
include Common::Helper::UploadShCommand
|
11
|
-
|
12
|
-
def call(env)
|
13
|
-
name = env.task.name
|
14
|
-
deploy_key = env.task.deploy_key
|
15
|
-
|
16
|
-
repo_path = "${VX_ROOT}/code/#{name}"
|
17
|
-
data_path = "${VX_ROOT}/data/#{name}"
|
18
|
-
key_file = "#{data_path}/key"
|
19
|
-
git_ssh_file = "#{data_path}/git_ssh"
|
20
|
-
|
21
|
-
sha = env.task.sha
|
22
|
-
scm = build_scm(env, sha, repo_path)
|
23
|
-
git_ssh = scm.git_ssh_content(deploy_key && "#{key_file}")
|
24
|
-
|
25
|
-
env.init.tap do |i|
|
26
|
-
i << 'export VX_ROOT=$(pwd)'
|
27
|
-
|
28
|
-
i << "mkdir -p #{data_path}"
|
29
|
-
i << "mkdir -p #{repo_path}"
|
30
|
-
|
31
|
-
if deploy_key
|
32
|
-
i << upload_sh_command(key_file, deploy_key)
|
33
|
-
i << "chmod 0600 #{key_file}"
|
34
|
-
i << "export VX_PRIVATE_KEY=#{key_file}"
|
35
|
-
end
|
36
|
-
|
37
|
-
i << upload_sh_command(git_ssh_file, git_ssh)
|
38
|
-
i << "chmod 0750 #{git_ssh_file}"
|
39
|
-
|
40
|
-
i << "export GIT_SSH=#{git_ssh_file}"
|
41
|
-
i << scm.fetch_cmd
|
42
|
-
i << "unset GIT_SSH"
|
43
|
-
|
44
|
-
i << 'echo "Starting SSH Agent"'
|
45
|
-
i << 'eval "$(ssh-agent)"'
|
46
|
-
i << "ssh-add $VX_PRIVATE_KEY"
|
47
|
-
|
48
|
-
i << "cd #{repo_path}"
|
49
|
-
end
|
50
|
-
|
51
|
-
env.after_script_init.tap do |i|
|
52
|
-
i << 'export VX_ROOT=$(pwd)'
|
53
|
-
i << "cd #{repo_path}"
|
54
|
-
end
|
55
|
-
|
56
|
-
app.call env
|
57
|
-
end
|
58
|
-
|
59
|
-
private
|
60
|
-
|
61
|
-
def build_scm(env, sha, path)
|
62
|
-
Common::Git.new(env.task.src,
|
63
|
-
sha,
|
64
|
-
path,
|
65
|
-
branch: env.task.branch,
|
66
|
-
pull_request_id: env.task.pull_request_id)
|
67
|
-
end
|
68
|
-
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
@@ -1,80 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module Builder
|
3
|
-
class Script
|
4
|
-
|
5
|
-
class Ruby < Base
|
6
|
-
|
7
|
-
DEFAULT_RUBY = '1.9.3'
|
8
|
-
|
9
|
-
def call(env)
|
10
|
-
if enabled?(env)
|
11
|
-
do_cache_key(env) do |i|
|
12
|
-
i << "rvm-#{ruby env}"
|
13
|
-
i << gemfile(env)
|
14
|
-
end
|
15
|
-
|
16
|
-
do_before_install(env) do |i|
|
17
|
-
i << 'eval "$(rbenv init -)" || true'
|
18
|
-
i << "rbenv shell #{make_rbenv_version_command env}"
|
19
|
-
i << trace_sh_command("export BUNDLE_GEMFILE=${PWD}/#{gemfile(env)}")
|
20
|
-
i << trace_sh_command('export GEM_HOME=~/.rubygems')
|
21
|
-
end
|
22
|
-
|
23
|
-
do_announce(env) do |i|
|
24
|
-
i << trace_sh_command("ruby --version")
|
25
|
-
i << trace_sh_command("gem --version")
|
26
|
-
i << trace_sh_command("bundle --version")
|
27
|
-
end
|
28
|
-
|
29
|
-
do_install(env) do |i|
|
30
|
-
bundler_args = env.source.bundler_args.first
|
31
|
-
i << trace_sh_command("bundle install #{bundler_args}")
|
32
|
-
i << trace_sh_command("bundle clean --force")
|
33
|
-
end
|
34
|
-
|
35
|
-
do_script(env) do |i|
|
36
|
-
script = "if [ -f Rakefile ] ; then \n #{trace_sh_command "bundle exec rake"}\nfi"
|
37
|
-
i << script
|
38
|
-
end
|
39
|
-
|
40
|
-
do_cached_directories(env) do |i|
|
41
|
-
i << "~/.rubygems"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
app.call(env)
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def enabled?(env)
|
51
|
-
env.source.rvm.first || env.source.language == 'ruby'
|
52
|
-
end
|
53
|
-
|
54
|
-
def ruby(env)
|
55
|
-
env.source.rvm.first || DEFAULT_RUBY
|
56
|
-
end
|
57
|
-
|
58
|
-
def gemfile(env)
|
59
|
-
env.source.gemfile.first || "Gemfile"
|
60
|
-
end
|
61
|
-
|
62
|
-
def make_rbenv_version_command(env)
|
63
|
-
select_rbenv_version(env)
|
64
|
-
end
|
65
|
-
|
66
|
-
def select_rbenv_version(env)
|
67
|
-
%{
|
68
|
-
$(rbenv versions |
|
69
|
-
sed -e 's/^\*/ /' |
|
70
|
-
awk '{print $1}' |
|
71
|
-
grep -v 'system' |
|
72
|
-
grep '#{ruby env}' |
|
73
|
-
tail -n1)
|
74
|
-
}.gsub(/\n/, ' ').gsub(/ +/, ' ').strip
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module Builder
|
3
|
-
class Script
|
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
|
@@ -1,32 +0,0 @@
|
|
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
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Vx
|
2
|
-
module Builder
|
3
|
-
class Script
|
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
|