Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: relevance/relevance_rails
base: c6f80a7b1b
...
head fork: relevance/relevance_rails
compare: 7b91ef961a
  • 20 commits
  • 7 files changed
  • 1 commit comment
  • 3 contributors
Commits on Apr 09, 2012
Larry Karnowski and Lake Denman Reviewing trade off of using ruby vs bash eebe723
Commits on Apr 10, 2012
Relevance Pair WIP c248d94
Relevance Pair Merge branch 'master' into nightly-build
Conflicts:
	script/ci
ce3ab6f
Larry Karnowski and Lake Denman GH #22: adding better logging 4032b7a
Larry Karnowski and Lake Denman GH #22: implementing nightly build script 672a867
Larry Karnowski and Lake Denman GH #22: added ability to "force" a stop or destroy of EC2 instance via
Rake
8b7a2ed
Larry Karnowski and Lake Denman GH #22: bugfix, removed unused, broken code e295eda
Larry Karnowski and Lake Denman GH #22: added rake task to determine the EC2 instance's current DNS name fb21681
Larry Karnowski and Lake Denman GH #22: changed the acceptance tests to work in production environment
on an EC2 instance
b24bd94
Larry Karnowski and Lake Denman GH #22: getting the nightly build pieces all together 0661d8d
Larry Karnowski and Lake Denman Merge branch 'master' into nightly-build
Conflicts:
	lib/relevance_rails/provision.rb
