vx-builder 0.0.4 → 0.0.5
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/script/env.rb +1 -1
- data/lib/vx/builder/script/prepare.rb +11 -9
- data/lib/vx/builder/version.rb +1 -1
- data/spec/lib/builder/script/env_spec.rb +22 -0
- data/spec/lib/builder/script/prepare_spec.rb +32 -0
- data/spec/support/create.rb +24 -5
- data/vx-builder.gemspec +1 -1
- metadata +10 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0532b05f9d5890cad0fd2b6a4097f0a24434cb2
|
4
|
+
data.tar.gz: d7242c8f70bd18dc7cc41aafab1a2d28c927b03c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94987973aca134b0db7e094d415cfb34dd4190d4e3210a9eb2a079d28c9d5f308902b56d86d002317453fe6e9a0199f9fceef7c789f91687f893b81f93924ece
|
7
|
+
data.tar.gz: 78b318295d9eb7e4283e200c983999c8d750d4dd2be907a2203a1fbafd30802c70076401a740ccde00ad96ba91530f669ed405904eff68af97bcb3264dd8f581
|
@@ -7,11 +7,11 @@ module Vx
|
|
7
7
|
include Helper::TraceShCommand
|
8
8
|
|
9
9
|
def call(env)
|
10
|
+
env.init << "set -e"
|
10
11
|
env.init << 'export LC_ALL=en_US.UTF8'
|
11
12
|
env.source.global_env.each do |e|
|
12
13
|
env.init << trace_sh_command("export #{e}")
|
13
14
|
end
|
14
|
-
env.announce << trace_sh_command("env")
|
15
15
|
app.call(env)
|
16
16
|
end
|
17
17
|
|
@@ -13,21 +13,22 @@ module Vx
|
|
13
13
|
name = env.task.name
|
14
14
|
deploy_key = env.task.deploy_key
|
15
15
|
|
16
|
-
repo_path = "code/#{name}"
|
17
|
-
data_path = "data/#{name}"
|
16
|
+
repo_path = "${VX_ROOT}/code/#{name}"
|
17
|
+
data_path = "${VX_ROOT}/data/#{name}"
|
18
18
|
key_file = "#{data_path}/key"
|
19
19
|
git_ssh_file = "#{data_path}/git_ssh"
|
20
20
|
|
21
21
|
sha = env.task.sha
|
22
22
|
scm = build_scm(env, sha, repo_path)
|
23
|
-
git_ssh = scm.
|
23
|
+
git_ssh = scm.git_ssh_content(deploy_key && "#{key_file}")
|
24
24
|
|
25
25
|
env.init.tap do |i|
|
26
|
-
i <<
|
27
|
-
|
26
|
+
i << 'export VX_ROOT=$(pwd)'
|
27
|
+
|
28
|
+
i << "mkdir -p #{data_path}"
|
29
|
+
i << "mkdir -p #{repo_path}"
|
28
30
|
|
29
31
|
if deploy_key
|
30
|
-
i << "echo instaling keys"
|
31
32
|
i << upload_sh_command(key_file, deploy_key)
|
32
33
|
i << "chmod 0600 #{key_file}"
|
33
34
|
end
|
@@ -35,9 +36,10 @@ module Vx
|
|
35
36
|
i << upload_sh_command(git_ssh_file, git_ssh)
|
36
37
|
i << "chmod 0750 #{git_ssh_file}"
|
37
38
|
|
38
|
-
i << "export GIT_SSH
|
39
|
-
i << scm.
|
39
|
+
i << "export GIT_SSH=#{git_ssh_file}"
|
40
|
+
i << scm.fetch_cmd
|
40
41
|
i << "unset GIT_SSH"
|
42
|
+
i << "cd #{repo_path}"
|
41
43
|
end
|
42
44
|
|
43
45
|
app.call env
|
@@ -46,7 +48,7 @@ module Vx
|
|
46
48
|
private
|
47
49
|
|
48
50
|
def build_scm(env, sha, path)
|
49
|
-
|
51
|
+
Common::Git.new(env.task.src,
|
50
52
|
sha,
|
51
53
|
"$PWD/#{path}",
|
52
54
|
branch: env.task.branch,
|
data/lib/vx/builder/version.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Vx::Builder::Script::Env do
|
4
|
+
let(:app) { ->(_) { 0 } }
|
5
|
+
let(:script) { described_class.new app }
|
6
|
+
let(:env) { create :env }
|
7
|
+
let(:run) { script.call env }
|
8
|
+
subject { run }
|
9
|
+
|
10
|
+
it { should eq 0 }
|
11
|
+
|
12
|
+
context "run it" do
|
13
|
+
let(:command) { create :command_from_env, env: env }
|
14
|
+
before { run }
|
15
|
+
|
16
|
+
it "should be success" do
|
17
|
+
system( command )
|
18
|
+
expect($?.to_i).to eq 0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
describe Vx::Builder::Script::Prepare do
|
6
|
+
let(:app) { ->(_) { 0 } }
|
7
|
+
let(:script) { described_class.new app }
|
8
|
+
let(:env) { create :env }
|
9
|
+
let(:run) { script.call env }
|
10
|
+
let(:path) { Dir.tmpdir }
|
11
|
+
subject { run }
|
12
|
+
|
13
|
+
before { FileUtils.rm_rf(path) }
|
14
|
+
after { FileUtils.rm_rf(path) }
|
15
|
+
|
16
|
+
it { should eq 0 }
|
17
|
+
|
18
|
+
context "run it" do
|
19
|
+
let(:command) { create :command_from_env, env: env }
|
20
|
+
before { run }
|
21
|
+
|
22
|
+
context "success" do
|
23
|
+
it "should return zero code" do
|
24
|
+
Dir.chdir(path) do
|
25
|
+
system( command )
|
26
|
+
end
|
27
|
+
expect($?.to_i).to eq 0
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
data/spec/support/create.rb
CHANGED
@@ -1,15 +1,34 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
1
3
|
def create(name, options = {})
|
2
4
|
case name
|
5
|
+
when :message
|
6
|
+
Vx::Message::PerformBuild.test_message
|
7
|
+
|
3
8
|
when :task
|
9
|
+
msg = create(:message)
|
4
10
|
Vx::Builder::Task.new(
|
5
11
|
'name',
|
6
|
-
|
7
|
-
|
8
|
-
deploy_key:
|
9
|
-
branch:
|
10
|
-
cache_url_prefix: "http://localhost"
|
12
|
+
msg.src,
|
13
|
+
msg.sha,
|
14
|
+
deploy_key: msg.deploy_key,
|
15
|
+
branch: msg.branch
|
11
16
|
)
|
17
|
+
|
12
18
|
when :source
|
13
19
|
Vx::Builder::Source.from_yaml(fixture("travis.yml"))
|
20
|
+
|
21
|
+
when :env
|
22
|
+
OpenStruct.new(
|
23
|
+
init: [],
|
24
|
+
source: create(:source),
|
25
|
+
task: create(:task)
|
26
|
+
)
|
27
|
+
|
28
|
+
when :command_from_env
|
29
|
+
env = options[:env]
|
30
|
+
a = ["set -e"]
|
31
|
+
a += env.init
|
32
|
+
a.join("\n")
|
14
33
|
end
|
15
34
|
end
|
data/vx-builder.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency 'vx-common'
|
21
|
+
spec.add_runtime_dependency 'vx-common', '0.3.0'
|
22
22
|
spec.add_runtime_dependency 'vx-message'
|
23
23
|
spec.add_runtime_dependency 'hashr'
|
24
24
|
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vx-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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-01-
|
11
|
+
date: 2014-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vx-common
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - '
|
17
|
+
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.3.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - '
|
24
|
+
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.3.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: vx-message
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,6 +144,8 @@ files:
|
|
144
144
|
- spec/fixtures/travis_bug_1.yml
|
145
145
|
- spec/fixtures/travis_bug_2.yml
|
146
146
|
- spec/lib/builder/configuration_spec.rb
|
147
|
+
- spec/lib/builder/script/env_spec.rb
|
148
|
+
- spec/lib/builder/script/prepare_spec.rb
|
147
149
|
- spec/lib/builder/script_spec.rb
|
148
150
|
- spec/lib/builder/source_matrix_spec.rb
|
149
151
|
- spec/lib/builder/source_spec.rb
|
@@ -182,6 +184,8 @@ test_files:
|
|
182
184
|
- spec/fixtures/travis_bug_1.yml
|
183
185
|
- spec/fixtures/travis_bug_2.yml
|
184
186
|
- spec/lib/builder/configuration_spec.rb
|
187
|
+
- spec/lib/builder/script/env_spec.rb
|
188
|
+
- spec/lib/builder/script/prepare_spec.rb
|
185
189
|
- spec/lib/builder/script_spec.rb
|
186
190
|
- spec/lib/builder/source_matrix_spec.rb
|
187
191
|
- spec/lib/builder/source_spec.rb
|