-
Notifications
You must be signed in to change notification settings - Fork 186
/
ci
executable file
·44 lines (36 loc) · 1.01 KB
/
ci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env bash
set -x
set -e
export LANG=en_US.UTF-8
db_host=$DB_HOST
db_user=$USER
db_pass=$DB_PASS
db_name=ensemble_ci_$$
internal_key="/home/$USER/.ssh/internal"
db_create_command="createdb -U postgres -h localhost -O $db_user $db_name"
db_drop_command="dropdb -U postgres -h localhost $db_name"
db_remote_command="ssh -F /dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no -i $internal_key root@$db_host"
if [[ $db_host == "localhost" ]]; then
sudo -u postgres $db_create_command
trap "echo 'database cleanup'; sudo -u postgres ${db_drop_command}" EXIT
else
$db_remote_command $db_create_command
trap "echo 'database cleanup'; ${db_remote_command} ${db_drop_command}" EXIT
fi
test -d config && {
cat > config/database.yml <<EOF
test:
adapter: postgresql
user: $db_user
host: $db_host
database: $db_name
password: $db_pass
EOF
}
source use_ruby.sh
use_ruby 1.9.2
test -f Gemfile
gem install bundler --no-rdoc --no-ri
bundle
bundle exec rake db:migrate
time bundle exec rake --trace