Skip to content
Browse files

ci setup

  • Loading branch information...
1 parent 3ef1352 commit 80423784d5528d6d7814db9f5fa2f822bda6c305 Mark Yoon committed Dec 8, 2010
Showing with 81 additions and 0 deletions.
  1. +60 −0 ci-env.sh
  2. +21 −0 init_ci.rakefile
View
60 ci-env.sh
@@ -0,0 +1,60 @@
+######
+# This is not an executable script. It selects and configures rvm for
+# bcsec's CI process based on the RVM_RUBY environment variable.
+#
+# Use it by sourcing it:
+#
+# . ci-env.sh
+#
+# Assumes that the create-on-use settings are set in your ~/.rvmrc:
+#
+# rvm_install_on_use_flag=1
+# rvm_gemset_create_on_use_flag=1
+#
+# Hudson Build Execute Shell Commands:
+#
+# source ci-env.sh
+# export RAILS_ENV="hudson"
+# rake -f init_ci.rakefile --trace
+# rake -f init_testbed.rakefile
+# cd testbed
+# bundle exec rake spec cucumber
+
+set +x
+echo "Loading RVM"
+source ~/.rvm/scripts/rvm
+set -x
+
+RVM_RUBY=ree
+GEMSET=surveyor-dev
+
+if [ -z "$RVM_RUBY" ]; then
+ echo "Could not map env (RVM_RUBY=\"${RVM_RUBY}\") to an RVM version.";
+ shopt -q login_shell
+ if [ $? -eq 0 ]; then
+ echo "This means you are still using the previously selected RVM ruby."
+ echo "Probably not what you want -- aborting."
+ # don't exit an interactive shell
+ return;
+ else
+ exit 1;
+ fi
+fi
+
+echo "Switching to ${RVM_RUBY}@${GEMSET}"
+set +xe
+rvm use "${RVM_RUBY}@${GEMSET}"
+if [ $? -ne 0 ]; then
+ echo "Switch failed"
+ exit 2;
+fi
+set -xe
+ruby -v
+
+set +e
+gem list -i rake
+if [ $? -ne 0 ]; then
+ echo "Installing rake since it is not available"
+ gem install rake
+fi
+set -e
View
21 init_ci.rakefile
@@ -0,0 +1,21 @@
+BUNDLER_VERSION="1.0.7"
+
+namespace :bundle do
+ task :ensure_bundler_available do
+ `gem list -i bundler -v '=#{BUNDLER_VERSION}'`
+ unless $? == 0
+ puts bordered_message("Installing bundler #{BUNDLER_VERSION}")
+ system("gem install bundler -v '=#{BUNDLER_VERSION}' --no-ri --no-rdoc")
+ unless $? == 0
+ fail bordered_message("Install failed.\nPlease fix the problem and try again or manually install bundler #{BUNDLER_VERSION}.")
+ end
+ end
+ end
+
+ def bordered_message(msg)
+ len = msg.split("\n").collect { |l| l.size }.max
+ ['=' * len, msg, '=' * len].join("\n")
+ end
+end
+
+task :default => :'bundle:ensure_bundler_available'

0 comments on commit 8042378

Please sign in to comment.
Something went wrong with that request. Please try again.