Merge pull request #2555 from stanley-cheung/add_homebrew_to_jenkins

Add per-language homebrew testing for Mac on Jenkins
pull/2589/head
Jan Tattermusch 10 years ago
commit 45d336b8e8
  1. 95
      tools/jenkins/run_distribution.sh

@ -39,19 +39,19 @@ if [ "$platform" == "linux" ]; then
sha1=$(sha1sum tools/jenkins/grpc_linuxbrew/Dockerfile | cut -f1 -d\ ) sha1=$(sha1sum tools/jenkins/grpc_linuxbrew/Dockerfile | cut -f1 -d\ )
DOCKER_IMAGE_NAME=grpc_linuxbrew_$sha1 DOCKER_IMAGE_NAME=grpc_linuxbrew_$sha1
# build docker image, contains all pre-requisites
docker build -t $DOCKER_IMAGE_NAME tools/jenkins/grpc_linuxbrew docker build -t $DOCKER_IMAGE_NAME tools/jenkins/grpc_linuxbrew
supported="python nodejs ruby php"
if [ "$language" == "core" ]; then if [ "$language" == "core" ]; then
command="curl -fsSL https://goo.gl/getgrpc | bash -" command="curl -fsSL https://goo.gl/getgrpc | bash -"
elif [[ "$supported" =~ "$language" ]]; then elif [[ "python nodejs ruby php" =~ "$language" ]]; then
command="curl -fsSL https://goo.gl/getgrpc | bash -s $language" command="curl -fsSL https://goo.gl/getgrpc | bash -s $language"
else else
echo "unsupported language $language" echo "unsupported language $language"
exit 1 exit 1
fi fi
# run per-language homebrew installation script
docker run $DOCKER_IMAGE_NAME bash -l \ docker run $DOCKER_IMAGE_NAME bash -l \
-c "nvm use 0.12; \ -c "nvm use 0.12; \
npm set unsafe-perm true; \ npm set unsafe-perm true; \
@ -66,26 +66,81 @@ if [ "$platform" == "linux" ]; then
elif [ "$platform" == "macos" ]; then elif [ "$platform" == "macos" ]; then
if [ "$dist_channel" == "homebrew" ]; then if [ "$dist_channel" == "homebrew" ]; then
which brew # TODO: for debug, can be removed later # system installed homebrew, don't interfere
brew list -l brew list -l
dir=/tmp/homebrew-test-$language
rm -rf $dir # Set up temp directories for test installation of homebrew
mkdir -p $dir brew_root=/tmp/homebrew-test-$language
git clone https://github.com/Homebrew/homebrew.git $dir rm -rf $brew_root
cd $dir mkdir -p $brew_root
# TODO: Uncomment these when the general structure of the script is verified git clone https://github.com/Homebrew/homebrew.git $brew_root
# PATH=$dir/bin:$PATH brew tap homebrew/dupes
# PATH=$dir/bin:$PATH brew install zlib # Install grpc via homebrew
# PATH=$dir/bin:$PATH brew install openssl #
# PATH=$dir/bin:$PATH brew tap grpc/grpc # The temp $PATH env variable makes sure we are operating at the right copy of
# PATH=$dir/bin:$PATH brew install --without-python google-protobuf # temp homebrew installation, and do not interfere with the system's main brew
# PATH=$dir/bin:$PATH brew install grpc # installation.
PATH=$dir/bin:$PATH brew list -l #
# TODO: replace the next section with the actual homebrew installation script
# i.e. curl -fsSL https://goo.gl/getgrpc | bash -s $language
# need to resolve a bunch of environment and privilege issue on the jenkins
# mac machine itself
local OLD_PATH=$PATH
local PATH=$brew_root/bin:$PATH
cd $brew_root
brew tap homebrew/dupes
brew install zlib
brew install openssl
brew tap grpc/grpc
brew install --without-python google-protobuf
brew install grpc
brew list -l brew list -l
# Install per-language modules/extensions on top of core grpc
#
# If a command below needs root access, the binary had been added to
# /etc/sudoers. This step needs to be repeated if we add more mac instances
# to our jenkins project.
#
# Examples (lines that needed to be added to /etc/sudoers):
# + Defaults env_keep += "CFLAGS CXXFLAGS LDFLAGS enable_grpc"
# + jenkinsnode1 ALL=(ALL) NOPASSWD: /usr/bin/pecl, /usr/local/bin/pip,
# + /usr/local/bin/npm
case $language in
*core*) ;;
*python*)
sudo CFLAGS=-I$brew_root/include LDFLAGS=-L$brew_root/lib pip install grpcio
pip list | grep grpcio
echo 'y' | sudo pip uninstall grpcio
;;
*nodejs*)
sudo CXXFLAGS=-I$brew_root/include LDFLAGS=-L$brew_root/lib npm install grpc
npm list | grep grpc
sudo npm uninstall grpc
;;
*ruby*)
gem install grpc -- --with-grpc-dir=$brew_root
gem list | grep grpc
gem uninstall grpc
;;
*php*)
sudo enable_grpc=$brew_root CFLAGS="-Wno-parentheses-equality" pecl install grpc-alpha
pecl list | grep grpc
sudo pecl uninstall grpc
;;
*)
echo "Unsupported language $language"
exit 1
;;
esac
# clean up
cd ~/ cd ~/
rm -rf $dir rm -rf $brew_root
echo $PATH # TODO: for debug, can be removed later
brew list -l # TODO: for debug, can be removed later # Make sure the system brew installation is still unaffected
local PATH=$OLD_PATH
brew list -l
else else
echo "Unsupported $platform dist_channel $dist_channel" echo "Unsupported $platform dist_channel $dist_channel"

Loading…
Cancel
Save