travis_dedup 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/travis_dedup.rb +29 -2
- data/lib/travis_dedup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a16be148e31528f8174764a66c9432df37a3c45
|
4
|
+
data.tar.gz: d9cbf5d59ddaa85f369acaf90a6c2a4864aa5a06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99650998edaf069bdb7e932cfa48813ab8c893862a01ce9169d71243dbe9c267bde6ab1f90b20499e9b5aae08b61c1a99b366114b807bef73c85719c3c722f42
|
7
|
+
data.tar.gz: f8c17cabb09465a4a680cb123f9c6df83dafecfc95085cd6bc8f7c9469f92246ee919a8b14061aa0963b92deb645fcd44577ea5f29aefe9f434ac6f8abb7074b
|
data/lib/travis_dedup.rb
CHANGED
@@ -5,8 +5,11 @@ require 'optparse'
|
|
5
5
|
module TravisDedup
|
6
6
|
ACTIVE = %w[created started queued]
|
7
7
|
|
8
|
+
RETRY = 3
|
9
|
+
class RetryWhen500 < StandardError; end
|
10
|
+
|
8
11
|
class << self
|
9
|
-
attr_accessor :pro, :verbose, :branches
|
12
|
+
attr_accessor :pro, :verbose, :branches, :retry_option, :ignore_error_500
|
10
13
|
|
11
14
|
def cli(argv)
|
12
15
|
parser = OptionParser.new do |opts|
|
@@ -20,6 +23,8 @@ module TravisDedup
|
|
20
23
|
BANNER
|
21
24
|
opts.on("--pro", "travis pro") { self.pro = true }
|
22
25
|
opts.on("--branches", "dedup builds on branches too") { self.branches = true }
|
26
|
+
opts.on("--retry [COUNT]", Integer, "number of times to retry when Travis returns a 500. #{RETRY} times by default") { |value| self.retry_option = value }
|
27
|
+
opts.on("--ignore-error-500", "let the build run when Travis API keeps returning 500") { self.ignore_error_500 = true }
|
23
28
|
opts.on("-h", "--help","Show this") { puts opts; exit }
|
24
29
|
opts.on('-v', '--version','Show Version'){ require 'travis_dedup/version'; puts TravisDedup::VERSION; exit}
|
25
30
|
end
|
@@ -30,7 +35,11 @@ module TravisDedup
|
|
30
35
|
return 1
|
31
36
|
end
|
32
37
|
|
33
|
-
|
38
|
+
begin
|
39
|
+
puts dedup_message(*argv)
|
40
|
+
rescue TravisDedup::RetryWhen500 => error
|
41
|
+
raise error unless ignore_error_500
|
42
|
+
end
|
34
43
|
0
|
35
44
|
end
|
36
45
|
|
@@ -98,10 +107,27 @@ module TravisDedup
|
|
98
107
|
end
|
99
108
|
|
100
109
|
def request(method, path, params, headers={})
|
110
|
+
attempts = 1
|
111
|
+
begin
|
112
|
+
faraday_send(method, path, params, headers)
|
113
|
+
rescue TravisDedup::RetryWhen500 => error
|
114
|
+
raise error if (attempts += 1) > max_attempts
|
115
|
+
puts "Travis returned an error 500. Retrying ..."
|
116
|
+
retry
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def max_attempts
|
121
|
+
retry_option || RETRY
|
122
|
+
end
|
123
|
+
|
124
|
+
def faraday_send(method, path, params, headers={})
|
101
125
|
response = Faraday.send(method, "#{host}/#{path}", params, headers)
|
102
126
|
case response.status
|
103
127
|
when 200 then JSON.parse(response.body)
|
104
128
|
when 204 then nil
|
129
|
+
when 500
|
130
|
+
raise TravisDedup::RetryWhen500
|
105
131
|
else
|
106
132
|
raise(
|
107
133
|
Faraday::Error,
|
@@ -110,5 +136,6 @@ module TravisDedup
|
|
110
136
|
)
|
111
137
|
end
|
112
138
|
end
|
139
|
+
|
113
140
|
end
|
114
141
|
end
|
data/lib/travis_dedup/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: travis_dedup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|