Permalink
Browse files

refactor ci scripts

  • Loading branch information...
1 parent 9d391d5 commit 1277cf92b2e1893f5a986b9d897ed27f5d8cb574 @jhass jhass committed Sep 12, 2012
Showing with 49 additions and 135 deletions.
  1. +2 −7 .rvmrc
  2. +5 −7 .travis.yml
  3. +11 −7 config/database.yml.example
  4. +9 −42 lib/tasks/ci.rake
  5. +0 −32 script/ci/before.sh
  6. +3 −12 script/ci/before_install.sh
  7. +13 −0 script/ci/build.sh
  8. +0 −28 script/ci/xvfb
  9. +3 −0 script/env/ensure_right_rubygems
  10. +3 −0 script/env/ruby_env
View
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
View
@@ -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
View
@@ -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"
View
@@ -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"
View
@@ -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
View
@@ -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
@@ -0,0 +1,3 @@
+if [ "$(gem --version)" != "$rubygems_version" ]; then
+ rvm rubygems "$rubygems_version"
+fi
View
@@ -0,0 +1,3 @@
+rubygems_version="1.8.24"
+ruby_version="1.9.3-p194"
+gemset="diaspora"

0 comments on commit 1277cf9

Please sign in to comment.