• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -ex
2# Copyright 2017 gRPC authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15# Source this rc script to prepare the environment for macos builds
16
17# show original open file limit values
18launchctl limit maxfiles
19ulimit -a
20
21# WARNING: TRY TO KEEP THIS FILE AS LEAN AS POSSIBLE
22# The rules:
23# - think twice before adding installer that takes long time (builds are already slow)
24# - do not add any steps that are flaky (builds will become flaky)
25# - try adding a dependency under a language-specific section first (reduces latency and increases build stability)
26# - only add stuff that you absolutely need for your builds to work (add comment to explain why its needed)
27
28# Add GCP credentials for BQ access
29pip install --user google-api-python-client oauth2client
30export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json
31
32# If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests
33if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ]; then
34  export RUN_TESTS_FLAGS="--filter_pr_tests --base_branch origin/$KOKORO_GITHUB_PULL_REQUEST_TARGET_BRANCH $RUN_TESTS_FLAGS"
35fi
36
37if [ "${PREPARE_BUILD_INSTALL_DEPS_RUBY}" == "true" ]
38then
39  brew update
40  # special case fix for https://github.com/grpc/grpc/issues/23027
41  rm -f /usr/local/bin/gpg
42  rm -f /usr/local/bin/gpgconf
43  rm -f /usr/local/bin/gpgsm
44  # end https://github.com/grpc/grpc/issues/23027
45  brew cleanup
46  set +ex
47  source $HOME/.rvm/scripts/rvm
48  set -ex
49  for RUBY_VERSION in 2.5.0 2.7.0; do
50    rvm --debug requirements "ruby-${RUBY_VERSION}"
51    time rvm install "$RUBY_VERSION"
52    time gem install bundler -v 1.17.3 --no-document
53    time gem install rake-compiler --no-document
54  done;
55  rvm use 2.5.0 --default
56  time gem install cocoapods --version 1.3.1 --no-document
57  rvm osx-ssl-certs status all
58  rvm osx-ssl-certs update all
59fi
60
61if [ "${PREPARE_BUILD_INSTALL_DEPS_OBJC}" == "true" ]
62then
63  # cocoapods
64  export LANG=en_US.UTF-8
65  # pre-fetch cocoapods master repo's most recent commit only
66  mkdir -p ~/.cocoapods/repos
67  time git clone --depth 1 https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master
68
69  # set xcode version for Obj-C tests
70  sudo xcode-select -switch /Applications/Xcode_9.2.app/Contents/Developer/
71
72  # Needed for ios-binary-size
73  time pip install --user pyyaml pyjwt cryptography requests
74
75  # Store intermediate build files of ObjC tests into /tmpfs
76  # TODO(jtattermusch): this has likely been done to avoid running
77  # out of disk space when running ios-binary-size tests, but
78  # it would be good to revisit.
79  mkdir /tmpfs/Build-ios-binary-size
80  ln -s /tmpfs/Build-ios-binary-size src/objective-c/examples/Sample/Build
81  mkdir -p /tmpfs/DerivedData
82  rm -rf ~/Library/Developer/Xcode/DerivedData
83  mkdir -p ~/Library/Developer/Xcode
84  ln -s /tmpfs/DerivedData ~/Library/Developer/Xcode/DerivedData
85fi
86
87if [ "${PREPARE_BUILD_INSTALL_DEPS_PYTHON}" == "true" ]
88then
89  # python
90  time pip install --user virtualenv
91  time pip install --user --upgrade Mako six tox setuptools twisted pyyaml pyjwt cryptography requests
92  export PYTHONPATH=/Library/Python/3.4/site-packages
93
94  # make sure md5sum is available (requires coreutils 8.31+)
95  brew upgrade coreutils
96
97  # Install Python 3.7 and Python 3.8
98  time curl -O https://www.python.org/ftp/python/3.7.0/python-3.7.0-macosx10.9.pkg
99  time curl -O https://www.python.org/ftp/python/3.8.0/python-3.8.0-macosx10.9.pkg
100  echo "ae0717a02efea3b0eb34aadc680dc498 python-3.7.0-macosx10.9.pkg" > /tmp/python_installer_checksum.md5
101  echo "f5f9ae9f416170c6355cab7256bb75b5 python-3.8.0-macosx10.9.pkg" >> /tmp/python_installer_checksum.md5
102  md5sum -c /tmp/python_installer_checksum.md5
103  time sudo installer -pkg ./python-3.7.0-macosx10.9.pkg -target /
104  time sudo installer -pkg ./python-3.8.0-macosx10.9.pkg -target /
105fi
106
107if [ "${PREPARE_BUILD_INSTALL_DEPS_CSHARP}" == "true" ]
108then
109  # Disable some unwanted dotnet options
110  export NUGET_XMLDOC_MODE=skip
111  export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
112  export DOTNET_CLI_TELEMETRY_OPTOUT=true
113
114  # Xcode 10+ doesn't support building for i386 architecture
115  sudo xcode-select -switch /Applications/Xcode_9.2.app/Contents/Developer/
116fi
117
118# PHP tests currently require using an older version of PHPUnit
119ln -sf /usr/local/bin/phpunit-5.7 /usr/local/bin/phpunit
120
121# TODO(jtattermusch): better debugging of clock skew, remove once not needed
122date
123
124time git submodule update --init
125