e9ec07cd0f9a7404ad6f7346a3172da83eaab13b
[platform/upstream/grpc.git] / tools / internal_ci / helper_scripts / prepare_build_macos_rc
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 # show original open file limit values
19 launchctl limit maxfiles
20 ulimit -a
21
22 # Add GCP credentials for BQ access
23 pip install google-api-python-client oauth2client --user python
24 export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/GrpcTesting-d0eeee2db331.json
25
26 # If this is a PR using RUN_TESTS_FLAGS var, then add flags to filter tests
27 if [ -n "$KOKORO_GITHUB_PULL_REQUEST_NUMBER" ]; then
28   brew update
29   brew install jq || brew upgrade jq
30   ghprbTargetBranch=$(curl -s https://api.github.com/repos/grpc/grpc/pulls/$KOKORO_GITHUB_PULL_REQUEST_NUMBER | jq -r .base.ref)
31   export RUN_TESTS_FLAGS="$RUN_TESTS_FLAGS --filter_pr_tests --base_branch origin/$ghprbTargetBranch"
32 fi
33
34 set +ex  # rvm script is very verbose and exits with errorcode
35 # Advice from https://github.com/Homebrew/homebrew-cask/issues/8629#issuecomment-68641176
36 brew update && brew upgrade brew-cask && brew cleanup && brew cask cleanup
37 rvm --debug requirements ruby-2.5.0
38 source $HOME/.rvm/scripts/rvm
39 set -e  # rvm commands are very verbose
40 time rvm install 2.5.0
41 rvm use 2.5.0 --default
42 time gem install bundler -v 1.17.3 --no-ri --no-doc
43 time gem install cocoapods --version 1.3.1 --no-ri --no-doc
44 time gem install rake-compiler --no-ri --no-doc
45 rvm osx-ssl-certs status all
46 rvm osx-ssl-certs update all
47 set -ex
48
49 # cocoapods
50 export LANG=en_US.UTF-8
51 # pre-fetch cocoapods master repo's most recent commit only
52 mkdir -p ~/.cocoapods/repos
53 time git clone --depth 1 https://github.com/CocoaPods/Specs.git ~/.cocoapods/repos/master
54
55 # python
56 time pip install virtualenv --user python
57 time pip install -U Mako six tox setuptools twisted pyyaml pyjwt cryptography requests --user python
58 export PYTHONPATH=/Library/Python/3.4/site-packages
59
60 # Install Python 3.7
61 time curl -O https://www.python.org/ftp/python/3.7.0/python-3.7.0-macosx10.9.pkg
62 time sudo installer -pkg ./python-3.7.0-macosx10.9.pkg -target /
63
64 # set xcode version for Obj-C tests
65 sudo xcode-select -switch /Applications/Xcode_9.2.app/Contents/Developer/
66
67 # Disable some unwanted dotnet options
68 export NUGET_XMLDOC_MODE=skip
69 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true
70 export DOTNET_CLI_TELEMETRY_OPTOUT=true
71
72 # TODO(jtattermusch): better debugging of clock skew, remove once not needed
73 date
74
75 time git submodule update --init
76
77 # Store intermediate build files of ObjC tests into /tmpfs
78 mkdir /tmpfs/Build-ios-binary-size
79 ln -s /tmpfs/Build-ios-binary-size src/objective-c/examples/Sample/Build
80 mkdir -p /tmpfs/DerivedData
81 rm -rf ~/Library/Developer/Xcode/DerivedData
82 mkdir -p ~/Library/Developer/Xcode
83 ln -s /tmpfs/DerivedData ~/Library/Developer/Xcode/DerivedData
84
85 # PHP tests currently require using an older version of PHPUnit
86 ln -sf /usr/local/bin/phpunit-5.7 /usr/local/bin/phpunit