buildbox 0.6.2 → 0.7.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -16
- data/buildbox.gemspec +5 -7
- data/lib/buildbox.rb +2 -0
- data/lib/buildbox/api.rb +13 -71
- data/lib/buildbox/artifact/poster.rb +19 -22
- data/lib/buildbox/artifact/uploader.rb +4 -4
- data/lib/buildbox/build.rb +7 -3
- data/lib/buildbox/cli.rb +2 -2
- data/lib/buildbox/command.rb +17 -21
- data/lib/buildbox/configuration.rb +10 -7
- data/lib/buildbox/connection.rb +88 -0
- data/lib/buildbox/model.rb +15 -0
- data/lib/buildbox/monitor.rb +1 -1
- data/lib/buildbox/server.rb +5 -2
- data/lib/buildbox/version.rb +1 -1
- data/spec/integration/running_a_build_spec.rb +1 -2
- metadata +20 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c826fa8d512aa4840866a5c42d71739e8e7a5f5
|
4
|
+
data.tar.gz: 0c8573bf2fed15b3a1b1a9985186e1cad0a94269
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80fe44701584eceef7d1876cda79d8da7421023eb3c52644f1e54adf232f2322e474e69b5c2ed722fc1e36a3a8e65b7a07e798d6166473c24ebe855939426748
|
7
|
+
data.tar.gz: 1e4bbd814110f6f5ade70580876447567cb1736bb537e87999577195f1f0aa1d0adaf00bee96153ab2db38facd877249555a21bf87aabac2b7b009f0888e16a8
|
data/Gemfile.lock
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
buildbox (0.6
|
5
|
-
celluloid (~> 0.
|
4
|
+
buildbox (0.6)
|
5
|
+
celluloid (~> 0.15)
|
6
6
|
childprocess (~> 0.3)
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
mime-types (~> 2.0)
|
11
|
-
multi_json (~> 1.7)
|
7
|
+
mime-types (~> 2)
|
8
|
+
multipart-post (~> 2)
|
9
|
+
oj (~> 2.5)
|
12
10
|
|
13
11
|
GEM
|
14
12
|
remote: https://rubygems.org/
|
@@ -16,23 +14,18 @@ GEM
|
|
16
14
|
addressable (2.3.5)
|
17
15
|
celluloid (0.15.2)
|
18
16
|
timers (~> 1.1.0)
|
19
|
-
childprocess (0.4.
|
17
|
+
childprocess (0.4.0)
|
20
18
|
ffi (~> 1.0, >= 1.0.11)
|
21
19
|
crack (0.4.1)
|
22
20
|
safe_yaml (~> 0.9.0)
|
23
21
|
diff-lcs (1.2.5)
|
24
22
|
docile (1.1.0)
|
25
|
-
faraday (0.8.9)
|
26
|
-
multipart-post (~> 1.2.0)
|
27
|
-
faraday_middleware (0.9.0)
|
28
|
-
faraday (>= 0.7.4, < 0.9)
|
29
23
|
ffi (1.9.3)
|
30
|
-
ffi (1.9.3-x86-mingw32)
|
31
|
-
hashie (2.0.5)
|
32
24
|
lockfile (2.1.0)
|
33
|
-
mime-types (2.
|
25
|
+
mime-types (2.0)
|
34
26
|
multi_json (1.8.2)
|
35
|
-
multipart-post (
|
27
|
+
multipart-post (2.0.0)
|
28
|
+
oj (2.5.4)
|
36
29
|
rake (10.1.0)
|
37
30
|
rspec (2.14.1)
|
38
31
|
rspec-core (~> 2.14.0)
|
data/buildbox.gemspec
CHANGED
@@ -18,13 +18,11 @@ 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_dependency '
|
22
|
-
spec.add_dependency '
|
23
|
-
spec.add_dependency '
|
24
|
-
spec.add_dependency '
|
25
|
-
spec.add_dependency '
|
26
|
-
spec.add_dependency 'childprocess', '~> 0.3'
|
27
|
-
spec.add_dependency 'mime-types', '~> 2.0'
|
21
|
+
spec.add_dependency 'oj', '~> 2.5'
|
22
|
+
spec.add_dependency 'celluloid', '~> 0.15'
|
23
|
+
spec.add_dependency 'childprocess', '~> 0.3'
|
24
|
+
spec.add_dependency 'multipart-post', '~> 2'
|
25
|
+
spec.add_dependency 'mime-types', '~> 2'
|
28
26
|
|
29
27
|
spec.add_development_dependency 'rake'
|
30
28
|
spec.add_development_dependency 'rspec'
|
data/lib/buildbox.rb
CHANGED
@@ -6,10 +6,12 @@ module Buildbox
|
|
6
6
|
autoload :Artifact, "buildbox/artifact"
|
7
7
|
autoload :Build, "buildbox/build"
|
8
8
|
autoload :Command, "buildbox/command"
|
9
|
+
autoload :Connection, "buildbox/connection"
|
9
10
|
autoload :Canceler, "buildbox/canceler"
|
10
11
|
autoload :CLI, "buildbox/cli"
|
11
12
|
autoload :Configuration, "buildbox/configuration"
|
12
13
|
autoload :Monitor, "buildbox/monitor"
|
14
|
+
autoload :Model, "buildbox/model"
|
13
15
|
autoload :Platform, "buildbox/platform"
|
14
16
|
autoload :Runner, "buildbox/runner"
|
15
17
|
autoload :Script, "buildbox/script"
|
data/lib/buildbox/api.rb
CHANGED
@@ -1,29 +1,6 @@
|
|
1
|
-
require 'faraday'
|
2
|
-
require 'faraday_middleware'
|
3
|
-
require 'hashie/mash'
|
4
|
-
require 'delegate'
|
5
|
-
|
6
1
|
module Buildbox
|
7
2
|
class API
|
8
|
-
|
9
|
-
# DEBUG mode, it's kinda useless noise. So we use a ProxyLogger to only push
|
10
|
-
# the information we care about to the logger.
|
11
|
-
class ProxyLogger
|
12
|
-
def initialize(logger)
|
13
|
-
@logger = logger
|
14
|
-
end
|
15
|
-
|
16
|
-
def info(*args)
|
17
|
-
@logger.debug(*args)
|
18
|
-
end
|
19
|
-
|
20
|
-
def debug(*args)
|
21
|
-
# no-op
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class AgentNotFoundError < Faraday::Error::ClientError; end
|
26
|
-
class ServerError < Faraday::Error::ClientError; end
|
3
|
+
class AgentNotFoundError < StandardError; end
|
27
4
|
|
28
5
|
def initialize(config = Buildbox.config, logger = Buildbox.logger)
|
29
6
|
@config = config
|
@@ -31,19 +8,15 @@ module Buildbox
|
|
31
8
|
end
|
32
9
|
|
33
10
|
def agent(access_token, options)
|
34
|
-
put
|
35
|
-
rescue
|
36
|
-
|
37
|
-
raise AgentNotFoundError.new(e, e.response)
|
38
|
-
else
|
39
|
-
raise ServerError.new(e, e.response)
|
40
|
-
end
|
11
|
+
connection.request(:put, access_token, options)
|
12
|
+
rescue Buildbox::Connection::NotFoundError => e
|
13
|
+
raise AgentNotFoundError.new(e.message)
|
41
14
|
end
|
42
15
|
|
43
16
|
def next_build(access_token)
|
44
|
-
response = get
|
17
|
+
response = connection.request(:get, "#{access_token}/builds/queue/next")
|
45
18
|
|
46
|
-
if build = response
|
19
|
+
if build = response['build']
|
47
20
|
Buildbox::Build.new(build)
|
48
21
|
else
|
49
22
|
nil
|
@@ -51,56 +24,25 @@ module Buildbox
|
|
51
24
|
end
|
52
25
|
|
53
26
|
def update_build(access_token, build, options)
|
54
|
-
put
|
27
|
+
connection.request(:put, "#{access_token}/builds/#{build.id}", options)
|
55
28
|
end
|
56
29
|
|
57
30
|
def create_artifacts(access_token, build, artifacts)
|
58
|
-
post
|
31
|
+
connection.request(:post, "#{access_token}/builds/#{build.id}/artifacts", :artifacts => artifacts.map(&:as_json))
|
59
32
|
end
|
60
33
|
|
61
34
|
def update_artifact(access_token, build, artifact_id, options)
|
62
|
-
put
|
35
|
+
connection.request(:put, "#{access_token}/builds/#{build.id}/artifacts/#{artifact_id}", options)
|
63
36
|
end
|
64
37
|
|
65
38
|
private
|
66
39
|
|
67
40
|
def connection
|
68
|
-
@connection ||=
|
69
|
-
|
70
|
-
faraday.request :retry
|
71
|
-
faraday.request :json
|
72
|
-
|
73
|
-
faraday.response :logger, ProxyLogger.new(@logger)
|
74
|
-
faraday.response :mashify
|
75
|
-
|
76
|
-
# JSON needs to come after mashify as it needs to run before the mashify
|
77
|
-
# middleware.
|
78
|
-
faraday.response :json
|
79
|
-
faraday.response :raise_error
|
80
|
-
|
81
|
-
faraday.adapter Faraday.default_adapter
|
82
|
-
|
83
|
-
# Set some sensible defaults on the adapter.
|
84
|
-
faraday.options[:timeout] = 60
|
85
|
-
faraday.options[:open_timeout] = 60
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def post(path, body = {})
|
90
|
-
connection.post(path) do |request|
|
91
|
-
request.body = body
|
92
|
-
request.headers['Content-Type'] = 'application/json'
|
93
|
-
end.body
|
94
|
-
end
|
95
|
-
|
96
|
-
def put(path, body = {})
|
97
|
-
connection.put(path) do |request|
|
98
|
-
request.body = body
|
99
|
-
end.body
|
100
|
-
end
|
41
|
+
@connection ||= begin
|
42
|
+
ca_file = Buildbox.gem_path.join("lib", "certs", "cacert.pem").to_s
|
101
43
|
|
102
|
-
|
103
|
-
|
44
|
+
Buildbox::Connection.new(@logger, @config.api_endpoint, ca_file)
|
45
|
+
end
|
104
46
|
end
|
105
47
|
end
|
106
48
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'celluloid'
|
2
|
-
require '
|
2
|
+
require 'net/http/post/multipart'
|
3
|
+
require 'mime-types'
|
3
4
|
|
4
5
|
module Buildbox
|
5
6
|
class Artifact::Poster
|
@@ -8,40 +9,36 @@ module Buildbox
|
|
8
9
|
|
9
10
|
def post(api, access_token, build, artifact)
|
10
11
|
upload_action = artifact.upload_instructions['action']
|
11
|
-
form_data
|
12
|
-
|
13
|
-
connection = Faraday.new(:url => upload_action['url']) do |faraday|
|
14
|
-
faraday.request :multipart
|
15
|
-
|
16
|
-
faraday.response :raise_error
|
17
|
-
|
18
|
-
faraday.options[:timeout] = 60
|
19
|
-
faraday.options[:open_timeout] = 60
|
20
|
-
|
21
|
-
faraday.adapter Faraday.default_adapter
|
22
|
-
end
|
12
|
+
form_data = artifact.upload_instructions['data']
|
23
13
|
|
24
14
|
mime_type = MIME::Types.type_for(artifact.path)[0].to_s
|
25
15
|
|
16
|
+
# Assign the file to upload to the right key in the form
|
17
|
+
# data hash.
|
26
18
|
file_input_key = upload_action['file_input']
|
27
|
-
form_data[file_input_key] =
|
19
|
+
form_data[file_input_key] = UploadIO.new(artifact.path, mime_type)
|
28
20
|
|
21
|
+
# Let Buildbox know we've started the upload
|
29
22
|
api.update_artifact(access_token, build, artifact.remote_id, :state => 'uploading')
|
30
23
|
|
31
|
-
|
32
|
-
response
|
24
|
+
# Do the file upload
|
25
|
+
response = begin
|
26
|
+
uri = URI.join(upload_action['url'], upload_action['path'])
|
33
27
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
28
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
29
|
+
http.open_timeout = 64
|
30
|
+
http.read_timeout = 64
|
31
|
+
http.use_ssl = uri.scheme == "https"
|
32
|
+
|
33
|
+
http.request(Net::HTTP::Post::Multipart.new(uri.path, form_data))
|
34
|
+
rescue => upload_exception
|
35
|
+
end
|
39
36
|
|
40
37
|
if upload_exception
|
41
38
|
error "Error uploading #{artifact.basename} with a status of (#{upload_exception.class.name}: #{upload_exception.message})"
|
42
39
|
finished_state = 'error'
|
43
40
|
else
|
44
|
-
info "Finished uploading #{artifact.basename} with a status of #{response.
|
41
|
+
info "Finished uploading #{artifact.basename} with a status of #{response.code}"
|
45
42
|
finished_state = 'finished'
|
46
43
|
end
|
47
44
|
|
@@ -7,10 +7,10 @@ module Buildbox
|
|
7
7
|
include Celluloid::Logger
|
8
8
|
|
9
9
|
def initialize(api, access_token, build, artifacts)
|
10
|
-
@api
|
10
|
+
@api = api
|
11
11
|
@access_token = access_token
|
12
|
-
@build
|
13
|
-
@artifacts
|
12
|
+
@build = build
|
13
|
+
@artifacts = artifacts
|
14
14
|
end
|
15
15
|
|
16
16
|
def prepare_and_upload
|
@@ -20,7 +20,7 @@ module Buildbox
|
|
20
20
|
responses.each do |response|
|
21
21
|
artifact = @artifacts.find { |artifact| artifact.id == response['id'] }
|
22
22
|
|
23
|
-
artifact.remote_id
|
23
|
+
artifact.remote_id = response['artifact']['id']
|
24
24
|
artifact.upload_instructions = response['artifact']['uploader']
|
25
25
|
end
|
26
26
|
|
data/lib/buildbox/build.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
require 'hashie/mash'
|
2
|
-
|
3
1
|
module Buildbox
|
4
|
-
class Build
|
2
|
+
class Build
|
3
|
+
include Buildbox::Model
|
4
|
+
|
5
|
+
attr_accessor :id, :script, :env, :namespace,
|
6
|
+
:started_at, :output, :exit_status, :finished_at,
|
7
|
+
:process, :artifact_paths
|
8
|
+
|
5
9
|
def success?
|
6
10
|
exit_status == 0
|
7
11
|
end
|
data/lib/buildbox/cli.rb
CHANGED
@@ -59,8 +59,8 @@ module Buildbox
|
|
59
59
|
end
|
60
60
|
|
61
61
|
access_token = @argv.first
|
62
|
-
|
63
|
-
Buildbox.config.update(:agent_access_tokens =>
|
62
|
+
agent_access_tokens = Buildbox.config.agent_access_tokens
|
63
|
+
Buildbox.config.update(:agent_access_tokens => agent_access_tokens << access_token)
|
64
64
|
|
65
65
|
puts "Successfully added agent access token"
|
66
66
|
puts "You can now start the agent with: buildbox agent:start."
|
data/lib/buildbox/command.rb
CHANGED
@@ -26,9 +26,9 @@ module Buildbox
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def initialize(*args)
|
29
|
-
@options
|
29
|
+
@options = args.last.is_a?(Hash) ? args.pop : {}
|
30
30
|
@arguments = args.dup
|
31
|
-
@logger
|
31
|
+
@logger = Buildbox.logger
|
32
32
|
end
|
33
33
|
|
34
34
|
def arguments
|
@@ -55,9 +55,9 @@ module Buildbox
|
|
55
55
|
IO.pipe
|
56
56
|
end
|
57
57
|
|
58
|
-
process.io.stdout
|
59
|
-
process.io.stderr
|
60
|
-
process.duplex
|
58
|
+
process.io.stdout = write_pipe
|
59
|
+
process.io.stderr = write_pipe
|
60
|
+
process.duplex = true
|
61
61
|
|
62
62
|
# Set the environment on the process
|
63
63
|
if @options[:environment]
|
@@ -66,14 +66,20 @@ module Buildbox
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
# Record the start time for timeout purposes
|
70
|
+
start_time = Time.now.to_i
|
71
|
+
|
72
|
+
# Track the output as it goes
|
73
|
+
output = ""
|
74
|
+
|
69
75
|
# Start the process
|
70
76
|
process.start
|
71
77
|
|
78
|
+
@logger.debug("Process #{arguments} started with PID: #{process.pid}")
|
79
|
+
|
72
80
|
# Make sure the stdin does not buffer
|
73
81
|
process.io.stdin.sync = true
|
74
82
|
|
75
|
-
@logger.debug("Process #{arguments} started with PID: #{process.pid}")
|
76
|
-
|
77
83
|
if RUBY_PLATFORM != "java"
|
78
84
|
# On Java, we have to close after. See down the method...
|
79
85
|
# Otherwise, we close the writer right here, since we're
|
@@ -81,28 +87,18 @@ module Buildbox
|
|
81
87
|
write_pipe.close
|
82
88
|
end
|
83
89
|
|
84
|
-
# Record the start time for timeout purposes
|
85
|
-
start_time = Time.now.to_i
|
86
|
-
|
87
|
-
# Track the output as it goes
|
88
|
-
output = ""
|
89
|
-
|
90
|
-
@logger.debug("Selecting on IO")
|
91
90
|
while true
|
92
91
|
results = IO.select([read_pipe], nil, nil, timeout || 0.1) || []
|
93
92
|
readers = results[0]
|
94
93
|
|
95
94
|
# Check if we have exceeded our timeout
|
96
95
|
raise TimeoutExceeded if timeout && (Time.now.to_i - start_time) > timeout
|
97
|
-
# Kill the process and wait a bit for it to disappear
|
98
|
-
# Process.kill('KILL', process.pid)
|
99
|
-
# Process.waitpid2(process.pid)
|
100
96
|
|
101
97
|
# Check the readers to see if they're ready
|
102
98
|
if readers && !readers.empty?
|
103
99
|
readers.each do |r|
|
104
100
|
# Read from the IO object
|
105
|
-
data =
|
101
|
+
data = read_until_block(r)
|
106
102
|
|
107
103
|
# We don't need to do anything if the data is empty
|
108
104
|
next if data.empty?
|
@@ -136,7 +132,7 @@ module Buildbox
|
|
136
132
|
# process exited.
|
137
133
|
|
138
134
|
# Read the extra data
|
139
|
-
extra_data =
|
135
|
+
extra_data = read_until_block(read_pipe)
|
140
136
|
|
141
137
|
# If there's some that we missed
|
142
138
|
if extra_data != ""
|
@@ -150,7 +146,7 @@ module Buildbox
|
|
150
146
|
write_pipe.close
|
151
147
|
end
|
152
148
|
|
153
|
-
@output
|
149
|
+
@output = output.chomp
|
154
150
|
@exit_status = process.exit_code
|
155
151
|
end
|
156
152
|
|
@@ -161,7 +157,7 @@ module Buildbox
|
|
161
157
|
# data.
|
162
158
|
#
|
163
159
|
# @return [String]
|
164
|
-
def
|
160
|
+
def read_until_block(io)
|
165
161
|
data = ""
|
166
162
|
|
167
163
|
while true
|
@@ -1,20 +1,21 @@
|
|
1
|
-
require 'hashie/mash'
|
2
1
|
require 'json'
|
3
2
|
|
4
3
|
module Buildbox
|
5
|
-
class Configuration
|
4
|
+
class Configuration
|
5
|
+
include Buildbox::Model
|
6
|
+
|
6
7
|
def agent_access_tokens
|
7
8
|
env_agents = ENV['BUILDBOX_AGENTS']
|
8
9
|
|
9
10
|
if env_agents.nil?
|
10
|
-
|
11
|
+
@agent_access_tokens || []
|
11
12
|
else
|
12
13
|
env_agents.to_s.split(",")
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
16
17
|
def api_endpoint
|
17
|
-
endpoint = ENV['BUILDBOX_API_ENDPOINT'] ||
|
18
|
+
endpoint = ENV['BUILDBOX_API_ENDPOINT'] || @api_endpoint || "https://agent.buildbox.io/v1"
|
18
19
|
|
19
20
|
# hack to update legacy endpoints
|
20
21
|
if endpoint == "https://api.buildbox.io/v1"
|
@@ -27,7 +28,8 @@ module Buildbox
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def update(attributes)
|
30
|
-
attributes
|
31
|
+
self.attributes = attributes
|
32
|
+
|
31
33
|
save
|
32
34
|
end
|
33
35
|
|
@@ -46,11 +48,12 @@ module Buildbox
|
|
46
48
|
private
|
47
49
|
|
48
50
|
def pretty_json
|
49
|
-
JSON.pretty_generate(
|
51
|
+
JSON.pretty_generate(:agent_access_tokens => agent_access_tokens,
|
52
|
+
:api_endpoint => api_endpoint)
|
50
53
|
end
|
51
54
|
|
52
55
|
def read_and_load
|
53
|
-
|
56
|
+
self.attributes = JSON.parse(path.read)
|
54
57
|
end
|
55
58
|
|
56
59
|
def path
|
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'oj'
|
4
|
+
|
5
|
+
module Buildbox
|
6
|
+
class Connection
|
7
|
+
class Error < StandardError; end
|
8
|
+
class NotFoundError < Error; end
|
9
|
+
class UnexpectedResponseError < Error; end
|
10
|
+
|
11
|
+
def initialize(logger, endpoint, ca_file)
|
12
|
+
@logger = logger
|
13
|
+
@endpoint = URI.parse(endpoint)
|
14
|
+
@ca_file = ca_file
|
15
|
+
end
|
16
|
+
|
17
|
+
def request(method, path, body = nil)
|
18
|
+
# Poor mans URI concatination
|
19
|
+
path = File.join(@endpoint.request_uri, path)
|
20
|
+
attempts = 3
|
21
|
+
|
22
|
+
begin
|
23
|
+
@logger.debug "#{method} #{path}"
|
24
|
+
|
25
|
+
response = case method
|
26
|
+
when :get
|
27
|
+
http.get(path)
|
28
|
+
when :post
|
29
|
+
http.post(path, dump_request_json(body), headers)
|
30
|
+
when :put
|
31
|
+
http.put(path, dump_request_json(body), headers)
|
32
|
+
end
|
33
|
+
|
34
|
+
handle_response(response)
|
35
|
+
rescue => e
|
36
|
+
if (attempts -= 1).zero?
|
37
|
+
raise e
|
38
|
+
else
|
39
|
+
retry
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def headers
|
47
|
+
{ "Content-Type" => "application/json" }
|
48
|
+
end
|
49
|
+
|
50
|
+
def dump_request_json(json)
|
51
|
+
# Compact ensures symbols get turned into strings
|
52
|
+
Oj.dump(json, :mode => :compat)
|
53
|
+
end
|
54
|
+
|
55
|
+
def parse_response_json(response)
|
56
|
+
if response.content_type == "application/json"
|
57
|
+
Oj.load(response.body)
|
58
|
+
else
|
59
|
+
raise UnexpectedResponseError.new(response.body[0..100])
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def handle_response(response)
|
64
|
+
case response.code.to_i
|
65
|
+
when 200...300
|
66
|
+
parse_response_json(response)
|
67
|
+
when 404
|
68
|
+
raise NotFoundError.new(parse_response_json(response))
|
69
|
+
else
|
70
|
+
raise UnexpectedResponseError.new(response.body)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def http
|
75
|
+
http = Net::HTTP.new(@endpoint.host, @endpoint.port)
|
76
|
+
http.open_timeout = 64
|
77
|
+
http.read_timeout = 64
|
78
|
+
|
79
|
+
if @endpoint.scheme == "https"
|
80
|
+
http.use_ssl = true
|
81
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
82
|
+
end
|
83
|
+
|
84
|
+
http.ca_file = @ca_file
|
85
|
+
http
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Buildbox
|
2
|
+
module Model
|
3
|
+
def initialize(attributes = {})
|
4
|
+
if attributes.kind_of?(Hash)
|
5
|
+
self.attributes = attributes
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def attributes=(attributes)
|
10
|
+
attributes.each_pair do |key, value|
|
11
|
+
instance_variable_set("@#{key}", value)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/buildbox/monitor.rb
CHANGED
@@ -23,7 +23,7 @@ module Buildbox
|
|
23
23
|
:output => @build.output,
|
24
24
|
:exit_status => @build.exit_status)
|
25
25
|
|
26
|
-
if updated_build
|
26
|
+
if updated_build['state'] == 'canceled' && !@build.cancelling?
|
27
27
|
Buildbox::Canceler.new(@build).async.cancel
|
28
28
|
end
|
29
29
|
|
data/lib/buildbox/server.rb
CHANGED
@@ -5,9 +5,10 @@ module Buildbox
|
|
5
5
|
INTERVAL = 5
|
6
6
|
|
7
7
|
def initialize(config = Buildbox.config, logger = Buildbox.logger)
|
8
|
-
@config
|
9
|
-
@logger
|
8
|
+
@config = config
|
9
|
+
@logger = logger
|
10
10
|
@supervisors = []
|
11
|
+
@iterations = 0
|
11
12
|
end
|
12
13
|
|
13
14
|
def start
|
@@ -25,6 +26,8 @@ module Buildbox
|
|
25
26
|
supervisor.actors.first.async.process
|
26
27
|
end
|
27
28
|
|
29
|
+
GC.start
|
30
|
+
|
28
31
|
wait INTERVAL
|
29
32
|
end
|
30
33
|
end
|
data/lib/buildbox/version.rb
CHANGED
@@ -6,7 +6,7 @@ describe 'running a build' do
|
|
6
6
|
let(:commit) { "3e0c65433b241ff2c59220f80bcdcd2ebb7e4b96" }
|
7
7
|
let(:command) { "rspec test_spec.rb" }
|
8
8
|
let(:env) { { } }
|
9
|
-
let(:build) { Buildbox::Build.new(:
|
9
|
+
let(:build) { Buildbox::Build.new(:namespace => "test/test", :id => 1, :script => script, :env => env) }
|
10
10
|
let(:runner) { Buildbox::Runner.new(build) }
|
11
11
|
let(:script) do
|
12
12
|
<<-SCRIPT
|
@@ -19,7 +19,6 @@ fi
|
|
19
19
|
git clean -fd
|
20
20
|
git fetch -q
|
21
21
|
git checkout -qf #{commit}
|
22
|
-
bundle install --local
|
23
22
|
#{command}
|
24
23
|
SCRIPT
|
25
24
|
end
|
metadata
CHANGED
@@ -1,113 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Keith Pitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: oj
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: '2.5'
|
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: '2.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0.9'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0.9'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: hashie
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: multi_json
|
28
|
+
name: celluloid
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
58
30
|
requirements:
|
59
31
|
- - "~>"
|
60
32
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
33
|
+
version: '0.15'
|
62
34
|
type: :runtime
|
63
35
|
prerelease: false
|
64
36
|
version_requirements: !ruby/object:Gem::Requirement
|
65
37
|
requirements:
|
66
38
|
- - "~>"
|
67
39
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
40
|
+
version: '0.15'
|
69
41
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
42
|
+
name: childprocess
|
71
43
|
requirement: !ruby/object:Gem::Requirement
|
72
44
|
requirements:
|
73
45
|
- - "~>"
|
74
46
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
47
|
+
version: '0.3'
|
76
48
|
type: :runtime
|
77
49
|
prerelease: false
|
78
50
|
version_requirements: !ruby/object:Gem::Requirement
|
79
51
|
requirements:
|
80
52
|
- - "~>"
|
81
53
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
54
|
+
version: '0.3'
|
83
55
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
56
|
+
name: multipart-post
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
86
58
|
requirements:
|
87
59
|
- - "~>"
|
88
60
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
61
|
+
version: '2'
|
90
62
|
type: :runtime
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
94
66
|
- - "~>"
|
95
67
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
68
|
+
version: '2'
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: mime-types
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
100
72
|
requirements:
|
101
73
|
- - "~>"
|
102
74
|
- !ruby/object:Gem::Version
|
103
|
-
version: '2
|
75
|
+
version: '2'
|
104
76
|
type: :runtime
|
105
77
|
prerelease: false
|
106
78
|
version_requirements: !ruby/object:Gem::Requirement
|
107
79
|
requirements:
|
108
80
|
- - "~>"
|
109
81
|
- !ruby/object:Gem::Version
|
110
|
-
version: '2
|
82
|
+
version: '2'
|
111
83
|
- !ruby/object:Gem::Dependency
|
112
84
|
name: rake
|
113
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,6 +165,8 @@ files:
|
|
193
165
|
- lib/buildbox/cli.rb
|
194
166
|
- lib/buildbox/command.rb
|
195
167
|
- lib/buildbox/configuration.rb
|
168
|
+
- lib/buildbox/connection.rb
|
169
|
+
- lib/buildbox/model.rb
|
196
170
|
- lib/buildbox/monitor.rb
|
197
171
|
- lib/buildbox/platform.rb
|
198
172
|
- lib/buildbox/runner.rb
|
@@ -287,9 +261,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
287
261
|
version: '0'
|
288
262
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
289
263
|
requirements:
|
290
|
-
- - "
|
264
|
+
- - ">"
|
291
265
|
- !ruby/object:Gem::Version
|
292
|
-
version:
|
266
|
+
version: 1.3.1
|
293
267
|
requirements: []
|
294
268
|
rubyforge_project:
|
295
269
|
rubygems_version: 2.2.0
|