dockly 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/dockly/build_cache.rb +9 -2
- data/lib/dockly/version.rb +1 -1
- data/spec/dockly/build_cache_spec.rb +46 -15
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
data/lib/dockly/build_cache.rb
CHANGED
@@ -44,6 +44,8 @@ class Dockly::BuildCache
|
|
44
44
|
|
45
45
|
def run_build
|
46
46
|
container = image.run(build_command)
|
47
|
+
status = container.wait(3600)['StatusCode'] # 1 hour max timeout
|
48
|
+
raise "Build Cache `#{build_command}` failed to run." unless status.zero?
|
47
49
|
cache = copy_output_dir(container)
|
48
50
|
debug "pushing #{output_dir} to s3"
|
49
51
|
push_to_s3(cache)
|
@@ -55,7 +57,9 @@ class Dockly::BuildCache
|
|
55
57
|
ensure_present! :output_dir
|
56
58
|
if cache = pull_from_s3(version)
|
57
59
|
debug "inserting to #{output_dir}"
|
58
|
-
|
60
|
+
container = image.run("mkdir #{File.dirname(output_dir)}")
|
61
|
+
image_with_dir = container.tap { |c| c.wait }.commit
|
62
|
+
self.image = image_with_dir.insert_local(
|
59
63
|
'localPath' => cache.path,
|
60
64
|
'outputPath' => File.dirname(output_dir)
|
61
65
|
)
|
@@ -113,7 +117,10 @@ class Dockly::BuildCache
|
|
113
117
|
ensure_present! :image, :hash_command
|
114
118
|
@hash_output ||= begin
|
115
119
|
resp = ""
|
116
|
-
image.run(hash_command)
|
120
|
+
container = image.run(hash_command)
|
121
|
+
container.attach { |chunk| resp += chunk }
|
122
|
+
status = container.wait['StatusCode']
|
123
|
+
raise "Hash Command `#{hash_command} failed to run" unless status.zero?
|
117
124
|
resp.strip
|
118
125
|
end
|
119
126
|
end
|
data/lib/dockly/version.rb
CHANGED
@@ -8,7 +8,7 @@ describe Dockly::BuildCache, :docker do
|
|
8
8
|
subject.s3_bucket 'lol'
|
9
9
|
subject.s3_object_prefix 'swag'
|
10
10
|
subject.image = image
|
11
|
-
subject.hash_command '
|
11
|
+
subject.hash_command 'md5sum /etc/vim/vimrc'
|
12
12
|
subject.build_command 'touch lol'
|
13
13
|
subject.output_dir '/'
|
14
14
|
end
|
@@ -26,8 +26,7 @@ describe Dockly::BuildCache, :docker do
|
|
26
26
|
it "does not have the file lol" do
|
27
27
|
i = subject.execute!
|
28
28
|
output = ""
|
29
|
-
|
30
|
-
i.run('ls').start.attach { |chunk| output += chunk }
|
29
|
+
i.run('ls').attach { |chunk| output += chunk }
|
31
30
|
output.should_not include('lol')
|
32
31
|
end
|
33
32
|
end
|
@@ -49,17 +48,36 @@ describe Dockly::BuildCache, :docker do
|
|
49
48
|
subject.stub(:push_to_s3)
|
50
49
|
end
|
51
50
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
51
|
+
context "when the build succeeds" do
|
52
|
+
it "does have the file lol" do
|
53
|
+
i = subject.run_build
|
54
|
+
output = ""
|
55
|
+
i.run('ls').attach { |chunk| output += chunk }
|
56
|
+
output.should include('lol')
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when the build fails" do
|
61
|
+
let!(:image) { subject.image }
|
62
|
+
before do
|
63
|
+
subject.image = double(:image).stub(:run) {
|
64
|
+
stub(:container, { :wait => { 'StatusCode' => 1 } })
|
65
|
+
}
|
66
|
+
end
|
67
|
+
|
68
|
+
after do
|
69
|
+
subject.image = image
|
70
|
+
end
|
71
|
+
|
72
|
+
it "raises an error" do
|
73
|
+
expect { subject.run_build }.to raise_error
|
74
|
+
end
|
57
75
|
end
|
58
76
|
end
|
59
77
|
|
60
78
|
describe '#pull_from_s3' do
|
61
|
-
let
|
62
|
-
let
|
79
|
+
let(:file) { subject.pull_from_s3('hey') }
|
80
|
+
let(:object) { double(:object) }
|
63
81
|
|
64
82
|
before do
|
65
83
|
subject.connection.stub(:get_object).and_return object
|
@@ -99,13 +117,26 @@ describe Dockly::BuildCache, :docker do
|
|
99
117
|
"682aa2a07693cc27756eee9751db3903 /etc/vim/vimrc"
|
100
118
|
}
|
101
119
|
|
102
|
-
|
103
|
-
|
104
|
-
|
120
|
+
context "when hash command returns successfully" do
|
121
|
+
before do
|
122
|
+
subject.image = image
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'returns the output of the hash_command in the container' do
|
126
|
+
subject.hash_output.should == output
|
127
|
+
end
|
105
128
|
end
|
106
129
|
|
107
|
-
|
108
|
-
|
130
|
+
context "when hash command returns failure" do
|
131
|
+
before do
|
132
|
+
subject.image = double(:image).stub(:run, {
|
133
|
+
:wait => { 'StatusCode' => 1 }
|
134
|
+
})
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'raises an error' do
|
138
|
+
expect { subject.hash_output }.to raise_error
|
139
|
+
end
|
109
140
|
end
|
110
141
|
end
|
111
142
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dockly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: clamp
|