From 57be1d7eb25432b9f0106d64faed323ef954f7d2 Mon Sep 17 00:00:00 2001 From: Josh Haberman Date: Thu, 18 Feb 2016 14:55:00 -0800 Subject: Added some initial shell scripts and docker file. --- .travis.yml | 2 +- tools/docker/Dockerfile | 57 ++++++ tools/jenkins/build_and_run_docker.sh | 78 +++++++++ tools/jenkins/pull_request.sh | 6 + tools/run_tests/jenkins.sh | 13 ++ tools/run_tests/tests.sh | 279 ++++++++++++++++++++++++++++++ tools/run_tests/travis.sh | 42 +++++ travis.sh | 314 ---------------------------------- 8 files changed, 476 insertions(+), 315 deletions(-) create mode 100644 tools/docker/Dockerfile create mode 100755 tools/jenkins/build_and_run_docker.sh create mode 100755 tools/jenkins/pull_request.sh create mode 100755 tools/run_tests/jenkins.sh create mode 100644 tools/run_tests/tests.sh create mode 100755 tools/run_tests/travis.sh delete mode 100755 travis.sh diff --git a/.travis.yml b/.travis.yml index 9bc4d88f..4a295401 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ os: # The Objective C build needs Xcode 7.0 or later. osx_image: xcode7.2 script: - - ./travis.sh $CONFIG + - ./tools/run_tests/travis.sh $CONFIG env: - CONFIG=cpp - CONFIG=cpp_distcheck diff --git a/tools/docker/Dockerfile b/tools/docker/Dockerfile new file mode 100644 index 00000000..b5e26f9a --- /dev/null +++ b/tools/docker/Dockerfile @@ -0,0 +1,57 @@ +# Copyright 2015, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Base Dockerfile for gRPC dev images +FROM debian:latest + +# Install Git. +RUN apt-get update && apt-get install -y \ + autoconf \ + autotools-dev \ + build-essential \ + bzip2 \ + curl \ + gcc \ + git \ + libc6 \ + libc6-dbg \ + libc6-dev \ + libgtest-dev \ + libtool \ + make \ + strace \ + python-dev \ + python-setuptools \ + telnet \ + unzip \ + wget \ + zip && apt-get clean + +# Define the default command. +CMD ["bash"] diff --git a/tools/jenkins/build_and_run_docker.sh b/tools/jenkins/build_and_run_docker.sh new file mode 100755 index 00000000..e77ffd61 --- /dev/null +++ b/tools/jenkins/build_and_run_docker.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# Copyright 2016, Google Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Builds docker image and runs a command under it. +# You should never need to call this script on your own. + +set -ex + +cd $(dirname $0)/../.. +git_root=$(pwd) +cd - + +# Inputs +# DOCKERFILE_DIR - Directory in which Dockerfile file is located. +# DOCKER_RUN_SCRIPT - Script to run under docker (relative to protobuf repo root) +# OUTPUT_DIR - Directory that will be copied from inside docker after finishing. +# $@ - Extra args to pass to docker run + +# Use image name based on Dockerfile location checksum +DOCKER_IMAGE_NAME=$(basename $DOCKERFILE_DIR)_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ ) + +# Make sure docker image has been built. Should be instantaneous if so. +docker build -t $DOCKER_IMAGE_NAME $DOCKERFILE_DIR + +# Choose random name for docker container +CONTAINER_NAME="build_and_run_docker_$(uuidgen)" + +# Run command inside docker +docker run \ + "$@" \ + -e EXTERNAL_GIT_ROOT="/var/local/jenkins/protobuf" \ + -e THIS_IS_REALLY_NEEDED='see https://github.com/docker/docker/issues/14203 for why docker is awful' \ + -v "$git_root:/var/local/jenkins/protobuf:ro" \ + -w /var/local/git/protobuf \ + --name=$CONTAINER_NAME \ + $DOCKER_IMAGE_NAME \ + bash -l "/var/local/jenkins/protobuf/$DOCKER_RUN_SCRIPT" || FAILED="true" + +# Copy output artifacts +if [ "$OUTPUT_DIR" != "" ] +then + docker cp "$CONTAINER_NAME:/var/local/git/protobuf/$OUTPUT_DIR" "$git_root" || FAILED="true" +fi + +# remove the container, possibly killing it first +docker rm -f $CONTAINER_NAME || true + +if [ "$FAILED" != "" ] +then + exit 1 +fi diff --git a/tools/jenkins/pull_request.sh b/tools/jenkins/pull_request.sh new file mode 100755 index 00000000..cb0f4072 --- /dev/null +++ b/tools/jenkins/pull_request.sh @@ -0,0 +1,6 @@ +#!/bin/bash + + +export DOCKERFILE_DIR=tools/docker +export DOCKER_RUN_SCRIPT=tools/run_tests/jenkins.sh +./tools/jenkins/build_and_run_docker.sh diff --git a/tools/run_tests/jenkins.sh b/tools/run_tests/jenkins.sh new file mode 100755 index 00000000..34a16829 --- /dev/null +++ b/tools/run_tests/jenkins.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +MY_DIR="$(dirname "$0")" +BUILD_DIR=/tmp/protobuf + +source $MY_DIR/tests.sh + +rm -rf $BUILD_DIR +mkdir -p $BUILD_DIR +cd $BUILD_DIR +git clone /var/local/jenkins/protobuf +cd protobuf +build_cpp diff --git a/tools/run_tests/tests.sh b/tools/run_tests/tests.sh new file mode 100644 index 00000000..f1c7e969 --- /dev/null +++ b/tools/run_tests/tests.sh @@ -0,0 +1,279 @@ +# This file is not intended to be executed directly. It is intended to be +# included in a larger shell script. + +# For when some other test needs the C++ main build, including protoc and +# libprotobuf. +internal_build_cpp() { + if [ $(uname -s) == "Linux" && "$TRAVIS" == "true" ]; then + # Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more + # decent C++ 11 support in order to compile conformance tests. + sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y + sudo apt-get update -qq + sudo apt-get install -qq g++-4.8 + export CXX="g++-4.8" CC="gcc-4.8" + fi + + ./autogen.sh + ./configure + make -j2 +} + +build_cpp() { + internal_build_cpp + make check -j2 + cd conformance && make test_cpp && cd .. +} + +build_cpp_distcheck() { + ./autogen.sh + ./configure + make distcheck -j2 +} + +build_csharp() { + # Just for the conformance tests. We don't currently + # need to really build protoc, but it's simplest to keep with the + # conventions of the other builds. + internal_build_cpp + + # Install latest version of Mono + sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF + echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list + echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list + sudo apt-get update -qq + sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit + wget www.nuget.org/NuGet.exe -O nuget.exe + + (cd csharp/src; mono ../../nuget.exe restore) + csharp/buildall.sh + cd conformance && make test_csharp && cd .. +} + +build_golang() { + # Go build needs `protoc`. + internal_build_cpp + # Add protoc to the path so that the examples build finds it. + export PATH="`pwd`/src:$PATH" + + # Install Go and the Go protobuf compiler plugin. + sudo apt-get update -qq + sudo apt-get install -qq golang + export GOPATH="$HOME/gocode" + mkdir -p "$GOPATH/src/github.com/google" + ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf" + export PATH="$GOPATH/bin:$PATH" + go get github.com/golang/protobuf/protoc-gen-go + + cd examples && make gotest && cd .. +} + +use_java() { + version=$1 + case "$version" in + jdk6) + sudo apt-get install openjdk-6-jdk + export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH + ;; + jdk7) + sudo apt-get install openjdk-7-jdk + export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH + ;; + oracle7) + sudo apt-get install python-software-properties # for apt-add-repository + echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \ + sudo debconf-set-selections + yes | sudo apt-add-repository ppa:webupd8team/java + yes | sudo apt-get install oracle-java7-installer + export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH + ;; + esac + + which java + java -version +} + +build_java() { + # Java build needs `protoc`. + internal_build_cpp + cd java && mvn test && mvn install + cd util && mvn test + cd ../.. +} + +build_java_with_conformance_tests() { + # Java build needs `protoc`. + internal_build_cpp + cd java && mvn test && mvn install + cd util && mvn test && mvn assembly:single + cd ../.. + cd conformance && make test_java && cd .. +} + +build_javanano() { + # Java build needs `protoc`. + internal_build_cpp + cd javanano && mvn test && cd .. +} + +build_java_jdk6() { + use_java jdk6 + build_java +} +build_java_jdk7() { + use_java jdk7 + build_java_with_conformance_tests +} +build_java_oracle7() { + use_java oracle7 + build_java +} + +build_javanano_jdk6() { + use_java jdk6 + build_javanano +} +build_javanano_jdk7() { + use_java jdk7 + build_javanano +} +build_javanano_oracle7() { + use_java oracle7 + build_javanano +} + +internal_install_python_deps() { + # Install tox (OS X doesn't have pip). + if [ $(uname -s) == "Darwin" ]; then + sudo easy_install tox + else + sudo pip install tox + fi + # Only install Python2.6/3.x on Linux. + if [ $(uname -s) == "Linux" ]; then + sudo apt-get install -y python-software-properties # for apt-add-repository + sudo apt-add-repository -y ppa:fkrull/deadsnakes + sudo apt-get update -qq + sudo apt-get install -y python2.6 python2.6-dev + sudo apt-get install -y python3.3 python3.3-dev + sudo apt-get install -y python3.4 python3.4-dev + fi +} + +internal_objectivec_common () { + # Make sure xctool is up to date. Adapted from + # http://docs.travis-ci.com/user/osx-ci-environment/ + # We don't use a before_install because we test multiple OSes. + brew update + # xctool 0.2.8 seems to have a bug where it randomly kills tests saying + # they failed. Disabling the updates, but letting it report about being + # updates as a hint that this needs to eventually get re-enabled. + # https://github.com/facebook/xctool/issues/619 + # https://github.com/google/protobuf/issues/1232 + brew outdated xctool || true + #brew outdated xctool || brew upgrade xctool + # Reused the build script that takes care of configuring and ensuring things + # are up to date. Xcode and conformance tests will be directly invoked. + objectivec/DevTools/full_mac_build.sh \ + --core-only --skip-xcode --skip-objc-conformance +} + +internal_xctool_debug_and_release() { + # Always use -reporter plain to avoid escape codes in output (makes travis + # logs easier to read). + xctool -reporter plain -configuration Debug "$@" + xctool -reporter plain -configuration Release "$@" +} + +build_objectivec_ios() { + internal_objectivec_common + # https://github.com/facebook/xctool/issues/509 - unlike xcodebuild, xctool + # doesn't support >1 destination, so we have to build first and then run the + # tests one destination at a time. + internal_xctool_debug_and_release \ + -project objectivec/ProtocolBuffers_iOS.xcodeproj \ + -scheme ProtocolBuffers \ + -sdk iphonesimulator \ + build-tests + IOS_DESTINATIONS=( + "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit + "platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit + "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit + "platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit + ) + for i in "${IOS_DESTINATIONS[@]}" ; do + internal_xctool_debug_and_release \ + -project objectivec/ProtocolBuffers_iOS.xcodeproj \ + -scheme ProtocolBuffers \ + -sdk iphonesimulator \ + -destination "${i}" \ + run-tests + done +} + +build_objectivec_osx() { + internal_objectivec_common + internal_xctool_debug_and_release \ + -project objectivec/ProtocolBuffers_OSX.xcodeproj \ + -scheme ProtocolBuffers \ + -destination "platform=OS X,arch=x86_64" \ + test + cd conformance && make test_objc && cd .. +} + +build_python() { + internal_build_cpp + internal_install_python_deps + cd python + # Only test Python 2.6/3.x on Linux + if [ $(uname -s) == "Linux" ]; then + envlist=py\{26,27,33,34\}-python + else + envlist=py27-python + fi + tox -e $envlist + cd .. +} + +build_python_cpp() { + internal_build_cpp + internal_install_python_deps + export LD_LIBRARY_PATH=../src/.libs # for Linux + export DYLD_LIBRARY_PATH=../src/.libs # for OS X + cd python + # Only test Python 2.6/3.x on Linux + if [ $(uname -s) == "Linux" ]; then + # py26 is currently disabled due to json_format + envlist=py\{27,33,34\}-cpp + else + envlist=py27-cpp + fi + tox -e $envlist + cd .. +} + +build_ruby19() { + internal_build_cpp # For conformance tests. + cd ruby && bash travis-test.sh ruby-1.9 && cd .. +} +build_ruby20() { + internal_build_cpp # For conformance tests. + cd ruby && bash travis-test.sh ruby-2.0 && cd .. +} +build_ruby21() { + internal_build_cpp # For conformance tests. + cd ruby && bash travis-test.sh ruby-2.1 && cd .. +} +build_ruby22() { + internal_build_cpp # For conformance tests. + cd ruby && bash travis-test.sh ruby-2.2 && cd .. +} +build_jruby() { + internal_build_cpp # For conformance tests. + cd ruby && bash travis-test.sh jruby && cd .. +} + +build_javascript() { + internal_build_cpp + cd js && npm install && npm test && cd .. +} + diff --git a/tools/run_tests/travis.sh b/tools/run_tests/travis.sh new file mode 100755 index 00000000..8c87a47b --- /dev/null +++ b/tools/run_tests/travis.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +my_dir="$(dirname "$0")" + +source $my_dir/tests.sh + +# Note: travis currently does not support testing more than one language so the +# .travis.yml cheats and claims to only be cpp. If they add multiple language +# support, this should probably get updated to install steps and/or +# rvm/gemfile/jdk/etc. entries rather than manually doing the work. + +# .travis.yml uses matrix.exclude to block the cases where app-get can't be +# use to install things. + +# -------- main -------- + +if [ "$#" -ne 1 ]; then + echo " +Usage: $0 { cpp | + csharp | + java_jdk6 | + java_jdk7 | + java_oracle7 | + javanano_jdk6 | + javanano_jdk7 | + javanano_oracle7 | + objectivec_ios | + objectivec_osx | + python | + python_cpp | + ruby_19 | + ruby_20 | + ruby_21 | + ruby_22 | + jruby } +" + exit 1 +fi + +set -e # exit immediately on error +set -x # display all commands +eval "build_$1" diff --git a/travis.sh b/travis.sh deleted file mode 100755 index ff5e99d5..00000000 --- a/travis.sh +++ /dev/null @@ -1,314 +0,0 @@ -#!/usr/bin/env bash - -# Note: travis currently does not support testing more than one language so the -# .travis.yml cheats and claims to only be cpp. If they add multiple language -# support, this should probably get updated to install steps and/or -# rvm/gemfile/jdk/etc. entries rather than manually doing the work. - -# .travis.yml uses matrix.exclude to block the cases where app-get can't be -# use to install things. - -# For when some other test needs the C++ main build, including protoc and -# libprotobuf. -internal_build_cpp() { - if [ $(uname -s) == "Linux" ]; then - # Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more - # decent C++ 11 support in order to compile conformance tests. - sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y - sudo apt-get update -qq - sudo apt-get install -qq g++-4.8 - export CXX="g++-4.8" CC="gcc-4.8" - fi - - ./autogen.sh - ./configure - make -j2 -} - -build_cpp() { - internal_build_cpp - make check -j2 - cd conformance && make test_cpp && cd .. -} - -build_cpp_distcheck() { - ./autogen.sh - ./configure - make distcheck -j2 -} - -build_csharp() { - # Just for the conformance tests. We don't currently - # need to really build protoc, but it's simplest to keep with the - # conventions of the other builds. - internal_build_cpp - - # Install latest version of Mono - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF - echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list - echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list - sudo apt-get update -qq - sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit - wget www.nuget.org/NuGet.exe -O nuget.exe - - (cd csharp/src; mono ../../nuget.exe restore) - csharp/buildall.sh - cd conformance && make test_csharp && cd .. -} - -build_golang() { - # Go build needs `protoc`. - internal_build_cpp - # Add protoc to the path so that the examples build finds it. - export PATH="`pwd`/src:$PATH" - - # Install Go and the Go protobuf compiler plugin. - sudo apt-get update -qq - sudo apt-get install -qq golang - export GOPATH="$HOME/gocode" - mkdir -p "$GOPATH/src/github.com/google" - ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf" - export PATH="$GOPATH/bin:$PATH" - go get github.com/golang/protobuf/protoc-gen-go - - cd examples && make gotest && cd .. -} - -use_java() { - version=$1 - case "$version" in - jdk6) - sudo apt-get install openjdk-6-jdk - export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH - ;; - jdk7) - sudo apt-get install openjdk-7-jdk - export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH - ;; - oracle7) - sudo apt-get install python-software-properties # for apt-add-repository - echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \ - sudo debconf-set-selections - yes | sudo apt-add-repository ppa:webupd8team/java - yes | sudo apt-get install oracle-java7-installer - export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH - ;; - esac - - which java - java -version -} - -build_java() { - # Java build needs `protoc`. - internal_build_cpp - cd java && mvn test && mvn install - cd util && mvn test - cd ../.. -} - -build_java_with_conformance_tests() { - # Java build needs `protoc`. - internal_build_cpp - cd java && mvn test && mvn install - cd util && mvn test && mvn assembly:single - cd ../.. - cd conformance && make test_java && cd .. -} - -build_javanano() { - # Java build needs `protoc`. - internal_build_cpp - cd javanano && mvn test && cd .. -} - -build_java_jdk6() { - use_java jdk6 - build_java -} -build_java_jdk7() { - use_java jdk7 - build_java_with_conformance_tests -} -build_java_oracle7() { - use_java oracle7 - build_java -} - -build_javanano_jdk6() { - use_java jdk6 - build_javanano -} -build_javanano_jdk7() { - use_java jdk7 - build_javanano -} -build_javanano_oracle7() { - use_java oracle7 - build_javanano -} - -internal_install_python_deps() { - # Install tox (OS X doesn't have pip). - if [ $(uname -s) == "Darwin" ]; then - sudo easy_install tox - else - sudo pip install tox - fi - # Only install Python2.6/3.x on Linux. - if [ $(uname -s) == "Linux" ]; then - sudo apt-get install -y python-software-properties # for apt-add-repository - sudo apt-add-repository -y ppa:fkrull/deadsnakes - sudo apt-get update -qq - sudo apt-get install -y python2.6 python2.6-dev - sudo apt-get install -y python3.3 python3.3-dev - sudo apt-get install -y python3.4 python3.4-dev - fi -} - -internal_objectivec_common () { - # Make sure xctool is up to date. Adapted from - # http://docs.travis-ci.com/user/osx-ci-environment/ - # We don't use a before_install because we test multiple OSes. - brew update - # xctool 0.2.8 seems to have a bug where it randomly kills tests saying - # they failed. Disabling the updates, but letting it report about being - # updates as a hint that this needs to eventually get re-enabled. - # https://github.com/facebook/xctool/issues/619 - # https://github.com/google/protobuf/issues/1232 - brew outdated xctool || true - #brew outdated xctool || brew upgrade xctool - # Reused the build script that takes care of configuring and ensuring things - # are up to date. Xcode and conformance tests will be directly invoked. - objectivec/DevTools/full_mac_build.sh \ - --core-only --skip-xcode --skip-objc-conformance -} - -internal_xctool_debug_and_release() { - # Always use -reporter plain to avoid escape codes in output (makes travis - # logs easier to read). - xctool -reporter plain -configuration Debug "$@" - xctool -reporter plain -configuration Release "$@" -} - -build_objectivec_ios() { - internal_objectivec_common - # https://github.com/facebook/xctool/issues/509 - unlike xcodebuild, xctool - # doesn't support >1 destination, so we have to build first and then run the - # tests one destination at a time. - internal_xctool_debug_and_release \ - -project objectivec/ProtocolBuffers_iOS.xcodeproj \ - -scheme ProtocolBuffers \ - -sdk iphonesimulator \ - build-tests - IOS_DESTINATIONS=( - "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit - "platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit - "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit - "platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit - ) - for i in "${IOS_DESTINATIONS[@]}" ; do - internal_xctool_debug_and_release \ - -project objectivec/ProtocolBuffers_iOS.xcodeproj \ - -scheme ProtocolBuffers \ - -sdk iphonesimulator \ - -destination "${i}" \ - run-tests - done -} - -build_objectivec_osx() { - internal_objectivec_common - internal_xctool_debug_and_release \ - -project objectivec/ProtocolBuffers_OSX.xcodeproj \ - -scheme ProtocolBuffers \ - -destination "platform=OS X,arch=x86_64" \ - test - cd conformance && make test_objc && cd .. -} - -build_python() { - internal_build_cpp - internal_install_python_deps - cd python - # Only test Python 2.6/3.x on Linux - if [ $(uname -s) == "Linux" ]; then - envlist=py\{26,27,33,34\}-python - else - envlist=py27-python - fi - tox -e $envlist - cd .. -} - -build_python_cpp() { - internal_build_cpp - internal_install_python_deps - export LD_LIBRARY_PATH=../src/.libs # for Linux - export DYLD_LIBRARY_PATH=../src/.libs # for OS X - cd python - # Only test Python 2.6/3.x on Linux - if [ $(uname -s) == "Linux" ]; then - # py26 is currently disabled due to json_format - envlist=py\{27,33,34\}-cpp - else - envlist=py27-cpp - fi - tox -e $envlist - cd .. -} - -build_ruby19() { - internal_build_cpp # For conformance tests. - cd ruby && bash travis-test.sh ruby-1.9 && cd .. -} -build_ruby20() { - internal_build_cpp # For conformance tests. - cd ruby && bash travis-test.sh ruby-2.0 && cd .. -} -build_ruby21() { - internal_build_cpp # For conformance tests. - cd ruby && bash travis-test.sh ruby-2.1 && cd .. -} -build_ruby22() { - internal_build_cpp # For conformance tests. - cd ruby && bash travis-test.sh ruby-2.2 && cd .. -} -build_jruby() { - internal_build_cpp # For conformance tests. - cd ruby && bash travis-test.sh jruby && cd .. -} - -build_javascript() { - internal_build_cpp - cd js && npm install && npm test && cd .. -} - -# -------- main -------- - -if [ "$#" -ne 1 ]; then - echo " -Usage: $0 { cpp | - csharp | - java_jdk6 | - java_jdk7 | - java_oracle7 | - javanano_jdk6 | - javanano_jdk7 | - javanano_oracle7 | - objectivec_ios | - objectivec_osx | - python | - python_cpp | - ruby_19 | - ruby_20 | - ruby_21 | - ruby_22 | - jruby } -" - exit 1 -fi - -set -e # exit immediately on error -set -x # display all commands -eval "build_$1" -- cgit v1.2.3