lcoveralls 0.1.0 → 0.2.0

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.
@@ -23,10 +23,12 @@ module Lcoveralls
23
23
 
24
24
  def parse!(args)
25
25
  options = {
26
- :color => $stderr.isatty,
27
- :git => 'git',
28
- :service => File.basename($0),
29
- :severity => Logger::INFO
26
+ :color => $stderr.isatty,
27
+ :git => 'git',
28
+ :retry_count => 0,
29
+ :retry_interval => 10.0,
30
+ :service => File.basename($0),
31
+ :severity => Logger::INFO
30
32
  }
31
33
 
32
34
  if ENV.has_key? 'TRAVIS_JOB_NUMBER' then
@@ -54,6 +56,19 @@ module Lcoveralls
54
56
  o.on('-t', '--token TOKEN', 'Set coveralls repo token') { |token| options[:token] = token }
55
57
  o.separator ''
56
58
 
59
+ o.separator 'Network options:'
60
+ o.on('--timeout DURATION',
61
+ 'Timout, in seconds, for network open and read operations') do |duration|
62
+ options[:timeout] = duration.to_f
63
+ end
64
+ o.on('--retry-count COUNT', 'Number of times to retry sending to coveralls.io') do |count|
65
+ options[:retry_count] = count.to_i
66
+ end
67
+ o.on('--retry-interval DURATION', 'Time to wait between retries') do |count|
68
+ options[:retry_interval] = count.to_f;
69
+ end
70
+ o.separator ''
71
+
57
72
  o.separator 'Stderr output options:'
58
73
  o.on( '--[no-]color', 'Colorize output') { |color| options[:color] = color }
59
74
  o.on('-d', '--debug', 'Enable debugging') { options[:severity] = Logger::DEBUG }
@@ -159,6 +159,21 @@ module Lcoveralls
159
159
  end if Dir.exist?(root_dir)
160
160
  end
161
161
 
162
+ def should_retry
163
+ return false unless @options[:retry_count] > 0
164
+ @options[:retry_count] = @options[:retry_count] - 1;
165
+
166
+ if @options[:retry_interval] > 0 then
167
+ @log.info { "Sleeping for #{@options[:retry_interval]} seconds before retrying" }
168
+ begin
169
+ sleep @options[:retry_interval]
170
+ rescue Interrupt
171
+ return false
172
+ end
173
+ end
174
+ true
175
+ end
176
+
162
177
  def run
163
178
  # Find *.info tracefiles if none specified on the command line.
164
179
  Find.find('.') do |path|
@@ -197,13 +212,30 @@ module Lcoveralls
197
212
  # Send (if not in dryrun mode) the Coveralls API request.
198
213
  uri = URI('https://coveralls.io/api/v1/jobs')
199
214
  http = Net::HTTP.new(uri.host, uri.port)
215
+ http.open_timeout = @options[:timeout] if @options.has_key? :timeout
216
+ http.read_timeout = @options[:timeout] if @options.has_key? :timeout
217
+ http.ssl_timeout = @options[:timeout] if @options.has_key? :timeout
200
218
  http.use_ssl = true
201
219
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
202
220
 
203
221
  if !@options[:dryrun] then
204
- @log.debug { "Sending #{request.body.size} bytes to coveralls.io" }
205
- res = http.request(request)
206
- puts res.body if res
222
+ begin
223
+ @log.debug { "Sending #{request.body.size} bytes to coveralls.io" }
224
+ response = http.request(request)
225
+ @log.debug { "HTTP response status: #{response.code} #{response.message}" }
226
+ raise response.code unless response.is_a? Net::HTTPSuccess
227
+ puts response.body
228
+ rescue RuntimeError => e
229
+ raise unless response
230
+ @log.error { "Received non-OK response: #{response.code} #{response.message}" }
231
+ puts response.body
232
+ retry if should_retry unless response.is_a? Net::HTTPClientError
233
+ exit!
234
+ rescue SocketError => error
235
+ @log.error { error }
236
+ retry if should_retry
237
+ exit!
238
+ end
207
239
  end
208
240
  end
209
241
 
@@ -15,5 +15,5 @@
15
15
  #
16
16
 
17
17
  module Lcoveralls
18
- VERSION = [ 0, 1, 0 ]
18
+ VERSION = [ 0, 2, 0 ]
19
19
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lcoveralls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: