forked from newtonapple/db-charmer
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathci_build
executable file
·43 lines (34 loc) · 1.19 KB
/
ci_build
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
#!/bin/bash
# Making the script more robust
set -e # Exit on errors
set -u # Exit on uninitialized variables
# Change directory according to the rails version
if [ "$RAILS_VERSION" == "2.x" ]; then
cd test-project-2.x
else
cd test-project
fi
# Print version info
echo "-----------------------------------------------------------------------------------------------------------------"
echo " * Running specs for Rails version $RAILS_VERSION..."
echo " * Ruby version: `ruby --version`"
echo " * DbCharmer gem version: '${DB_CHARMER_GEM:-trunk}'"
echo "-----------------------------------------------------------------------------------------------------------------"
# Test environment
export RAILS_ENV=test
# Configure database access
cp -f config/database.yml.example config/database.yml
# Create databases and sharding tables
mysql -u root < db/create_databases.sql
mysql -u root db_charmer_sandbox_test < db/sharding.sql
# Install gems
rm -f Gemfile.lock
bundle install
# Run migrations
bundle exec rake --trace db:migrate
# Run the build and return its exit code
if [ "$RAILS_VERSION" == "2.x" ]; then
exec bundle exec spec -p '/*/**/*_spec.rb' -cbfs spec
else
exec bundle exec rspec -cbfs spec
fi