Skip to content

Commit c08f382

Browse files
committed
travis: Make more network requests retryable
This commit attempts to move more network operations to being retryable through various operations. For example git submodule updates, downloading snapshots, etc, are now all in retryable steps. Hopefully this commit can cut down on the number of network failures we've been seeing!
1 parent 1572bf1 commit c08f382

File tree

6 files changed

+48
-11
lines changed

6 files changed

+48
-11
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ matrix:
4545
os: osx
4646
osx_image: xcode8.2
4747
install: &osx_install_sccache >
48-
curl -o /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-apple-darwin &&
48+
travis_retry curl -o /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-apple-darwin &&
4949
chmod +x /usr/local/bin/sccache
5050
- env: >
5151
RUST_CHECK_TARGET=check
@@ -63,7 +63,7 @@ matrix:
6363
os: osx
6464
osx_image: xcode8.2
6565
install: >
66-
curl -o /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-apple-darwin &&
66+
travis_retry curl -o /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-apple-darwin &&
6767
chmod +x /usr/local/bin/sccache &&
6868
brew uninstall --ignore-dependencies openssl &&
6969
brew install openssl --universal --without-test

appveyor.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ install:
103103
# /usr/bin/python2.7.exe is not. To ensure we use the right interpreter we
104104
# move `C:\Python27` ahead in PATH and then also make sure the `python2.7.exe`
105105
# file exists in there (which it doesn't by default).
106-
- if defined MINGW_URL appveyor DownloadFile %MINGW_URL%/%MINGW_ARCHIVE%
106+
- if defined MINGW_URL appveyor-retry appveyor DownloadFile %MINGW_URL%/%MINGW_ARCHIVE%
107107
- if defined MINGW_URL 7z x -y %MINGW_ARCHIVE% > nul
108108
- if defined MINGW_URL set PATH=%CD%\%MINGW_DIR%\bin;C:\msys64\usr\bin;%PATH%
109109

@@ -115,12 +115,12 @@ install:
115115
- set PATH=C:\Python27;%PATH%
116116

117117
# Download and install sccache
118-
- appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-pc-windows-msvc
118+
- appveyor-retry appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-02-24-sccache-x86_64-pc-windows-msvc
119119
- mv 2017-02-24-sccache-x86_64-pc-windows-msvc sccache
120120
- set PATH=%PATH%;%CD%
121121

122122
# Install InnoSetup to get `iscc` used to produce installers
123-
- choco install -y InnoSetup
123+
- appveyor-retry choco install -y InnoSetup
124124
- set PATH="C:\Program Files (x86)\Inno Setup 5";%PATH%
125125

126126
# Help debug some handle issues on AppVeyor
@@ -131,7 +131,7 @@ install:
131131
- handle.exe -accepteula -help
132132

133133
test_script:
134-
- git submodule update --init
134+
- appveyor-retry sh -c 'git submodule deinit -f . && git submodule update --init'
135135
- set SRC=.
136136
- set NO_CCACHE=1
137137
- sh src/ci/run.sh

src/bootstrap/mk/Makefile.in

+2
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ install:
7171
$(Q)$(BOOTSTRAP) dist --install $(BOOTSTRAP_ARGS)
7272
tidy:
7373
$(Q)$(BOOTSTRAP) test src/tools/tidy $(BOOTSTRAP_ARGS)
74+
prepare:
75+
$(Q)$(BOOTSTRAP) build nonexistent/path/to/trigger/cargo/metadata
7476

7577
check-stage2-T-arm-linux-androideabi-H-x86_64-unknown-linux-gnu:
7678
$(Q)$(BOOTSTRAP) test --target arm-linux-androideabi

src/ci/docker/run.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
33
# file at the top-level directory of this distribution and at
44
# http://rust-lang.org/COPYRIGHT.
@@ -19,7 +19,9 @@ ci_dir="`dirname $docker_dir`"
1919
src_dir="`dirname $ci_dir`"
2020
root_dir="`dirname $src_dir`"
2121

22-
docker \
22+
source "$ci_dir/shared.sh"
23+
24+
retry docker \
2325
build \
2426
--rm \
2527
-t rust-ci \

src/ci/run.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/bin/sh
1+
#!/bin/bash
22
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
33
# file at the top-level directory of this distribution and at
44
# http://rust-lang.org/COPYRIGHT.
@@ -20,6 +20,9 @@ if [ "$NO_CHANGE_USER" = "" ]; then
2020
fi
2121
fi
2222

23+
ci_dir=`cd $(dirname $0) && pwd`
24+
source "$ci_dir/shared.sh"
25+
2326
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache"
2427
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-quiet-tests"
2528
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
@@ -54,16 +57,17 @@ else
5457
fi
5558
fi
5659

57-
set -ex
58-
5960
$SRC/configure $RUST_CONFIGURE_ARGS
61+
retry make prepare
6062

6163
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
6264
ncpus=$(sysctl -n hw.ncpu)
6365
else
6466
ncpus=$(grep processor /proc/cpuinfo | wc -l)
6567
fi
6668

69+
set -x
70+
6771
if [ ! -z "$SCRIPT" ]; then
6872
sh -x -c "$SCRIPT"
6973
else

src/ci/shared.sh

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Copyright 2016 The Rust Project Developers. See the COPYRIGHT
3+
# file at the top-level directory of this distribution and at
4+
# http://rust-lang.org/COPYRIGHT.
5+
#
6+
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
7+
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
8+
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
9+
# option. This file may not be copied, modified, or distributed
10+
# except according to those terms.
11+
12+
# See http://unix.stackexchange.com/questions/82598
13+
function retry {
14+
local n=1
15+
local max=5
16+
local delay=15
17+
while true; do
18+
echo "Attempting:" "$@"
19+
"$@" && break || {
20+
if [[ $n -lt $max ]]; then
21+
((n++))
22+
echo "Command failed. Attempt $n/$max:"
23+
else
24+
echo "The command has failed after $n attempts."
25+
exit 1
26+
fi
27+
}
28+
done
29+
}

0 commit comments

Comments
 (0)