Skip to content

Commit

Permalink
Travis CI: don't try to test mysql2 adapter on Rails 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Aug 2, 2011
1 parent 033f9e7 commit 16636f5
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 24 deletions.
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
script: spec/ci.rb
rvm:
- 1.8.7
- 1.9.2
gemfile:
- Gemfile
- Gemfile.rails3.0
env:
- DB=sqlite3
- DB=mysql
- DB=mysql2
- DB=postgres
5 changes: 1 addition & 4 deletions Gemfile.rails3.0
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@ gem 'mocha', '~> 0.9.8'

gem 'sqlite3', '~> 1.3.3'

group :mysql do
gem 'mysql', '~> 2.8.1'
gem 'mysql2', '>= 0.3.6'
end
gem 'mysql', '~> 2.8.1', :group => :mysql
gem 'pg', '~> 0.11', :group => :pg

group :debug do
Expand Down
2 changes: 0 additions & 2 deletions Gemfile.rails3.0.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ GEM
ruby_core_source (>= 0.1.4)
mocha (0.9.12)
mysql (2.8.1)
mysql2 (0.3.6)
pg (0.11.0)
rack (1.2.3)
rack-mount (0.6.14)
Expand Down Expand Up @@ -83,7 +82,6 @@ DEPENDENCIES
activeresource (~> 3.0.0)
mocha (~> 0.9.8)
mysql (~> 2.8.1)
mysql2 (>= 0.3.6)
pg (~> 0.11)
rake
rspec (~> 2.6.0)
Expand Down
14 changes: 1 addition & 13 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ begin
rescue LoadError
# no spec tasks
else
task :default => [:create_database, :spec]
task :default => :spec

desc 'Run ALL OF the specs'
RSpec::Core::RakeTask.new(:spec) do |t|
Expand All @@ -19,18 +19,6 @@ else
end
end

desc 'Create necessary databases'
task :create_database do |variable|
case ENV['DB']
when 'mysql', 'mysql2'
`mysql -e 'create database will_paginate;'`
abort "failed to create mysql database" unless $?.success?
when 'postgres'
`psql -c 'create database will_paginate;' -U postgres`
abort "failed to create postgres database" unless $?.success?
end
end

desc 'Run specs against both Rails 3.1 and Rails 3.0'
task :rails3 do |variable|
system 'bundle exec rake spec && BUNDLE_GEMFILE=Gemfile.rails3.0 bundle exec rake spec:rails'
Expand Down
29 changes: 29 additions & 0 deletions spec/ci.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
databases = %w[ sqlite3 mysql mysql2 postgres ]
databases.delete 'mysql2' if ENV['BUNDLE_GEMFILE'].to_s.include? 'rails3.0'

def announce(name, msg)
puts "\n\e[1;33m[#{name}] #{msg}\e[m\n"
end

def system(*args)
puts "$ #{args.join(' ')}"
super
end

if ENV['TRAVIS']
system "mysql -e 'create database will_paginate;' >/dev/null"
abort "failed to create mysql database" unless $?.success?
system "psql -c 'create database will_paginate;' -U postgres >/dev/null"
abort "failed to create postgres database" unless $?.success?
end

failed = false

for db in databases
announce "DB", db
ENV['DB'] = db
failed = true unless system %(rake)
end

exit 1 if failed

0 comments on commit 16636f5

Please sign in to comment.