• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
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
16# Source this rc script to prepare the environment for macos builds
17
18sudo launchctl limit maxfiles unlimited unlimited
19
20# show current maxfiles
21launchctl limit maxfiles
22
23ulimit -n 10000
24
25# show current limits
26ulimit -a
27
28# synchronize the clock
29date
30sudo systemsetup -setusingnetworktime off
31sudo systemsetup -setnetworktimeserver "$( ipconfig getoption en0 server_identifier )"
32sudo systemsetup -settimezone America/Los_Angeles
33sudo systemsetup -setusingnetworktime on
34date
35
36# Add GCP credentials for BQ access
37# pin google-api-python-client to avoid https://github.com/grpc/grpc/issues/15600
38pip install google-api-python-client==1.6.7 --user python
39export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json
40
41# If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests
42if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ]; then
43  set +x
44  brew update
45  brew install jq
46  ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref)
47  export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch"
48
49  # TODO(matt-kwong): rename this to GITHUB_OAUTH_TOKEN after Jenkins deprecation
50  export JENKINS_OAUTH_TOKEN=$(cat ${KOKORO_GFILE_DIR}/oauth_token.txt)
51  export ghprbPullId=$KOKORO_GITHUB_PULL_REQUEST_NUMBER
52  set -x
53fi
54
55set +ex  # rvm script is very verbose and exits with errorcode
56source $HOME/.rvm/scripts/rvm
57set -e  # rvm commands are very verbose
58time rvm install 2.5.0
59rvm use 2.5.0 --default
60gem install bundler --no-ri --no-doc
61gem install cocoapods --version 1.3.1 --no-ri --no-doc
62gem install rake-compiler --no-ri --no-doc
63rvm osx-ssl-certs status all
64rvm osx-ssl-certs update all
65set -ex
66
67# cocoapods
68export LANG=en_US.UTF-8
69pod repo update  # needed by python
70
71# python
72pip install virtualenv --user python
73pip install -U Mako six tox setuptools twisted pyyaml --user python
74export PYTHONPATH=/Library/Python/3.4/site-packages
75
76# Install Python 3.7
77curl -O https://www.python.org/ftp/python/3.7.0/python-3.7.0-macosx10.9.pkg
78sudo installer -pkg ./python-3.7.0-macosx10.9.pkg -target /
79
80# set xcode version for Obj-C tests
81sudo xcode-select -switch /Applications/Xcode_9.2.app/Contents/Developer/
82
83# Disable some unwanted dotnet options
84export NUGET_XMLDOC_MODE=skip
85export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
86export DOTNET_CLI_TELEMETRY_OPTOUT=true
87
88# TODO(jtattermusch): better debugging of clock skew, remove once not needed
89date
90
91git submodule update --init
92
93# Store intermediate build files of ObjC tests into /tmpfs
94mkdir /tmpfs/Build-ios-binary-size
95ln -s /tmpfs/Build-ios-binary-size src/objective-c/examples/Sample/Build
96mkdir /tmpfs/DerivedData
97rm -rf ~/Library/Developer/Xcode/DerivedData
98ln -s /tmpfs/DerivedData ~/Library/Developer/Xcode/DerivedData
99