vx-builder 0.0.12 → 0.0.13
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 +0 -5
- data/lib/vx/builder/configuration.rb +2 -5
- data/lib/vx/builder/script.rb +11 -10
- data/lib/vx/builder/script/cache.rb +9 -3
- data/lib/vx/builder/script/ruby.rb +6 -2
- data/lib/vx/builder/source.rb +8 -0
- data/lib/vx/builder/version.rb +1 -1
- data/spec/fixtures/travis.yml +4 -0
- data/spec/lib/builder/configuration_spec.rb +1 -2
- data/spec/lib/builder/script/cache_spec.rb +12 -0
- data/spec/lib/builder/script/ruby_spec.rb +11 -8
- data/spec/lib/builder/source_spec.rb +31 -3
- data/spec/lib/builder_spec.rb +0 -1
- data/spec/support/create.rb +4 -2
- metadata +4 -3
- data/lib/vx/builder/helper/logger.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2337275d42297ff4b29ba6182f58b872f98eaa64
|
4
|
+
data.tar.gz: 6064c28dc12fbf2f69f2e609b650c64bbd8bdea8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71dc59d14727f7b33483d8e480a6e81764ecc19fe95cd6b815af0be0b05857d47d5f254e2bd9811b4b106d48aca2549ef477722e30438ca641b75967ed12e400
|
7
|
+
data.tar.gz: a5a89fc805bb85257eaa20013e0462aeb3dbf7b67b4409fe56ae696df1437dac2a8c5fa6efc9e79d494b1175fab13418c22a658cd90d5fc70f22ccabfd317d32
|
data/lib/vx/builder.rb
CHANGED
@@ -9,7 +9,6 @@ module Vx
|
|
9
9
|
|
10
10
|
module Helper
|
11
11
|
autoload :Config, File.expand_path("../builder/helper/config", __FILE__)
|
12
|
-
autoload :Logger, File.expand_path("../builder/helper/logger", __FILE__)
|
13
12
|
autoload :TraceShCommand, File.expand_path("../builder/helper/trace_sh_command", __FILE__)
|
14
13
|
end
|
15
14
|
|
@@ -17,10 +16,6 @@ module Vx
|
|
17
16
|
|
18
17
|
extend self
|
19
18
|
|
20
|
-
def logger
|
21
|
-
config.logger
|
22
|
-
end
|
23
|
-
|
24
19
|
def configure
|
25
20
|
yield config if block_given?
|
26
21
|
config
|
@@ -1,6 +1,4 @@
|
|
1
1
|
require 'hashr'
|
2
|
-
require 'logger'
|
3
|
-
require 'vx/common/tagged_logging'
|
4
2
|
|
5
3
|
module Vx
|
6
4
|
module Builder
|
@@ -8,11 +6,10 @@ module Vx
|
|
8
6
|
|
9
7
|
extend Hashr::EnvDefaults
|
10
8
|
|
11
|
-
self.env_namespace
|
9
|
+
self.env_namespace = 'vx'
|
12
10
|
self.raise_missing_keys = true
|
13
11
|
|
14
|
-
define
|
15
|
-
casher_ruby: "/usr/local/rbenv/versions/1.9.3-p484/bin/ruby"
|
12
|
+
define casher_ruby: "/usr/local/rbenv/versions/1.9.3-p484/bin/ruby"
|
16
13
|
|
17
14
|
end
|
18
15
|
end
|
data/lib/vx/builder/script.rb
CHANGED
@@ -72,24 +72,25 @@ module Vx
|
|
72
72
|
def default_env
|
73
73
|
OpenStruct.new(
|
74
74
|
# initialization, repo does not exists
|
75
|
-
init:
|
75
|
+
init: [],
|
76
76
|
|
77
77
|
# before instalation, using for system setup
|
78
|
-
before_install:
|
78
|
+
before_install: [],
|
79
79
|
|
80
80
|
# instalation, using for application setup
|
81
|
-
install:
|
81
|
+
install: [],
|
82
82
|
|
83
83
|
# announce software and services version
|
84
|
-
announce:
|
84
|
+
announce: [],
|
85
85
|
|
86
|
-
before_script:
|
87
|
-
script:
|
88
|
-
after_script:
|
86
|
+
before_script: [],
|
87
|
+
script: [],
|
88
|
+
after_script: [],
|
89
89
|
|
90
|
-
source:
|
91
|
-
task:
|
92
|
-
cache_key:
|
90
|
+
source: source,
|
91
|
+
task: task,
|
92
|
+
cache_key: [],
|
93
|
+
cached_directories: []
|
93
94
|
)
|
94
95
|
end
|
95
96
|
|
@@ -5,7 +5,6 @@ module Vx
|
|
5
5
|
Cache = Struct.new(:app) do
|
6
6
|
|
7
7
|
include Helper::Config
|
8
|
-
include Helper::Logger
|
9
8
|
|
10
9
|
CASHER_URL = "https://raw2.github.com/dima-exe/casher/master/bin/casher"
|
11
10
|
CASHER_BIN = "$HOME/.casher/bin/casher"
|
@@ -13,7 +12,7 @@ module Vx
|
|
13
12
|
def call(env)
|
14
13
|
rs = app.call env
|
15
14
|
|
16
|
-
if env.task.cache_url_prefix
|
15
|
+
if env.task.cache_url_prefix && enabled?(env)
|
17
16
|
assign_url_to_env(env)
|
18
17
|
prepare(env)
|
19
18
|
fetch(env)
|
@@ -26,6 +25,11 @@ module Vx
|
|
26
25
|
|
27
26
|
private
|
28
27
|
|
28
|
+
def enabled?(env)
|
29
|
+
puts env.cached_directories.inspect
|
30
|
+
!env.cached_directories.empty?
|
31
|
+
end
|
32
|
+
|
29
33
|
def casher_cmd
|
30
34
|
"test -f #{CASHER_BIN} && #{config.casher_ruby} #{CASHER_BIN}"
|
31
35
|
end
|
@@ -73,7 +77,9 @@ module Vx
|
|
73
77
|
end
|
74
78
|
|
75
79
|
def add(env)
|
76
|
-
env.
|
80
|
+
env.cached_directories.each do |d|
|
81
|
+
env.init << "#{casher_cmd} add #{d} || true"
|
82
|
+
end
|
77
83
|
env.init << "unset CASHER_DIR"
|
78
84
|
end
|
79
85
|
|
@@ -13,8 +13,8 @@ module Vx
|
|
13
13
|
env.before_install.tap do |i|
|
14
14
|
i << 'eval "$(rbenv init -)" || true'
|
15
15
|
i << "rbenv shell #{make_rbenv_version_command env}"
|
16
|
-
i << "export BUNDLE_GEMFILE=${PWD}/#{gemfile(env)}"
|
17
|
-
i << 'export GEM_HOME
|
16
|
+
i << trace_sh_command("export BUNDLE_GEMFILE=${PWD}/#{gemfile(env)}")
|
17
|
+
i << trace_sh_command('export GEM_HOME=~/.rubygems')
|
18
18
|
end
|
19
19
|
|
20
20
|
env.announce.tap do |a|
|
@@ -27,6 +27,10 @@ module Vx
|
|
27
27
|
i << trace_sh_command("bundle install")
|
28
28
|
i << trace_sh_command("bundle clean --force")
|
29
29
|
end
|
30
|
+
|
31
|
+
if env.source.cached_directories != false
|
32
|
+
env.cached_directories.push "~/.rubygems"
|
33
|
+
end
|
30
34
|
end
|
31
35
|
|
32
36
|
app.call(env)
|
data/lib/vx/builder/source.rb
CHANGED
@@ -52,6 +52,14 @@ module Vx
|
|
52
52
|
attributes["env"]["global"]
|
53
53
|
end
|
54
54
|
|
55
|
+
def cached_directories
|
56
|
+
if attributes["cache"] == false
|
57
|
+
false
|
58
|
+
else
|
59
|
+
(attributes["cache"] && attributes["cache"]["directories"]) || []
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
55
63
|
AS_ARRAY.each do |m|
|
56
64
|
define_method m do
|
57
65
|
@attributes[m] || []
|
data/lib/vx/builder/version.rb
CHANGED
data/spec/fixtures/travis.yml
CHANGED
@@ -1,25 +1,28 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Vx::Builder::Script::Ruby do
|
4
|
-
let(:app) { ->(
|
4
|
+
let(:app) { ->(env) { env } }
|
5
5
|
let(:script) { described_class.new app }
|
6
6
|
let(:env) { create :env }
|
7
7
|
let(:run) { script.call env }
|
8
8
|
subject { run }
|
9
9
|
|
10
|
-
it { should eq
|
10
|
+
it { should eq env }
|
11
11
|
|
12
12
|
context "run it" do
|
13
13
|
let(:command) { create :command_from_env, env: env }
|
14
|
-
|
14
|
+
subject { env }
|
15
15
|
|
16
|
-
|
17
|
-
puts env
|
18
|
-
puts command
|
16
|
+
before { run }
|
19
17
|
|
20
|
-
|
21
|
-
|
18
|
+
context "should be success" do
|
19
|
+
its(:before_install) { should_not be_empty }
|
20
|
+
its(:announce) { should_not be_empty }
|
21
|
+
its(:install) { should_not be_empty }
|
22
|
+
its(:cached_directories) { should eq %w{ ~/.rubygems } }
|
22
23
|
end
|
24
|
+
|
25
|
+
|
23
26
|
end
|
24
27
|
|
25
28
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Vx::Builder::Source do
|
4
|
-
let(:
|
5
|
-
let(:
|
4
|
+
let(:default_content) { YAML.load fixture('travis.yml') }
|
5
|
+
let(:content) { default_content }
|
6
|
+
let(:config) { described_class.from_attributes content }
|
6
7
|
subject { config }
|
7
8
|
|
8
9
|
its(:attributes) { should be }
|
@@ -24,6 +25,27 @@ describe Vx::Builder::Source do
|
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
28
|
+
context "cached_directories" do
|
29
|
+
subject { config.cached_directories }
|
30
|
+
context "when cache is false" do
|
31
|
+
let(:content) { default_content.merge("cache" => false) }
|
32
|
+
it { should be_false }
|
33
|
+
end
|
34
|
+
context "when cache is nil" do
|
35
|
+
let(:content) { default_content.delete("cache") && default_content }
|
36
|
+
it { should eq [] }
|
37
|
+
end
|
38
|
+
|
39
|
+
context "when cache.directories is nil" do
|
40
|
+
let(:content) { default_content["cache"].delete("directories") && default_content }
|
41
|
+
it { should eq [] }
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when exists" do
|
45
|
+
it { should eq ["~/.cache"] }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
27
49
|
context "(serialization)" do
|
28
50
|
|
29
51
|
context "build new instance" do
|
@@ -31,6 +53,9 @@ describe Vx::Builder::Source do
|
|
31
53
|
"rvm" => ["2.0.0"],
|
32
54
|
"gemfile" => ["Gemfile"],
|
33
55
|
"before_script" => ["echo before_script"],
|
56
|
+
"cache" => {
|
57
|
+
"directories"=>["~/.cache"]
|
58
|
+
},
|
34
59
|
"before_install" => ["echo before_install"],
|
35
60
|
"script" => ["RAILS_ENV=test ls -1 && echo DONE!"],
|
36
61
|
"env" => {
|
@@ -55,7 +80,10 @@ describe Vx::Builder::Source do
|
|
55
80
|
gemfile: "Gemfile",
|
56
81
|
before_script: "echo before_script",
|
57
82
|
before_install: "echo before_install",
|
58
|
-
script: "RAILS_ENV=test ls -1 && echo DONE!"
|
83
|
+
script: "RAILS_ENV=test ls -1 && echo DONE!",
|
84
|
+
cache: {
|
85
|
+
"directories" => ["~/.cache"]
|
86
|
+
}
|
59
87
|
}}
|
60
88
|
subject { described_class.from_attributes(attrs).attributes }
|
61
89
|
it { should eq expected }
|
data/spec/lib/builder_spec.rb
CHANGED
data/spec/support/create.rb
CHANGED
@@ -12,7 +12,8 @@ def create(name, options = {})
|
|
12
12
|
msg.src,
|
13
13
|
msg.sha,
|
14
14
|
deploy_key: msg.deploy_key,
|
15
|
-
branch: msg.branch
|
15
|
+
branch: msg.branch,
|
16
|
+
cache_url_prefix: "http://example.com/"
|
16
17
|
)
|
17
18
|
|
18
19
|
when :source
|
@@ -29,7 +30,8 @@ def create(name, options = {})
|
|
29
30
|
after_script: [],
|
30
31
|
source: create(:source),
|
31
32
|
task: create(:task),
|
32
|
-
cache_key: []
|
33
|
+
cache_key: [],
|
34
|
+
cached_directories: []
|
33
35
|
)
|
34
36
|
|
35
37
|
when :command_from_env
|
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.0.
|
4
|
+
version: 0.0.13
|
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-02-
|
11
|
+
date: 2014-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: vx-common
|
@@ -125,7 +125,6 @@ files:
|
|
125
125
|
- lib/vx/builder.rb
|
126
126
|
- lib/vx/builder/configuration.rb
|
127
127
|
- lib/vx/builder/helper/config.rb
|
128
|
-
- lib/vx/builder/helper/logger.rb
|
129
128
|
- lib/vx/builder/helper/trace_sh_command.rb
|
130
129
|
- lib/vx/builder/script.rb
|
131
130
|
- lib/vx/builder/script/cache.rb
|
@@ -144,6 +143,7 @@ files:
|
|
144
143
|
- spec/fixtures/travis_bug_1.yml
|
145
144
|
- spec/fixtures/travis_bug_2.yml
|
146
145
|
- spec/lib/builder/configuration_spec.rb
|
146
|
+
- spec/lib/builder/script/cache_spec.rb
|
147
147
|
- spec/lib/builder/script/env_spec.rb
|
148
148
|
- spec/lib/builder/script/prepare_spec.rb
|
149
149
|
- spec/lib/builder/script/ruby_spec.rb
|
@@ -185,6 +185,7 @@ test_files:
|
|
185
185
|
- spec/fixtures/travis_bug_1.yml
|
186
186
|
- spec/fixtures/travis_bug_2.yml
|
187
187
|
- spec/lib/builder/configuration_spec.rb
|
188
|
+
- spec/lib/builder/script/cache_spec.rb
|
188
189
|
- spec/lib/builder/script/env_spec.rb
|
189
190
|
- spec/lib/builder/script/prepare_spec.rb
|
190
191
|
- spec/lib/builder/script/ruby_spec.rb
|