Skip to content

Commit 20f0809

Browse files
committed
Add some retries
Getting a lot of connection errors on the CI and it's annoying.
1 parent bd1577b commit 20f0809

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ env:
77
- RAILS_VERSION="~> 3.2.0"
88
- RAILS_VERSION="~> 4.0.0"
99
- RAILS_VERSION="~> 4.1.0.rc1"
10+
before_script:
11+
- travis_retry gem install rails --version "$RAILS_VERSION"

test/acceptance/helper.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,25 @@ def await_reload
220220
end
221221
end
222222

223-
def run!(*args)
224-
artifacts = run(*args)
225-
unless artifacts[:status].success?
223+
def run!(command, options = {})
224+
attempts = (options.delete(:retry) || 0) + 1
225+
artifacts = nil
226+
227+
until attempts == 0 || artifacts && artifacts[:status].success?
228+
artifacts = run(command, options)
229+
attempts -= 1
230+
end
231+
232+
if artifacts[:status].success?
233+
artifacts
234+
else
226235
raise "command failed\n\n#{debug(artifacts)}"
227236
end
228-
artifacts
229237
end
230238

231239
def bundle
232-
run! "(gem list bundler | grep bundler) || gem install bundler", timeout: nil
233-
run! "bundle update", timeout: nil
240+
run! "(gem list bundler | grep bundler) || gem install bundler", timeout: nil, retry: 2
241+
run! "bundle update --retry=2", timeout: nil
234242
end
235243

236244
private

0 commit comments

Comments
 (0)