From 5dd03f5f085b7fe791da6f0b58fda27797172793 Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 27 Apr 2019 17:45:16 +0500 Subject: [PATCH] Fix CI --- .travis.yml | 2 +- script/setup | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d62376b..98c5ed4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ before_install: - sudo mv geckodriver /usr/local/bin/ - geckodriver --version -install: script/setup --initial +install: script/setup --travis script: bundle exec rake all diff --git a/script/setup b/script/setup index 3671800..1b53af4 100755 --- a/script/setup +++ b/script/setup @@ -9,7 +9,19 @@ def system!(*args) system(*args) or abort "\n== Command #{args} failed ==" end +postgres_user = ENV['POSTGRES_USER'].to_s.strip +postgres_user = nil if postgres_user.empty? + +postgres_db = ENV['POSTGRES_DB'].to_s.strip +postgres_db = nil if postgres_db.empty? + initial = !!ARGV.delete('--initial') +travis = !!ARGV.delete('--travis') + +raise 'Select single option' if initial && travis + +raise 'Set env var POSTGRES_USER' if travis && postgres_user.nil? +raise 'Set env var POSTGRES_DB' if travis && postgres_db.nil? FileUtils.chdir APP_ROOT do puts '== Update RubyGems ==' @@ -27,6 +39,9 @@ FileUtils.chdir APP_ROOT do if initial puts '== Preparing database ==' system! 'bin/rails db:setup' + elsif travis + puts '== Preparing database ==' + system! "psql -U #{postgres_user} -c 'CREATE DATABASE #{postgres_db};'" else puts '== Updating database ==' system! 'bin/rails db:migrate'