From cf38baae089aa0d92ff2a1365f54f8151bc1278e Mon Sep 17 00:00:00 2001 From: Robert Moore Date: Fri, 11 Jan 2019 10:14:45 -0500 Subject: [PATCH] {kokoro} Only upgrade gem/homebrew when needed. (#6261) 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 --- .kokoro | 22 +++++++------------- scripts/lib/package_managers.sh | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 15 deletions(-) create mode 100755 scripts/lib/package_managers.sh diff --git a/.kokoro b/.kokoro index 024fe7eaff9..54335261dc6 100755 --- a/.kokoro +++ b/.kokoro @@ -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 @@ -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. @@ -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. @@ -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 @@ -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 @@ -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 diff --git a/scripts/lib/package_managers.sh b/scripts/lib/package_managers.sh new file mode 100755 index 00000000000..1d5212bd42a --- /dev/null +++ b/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 "$@" +} +