Skip to content

Cache CI dependencies #827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -77,8 +77,8 @@ stages:
cache:
apt: true
directories:
- .build
- $HOME/bin_cache
- $HOME/zip_cache

addons:
apt:
Expand Down