This repository has been archived by the owner on Jan 23, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
/
ci_build
executable file
·52 lines (42 loc) · 1.48 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
44
45
46
47
48
49
50
51
52
#!/bin/bash
# Making the script more robust
set -e # Exit on errors
set -u # Exit on uninitialized variables
RAILS_VERSION=${RAILS_VERSION:-}
if [ "$RAILS_VERSION" == "" ]; then
echo "Please specify rails version using RAILS_VERSION environment variable!"
exit 1
fi
# Change directory according to the rails version
if [ "$RAILS_VERSION" == "2.x" ]; then
# Downgrade rubygems because rails 2.3 does not work on 2.0+
gem update --system 1.8.25
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 " * Rubygems version: `gem --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