Run core's extra migrations without JRuby

Instead of cloning travis-logs and using JRuby to run migrations
try copying core's extra migrations to db/migrate
and run migrations straight up.
This commit is contained in:
Hiro Asari 2014-06-18 12:56:35 -04:00
parent 7f66d4bce9
commit 013deb58f1
3 changed files with 14 additions and 44 deletions

View File

@ -9,11 +9,7 @@ addons:
postgresql: 9.3
before_script:
# create 'logs' table matching 'travis-logs'
- ./set_up_travis_logs.sh
- 'RAILS_ENV=test bundle exec rake db:create db:structure:load --trace'
# replace 'logs' table in travis_test DB with that in travis_logs_test
- psql -c "DROP TABLE IF EXISTS logs CASCADE" -U postgres travis_test
- pg_dump -t logs travis_logs_test | psql -U postgres travis_test
- 'RAILS_ENV=test bundle exec rake db:create db:structure:load mv_migrations db:migrate --trace'
notifications:
irc: "irc.freenode.org#travis"

View File

@ -1,5 +1,6 @@
require 'bundler/setup'
ENV['DB_STRUCTURE'] = "#{Gem.loaded_specs['travis-core'].full_gem_path}/db/structure.sql"
CORE_PATH = Gem.loaded_specs['travis-core'].full_gem_path
ENV['DB_STRUCTURE'] = "#{CORE_PATH}/db/structure.sql"
begin
require 'micro_migrations'
@ -16,6 +17,17 @@ rescue LoadError
warn "could not load rspec"
end
desc "move travis-core-specific migrations to db/migrate"
task 'mv_migrations' do
require 'fileutils'
migration_files = Dir["#{CORE_PATH}/spec/migrations/**/*.rb"]
migration_files.each do |f|
dest = 'db/migrate'
FileUtils.mkdir_p dest
FileUtils.cp f, dest
end
end
desc "generate gemspec"
task 'travis-api.gemspec' do
content = File.read 'travis-api.gemspec'

View File

@ -1,38 +0,0 @@
#!/bin/bash
travis_retry() {
local result=0
local count=1
while [ $count -le 3 ]; do
[ $result -ne 0 ] && {
echo -e "\n${RED}The command \"$@\" failed. Retrying, $count of 3.${RESET}\n" >&2
}
"$@"
result=$?
[ $result -eq 0 ] && break
count=$(($count + 1))
sleep 1
done
[ $count -eq 3 ] && {
echo "\n${RED}The command \"$@\" failed 3 times.${RESET}\n" >&2
}
return $result
}
# clone travis-logs
pushd $HOME
git clone --depth=1 https://github.com/travis-ci/travis-logs.git
cd travis-logs
# install ruby runtime which travis-logs wants
RUBY_RUNTIME=$(cat .ruby-version)
rvm install $RUBY_RUNTIME
# using JRuby, migrate the 'logs' table in 'travis_test' database
BUNDLE_GEMFILE=$PWD/Gemfile
travis_retry rvm $RUBY_RUNTIME do bundle install
psql -c "CREATE DATABASE travis_logs_test;" -U postgres
cp $TRAVIS_BUILD_DIR/config/database.yml config/travis.yml
rvm $RUBY_RUNTIME do bundle exec rake db:migrate
popd