Skip to content

Commit

Permalink
Cache CI dependencies (#827)
Browse files Browse the repository at this point in the history
Motivation:

The CI quite often fails because we get rate limited when downloading
protobuf from GitHub. Let's try sticking it in the Travis cache; it
still has to be downloaded from there but hopefully we won't get rate
limited.

Modifications:

- Cache protobuf
- Remove .build cache (the cache is currently *huge* and fetching this probably
  slows things down)

Result:

- Maybe fewer CI failures?
  • Loading branch information
glbrntt authored Jun 8, 2020
1 parent caaaa5f commit bc51201
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
31 changes: 24 additions & 7 deletions .travis-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

# Update .travis.yml if this changes.
BIN_CACHE="$HOME"/bin_cache
ZIP_CACHE="$HOME"/zip_cache

PROTOBUF_VERSION=3.9.1
# We need this to build gRPC C++ for the interop test server(s).
Expand All @@ -54,18 +55,33 @@ install_protoc() {
echo -en 'travis_fold:start:install.protoc\\r'
info "Installing protoc $PROTOBUF_VERSION"

# Install protoc
# Which protoc are we using?
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
PROTOC_URL=https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-osx-x86_64.zip
PROTOC_ZIP=protoc-${PROTOBUF_VERSION}-osx-x86_64.zip
else
PROTOC_URL=https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
PROTOC_ZIP=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
fi

info "Downloading protoc from: $PROTOC_URL"
curl -fSsL $PROTOC_URL -o protoc.zip
CACHED_PROTOC_ZIP="$ZIP_CACHE/$PROTOC_ZIP"

# Is it cached?
if [ ! -f "$CACHED_PROTOC_ZIP" ]; then
# No: download it.
PROTOC_URL=https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_ZIP}
info "Downloading protoc from: $PROTOC_URL"
if curl -fSsL "$PROTOC_URL" -o "$CACHED_PROTOC_ZIP"; then
info "Downloaded protoc from: $PROTOC_URL"
else
info "Downloading protoc failed, removing artifacts"
rm "$CACHED_PROTOC_ZIP"
exit 1
fi
else
info "Using cached protoc"
fi

info "Extracting protoc from protoc.zip"
unzip -q protoc.zip -d local
info "Extracting protoc from $CACHED_PROTOC_ZIP"
unzip -q "$CACHED_PROTOC_ZIP" -d local
success "Installed protoc $PROTOBUF_VERSION"
echo -en 'travis_fold:end:install.protoc\\r'
}
Expand Down Expand Up @@ -169,6 +185,7 @@ build_grpc_cpp_server() {
main() {
cd
mkdir -p local "$BIN_CACHE"
mkdir -p local "$ZIP_CACHE"

install_protoc
install_swift
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ stages:
cache:
apt: true
directories:
- .build
- $HOME/bin_cache
- $HOME/zip_cache

addons:
apt:
Expand Down

0 comments on commit bc51201

Please sign in to comment.