Skip to content

Commit

Permalink
Integrate passenger_rpm_automation
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Jul 25, 2014
1 parent c232206 commit 7402632
Show file tree
Hide file tree
Showing 25 changed files with 235 additions and 864 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -0,0 +1,3 @@
[submodule "packaging/rpm"]
path = packaging/rpm
url = https://github.com/phusion/passenger_rpm_automation.git
17 changes: 9 additions & 8 deletions .travis.yml
@@ -1,15 +1,16 @@
language: ruby

env:
- TEST_CXX=1 TEST_NODE=1
- TEST_CXX=1 SUDO=1
- TEST_RUBY=1 TEST_RUBY_VERSION=1.8.7 TEST_CLASSIC_RAILS=0 TEST_RUBYGEMS_VERSION=1.8.25
- TEST_RUBY=1 TEST_RUBY_VERSION=1.9.3 TEST_CLASSIC_RAILS=0
- TEST_NGINX=1 TEST_STANDALONE=1
- TEST_APACHE2=1
- TEST_SOURCE_PACKAGING=1 TEST_DEBIAN_PACKAGING=1
# - TEST_CXX=1 TEST_NODE=1
# - TEST_CXX=1 SUDO=1
# - TEST_RUBY=1 TEST_RUBY_VERSION=1.8.7 TEST_CLASSIC_RAILS=0 TEST_RUBYGEMS_VERSION=1.8.25
# - TEST_RUBY=1 TEST_RUBY_VERSION=1.9.3 TEST_CLASSIC_RAILS=0
# - TEST_NGINX=1 TEST_STANDALONE=1
# - TEST_APACHE2=1
# - TEST_SOURCE_PACKAGING=1 TEST_DEBIAN_PACKAGING=1
- TEST_RPM_PACKAGING=1

script: ./dev/run_travis.sh
script: ./dev/ci/run_travis.sh

notifications:
slack: phusionnl:PH5p7JYXyv2XLDpICHh8Nj6F
1 change: 0 additions & 1 deletion Rakefile
Expand Up @@ -38,7 +38,6 @@ else
require 'build/integration_tests'
require 'build/misc'
require 'build/debian'
require 'build/rpm'
end

#### Default tasks
Expand Down
16 changes: 12 additions & 4 deletions build/integration_tests.rb
Expand Up @@ -23,11 +23,19 @@

### Integration tests ###

def integration_test_dependencies(runtime_target_name)
if string_option('PASSENGER_LOCATION_CONFIGURATION_FILE')
return []
else
return [runtime_target_name, NATIVE_SUPPORT_TARGET].compact
end
end

desc "Run all integration tests"
task 'test:integration' => ['test:integration:apache2', 'test:integration:nginx'] do
end

dependencies = [:_apache2, NATIVE_SUPPORT_TARGET].compact
dependencies = integration_test_dependencies(:_apache2)
desc "Run Apache 2 integration tests"
task 'test:integration:apache2' => dependencies do
if PlatformInfo.rspec.nil?
Expand All @@ -45,7 +53,7 @@
end
end

dependencies = [:_nginx, NATIVE_SUPPORT_TARGET].compact
dependencies = integration_test_dependencies(:_nginx)
desc "Run Nginx integration tests"
task 'test:integration:nginx' => dependencies do
if PlatformInfo.rspec.nil?
Expand All @@ -67,7 +75,7 @@
end
end

dependencies = [:_nginx, NATIVE_SUPPORT_TARGET].compact
dependencies = integration_test_dependencies(:_nginx)
desc "Run Passenger Standalone integration tests"
task 'test:integration:standalone' => dependencies do
if PlatformInfo.rspec.nil?
Expand Down Expand Up @@ -124,7 +132,7 @@
sh "cd test && exec #{command}"
end

dependencies = [:_apache2, NATIVE_SUPPORT_TARGET].compact
dependencies = integration_test_dependencies(:_apache2)
desc "Run the 'apache2' integration test infinitely, and abort if/when it fails"
task 'test:restart' => dependencies do
require 'shellwords'
Expand Down
128 changes: 0 additions & 128 deletions build/rpm.rb

This file was deleted.

24 changes: 24 additions & 0 deletions dev/ci/inituidgid
@@ -0,0 +1,24 @@
#!/bin/bash
set -e

if grep -q docker_env /etc/group; then
delgroup docker_env >/dev/null
fi

chown -R "$APP_UID:$APP_GID" /home/appa
groupmod -g "$APP_GID" appa
usermod -u "$APP_UID" -g "$APP_GID" appa

groupmod -g "$DOCKER_GID" docker
usermod -a -G docker appa

# There's something strange with either Docker or the kernel, so that
# the 'appa' user cannot access its home directory even after a proper
# chown/chmod. We work around it like this.
mv /home/appa /home/appa2
cp -dpR /home/appa2 /home/appa
rm -rf /home/appa2

