Permalink
Browse files

Provide a script/ci file for Jenkins.

  • Loading branch information...
1 parent 46f4788 commit 258837acbeef412c86097e91bc7247f680b8ad02 @xaviershay xaviershay committed with Steve Conover & Xavier Shay Nov 10, 2011
Showing with 62 additions and 1 deletion.
  1. +2 −0 Gemfile
  2. +2 −0 Gemfile.lock
  3. +57 −0 script/ci
  4. +1 −1 spec/suite.rb
View
@@ -1,5 +1,7 @@
source 'https://rubygems.org'
+gem "rake"
+
group :test do
gem "rspec"
gem "open4"
View
@@ -3,6 +3,7 @@ GEM
specs:
diff-lcs (1.1.3)
open4 (1.1.0)
+ rake (0.9.2.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
@@ -18,4 +19,5 @@ PLATFORMS
DEPENDENCIES
open4
+ rake
rspec
View
@@ -0,0 +1,57 @@
+#!/usr/bin/env bash
+
+bundler_version="1.0.18"
+rspec_version="2.6.0"
+
+source "$HOME/.rvm/scripts/rvm"
+
+function install_ruby_if_needed() {
+ echo "Checking for $1..."
+ if ! rvm list rubies | grep $1 > /dev/null; then
+ rvm install $1
+ fi
+}
+function switch_ruby() {
+ install_ruby_if_needed $1 && rvm use $1
+}
+
+function install_bundler_if_needed() {
+ echo "Checking for Bundler $bundler_version..."
+ if ! gem list --installed bundler --version "$bundler_version" > /dev/null; then
+ gem install bundler --version "$bundler_version" --source http://mirrors.squareup.com/rubygems
+ fi
+}
+
+function install_rspec_if_needed() {
+ echo "Checking for rspec $rspec_version..."
+ if ! gem list --installed rspec --version "$rspec_version" > /dev/null; then
+ gem install rspec --version "$rspec_version" --source http://mirrors.squareup.com/rubygems
+ fi
+}
+
+function update_gems_if_needed() {
+ echo "Installing gems..."
+ bundle check || bundle install
+}
+
+function run_tests() {
+ bundle exec rake spec:setup
+ rspec spec/suite.rb # Cannot be bundle exec'd
+}
+
+function prepare_and_run() {
+ switch_ruby $1 &&
+ install_bundler_if_needed &&
+ install_rspec_if_needed &&
+ update_gems_if_needed &&
+ run_tests
+}
+
+function tag_green_build() {
+ tag_name="ci-preflight-master/latest"
+ git tag -f -m "tagging green build" "$tag_name"
+ git push -f origin "$tag_name"
+}
+
+prepare_and_run "1.9.3-p0" &&
+tag_green_build
View
@@ -1 +1 @@
-Dir["spec/**/*_spec.rb"].each{|f|require f}
+Dir["spec/**/*_spec.rb"].each{|f|require File.expand_path(f) }

0 comments on commit 258837a

Please sign in to comment.