2012-11-18 07:56:50 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2014-02-05 11:14:07 +00:00
|
|
|
set -e
|
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
|
|
|
|
|
|
2014-01-14 22:55:34 +00:00
|
|
|
#rm -rf vendor/bundle -- let jenkins config wipe workspace, or not
|
|
|
|
|
|
2013-01-30 05:14:30 +00:00
|
|
|
rm -rf tmp/capybara
|
2013-09-15 18:13:31 +00:00
|
|
|
rm -f Gemfile.lock # if we don't want versions to float, pin it in the Gemfile, not count on Gemfile.lock
|
2013-01-30 05:14:30 +00:00
|
|
|
# put all dependencies into vendor/bundle
|
2013-09-15 18:13:31 +00:00
|
|
|
|
|
|
|
|
# default build number to 1 if not found
|
|
|
|
|
if [ -z "$BUILD_NUMBER" ]; then
|
|
|
|
|
BUILD_NUMBER="1"
|
|
|
|
|
fi
|
|
|
|
|
|
2013-09-18 20:35:20 +00:00
|
|
|
GEM_VERSION="0.1.${BUILD_NUMBER}"
|
2013-09-15 18:13:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# by putting these gems in vendor/cache, bundle will see them when running 'bundle install'
|
|
|
|
|
mkdir -p vendor/cache
|
2013-09-16 02:36:21 +00:00
|
|
|
cp ../db/target/ruby_package/jam_db-${GEM_VERSION}.gem vendor/cache/ || { echo "unable to copy jam-db gem"; exit 1; }
|
|
|
|
|
cp ../pb/target/ruby/jampb/jampb-${GEM_VERSION}.gem vendor/cache/ || { echo "unable to copy jam-pb gem"; exit 1; }
|
|
|
|
|
cp ../ruby/jam_ruby-${GEM_VERSION}.gem vendor/cache/ || { echo "unable to copy jam-ruby gem"; exit 1; }
|
2013-09-15 18:13:31 +00:00
|
|
|
cp ../websocket-gateway/jam_websockets-${GEM_VERSION}.gem vendor/cache/ || { echo "unable to copy websocket-gateway gem"; exit 1; }
|
|
|
|
|
|
|
|
|
|
echo "updating dependencies"
|
2013-09-02 16:41:16 +00:00
|
|
|
bundle install --path vendor/bundle
|
2014-02-02 20:03:31 +00:00
|
|
|
#bundle update
|
2012-12-31 02:25:24 +00:00
|
|
|
|
2013-02-04 02:35:32 +00:00
|
|
|
# clean assets, because they may be lingering from last build
|
|
|
|
|
bundle exec rake assets:clean
|
|
|
|
|
|
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
|
|
|
|
|
|
2013-05-15 22:53:26 +00:00
|
|
|
phantomjs --version
|
|
|
|
|
if [ "$?" != "0" ]; then
|
|
|
|
|
echo "phantomjs is required to run rspec tests; please install it"
|
2013-05-15 23:37:21 +00:00
|
|
|
echo "emitting path to debug on build server $PATH"
|
2013-05-15 23:12:33 +00:00
|
|
|
exit 1
|
2013-05-15 22:53:26 +00:00
|
|
|
fi
|
|
|
|
|
|
2012-12-31 02:25:24 +00:00
|
|
|
echo "running rspec tests"
|
|
|
|
|
bundle exec rspec
|
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
echo "success: ran rspec tests"
|
2014-02-20 23:22:31 +00:00
|
|
|
elif [ "$?" = "20" ]; then
|
|
|
|
|
echo "retrying once more"
|
|
|
|
|
bundle exec rspec
|
|
|
|
|
|
|
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
echo "success: ran rspec tests"
|
|
|
|
|
else
|
|
|
|
|
echo "running rspec tests for the second time failed."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
else
|
2012-12-31 02:25:24 +00:00
|
|
|
echo "running rspec tests failed."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
2013-08-11 02:29:57 +00:00
|
|
|
if [ -z $SKIP_KARMA ]; then
|
|
|
|
|
echo "running karma 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" karma start spec/javascripts/karma.ci.conf.js
|
2012-12-31 02:25:24 +00:00
|
|
|
|
2013-08-11 02:29:57 +00:00
|
|
|
if [ "$?" = "0" ]; then
|
|
|
|
|
echo "success: karma tests completed"
|
|
|
|
|
else
|
|
|
|
|
echo "running karma tests failed"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2012-12-31 02:25:24 +00:00
|
|
|
|
2013-01-12 23:45:34 +00:00
|
|
|
if [ -z "$SKIP_CUCUMBER_TESTS" ]; then
|
|
|
|
|
echo "running cucumber tests"
|
2013-04-11 01:31:17 +00:00
|
|
|
# DISPLAY=":99" bundle exec cucumber
|
2013-01-12 23:45:34 +00:00
|
|
|
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
|
|
|
|
2013-08-29 13:39:08 +00:00
|
|
|
cat > lib/jam_web/version.rb << EOF
|
|
|
|
|
module JamWeb
|
|
|
|
|
VERSION = "0.1.$BUILD_NUMBER"
|
|
|
|
|
end
|
|
|
|
|
EOF
|
|
|
|
|
|
2013-09-16 17:03:26 +00:00
|
|
|
echo "$BUILD_NUMBER" > BUILD_NUMBER
|
2013-08-29 13:39:08 +00:00
|
|
|
|
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
|
2013-09-02 16:35:36 +00:00
|
|
|
#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-09-16 17:03:26 +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 BUILD_NUMBER
|
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"
|
|
|
|
|
|