6627b02
Commits on Apr 11, 2012
Larry Karnowski and Lake Denman GH #22: extra protection f5704f8
Larry Karnowski and Lake Denman Removed debug statement 65b1911
Larry Karnowski and Lake Denman GH #22: finer-grained timestamp on CI ec2 instance names b27357f
Larry Karnowski and Lake Denman GH #22: adding lots of RVM debug messages 6e51a7e
Larry Karnowski and Lake Denman GH #22: explicitly state which ruby to use (to make Jenkins happy) 3a52bde
Larry Karnowski and Lake Denman GH #22: always fail if command fails, even if we don't have an active
EC2 instance
8e96f09
Larry Karnowski and Lake Denman GH #22: fun with shell, spaces, and missing quotes 1c4865f
Larry Karnowski and Lake Denman GH #22: allow Selenium tests to run on Jenkins server 247775c
Commits on Apr 12, 2012
Lake Denman and Sam Umbach Merge branch 'nightly-build' 7b91ef9
View
4 lib/generators/fixtures/fixtures_generator.rb
@@ -11,7 +11,9 @@ def create_views
%h1 WELCOME HOME
STR
create_file "app/views/relevance_rails/db.html.haml", <<-STR
-%h1.database= ActiveRecord::Base.connection.current_database
+= conn = ActiveRecord::Base.connection
+= results = conn.execute("select 4200+42 as advanced_math")
+%h1.advanced_math= results.first["advanced_math"]
STR
end
View
28 lib/relevance_rails/provision.rb
@@ -6,11 +6,13 @@ module RelevanceRails
module Provision
def self.create_ec2(name = nil)
abort "Please provide a $NAME" unless name
- provision_ec2_instances(name)
+ server = provision_ec2_instances(name)
+ wait_for_ssh server
+ run_commands server
end
def self.stop_ec2
- return unless Thor::Shell::Basic.new.yes?("Are you sure you want to shut down EC2 instance #{instance_id}?")
+ return unless ENV["FORCE"] == "true" || Thor::Shell::Basic.new.yes?("Are you sure you want to shut down EC2 instance #{instance_id}?")
puts "Shutting down EC2 instance #{instance_id}..."
server = fog_connection.servers.get(instance_id)
server.stop
@@ -19,7 +21,7 @@ def self.stop_ec2
end
def self.destroy_ec2
- return unless Thor::Shell::Basic.new.yes?("Are you sure you want to destroy EC2 instance #{instance_id}?")
+ return unless ENV["FORCE"] == "true" || Thor::Shell::Basic.new.yes?("Are you sure you want to destroy EC2 instance #{instance_id}?")
puts "Destroying EC2 instance #{instance_id}..."
server = fog_connection.servers.get(instance_id)
server.destroy
@@ -29,6 +31,11 @@ def self.destroy_ec2
puts "Done!"
end
+ def self.current_dns
+ server = fog_connection.servers.get(instance_id)
+ puts server.reload.dns_name
+ end
+
private
def self.instance_id
@@ -44,19 +51,19 @@ def self.fog_connection
end
def self.provision_ec2_instances(name)
+ puts "Provisioning an instance..."
server = fog_connection.servers.create(config['server']['creation_config'])
fog_connection.tags.create(:key => 'Name',
:value => "#{Rails.application.class.parent_name} #{name}",
:resource_id => server.id)
server.private_key = config['server']['private_key']
- wait_for_ssh server
-
+
File.open("config/ec2_instance.txt", "w") do |f|
f.puts(server.id)
end
- run_commands server
- return server
+ puts "Provisioned!"
+ server
end
def self.run_commands(server)
@@ -75,6 +82,7 @@ def self.run_commands(server)
puts "Server Instance: #{server.id}"
puts "Server IP: #{server.public_ip_address}"
+ server
end
def self.run_command(server, command)
@@ -83,7 +91,7 @@ def self.run_command(server, command)
end
def self.wait_for_ssh(server)
- puts "Provisioning an instance..."
+ puts "Waiting for ssh connectivity..."
server.wait_for { ready? }
succeeded = false
attempts = 0
@@ -101,7 +109,7 @@ def self.wait_for_ssh(server)
end
end
raise last_error unless succeeded
- puts "Server up and listening for SSH..."
+ puts "Server up and listening for SSH!"
end
def self.jobs_succeeded?(jobs)
@@ -113,7 +121,7 @@ def self.jobs_succeeded?(jobs)
puts "STDERR: #{job.stderr}"
puts "----------------------"
end
- return false
+ false
end
end
View
5 lib/tasks/provision.rake
@@ -21,4 +21,9 @@ namespace :provision do
task :destroy do
RelevanceRails::Provision.destroy_ec2
end
+
+ desc 'Return the current public DNS name for your previously-provisioned EC2 instance'
+ task :current_dns do
+ RelevanceRails::Provision.current_dns
+ end
end
View
33 script/ci
@@ -28,8 +28,7 @@ TARGET_HOST="placeholder.example.com"
# Setup RVM
source "$HOME/.rvm/scripts/rvm"
rvm use "ruby-1.9.2@relevance_rails"
-
-echo "DEBUG: using gemset: `rvm gemset name`"
+echo "RVM is now using:` rvm current`"
# exit if any statement fails;
# must be set AFTER loading RVM
@@ -51,6 +50,7 @@ set +e
rvm --force gemset delete $RAILS_APP
rvm gemset create $RAILS_APP
rvm gemset use $RAILS_APP
+echo "RVM is now using:` rvm current`"
set -e
if $(gem list relevance_rails --installed); then
@@ -68,6 +68,7 @@ relevance_rails new $RAILS_APP --database=postgresql
# NOTE: this does NOT change the RVM gemset; we set it manually above
builtin cd $RAILS_APP
+echo "RVM is now using:` rvm current`"
files_must_NOT_exist public/index.html
files_must_exist config/database.yml provision/dna.json config/deploy.rb config/deploy/recipes/deploy.rb
@@ -79,25 +80,9 @@ git commit -m "Generated relevance_rails fixtures."
files_must_exist app/assets/javascripts/relevance_rails.js.coffee app/assets/stylesheets/relevance_rails.css.scss
echo "Done."
-# rake provision:ec2 --> writes to config/ec2_instance.txt
-# TARGET_HOST=something
-#
-# echo "Generating relevance_rails deployment scripts..."
-# ./script/rails generate deployment staging $TARGET_HOST
-# git add .
-# git commit -m "Generated relevance_rails deployment scripts."
-# files_must_exist config/deploy/staging.rb
-# echo "Done."
-#
-# cap staging deploy:setup
-# cap staging deploy:cold
-#
-# cd ..
-#
-# HOST=$TARGET_HOST rake acceptance
-
-# IF failure, stop the instance
-#cd $RAILS_APP; bundle exec rake provision:stop
-#IF success, terminate the instance
-#cd $RAILS_APP; bundle exec rake provision:terminate
-
+echo "Generating relevance_rails deployment scripts..."
+./script/rails generate deployment staging $TARGET_HOST
+git add .
+git commit -m "Generated relevance_rails deployment scripts for $TARGET_HOST."
+files_must_exist config/deploy/staging.rb
+echo "Done."
View
79 script/ci_nightly
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+# Set the DISPLAY variable if not already set
+: ${DISPLAY:=":1"}
+# Allows firefox to use display
+export DISPLAY
+
+RAILS_APP="app_for_ci"
+EC2_MEMENTO_FILE="config/ec2_instance.txt"
+
+function stop_server_and_exit {
+ if [ -f $EC2_MEMENTO_FILE ]; then
+ echo "Stopping newly-created server..."
+ bundle exec rake provision:stop FORCE=true --trace
+ echo "Done."
+ fi
+
+ echo "BUILD FAILED"
+ exit 1
+}
+
+echo "RVM is now using:` rvm current`"
+
+set -e
+./script/ci
+set +e
+
+source "$HOME/.rvm/scripts/rvm"
+rvm use "ruby-1.9.2@$RAILS_APP"
+echo "RVM is now using:` rvm current`"
+
+builtin cd $RAILS_APP
+
+echo "Provisioning an EC2 instance..."
+rm -f $EC2_MEMENTO_FILE
+server_name="Nightly Build Testing - `date "+%Y-%m-%d %H:%M:%S"` "
+bundle exec rake --trace provision:ec2 NAME="$server_name"
+[ $? -ne 0 ] && stop_server_and_exit
+echo "Done!"
+
+echo "Determine the EC2 instance's DNS name..."
+TARGET_HOST=`bundle exec rake provision:current_dns`
+[ $? -ne 0 ] && stop_server_and_exit
+echo "Done."
+
+echo "Generating relevance_rails deployment scripts..."
+./script/rails generate deployment staging $TARGET_HOST --force
+[ $? -ne 0 ] && stop_server_and_exit
+git add .
+git commit -m "Generated relevance_rails deployment scripts for $TARGET_HOST."
+[ $? -ne 0 ] && stop_server_and_exit
+echo "Done."
+
+echo "Capistrano: setup..."
+bundle exec cap staging deploy:setup
+[ $? -ne 0 ] && stop_server_and_exit
+echo "Done."
+
+echo "Capistrano: deploying..."
+bundle exec cap staging deploy:cold
+[ $? -ne 0 ] && stop_server_and_exit
+echo "Done."
+
+builtin cd -
+rvm gemset use relevance_rails
+echo "RVM is now using:` rvm current`"
+
+echo "Running the acceptance tests against our newly-created server..."
+ACCEPTANCE_HOST=$TARGET_HOST rake acceptance --trace
+[ $? -ne 0 ] && stop_server_and_exit
+echo "Done."
+
+builtin cd $RAILS_APP
+rvm gemset use $RAILS_APP
+
+echo "Terminating our newly-created server..."
+bundle exec rake provision:destroy FORCE=true --trace
+echo "Done!"
+
View
18 spec/acceptance_spec.rb
@@ -1,25 +1,25 @@
require 'spec_helper'
describe 'App is alive', :js => true, :acceptance => true do
- it 'verifies coffeescript served up as js' do
- visit '/assets/relevance_rails.js'
- page.should have_content "console.log('Hello from Relevance, Inc!');"
- end
-
it "verifies haml is served up" do
visit '/relevance_rails'
page.should have_content 'WELCOME HOME'
end
+ it 'verifies coffeescript served up as js' do
+ visit '/assets/application.js'
+ page.should have_content 'console.log("Hello from Relevance, Inc!")'
+ end
+
it "verifies scss is served up as css" do
- visit '/assets/relevance_rails.css'
- page.should have_content "background-color: blue;"
+ visit '/assets/application.css'
+ page.should have_content "background-color:blue"
end
it "verifies a working database connection" do
visit '/relevance_rails/db'
- within ('h1.database') do
- page.should have_content '_development'
+ within ('h1.advanced_math') do
+ page.should have_content '4242'
end
end
end
View
3  spec/spec_helper.rb
@@ -55,5 +55,4 @@ def should_abort_with(msg)
Capybara.current_driver = :selenium
Capybara.run_server = false
-#Capybara.app_host = 'http://' + (ENV["ACCEPTANCE_HOST"] || 'localhost:3000')
-Capybara.app_host = ENV["ACCEPTANCE_HOST"] || 'http://localhost:3000'
+Capybara.app_host = 'http://' + (ENV["ACCEPTANCE_HOST"] || 'localhost:3000')

Showing you all comments on commits in this comparison.

@aredington
Owner

The changes to the fixtures_generator in this commit have caused failures when Muness took a test drive in MySQL. Instead of returning a result set, it returned a single result with no column names.

Something went wrong with that request. Please try again.