jam-cloud/build

81 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
echo "updating dependencies"
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
#rm -rf vendor/bundle
bundle install --path vendor/bundle
bundle update
if [ "$?" = "0" ]; then
echo "success: updated dependencies"
else
echo "could not update dependencies"
exit 1
fi
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
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
if [ -n "$PACKAGE" ]; then
if [ -z "$BUILD_NUMBER" ]; then
echo "BUILD NUMBER is not defined"
exit 1
fi
set -e
# cache all gems local, and tell bundle to use local gems only
bundle install --path vendor/bundle --local
# prepare production acssets
rm -rf $DIR/public/assets
bundle exec rake assets:precompile RAILS_ENV=production
# create debian using fpm
bundle exec fpm -s dir -t deb -p target/deb/jam-web_0.1.${BUILD_NUMBER}_amd64.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 --exclude $DIR/.git .
fi
echo "build complete"