Commit 1277cf92 authored by Jonne Haß's avatar Jonne Haß

refactor ci scripts

parent 9d391d58
#!/bin/bash
rubygems_version="1.8.24"
ruby_version="1.9.3-p194"
gemset="diaspora"
source ./script/env/ruby_env
if [ -e '.rvmrc.local' ]; then
source .rvmrc.local;
......@@ -18,7 +16,4 @@ else
fi
fi
if [ "$(gem --version)" != "$rubygems_version" ]; then
rvm rubygems "$rubygems_version"
fi
source ./script/env/ensure_right_rubygems
branches:
only:
- 'master'
- 'develop'
language: ruby
rvm:
- 1.9.3
env:
- DB=postgres BUILD_TYPE=other
- DB=mysql BUILD_TYPE=other
- DB=postgres BUILD_TYPE=cucumber
- DB=mysql BUILD_TYPE=cucumber
before_install:
- "./script/ci/before_install.sh"
bundler_args: "--without development production heroku"
before_script: "./script/ci/before.sh"
script: "bundle exec rake travis"
before_install: "./script/ci/before_install.sh"
script: "./script/ci/build.sh"
notifications:
irc:
channels:
- 'irc.freenode.org:6667#diaspora-dev'
- "irc.freenode.org:6667#diaspora-dev"
......@@ -16,20 +16,24 @@ postgres: &postgres
password:
encoding: unicode
# You can ignore this
postgres_travis: &postgres_travis
adapter: postgresql
username: postgres
# Comment the the mysql line and uncomment the postgres line
# if you want to use postgres
common: &common
choose: &choose
# Choose one of the following
<<: *mysql
#<<: *postgres
##################################################
#### CONFIGURE ABOVE #############################
##################################################
# Normally you don't need to touch anything here
postgres_travis: &postgres_travis
adapter: postgresql
username: postgres
common: &common
<<: *choose
development:
<<: *common
database: diaspora_development
......
namespace :ci do
desc "Run tests in the cloud. ZOMG!"
task :travis do
if ENV['BUILD_TYPE'] == 'cucumber'
puts "Running cucumber features..."
system("export DISPLAY=:99.0 && bundle exec rake cucumber")
raise "Cucumber failed!" unless $?.exitstatus == 0
else
["rake generate_fixtures", "rake spec"].each do |cmd|
puts "Running bundle exec #{cmd}..."
system("bundle exec #{cmd}")
raise "#{cmd} failed!" unless $?.exitstatus == 0
end
["rake jasmine:ci"].each do |cmd|
puts "Running bundle exec #{cmd}..."
system("export DISPLAY=:99.0 && GROUP=oauth bundle exec #{cmd}")
raise "#{cmd} failed!" unless $?.exitstatus == 0
end
end
end
desc "Run tests that can't run on travis"
task :hard_things => [:environment, :'ci:migrate'] do
puts "Starting virtual display..."
`sh -e /etc/init.d/xvfb start`
puts "Starting specs..."
system('export DISPLAY=:99.0 && CI=true bundle exec rake cucumber')
exit_status = $?.exitstatus
puts "Stopping virtual display..."
`sh -e /etc/init.d/xvfb stop`
puts "Cleaning up..."
FileUtils.rm_rf(Rails.root.join('public', 'uploads', 'images'))
FileUtils.rm_rf(Rails.root.join('public', 'uploads', 'tmp'))
raise "tests failed!" unless exit_status == 0
puts "All tests passed!"
end
task :migrate => ['db:drop', 'db:create', 'db:schema:load'] do
system('bundle exec rake db:test:prepare')
raise "migration failed!" unless $?.exitstatus == 0
namespace :travis do
desc "Run everyhting except cucumber"
task :other => [ :prepare_db, :generate_fixtures, :spec, "jasmine:ci" ]
desc "Run cucumber"
task :cucumber => [ :prepare_db, "rake:cucumber" ]
desc "Prepare db"
task :prepare_db => [ "db:create", "db:test:load"]
end
end
task :travis => "ci:travis"
#!/bin/bash
# Install firefox & Xvfb, in preparation for cucumber & jasmine
#echo "Installing Firefox and Xvfb"
#sudo aptitude --quiet=2 --without-recommends --assume-yes install firefox xvfb
#sudo cp script/ci/xvfb /etc/init.d/xvfb
echo "Start Xvfb"
sh -e /etc/init.d/xvfb start
# Regenerate css files
#echo "Regenerating CSS files"
#bundle exec sass -q --update public/stylesheets/sass/:public/stylesheets/
# setup swapfile
#echo "creating a swapfile"
#sudo dd if=/dev/zero of=swapfile bs=1M count=96
#sudo mkswap swapfile
#sudo swapon swapfile
#sudo sysctl vm.swappiness=100
# Create a database.yml for the right database
echo "Setting up database.yml for $DB"
cp config/database.yml.example config/database.yml
if [ "$DB" = "postgres" ]; then
sed -i 's/*mysql/*postgres_travis/' config/database.yml
fi
# Set up database
echo "Creating databases for $DB and loading schema"
bundle exec rake db:create --trace
bundle exec rake db:schema:load --trace
#!/bin/bash
# Workaround dependency issues
if ([ "$DB" == "postgres" -a "$TRAVIS_RUBY_VERSION" == "ree" ]); then
echo "Rebuild Gemfile.lock to get rid of diaspora-clients 1.9 dependencies"
bundle update diaspora-client
fi
# Ensure known RubyGems version
if [ "$(gem --version)" != "1.8.17" ]; then
echo "RubyGems version is $(gem --version). Changing..."
rvm rubygems 1.8.17
echo "Changed RubyGems version to $(gem --version)."
fi
envdir="$(readlink -e $(dirname $0))/../env"
source "$envdir/ruby_env"
source "$envdir/ensure_right_rubygems"
#!/bin/bash
# Create a database.yml for the right database
echo "Setting up database.yml for $DB"
cp config/database.yml.example config/database.yml
if [ "$DB" = "postgres" ]; then
sed -i 's/*choose/*postgres_travis/' config/database.yml
fi
command="bundle exec rake --trace ci:travis:${BUILD_TYPE}"
exec xvfb-run --auto-servernum --server-num=1 --server-args="-screen 0 1280x1024x8" $command
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
XVFB=/usr/bin/Xvfb
XVFBARGS=":99 -ac -screen 0 1024x768x16"
PIDFILE=/tmp/cucumber_xvfb_99.pid
case "$1" in
start)
echo -n "Starting virtual X frame buffer: Xvfb"
/sbin/start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile --background --exec $XVFB -- $XVFBARGS
echo "."
;;
stop)
echo -n "Stopping virtual X frame buffer: Xvfb"
/sbin/start-stop-daemon --stop --quiet --pidfile $PIDFILE
rm -f $PIDFILE
echo "."
;;
restart)
$0 stop
$0 start
;;
*)
echo "Usage: /etc/init.d/xvfb {start|stop|restart}"
exit 1
esac
exit 0
\ No newline at end of file
if [ "$(gem --version)" != "$rubygems_version" ]; then
rvm rubygems "$rubygems_version"
fi
rubygems_version="1.8.24"
ruby_version="1.9.3-p194"
gemset="diaspora"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment