buildbox 0.6.beta1 → 0.6.beta2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3bc1d049d31a8e693636be1d2ba1c70d5e77ad1c
4
- data.tar.gz: d3c3d7a151a411f969a5bd7c78c287c2432963cc
3
+ metadata.gz: d09a24715e1c3a79b74647a1b775b7166cdcf952
4
+ data.tar.gz: 124c2dad15dbe1e38273803411e2eb73095cee42
5
5
  SHA512:
6
- metadata.gz: 7b1183a3ed2a559bd6ec924962017ddb72dc5ec7c4bb74a123478c708f4c8a1093d87387c1f545357863a502e26ce8744b6c162695fe4aa96f6f468465689137
7
- data.tar.gz: bb03588ca98125193bfd1d5238a14ea3d87e5b3c63a82c08e9bcb05c66fb3b86581ab2b1eebb05e14efb59de44b4291635bf8d4e8df7602aa1f5046e5856fde0
6
+ metadata.gz: 039183e2b691d6f18c4e009ec9468bed4225f3d90d15c200ea72773e86f53646a49c6ab8791ad12dd124f185f7f5b23481e005b1b978a4760b599f9cdf6d43b6
7
+ data.tar.gz: e87d1f3ce2c272bee640828402baf01e28eca316b4319bed05598f35de6c89cb7d5f926f1e038329782080ab515c42ed741a5983e3cef81cb7672466ac284daa
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- buildbox (0.6.beta1)
4
+ buildbox (0.6.beta2)
5
5
  celluloid (~> 0.14)
6
6
  childprocess (~> 0.3)
7
7
  faraday (~> 0.8)
@@ -27,7 +27,6 @@ GEM
27
27
  faraday_middleware (0.9.0)
28
28
  faraday (>= 0.7.4, < 0.9)
29
29
  ffi (1.9.3)
30
- ffi (1.9.3-x86-mingw32)
31
30
  hashie (2.0.5)
32
31
  lockfile (2.1.0)
33
32
  mime-types (2.0)
@@ -8,7 +8,6 @@ module Buildbox
8
8
  def initialize(access_token, api = Buildbox::API.new)
9
9
  @api = api
10
10
  @access_token = access_token
11
- @uploader_pool = Uploader.pool(:size => 10) # upload 10 things at a time
12
11
  end
13
12
 
14
13
  def process
@@ -46,13 +45,7 @@ module Buildbox
46
45
  files = Artifact.files_to_upload(build_directory, artifact_path)
47
46
 
48
47
  files.each_pair do |relative_path, absolute_path|
49
- artifact = @api.create_artifact(@access_token, @current_build,
50
- :path => relative_path,
51
- :file_size => File.size(absolute_path))
52
-
53
- @uploader_pool.upload(artifact[:uploader], absolute_path) do |state, response|
54
- @api.update_artifact(@access_token, @current_build, artifact[:id], :state => state)
55
- end
48
+ Celluloid::Actor[:uploader_pool].async.upload(@api, @access_token, @current_build, relative_path, absolute_path)
56
49
  end
57
50
  rescue => e
58
51
  error "There was an error uploading artifacts for path: #{artifact_path} (#{e.class.name}: #{e.message})"
@@ -12,6 +12,7 @@ module Buildbox
12
12
 
13
13
  def start
14
14
  Celluloid.logger = @logger
15
+ Celluloid::Actor[:uploader_pool] = Uploader.pool
15
16
 
16
17
  agent_access_tokens.each do |access_token|
17
18
  @supervisors << Buildbox::Agent.supervise(access_token)
@@ -6,15 +6,22 @@ module Buildbox
6
6
  include Celluloid
7
7
  include Celluloid::Logger
8
8
 
9
- def upload(credentials, absolute_path, &block)
9
+ def upload(api, access_token, current_build, relative_path, absolute_path)
10
10
  info "Uploading #{absolute_path}"
11
11
 
12
- action = credentials[:action]
13
- data = credentials[:data]
12
+ artifact = api.create_artifact(access_token, current_build,
13
+ :path => relative_path,
14
+ :file_size => File.size(absolute_path))
14
15
 
15
- connection = Faraday.new(:url => action[:url]) do |faraday|
16
+
17
+ upload_action = artifact[:uploader][:action]
18
+ form_data = artifact[:uploader][:data].to_hash.dup
19
+
20
+ connection = Faraday.new(:url => upload_action[:url]) do |faraday|
16
21
  faraday.request :multipart
17
22
 
23
+ faraday.response :raise_error
24
+
18
25
  faraday.options[:timeout] = 60
19
26
  faraday.options[:open_timeout] = 60
20
27
 
@@ -22,18 +29,30 @@ module Buildbox
22
29
  end
23
30
 
24
31
  mime_type = MIME::Types.type_for(absolute_path)[0].to_s
25
- file_input_key = action[:file_input]
26
32
 
27
- form_data = credentials[:data].to_hash.dup
33
+ file_input_key = upload_action[:file_input]
28
34
  form_data[file_input_key] = Faraday::UploadIO.new(absolute_path, mime_type)
29
35
 
30
- yield("uploading")
36
+ api.update_artifact(access_token, current_build, artifact[:id], :state => 'uploading')
31
37
 
32
- response = connection.post(action[:path], form_data)
38
+ upload_exception = nil
39
+ response = nil
33
40
 
34
- info "Finished uploading #{File.basename(absolute_path)} with a status of #{response.status}"
41
+ begin
42
+ response = connection.post(upload_action[:path], form_data)
43
+ rescue => e
44
+ upload_exception = e
45
+ end
46
+
47
+ if upload_exception
48
+ error "Error uploading #{File.basename(absolute_path)} with a status of (#{upload_exception.class.name}: #{upload_exception.message})"
49
+ finished_state = 'error'
50
+ else
51
+ info "Finished uploading #{File.basename(absolute_path)} with a status of #{response.status}"
52
+ finished_state = 'finished'
53
+ end
35
54
 
36
- yield("finished")
55
+ api.update_artifact(access_token, current_build, artifact[:id], :state => finished_state)
37
56
  end
38
57
  end
39
58
  end
@@ -1,3 +1,3 @@
1
1
  module Buildbox
2
- VERSION = "0.6.beta1"
2
+ VERSION = "0.6.beta2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.beta1
4
+ version: 0.6.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Pitt