Skip to content

Commit

Permalink
{kokoro} Only upgrade gem/homebrew when needed. (#6261)
Browse files Browse the repository at this point in the history
Instead of updating both RubyGems and Homebrew at the beginning of the kokoro
script, they should only be updated if they're going to be used for an install
or update command.

Closes #6256
  • Loading branch information
Robert Moore committed Jan 11, 2019
1 parent 1721aa0 commit cf38baa
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 15 deletions.
22 changes: 7 additions & 15 deletions .kokoro
Expand Up @@ -14,14 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Make sure both Homebrew and RubyGems are up to date
brew --version
brew update
brew --version
brew doctor

gem update --system --no-document

# Fail on any error
set -e

Expand All @@ -34,6 +26,7 @@ fi

source "${scripts_dir}/github_comments.sh"
source "${scripts_dir}/select_xcode.sh"
source "${scripts_dir}/package_managers.sh"

# To install homebrew formulas at specific versions we need to point directly
# to the desired sha in the homebrew formula repository.
Expand Down Expand Up @@ -146,7 +139,7 @@ upload_bazel_test_artifacts() {
done
}

brew install rename
brew_install rename

# rename all test.log to sponge_log.log and then copy them to the kokoro
# artifacts directory.
Expand Down Expand Up @@ -316,11 +309,11 @@ run_cocoapods() {
# Move into our cloned repo
cd github/repo

gem install xcpretty cocoapods --no-document --quiet
gem_install xcpretty cocoapods
pod --version

# Install git-lfs
brew install git-lfs
brew_install git-lfs
git lfs install
git lfs pull
fi
Expand Down Expand Up @@ -378,9 +371,8 @@ generate_website() {

./scripts/build_site.sh

gem install bundler --no-document --quiet
brew update
brew install yarn --without-node
gem_install bundler
brew_install yarn --without-node
fi

cd docsite-generator
Expand Down Expand Up @@ -419,7 +411,7 @@ generate_apidiff() {
cd github/repo

# Install sourcekitten, a dependency of the apidiff tool
brew install "$SOURCEKITTEN_FORMULA"
brew_install "$SOURCEKITTEN_FORMULA"

sourcekitten version
fi
Expand Down
36 changes: 36 additions & 0 deletions scripts/lib/package_managers.sh
@@ -0,0 +1,36 @@
#!/bin/bash
#
# Copyright 2019-present The Material Components for iOS Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

gem_update() {
gem update --system --no-document --quiet
}

gem_install() {
gem_update
gem install "$@" --no-document --quiet
}

brew_update() {
brew --version
brew update
brew --version
}

brew_install() {
brew_update
brew install "$@"
}

0 comments on commit cf38baa

Please sign in to comment.