Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 1 | #!/bin/bash |
Josh Haberman | 67c727c | 2016-03-04 14:21:18 -0800 | [diff] [blame] | 2 | # |
| 3 | # Build and runs tests for the protobuf project. The tests as written here are |
| 4 | # used by both Jenkins and Travis, though some specialized logic is required to |
| 5 | # handle the differences between them. |
Thomas Van Lenten | c4d3638 | 2015-06-09 13:35:41 -0400 | [diff] [blame] | 6 | |
Josh Haberman | 0f8c25d | 2016-02-19 09:11:38 -0800 | [diff] [blame] | 7 | on_travis() { |
| 8 | if [ "$TRAVIS" == "true" ]; then |
| 9 | "$@" |
| 10 | fi |
| 11 | } |
| 12 | |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 13 | # For when some other test needs the C++ main build, including protoc and |
| 14 | # libprotobuf. |
| 15 | internal_build_cpp() { |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 16 | if [ -f src/protoc ]; then |
| 17 | # Already built. |
| 18 | return |
| 19 | fi |
| 20 | |
Josh Haberman | d33e93b | 2016-02-18 19:13:07 -0800 | [diff] [blame] | 21 | if [[ $(uname -s) == "Linux" && "$TRAVIS" == "true" ]]; then |
Feng Xiao | 9125863 | 2015-12-21 03:34:28 -0800 | [diff] [blame] | 22 | # Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more |
| 23 | # decent C++ 11 support in order to compile conformance tests. |
| 24 | sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y |
| 25 | sudo apt-get update -qq |
| 26 | sudo apt-get install -qq g++-4.8 |
| 27 | export CXX="g++-4.8" CC="gcc-4.8" |
| 28 | fi |
Feng Xiao | 1e2fece | 2015-12-18 15:16:07 -0800 | [diff] [blame] | 29 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 30 | ./autogen.sh |
Paul Yang | daba665 | 2016-10-07 16:09:26 -0700 | [diff] [blame] | 31 | ./configure CXXFLAGS="-fPIC" # -fPIC is needed for python cpp test. |
| 32 | # See python/setup.py for more details |
Josh Haberman | 67c727c | 2016-03-04 14:21:18 -0800 | [diff] [blame] | 33 | make -j2 |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | build_cpp() { |
| 37 | internal_build_cpp |
Josh Haberman | 67c727c | 2016-03-04 14:21:18 -0800 | [diff] [blame] | 38 | make check -j2 |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 39 | cd conformance && make test_cpp && cd .. |
Josh Haberman | cb36bde | 2016-04-29 09:52:20 -0700 | [diff] [blame] | 40 | |
Thomas Van Lenten | bc9d077 | 2016-12-08 16:19:58 -0500 | [diff] [blame] | 41 | # The benchmark code depends on cmake, so test if it is installed before |
| 42 | # trying to do the build. |
| 43 | # NOTE: The travis macOS images say they have cmake, but the xcode8.1 image |
| 44 | # appears to be missing it: https://github.com/travis-ci/travis-ci/issues/6996 |
| 45 | if [[ $(type cmake 2>/dev/null) ]]; then |
| 46 | # Verify benchmarking code can build successfully. |
| 47 | git submodule init |
| 48 | git submodule update |
| 49 | cd third_party/benchmark && cmake -DCMAKE_BUILD_TYPE=Release && make && cd ../.. |
| 50 | cd benchmarks && make && ./generate-datasets && cd .. |
| 51 | else |
| 52 | echo "" |
| 53 | echo "WARNING: Skipping validation of the bench marking code, cmake isn't installed." |
| 54 | echo "" |
| 55 | fi |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 56 | } |
| 57 | |
| 58 | build_cpp_distcheck() { |
| 59 | ./autogen.sh |
| 60 | ./configure |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 61 | make dist |
| 62 | |
| 63 | # List all files that should be included in the distribution package. |
Feng Xiao | 599613e | 2016-11-18 15:36:28 -0800 | [diff] [blame] | 64 | git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\)" |\ |
Jie Luo | ea51149 | 2017-01-23 15:11:00 -0800 | [diff] [blame] | 65 | grep -v ".gitignore" | grep -v "java/compatibility_tests" |\ |
| 66 | grep -v "python/compatibility_tests" > dist.lst |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 67 | # Unzip the dist tar file. |
| 68 | DIST=`ls *.tar.gz` |
| 69 | tar -xf $DIST |
| 70 | cd ${DIST//.tar.gz} |
| 71 | # Check if every file exists in the dist tar file. |
| 72 | FILES_MISSING="" |
| 73 | for FILE in $(<../dist.lst); do |
| 74 | if ! file $FILE &>/dev/null; then |
| 75 | echo "$FILE is not found!" |
| 76 | FILES_MISSING="$FILE $FILES_MISSING" |
| 77 | fi |
| 78 | done |
| 79 | cd .. |
| 80 | if [ ! -z "$FILES_MISSING" ]; then |
| 81 | echo "Missing files in EXTRA_DIST: $FILES_MISSING" |
| 82 | exit 1 |
| 83 | fi |
| 84 | |
| 85 | # Do the regular dist-check for C++. |
Josh Haberman | 67c727c | 2016-03-04 14:21:18 -0800 | [diff] [blame] | 86 | make distcheck -j2 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 89 | build_csharp() { |
Jon Skeet | b6defa7 | 2015-08-04 10:01:40 +0100 | [diff] [blame] | 90 | # Just for the conformance tests. We don't currently |
| 91 | # need to really build protoc, but it's simplest to keep with the |
| 92 | # conventions of the other builds. |
| 93 | internal_build_cpp |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 94 | NUGET=/usr/local/bin/nuget.exe |
Jon Skeet | b6defa7 | 2015-08-04 10:01:40 +0100 | [diff] [blame] | 95 | |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 96 | if [ "$TRAVIS" == "true" ]; then |
| 97 | # Install latest version of Mono |
| 98 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF |
Jon Skeet | 10a8fb4 | 2016-07-14 22:01:47 +0100 | [diff] [blame] | 99 | sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551 |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 100 | echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 101 | sudo apt-get update -qq |
| 102 | sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 103 | |
Jon Skeet | 10a8fb4 | 2016-07-14 22:01:47 +0100 | [diff] [blame] | 104 | # Then install the dotnet SDK as per Ubuntu 14.04 instructions on dot.net. |
Jon Skeet | deaea21 | 2016-07-19 17:57:46 -0700 | [diff] [blame] | 105 | sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list' |
Jon Skeet | 10a8fb4 | 2016-07-14 22:01:47 +0100 | [diff] [blame] | 106 | sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893 |
| 107 | sudo apt-get update -qq |
| 108 | sudo apt-get install -qq dotnet-dev-1.0.0-preview2-003121 |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 109 | fi |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 110 | |
Jon Skeet | 10a8fb4 | 2016-07-14 22:01:47 +0100 | [diff] [blame] | 111 | # Perform "dotnet new" once to get the setup preprocessing out of the |
| 112 | # way. That spews a lot of output (including backspaces) into logs |
| 113 | # otherwise, and can cause problems. It doesn't matter if this step |
| 114 | # is performed multiple times; it's cheap after the first time anyway. |
| 115 | mkdir dotnettmp |
| 116 | (cd dotnettmp; dotnet new > /dev/null) |
| 117 | rm -rf dotnettmp |
| 118 | |
| 119 | (cd csharp/src; dotnet restore) |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 120 | csharp/buildall.sh |
Josh Haberman | e891c29 | 2015-12-30 16:03:49 -0800 | [diff] [blame] | 121 | cd conformance && make test_csharp && cd .. |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 122 | } |
| 123 | |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 124 | build_golang() { |
| 125 | # Go build needs `protoc`. |
| 126 | internal_build_cpp |
| 127 | # Add protoc to the path so that the examples build finds it. |
| 128 | export PATH="`pwd`/src:$PATH" |
| 129 | |
| 130 | # Install Go and the Go protobuf compiler plugin. |
Feng Xiao | 20fbb35 | 2016-07-21 18:04:56 -0700 | [diff] [blame] | 131 | on_travis sudo apt-get update -qq |
| 132 | on_travis sudo apt-get install -qq golang |
| 133 | |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 134 | export GOPATH="$HOME/gocode" |
| 135 | mkdir -p "$GOPATH/src/github.com/google" |
Feng Xiao | 20fbb35 | 2016-07-21 18:04:56 -0700 | [diff] [blame] | 136 | rm -f "$GOPATH/src/github.com/google/protobuf" |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 137 | ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf" |
| 138 | export PATH="$GOPATH/bin:$PATH" |
| 139 | go get github.com/golang/protobuf/protoc-gen-go |
| 140 | |
| 141 | cd examples && make gotest && cd .. |
| 142 | } |
| 143 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 144 | use_java() { |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 145 | version=$1 |
| 146 | case "$version" in |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 147 | jdk7) |
Josh Haberman | 0f8c25d | 2016-02-19 09:11:38 -0800 | [diff] [blame] | 148 | on_travis sudo apt-get install openjdk-7-jdk |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 149 | export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH |
Feng Xiao | ad49ed7 | 2016-07-21 11:37:46 -0700 | [diff] [blame] | 150 | export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 151 | ;; |
| 152 | oracle7) |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 153 | if [ "$TRAVIS" == "true" ]; then |
| 154 | sudo apt-get install python-software-properties # for apt-add-repository |
| 155 | echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \ |
| 156 | sudo debconf-set-selections |
| 157 | yes | sudo apt-add-repository ppa:webupd8team/java |
| 158 | yes | sudo apt-get install oracle-java7-installer |
| 159 | fi; |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 160 | export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH |
Feng Xiao | ad49ed7 | 2016-07-21 11:37:46 -0700 | [diff] [blame] | 161 | export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 162 | ;; |
| 163 | esac |
| 164 | |
Josh Haberman | 1ee0fda | 2016-03-03 16:02:55 -0800 | [diff] [blame] | 165 | if [ "$TRAVIS" != "true" ]; then |
| 166 | MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository |
| 167 | MVN="$MVN -e -X --offline -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY" |
| 168 | fi; |
| 169 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 170 | which java |
| 171 | java -version |
Feng Xiao | ad49ed7 | 2016-07-21 11:37:46 -0700 | [diff] [blame] | 172 | $MVN -version |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Josh Haberman | d08c39c | 2016-02-20 12:03:39 -0800 | [diff] [blame] | 175 | # --batch-mode supresses download progress output that spams the logs. |
Josh Haberman | b28b3f6 | 2016-02-20 12:17:10 -0800 | [diff] [blame] | 176 | MVN="mvn --batch-mode" |
Josh Haberman | d08c39c | 2016-02-20 12:03:39 -0800 | [diff] [blame] | 177 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 178 | build_java() { |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 179 | version=$1 |
| 180 | dir=java_$version |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 181 | # Java build needs `protoc`. |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 182 | internal_build_cpp |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 183 | cp -r java $dir |
| 184 | cd $dir && $MVN clean && $MVN test |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 185 | cd ../.. |
| 186 | } |
| 187 | |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 188 | # The conformance tests are hard-coded to work with the $ROOT/java directory. |
| 189 | # So this can't run in parallel with two different sets of tests. |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 190 | build_java_with_conformance_tests() { |
| 191 | # Java build needs `protoc`. |
| 192 | internal_build_cpp |
Josh Haberman | d08c39c | 2016-02-20 12:03:39 -0800 | [diff] [blame] | 193 | cd java && $MVN test && $MVN install |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 194 | cd util && $MVN package assembly:single |
Feng Xiao | af81dcf | 2015-12-21 03:25:59 -0800 | [diff] [blame] | 195 | cd ../.. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 196 | cd conformance && make test_java && cd .. |
| 197 | } |
| 198 | |
| 199 | build_javanano() { |
| 200 | # Java build needs `protoc`. |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 201 | internal_build_cpp |
Josh Haberman | b28b3f6 | 2016-02-20 12:17:10 -0800 | [diff] [blame] | 202 | cd javanano && $MVN test && cd .. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 203 | } |
| 204 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 205 | build_java_jdk7() { |
| 206 | use_java jdk7 |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 207 | build_java_with_conformance_tests |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 208 | } |
| 209 | build_java_oracle7() { |
| 210 | use_java oracle7 |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 211 | build_java oracle7 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 212 | } |
Feng Xiao | baa4023 | 2016-07-29 14:11:21 -0700 | [diff] [blame] | 213 | build_java_compatibility() { |
| 214 | use_java jdk7 |
| 215 | internal_build_cpp |
| 216 | # Use the unit-tests extraced from 2.5.0 to test the compatibilty between |
| 217 | # 3.0.0-beta-4 and the current version. |
| 218 | cd java/compatibility_tests/v2.5.0 |
| 219 | ./test.sh 3.0.0-beta-4 |
| 220 | } |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 221 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 222 | build_javanano_jdk7() { |
| 223 | use_java jdk7 |
| 224 | build_javanano |
| 225 | } |
| 226 | build_javanano_oracle7() { |
| 227 | use_java oracle7 |
| 228 | build_javanano |
| 229 | } |
| 230 | |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 231 | internal_install_python_deps() { |
Josh Haberman | 483533d | 2016-02-19 12:48:33 -0800 | [diff] [blame] | 232 | if [ "$TRAVIS" != "true" ]; then |
| 233 | return; |
| 234 | fi |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 235 | # Install tox (OS X doesn't have pip). |
| 236 | if [ $(uname -s) == "Darwin" ]; then |
| 237 | sudo easy_install tox |
| 238 | else |
| 239 | sudo pip install tox |
| 240 | fi |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 241 | # Only install Python2.6/3.x on Linux. |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 242 | if [ $(uname -s) == "Linux" ]; then |
| 243 | sudo apt-get install -y python-software-properties # for apt-add-repository |
| 244 | sudo apt-add-repository -y ppa:fkrull/deadsnakes |
| 245 | sudo apt-get update -qq |
| 246 | sudo apt-get install -y python2.6 python2.6-dev |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 247 | sudo apt-get install -y python3.3 python3.3-dev |
| 248 | sudo apt-get install -y python3.4 python3.4-dev |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 249 | fi |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 250 | } |
| 251 | |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 252 | build_objectivec_ios() { |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 253 | # Reused the build script that takes care of configuring and ensuring things |
| 254 | # are up to date. The OS X test runs the objc conformance test, so skip it |
| 255 | # here. |
| 256 | # Note: travis has xctool installed, and we've looked at using it in the past |
| 257 | # but it has ended up proving unreliable (bugs), an they are removing build |
| 258 | # support in favor of xcbuild (or just xcodebuild). |
| 259 | objectivec/DevTools/full_mac_build.sh \ |
| 260 | --core-only --skip-xcode-osx --skip-objc-conformance "$@" |
| 261 | } |
| 262 | |
| 263 | build_objectivec_ios_debug() { |
| 264 | build_objectivec_ios --skip-xcode-release |
| 265 | } |
| 266 | |
| 267 | build_objectivec_ios_release() { |
| 268 | build_objectivec_ios --skip-xcode-debug |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | build_objectivec_osx() { |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 272 | # Reused the build script that takes care of configuring and ensuring things |
| 273 | # are up to date. |
| 274 | objectivec/DevTools/full_mac_build.sh \ |
| 275 | --core-only --skip-xcode-ios |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 276 | } |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 277 | |
Sergio Campamá | f0c1492 | 2016-06-14 11:26:01 -0700 | [diff] [blame] | 278 | build_objectivec_cocoapods_integration() { |
Sergio Campamá | f0c1492 | 2016-06-14 11:26:01 -0700 | [diff] [blame] | 279 | # Update pod to the latest version. |
| 280 | gem install cocoapods --no-ri --no-rdoc |
| 281 | objectivec/Tests/CocoaPods/run_tests.sh |
| 282 | } |
| 283 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 284 | build_python() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 285 | internal_build_cpp |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 286 | internal_install_python_deps |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 287 | cd python |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 288 | # Only test Python 2.6/3.x on Linux |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 289 | if [ $(uname -s) == "Linux" ]; then |
Jie Luo | 2850a98 | 2015-10-09 17:07:03 -0700 | [diff] [blame] | 290 | envlist=py\{26,27,33,34\}-python |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 291 | else |
| 292 | envlist=py27-python |
| 293 | fi |
| 294 | tox -e $envlist |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 295 | cd .. |
| 296 | } |
| 297 | |
| 298 | build_python_cpp() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 299 | internal_build_cpp |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 300 | internal_install_python_deps |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 301 | export LD_LIBRARY_PATH=../src/.libs # for Linux |
| 302 | export DYLD_LIBRARY_PATH=../src/.libs # for OS X |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 303 | cd python |
Dan O'Reilly | d9598ca | 2015-08-26 20:30:41 -0400 | [diff] [blame] | 304 | # Only test Python 2.6/3.x on Linux |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 305 | if [ $(uname -s) == "Linux" ]; then |
Jisi Liu | 72bd9c9 | 2015-10-06 10:48:57 -0700 | [diff] [blame] | 306 | # py26 is currently disabled due to json_format |
| 307 | envlist=py\{27,33,34\}-cpp |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 308 | else |
| 309 | envlist=py27-cpp |
| 310 | fi |
| 311 | tox -e $envlist |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 312 | cd .. |
| 313 | } |
| 314 | |
Jie Luo | ea51149 | 2017-01-23 15:11:00 -0800 | [diff] [blame] | 315 | build_python_compatibility() { |
| 316 | internal_build_cpp |
| 317 | # Use the unit-tests extraced from 2.5.0 to test the compatibilty. |
| 318 | cd python/compatibility_tests/v2.5.0 |
| 319 | # Test between 2.5.0 and the current version. |
| 320 | ./test.sh 2.5.0 |
| 321 | # Test between 3.0.0-beta-1 and the current version. |
| 322 | ./test.sh 3.0.0-beta-1 |
| 323 | } |
| 324 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 325 | build_ruby21() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 326 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 327 | cd ruby && bash travis-test.sh ruby-2.1 && cd .. |
| 328 | } |
| 329 | build_ruby22() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 330 | internal_build_cpp # For conformance tests. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 331 | cd ruby && bash travis-test.sh ruby-2.2 && cd .. |
| 332 | } |
| 333 | build_jruby() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 334 | internal_build_cpp # For conformance tests. |
Feng Xiao | 20fbb35 | 2016-07-21 18:04:56 -0700 | [diff] [blame] | 335 | # TODO(xiaofeng): Upgrade to jruby-9.x. There are some broken jests to be |
| 336 | # fixed. |
| 337 | cd ruby && bash travis-test.sh jruby-1.7 && cd .. |
| 338 | } |
| 339 | build_ruby_all() { |
| 340 | build_ruby21 |
| 341 | build_ruby22 |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 342 | # TODO(teboring): Disable jruby test temperarily for it randomly fails. |
| 343 | # https://grpc-testing.appspot.com/job/protobuf_pull_request/735/consoleFull. |
Paul Yang | d8f54c4 | 2016-12-08 16:27:56 -0800 | [diff] [blame] | 344 | # build_jruby |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 345 | } |
| 346 | |
Josh Haberman | e9cf31e | 2015-12-21 15:18:17 -0800 | [diff] [blame] | 347 | build_javascript() { |
| 348 | internal_build_cpp |
Josh Haberman | 0d2d8bc | 2015-12-28 06:43:42 -0800 | [diff] [blame] | 349 | cd js && npm install && npm test && cd .. |
Josh Haberman | e9cf31e | 2015-12-21 15:18:17 -0800 | [diff] [blame] | 350 | } |
| 351 | |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 352 | generate_php_test_proto() { |
| 353 | internal_build_cpp |
| 354 | pushd php/tests |
| 355 | # Generate test file |
| 356 | rm -rf generated |
| 357 | mkdir generated |
| 358 | ../../src/protoc --php_out=generated proto/test.proto proto/test_include.proto proto/test_no_namespace.proto |
| 359 | pushd ../../src |
| 360 | ./protoc --php_out=../php/tests/generated google/protobuf/empty.proto |
| 361 | popd |
| 362 | popd |
| 363 | } |
| 364 | |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 365 | use_php() { |
| 366 | VERSION=$1 |
| 367 | PHP=`which php` |
| 368 | PHP_CONFIG=`which php-config` |
| 369 | PHPIZE=`which phpize` |
| 370 | rm $PHP |
| 371 | rm $PHP_CONFIG |
| 372 | rm $PHPIZE |
| 373 | cp "/usr/bin/php$VERSION" $PHP |
| 374 | cp "/usr/bin/php-config$VERSION" $PHP_CONFIG |
| 375 | cp "/usr/bin/phpize$VERSION" $PHPIZE |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 376 | generate_php_test_proto |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 377 | } |
| 378 | |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 379 | use_php_zts() { |
| 380 | VERSION=$1 |
| 381 | PHP=`which php` |
| 382 | PHP_CONFIG=`which php-config` |
| 383 | PHPIZE=`which phpize` |
| 384 | ln -sfn "/usr/local/php-${VERSION}-zts/bin/php" $PHP |
| 385 | ln -sfn "/usr/local/php-${VERSION}-zts/bin/php-config" $PHP_CONFIG |
| 386 | ln -sfn "/usr/local/php-${VERSION}-zts/bin/phpize" $PHPIZE |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 387 | generate_php_test_proto |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 388 | } |
| 389 | |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 390 | use_php_bc() { |
| 391 | VERSION=$1 |
| 392 | PHP=`which php` |
| 393 | PHP_CONFIG=`which php-config` |
| 394 | PHPIZE=`which phpize` |
| 395 | ln -sfn "/usr/local/php-${VERSION}-bc/bin/php" $PHP |
| 396 | ln -sfn "/usr/local/php-${VERSION}-bc/bin/php-config" $PHP_CONFIG |
| 397 | ln -sfn "/usr/local/php-${VERSION}-bc/bin/phpize" $PHPIZE |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 398 | generate_php_test_proto |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 399 | } |
| 400 | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 401 | build_php5.5() { |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 402 | use_php 5.5 |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 403 | pushd php |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 404 | rm -rf vendor |
| 405 | cp -r /usr/local/vendor-5.5 vendor |
| 406 | ./vendor/bin/phpunit |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 407 | popd |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 408 | } |
| 409 | |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 410 | build_php5.5_c() { |
| 411 | use_php 5.5 |
| 412 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 413 | } |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 414 | |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 415 | build_php5.5_zts_c() { |
| 416 | use_php_zts 5.5 |
Bo Yang | 4f3d20a | 2016-10-05 10:54:39 -0700 | [diff] [blame] | 417 | wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 418 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 419 | } |
| 420 | |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 421 | build_php5.5_32() { |
| 422 | use_php_bc 5.5 |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 423 | pushd php |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 424 | rm -rf vendor |
| 425 | cp -r /usr/local/vendor-5.5 vendor |
| 426 | ./vendor/bin/phpunit |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 427 | popd |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 428 | } |
| 429 | |
Paul Yang | df83907 | 2016-11-10 11:20:50 -0800 | [diff] [blame] | 430 | build_php5.5_c_32() { |
| 431 | use_php_bc 5.5 |
| 432 | wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit |
| 433 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 434 | } |
| 435 | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 436 | build_php5.6() { |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 437 | use_php 5.6 |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 438 | pushd php |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 439 | rm -rf vendor |
| 440 | cp -r /usr/local/vendor-5.6 vendor |
| 441 | ./vendor/bin/phpunit |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 442 | popd |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 443 | } |
| 444 | |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 445 | build_php5.6_c() { |
| 446 | use_php 5.6 |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 447 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 448 | } |
| 449 | |
Bo Yang | 63448e6 | 2016-10-05 18:28:13 -0700 | [diff] [blame] | 450 | build_php5.6_mac() { |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 451 | generate_php_test_proto |
Bo Yang | 63448e6 | 2016-10-05 18:28:13 -0700 | [diff] [blame] | 452 | # Install PHP |
| 453 | curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6 |
Paul Yang | 1f2dbc8 | 2016-11-08 11:38:34 -0800 | [diff] [blame] | 454 | PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time |
| 455 | export PATH="$PHP_FOLDER/bin:$PATH" |
Bo Yang | 63448e6 | 2016-10-05 18:28:13 -0700 | [diff] [blame] | 456 | |
| 457 | # Install phpunit |
| 458 | curl https://phar.phpunit.de/phpunit.phar -L -o phpunit.phar |
| 459 | chmod +x phpunit.phar |
| 460 | sudo mv phpunit.phar /usr/local/bin/phpunit |
| 461 | |
| 462 | # Install valgrind |
| 463 | echo "#! /bin/bash" > valgrind |
| 464 | chmod ug+x valgrind |
| 465 | sudo mv valgrind /usr/local/bin/valgrind |
| 466 | |
| 467 | # Test |
| 468 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 469 | } |
| 470 | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 471 | build_php7.0() { |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 472 | use_php 7.0 |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 473 | pushd php |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 474 | rm -rf vendor |
| 475 | cp -r /usr/local/vendor-7.0 vendor |
| 476 | ./vendor/bin/phpunit |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 477 | popd |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 478 | } |
| 479 | |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 480 | build_php7.0_c() { |
| 481 | use_php 7.0 |
| 482 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
| 483 | } |
| 484 | |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 485 | build_php_all() { |
| 486 | build_php5.5 |
| 487 | build_php5.6 |
| 488 | build_php7.0 |
| 489 | build_php5.5_c |
| 490 | build_php5.6_c |
| 491 | # build_php7.0_c |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 492 | build_php5.5_zts_c |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 493 | } |
| 494 | |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 495 | build_php_all_32() { |
| 496 | build_php5.5_32 |
Paul Yang | df83907 | 2016-11-10 11:20:50 -0800 | [diff] [blame] | 497 | build_php5.5_c_32 |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 498 | } |
| 499 | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 500 | # Note: travis currently does not support testing more than one language so the |
| 501 | # .travis.yml cheats and claims to only be cpp. If they add multiple language |
| 502 | # support, this should probably get updated to install steps and/or |
| 503 | # rvm/gemfile/jdk/etc. entries rather than manually doing the work. |
| 504 | |
| 505 | # .travis.yml uses matrix.exclude to block the cases where app-get can't be |
| 506 | # use to install things. |
| 507 | |
| 508 | # -------- main -------- |
| 509 | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 510 | if [ "$#" -ne 1 ]; then |
| 511 | echo " |
| 512 | Usage: $0 { cpp | |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 513 | cpp_distcheck | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 514 | csharp | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 515 | java_jdk7 | |
| 516 | java_oracle7 | |
Feng Xiao | baa4023 | 2016-07-29 14:11:21 -0700 | [diff] [blame] | 517 | java_compatibility | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 518 | javanano_jdk7 | |
| 519 | javanano_oracle7 | |
| 520 | objectivec_ios | |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 521 | objectivec_ios_debug | |
| 522 | objectivec_ios_release | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 523 | objectivec_osx | |
Sergio Campamá | f0c1492 | 2016-06-14 11:26:01 -0700 | [diff] [blame] | 524 | objectivec_cocoapods_integration | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 525 | python | |
| 526 | python_cpp | |
Jie Luo | ea51149 | 2017-01-23 15:11:00 -0800 | [diff] [blame] | 527 | python_compatibility | |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 528 | ruby21 | |
| 529 | ruby22 | |
Feng Xiao | 20fbb35 | 2016-07-21 18:04:56 -0700 | [diff] [blame] | 530 | jruby | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 531 | ruby_all | |
| 532 | php5.5 | |
| 533 | php5.5_c | |
| 534 | php5.6 | |
| 535 | php5.6_c | |
| 536 | php7.0 | |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 537 | php7.0_c | |
| 538 | php_all) |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 539 | " |
| 540 | exit 1 |
| 541 | fi |
| 542 | |
| 543 | set -e # exit immediately on error |
| 544 | set -x # display all commands |
| 545 | eval "build_$1" |