#!/bin/bash # This script is run by Travis, to execute tests in the CI environment. set -e PASSENGER_ROOT=`dirname "$0"` PASSENGER_ROOT=`cd "$PASSENGER_ROOT/../.." && pwd` PASSENGER_ROOT_ON_DOCKER_HOST=${PASSENGER_ROOT_ON_DOCKER_HOST:-$PASSENGER_ROOT} if [[ "$CACHE_DIR_ON_DOCKER_HOST" != "" ]]; then CACHE_DIR=/host_cache else CACHE_DIR="$PWD/cache" CACHE_DIR_ON_DOCKER_HOST="$PWD/cache" fi COMPILE_CONCURRENCY=${COMPILE_CONCURRENCY:-2} TEST_DYNAMIC_WITH_NGINX_VERSION=1.9.15 export VERBOSE=1 export TRACE=1 export DEVDEPS_DEFAULT=no export rvmsudo_secure_path=1 export LC_CTYPE=C.UTF-8 export DEPS_TARGET="$CACHE_DIR/bundle" export USE_CCACHE=true export CCACHE_DIR="$CACHE_DIR/ccache" export CCACHE_COMPRESS=1 export CCACHE_COMPRESS_LEVEL=3 unset BUNDLE_GEMFILE if [[ -e /etc/workaround-docker-2267 ]]; then HOSTS_FILE=/etc/workaround-docker-2267/hosts sudo ln -s /etc/hosts /etc/workaround-docker-2267/hosts sudo workaround-docker-2267 find /usr/local/rvm/rubies/*/lib/ruby -name resolv.rb | sudo xargs sed -i 's|/etc/hosts|/cte/hosts|g' else HOSTS_FILE=/etc/hosts fi mkdir -p "$DEPS_TARGET" mkdir -p "$CCACHE_DIR" sudo sh -c "cat >> $HOSTS_FILE" </dev/null <<<"force-unsafe-io" run cp test/config.json.travis test/config.json # Relax permissions on home directory so that the application root # permission checks pass. run chmod g+x,o+x $HOME if [[ "$TEST_RUBY_VERSION" != "" ]]; then echo "$ rvm use $TEST_RUBY_VERSION" if [[ -f ~/.rvm/scripts/rvm ]]; then source ~/.rvm/scripts/rvm else source /usr/local/rvm/scripts/rvm fi rvm use $TEST_RUBY_VERSION if [[ "$TEST_RUBYGEMS_VERSION" = "" ]]; then run gem --version fi fi if [[ "$TEST_RUBYGEMS_VERSION" != "" ]]; then retry_run 3 rvm install rubygems $TEST_RUBYGEMS_VERSION run gem --version fi ORIG_GEM_PATH="$GEM_PATH" if [[ "$INSTALL_ALL_DEPS" = 1 ]]; then run rake_test_install_deps DEVDEPS_DEFAULT=yes INSTALL_DEPS=0 fi if [[ "$TEST_CXX" = 1 ]]; then install_base_test_deps run bundle exec drake -j$COMPILE_CONCURRENCY test:cxx run bundle exec rake test:oxt fi if [[ "$TEST_RUBY" = 1 ]]; then retry_run 3 rake_test_install_deps BASE_DEPS=yes run bundle exec drake -j$COMPILE_CONCURRENCY test:ruby fi if [[ "$TEST_USH" = 1 ]]; then retry_run 3 rake_test_install_deps BASE_DEPS=yes USH_BUNDLES=yes export PASSENGER_CONFIG="$PWD/bin/passenger-config" run "$PASSENGER_CONFIG" install-standalone-runtime --auto pushd src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_core bundle exec rake spec:travis TRAVIS_WITH_SUDO=1 popd pushd src/ruby_supportlib/phusion_passenger/vendor/union_station_hooks_rails bundle exec rake spec:travis GEM_BUNDLE_PATH="$DEPS_TARGET" popd fi if [[ "$TEST_NODE" = 1 ]]; then install_node_and_modules run bundle exec drake -j$COMPILE_CONCURRENCY test:node fi if [[ "$TEST_NGINX" = 1 ]]; then install_base_test_deps install_node_and_modules run ./bin/passenger-install-nginx-module --auto --prefix=/tmp/nginx --auto-download run bundle exec drake -j$COMPILE_CONCURRENCY test:integration:nginx run curl -sSLO http://www.nginx.org/download/nginx-$TEST_DYNAMIC_WITH_NGINX_VERSION.tar.gz run tar zxf nginx-$TEST_DYNAMIC_WITH_NGINX_VERSION.tar.gz run cd nginx-$TEST_DYNAMIC_WITH_NGINX_VERSION run ./configure --add-dynamic-module=$(../bin/passenger-config --nginx-addon-dir) run make run cd .. fi if [[ "$TEST_APACHE2" = 1 ]]; then apt_get_update run sudo apt-get install -y --no-install-recommends \ apache2-mpm-worker apache2-threaded-dev install_base_test_deps install_node_and_modules run ./bin/passenger-install-apache2-module --auto #--no-update-config run rvmsudo ./bin/passenger-install-apache2-module --auto --no-compile run bundle exec drake -j$COMPILE_CONCURRENCY test:integration:apache2 fi if [[ "$TEST_STANDALONE" = 1 ]]; then install_base_test_deps run bundle exec drake -j$COMPILE_CONCURRENCY test:integration:standalone fi if [[ "$TEST_SOURCE_PACKAGING" = 1 ]]; then apt_get_update run sudo apt-get install -y --no-install-recommends source-highlight install_test_deps_with_doctools run bundle exec rspec -f s -c test/integration_tests/source_packaging_test.rb fi