refactor ci scripts
This commit is contained in:
parent
9d391d5885
commit
1277cf92b2
10 changed files with 49 additions and 135 deletions
9
.rvmrc
9
.rvmrc
|
|
@ -1,8 +1,6 @@
|
|||
#!/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
|
||||
|
|
|
|||
12
.travis.yml
12
.travis.yml
|
|
@ -1,27 +1,25 @@
|
|||
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
|
||||
|
|
|
|||
|
|
@ -1,45 +1,12 @@
|
|||
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"
|
||||
|
|
|
|||
|
|
@ -1,32 +0,0 @@
|
|||
#!/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
|
||||
|
|
@ -1,15 +1,6 @@
|
|||
#!/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"
|
||||
|
|
|
|||
13
script/ci/build.sh
Executable file
13
script/ci/build.sh
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
#!/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
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# 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
|
||||
3
script/env/ensure_right_rubygems
vendored
Normal file
3
script/env/ensure_right_rubygems
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if [ "$(gem --version)" != "$rubygems_version" ]; then
|
||||
rvm rubygems "$rubygems_version"
|
||||
fi
|
||||
3
script/env/ruby_env
vendored
Normal file
3
script/env/ruby_env
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
rubygems_version="1.8.24"
|
||||
ruby_version="1.9.3-p194"
|
||||
gemset="diaspora"
|
||||
Loading…
Reference in a new issue