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 18 sudo launchctl limit maxfiles unlimited unlimited 19 20 # show current maxfiles 21 launchctl limit maxfiles 22 23 ulimit -n 10000 24 25 # show current limits 26 ulimit -a 27 28 # synchronize the clock 29 date 30 sudo systemsetup -setusingnetworktime off 31 sudo systemsetup -setnetworktimeserver "$( ipconfig getoption en0 server_identifier )" 32 sudo systemsetup -settimezone America/Los_Angeles 33 sudo systemsetup -setusingnetworktime on 34 date 35 36 # Add GCP credentials for BQ access 37 # pin google-api-python-client to avoid https://github.com/grpc/grpc/issues/15600 38 pip install google-api-python-client==1.6.7 --user python 39 export 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 42 if [ -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 53 fi 54 55 set +ex # rvm script is very verbose and exits with errorcode 56 source $HOME/.rvm/scripts/rvm 57 set -e # rvm commands are very verbose 58 time rvm install 2.5.0 59 rvm use 2.5.0 --default 60 gem install bundler --no-ri --no-doc 61 gem install cocoapods --version 1.3.1 --no-ri --no-doc 62 gem install rake-compiler --no-ri --no-doc 63 rvm osx-ssl-certs status all 64 rvm osx-ssl-certs update all 65 set -ex 66 67 # cocoapods 68 export LANG=en_US.UTF-8 69 pod repo update # needed by python 70 71 # python 72 pip install virtualenv --user python 73 pip install -U Mako six tox setuptools twisted pyyaml --user python 74 export PYTHONPATH=/Library/Python/3.4/site-packages 75 76 # Install Python 3.7 77 curl -O https://www.python.org/ftp/python/3.7.0/python-3.7.0-macosx10.9.pkg 78 sudo installer -pkg ./python-3.7.0-macosx10.9.pkg -target / 79 80 # set xcode version for Obj-C tests 81 sudo xcode-select -switch /Applications/Xcode_9.2.app/Contents/Developer/ 82 83 # Disable some unwanted dotnet options 84 export NUGET_XMLDOC_MODE=skip 85 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true 86 export DOTNET_CLI_TELEMETRY_OPTOUT=true 87 88 # TODO(jtattermusch): better debugging of clock skew, remove once not needed 89 date 90 91 git submodule update --init 92 93 # Store intermediate build files of ObjC tests into /tmpfs 94 mkdir /tmpfs/Build-ios-binary-size 95 ln -s /tmpfs/Build-ios-binary-size src/objective-c/examples/Sample/Build 96 mkdir /tmpfs/DerivedData 97 rm -rf ~/Library/Developer/Xcode/DerivedData 98 ln -s /tmpfs/DerivedData ~/Library/Developer/Xcode/DerivedData 99