| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# This script sets up a Kokoro MacOS worker for running Protobuf tests |
| 4 |
|
| 5 |
set -eux |
| 6 |
|
| 7 |
export HOMEBREW_PREFIX=$(brew --prefix) |
| 8 |
|
| 9 |
## |
| 10 |
# Remove any pre-existing protobuf installation. |
| 11 |
brew uninstall protobuf |
| 12 |
|
| 13 |
## |
| 14 |
# Select Xcode version |
| 15 |
|
| 16 |
## |
| 17 |
# Select Xcode version |
| 18 |
export DEVELOPER_DIR=/Applications/Xcode_14.app/Contents/Developer |
| 19 |
sudo xcode-select -s "${DEVELOPER_DIR}" |
| 20 |
|
| 21 |
## |
| 22 |
# Select C/C++ compilers |
| 23 |
|
| 24 |
export CC=gcc |
| 25 |
export CXX=g++ |
| 26 |
|
| 27 |
## |
| 28 |
# Install Python 2 by default |
| 29 |
|
| 30 |
eval "$(pyenv init -)" |
| 31 |
pyenv install -v -s 2.7.18 && pyenv global 2.7.18 |
| 32 |
|
| 33 |
## |
| 34 |
# Install Tox |
| 35 |
|
| 36 |
if [[ "${KOKORO_INSTALL_TOX:-}" == "yes" ]] ; then |
| 37 |
pyenv install -v -s 3.7.13 |
| 38 |
pyenv global 3.7.13 |
| 39 |
sudo python -m pip install --upgrade pip 'tox==3.27.1' tox-pyenv |
| 40 |
fi |
| 41 |
|
| 42 |
## |
| 43 |
# Setup RVM |
| 44 |
if [[ "${KOKORO_INSTALL_RVM:-}" == "yes" ]] ; then |
| 45 |
git config --global --add safe.directory $HOMEBREW_PREFIX/Library/Taps/homebrew/homebrew-cask |
| 46 |
git config --global --add safe.directory $HOMEBREW_PREFIX/Library/Taps/homebrew/homebrew-core |
| 47 |
git config --global --add safe.directory $HOMEBREW_PREFIX/Library/Taps/homebrew/homebrew-services |
| 48 |
sudo chown -R $(whoami) $HOME/.rvm/ |
| 49 |
fi |