if [[ $# -gt 0 ]]; then
exec "$@"
fi
53 changes: 53 additions & 0 deletions dev/ci/run_jenkins.sh
@@ -0,0 +1,53 @@
#!/bin/bash
# This script is run by Jenkins, to execute tests in the CI environment.

set -e

PASSENGER_ROOT=`dirname "$0"`
PASSENGER_ROOT=`cd "$PASSENGER_ROOT/../.." && pwd`
WORKSPACE=${WORKSPACE:-/tmp}

JENKINS_CACHE_DIR="$WORKSPACE/jenkins_cache"
mkdir -p "$JENKINS_CACHE_DIR"
if [[ "$TEST_RPM_BUILDING" != 0 ]]; then
rm -rf "$JENKINS_CACHE_DIR/passenger_rpm/output"
fi

function run_exec()
{
echo "$ $@"
exec "$@"
}

# We do not use the my_init inside the image to work around
# a bug in baseimage-docker 0.9.12: pressing Ctrl-C does
# not properly result in a non-zero exit status.
run_exec docker run --rm -t -i \
-v "$PASSENGER_ROOT:/passenger" \
-v /var/run/docker.sock:/docker.sock \
-v "$JENKINS_CACHE_DIR:/host_cache" \
-e "DOCKER_HOST=unix:///docker.sock" \
-e "DOCKER_GID=`getent group docker | cut -d: -f3`" \
-e "PASSENGER_ROOT_ON_DOCKER_HOST=$PASSENGER_ROOT" \
-e "CACHE_DIR_ON_DOCKER_HOST=$JENKINS_CACHE_DIR" \
-e "APP_UID=`id -u`" \
-e "APP_GID=`id -g`" \
-e "SUDO=$SUDO" \
-e "TEST_CXX=$TEST_CXX" \
-e "TEST_RUBY=$TEST_RUBY" \
-e "TEST_NODE=$TEST_NODE" \
-e "TEST_RUBY_VERSION=$TEST_RUBY_VERSION" \
-e "TEST_CLASSIC_RAILS=$TEST_CLASSIC_RAILS" \
-e "TEST_RUBYGEMS_VERSION=$TEST_RUBYGEMS_VERSION" \
-e "TEST_NGINX=$TEST_NGINX" \
-e "TEST_APACHE2=$TEST_APACHE2" \
-e "TEST_STANDALONE=$TEST_STANDALONE" \
-e "TEST_SOURCE_PACKAGING=$TEST_SOURCE_PACKAGING" \
-e "TEST_DEBIAN_PACKAGING=$TEST_DEBIAN_PACKAGING" \
-e "TEST_RPM_PACKAGING=$TEST_RPM_PACKAGING" \
-e "TEST_RPM_BUILDING=$TEST_RPM_BUILDING" \
phusion/apachai-hopachai-sandbox \
python /passenger/packaging/rpm/internal/my_init --skip-runit --skip-startup-files --quiet -- \
/passenger/dev/ci/inituidgid \
/sbin/setuser appa \
/bin/bash -lc "cd /passenger && exec ./dev/ci/run_travis.sh"
59 changes: 59 additions & 0 deletions dev/ci/run_rpm_tests.sh
@@ -0,0 +1,59 @@
#!/bin/bash
# This script is run by run_travis.sh, to execute RPM packaging tests in the CI environment.

set -e

function run()
{
echo "$ $@"
"$@"
}

function retry_run()
{
local reset='\x1B[0m'
local red='\x1B[31m'
local yellow='\x1B[33m'

local max_tries="$1"
local number=2
shift

echo "$ $@"
while true; do
if "$@"; then
return 0
elif [[ $number -le $max_tries ]]; then
echo -e "${yellow}The command \"$@\" failed. Retrying, $number of $max_tries:${reset}"
(( number++ ))
else
echo -e "${red}The command \"$@\" failed after $max_tries attempts. Giving up.${reset}"
return 1
fi
done
}

function yum_install()
{
run yum install -y --skip-broken --enablerepo centosplus "$@"
}

export CACHING=false
export DEVDEPS_DEFAULT=no

cd /passenger

echo '%_excludedocs 0' > /etc/rpm/macros.imgcreate
sed -i 's/nodocs//' /etc/yum.conf

run yum_install /packages/*.x86_64.rpm /packages/*.noarch.rpm
retry_run 3 rake test:install_deps BASE_DEPS=yes
chown -R app: /var/log/nginx /var/lib/nginx

run rake test:integration:native_packaging
run /system/internal/setuser app \
env PASSENGER_LOCATION_CONFIGURATION_FILE=/usr/lib/ruby/site_ruby/1.8/phusion_passenger/locations.ini \
scl enable python27 nodejs010 'rake test:integration:apache2'
run /system/internal/setuser app \
env PASSENGER_LOCATION_CONFIGURATION_FILE=/usr/lib/ruby/site_ruby/1.8/phusion_passenger/locations.ini \
scl enable python27 nodejs010 'rake test:integration:nginx'

0 comments on commit 7402632

Please sign in to comment.