Skip to content

Commit

Permalink
Split out database testing into separate CI runs
Browse files Browse the repository at this point in the history
Fixes calagator#53

Previously, we were running `rake spec:db:all` on CI, which ran our test
suite using mysql, postgresql, and sqlite3, but didn't provide very much
visibility into which databases were passing or failing. This change
moves to using Travis to set a DB environment variable and then running
`rake spec` under each environment.
  • Loading branch information
reidab committed Oct 25, 2013
1 parent 3b4898e commit 52dd885
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .travis.yml
Expand Up @@ -18,8 +18,16 @@ rvm:
## Rubinius is not compatible, see Gemfile for details.
# - rbx-18mode
# - rbx-19mode
script:
- export DBUSER_MYSQL=root
- export DBUSER_POSTGRESQL=postgres
env:
- DB=mysql
- DB=postgresql
- DB=sqlite
before_install:
- ruby ci/copy_database_config.rb
before_script:
- mysql -e 'create database calagator_test;'
- psql -c 'create database calagator_test;' -U postgres
- bundle exec rake db:migrate
- cp "config/secrets.yml.sample" "config/secrets.yml"
- bundle exec rake spec:db:all --trace
script:
- bundle exec rake spec --trace
6 changes: 6 additions & 0 deletions ci/copy_database_config.rb
@@ -0,0 +1,6 @@
require 'fileutils'

which_config = "ci/database.#{ENV['DB'] || 'sqlite'}.yml"

puts "Copying database configuration for CI: #{which_config}"
FileUtils.cp which_config, 'config/database~custom.yml'
5 changes: 5 additions & 0 deletions ci/database.mysql.yml
@@ -0,0 +1,5 @@
test:
adapter: mysql2
database: calagator_test
username: travis
encoding: utf8
4 changes: 4 additions & 0 deletions ci/database.postgresql.yml
@@ -0,0 +1,4 @@
test:
adapter: postgresql
database: calagator_test
username: postgres
5 changes: 5 additions & 0 deletions ci/database.sqlite.yml
@@ -0,0 +1,5 @@
test:
adapter: sqlite3
database: db/test.sqlite3
timeout: 500

0 comments on commit 52dd885

Please sign in to comment.