2012-11-18 07:56:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
echo "updating dependencies"
|
2012-12-31 11:58:34 +00:00
|
|
|
|
|
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
|
|
|
|
|
|
# 'target' is the output directory
|
|
|
|
|
rm -rf $DIR/target
|
|
|
|
|
mkdir $DIR/target
|
|
|
|
|
mkdir $DIR/target/deb
|
|
|
|
|
|
|
|
|
|
# put all dependencies into vendor/bundle
|
2013-01-14 06:02:32 +00:00
|
|
|
rm -rf vendor/bundle
|
2013-01-15 14:35:03 +00:00
|
|
|
rm Gemfile.lock # if we don't want versions to float, pin it in the Gemfile, not count on Gemfile.lock
|
2013-01-15 13:52:43 +00:00
|
|
|
bundle install --path vendor/bundle
|
2013-01-15 14:35:03 +00:00
|
|
|
bundle update
|
2012-12-31 02:25:24 +00:00
|
|
|
|
2012-11-18 15:21:01 +00:00
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
echo "success: updated dependencies"
|
|
|
|
|
else
|
|
|
|
|
echo "could not update dependencies"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2012-12-31 02:25:24 +00:00
|
|
|
if [ -z $SKIP_TESTS ]; then
|
|
|
|
|
|
|
|
|
|
echo "running rspec tests"
|
|
|
|
|
bundle exec rspec
|
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
echo "success: ran rspec tests"
|
|
|
|
|
else
|
|
|
|
|
echo "running rspec tests failed."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo "running jasmine tests"
|
|
|
|
|
#http://shortforgilbert.com/blog/2011/03/25/headless-jasmine-ci
|
|
|
|
|
# TODO starting Xvfb here because we don't do this on start of build server
|
|
|
|
|
# If you run it once, it will background/nohup itself, so this is 'lazy'
|
|
|
|
|
Xvfb :99 -screen 0 1440x900x16 > /dev/null 2>&1 &
|
|
|
|
|
# run jasmine using the virtual screen, and in the test environment to use the jam_web_test db
|
|
|
|
|
DISPLAY=":99" rake jasmine:ci RAILS_ENV=test
|
|
|
|
|
|
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
echo "success: jasmine tests completed"
|
|
|
|
|
else
|
|
|
|
|
echo "running jasmine tests failed"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2013-01-12 23:45:34 +00:00
|
|
|
if [ -z "$SKIP_CUCUMBER_TESTS" ]; then
|
|
|
|
|
echo "running cucumber tests"
|
|
|
|
|
DISPLAY=":99" bundle exec cucumber
|
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
echo "success: cucumber tests completed"
|
|
|
|
|
else
|
|
|
|
|
echo "running cucumber tests failed"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2012-12-12 05:38:35 +00:00
|
|
|
fi
|
|
|
|
|
|
2012-12-29 16:12:05 +00:00
|
|
|
if [ -n "$PACKAGE" ]; then
|
2012-12-31 11:58:34 +00:00
|
|
|
|
|
|
|
|
if [ -z "$BUILD_NUMBER" ]; then
|
|
|
|
|
echo "BUILD NUMBER is not defined"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
2013-01-05 04:00:47 +00:00
|
|
|
|
|
|
|
|
type -P dpkg-architecture > /dev/null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
ARCH=`dpkg-architecture -qDEB_HOST_ARCH`
|
|
|
|
|
else
|
|
|
|
|
echo "WARN: unable to determine architecture."
|
|
|
|
|
ARCH=`all`
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
2012-12-31 18:45:11 +00:00
|
|
|
set -e
|
2012-12-29 16:12:05 +00:00
|
|
|
# cache all gems local, and tell bundle to use local gems only
|
|
|
|
|
bundle install --path vendor/bundle --local
|
2012-12-31 11:58:34 +00:00
|
|
|
# prepare production acssets
|
|
|
|
|
rm -rf $DIR/public/assets
|
|
|
|
|
bundle exec rake assets:precompile RAILS_ENV=production
|
|
|
|
|
|
|
|
|
|
# create debian using fpm
|
2013-01-05 14:12:23 +00:00
|
|
|
bundle exec fpm -s dir -t deb -p target/deb/jam-web_0.1.${BUILD_NUMBER}_${ARCH}.deb -n "jam-web" -v "0.1.$BUILD_NUMBER" --prefix /var/lib/jam-web --after-install $DIR/script/package/post-install.sh --before-install $DIR/script/package/pre-install.sh --before-remove $DIR/script/package/pre-uninstall.sh --after-remove $DIR/script/package/post-uninstall.sh Gemfile .bundle config Rakefile script config.ru lib public vendor app
|
2012-12-12 05:38:35 +00:00
|
|
|
|
2012-12-29 16:12:05 +00:00
|
|
|
fi
|
2012-12-12 05:38:35 +00:00
|
|
|
|
2012-11-18 07:56:50 +00:00
|
|
|
echo "build complete"
|
|
|
|
|
|