Skip to content

Commit

Permalink
Merge branch 'master' of github.com:AbleTech/easy-deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelramsay committed Apr 15, 2012
2 parents 6a71229 + cda8ee6 commit 08390d2
Show file tree
Hide file tree
Showing 26 changed files with 154 additions and 121 deletions.
15 changes: 13 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
*.gem
*.rbc
.bundle
.DS_Store
.config
.yardoc
Gemfile.lock
pkg/*
InstalledFiles
_yardoc
coverage
doc/
lib/bundler/man
pkg
rdoc
spec/reports
test/tmp
test/version_tmp
tmp
2 changes: 2 additions & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--color
--format progress
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source "http://rubygems.org"
source 'https://rubygems.org'

# Specify your gem's dependencies in the .gemspec
# Specify your gem's dependencies in easy-deployment.gemspec
gemspec
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2012 Able Technology

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Easy::Deployment

This gem is for encapsulating Abletech's common deployment patterns using capistrano.

## Installation

Add this line to your application's Gemfile:

gem 'easy-deployment', :git => "[email protected]:AbleTech/easy-deployment.git"

And then execute:

$ bundle

Or install it yourself as:

$ gem install easy-deployment

## Usage

Run:

$ rails g easy:deployment

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
14 changes: 0 additions & 14 deletions README.rdoc

This file was deleted.

22 changes: 4 additions & 18 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
require 'bundler'
Bundler::GemHelper.install_tasks
#!/usr/bin/env rake
require "bundler/gem_tasks"

require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end

require 'rcov/rcovtask'
Rcov::RcovTask.new do |test|
test.rcov_opts << '--exclude /gems/,/Library/,/usr/,spec,lib/tasks' # exclude external gems/libraries
test.libs << 'test'
test.pattern = 'test/**/test_*.rb'
test.verbose = true
end

task :default => :test
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new('spec')
27 changes: 0 additions & 27 deletions abletech-deployment.gemspec

This file was deleted.

26 changes: 26 additions & 0 deletions easy-deployment.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- encoding: utf-8 -*-
require File.expand_path('../lib/easy-deployment/version', __FILE__)

Gem::Specification.new do |gem|
gem.authors = ["Jeremy Olliver", "Nigel Ramsay", "Shevaun Coker"]
gem.email = ["[email protected]", "[email protected]", "[email protected]"]
gem.description = %q{Easy deployment: includes a generator, and capistrano configuration}
gem.summary = %q{Gem for encapsulating abletech's deployment practices}
gem.homepage = ""

gem.files = `git ls-files`.split($\)
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
gem.name = "easy-deployment"
gem.require_paths = ["lib"]
gem.version = Easy::Deployment::VERSION


gem.add_runtime_dependency 'rails', '>= 3.0.0'
gem.add_runtime_dependency 'capistrano'
gem.add_runtime_dependency 'capistrano-ext'
gem.add_runtime_dependency 'capistrano_colors'

gem.add_development_dependency 'bundler'
gem.add_development_dependency 'rspec', '~> 2.8'
end
3 changes: 0 additions & 3 deletions lib/abletech-deployment.rb

This file was deleted.

3 changes: 3 additions & 0 deletions lib/easy-deployment.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require "easy-deployment/version"
require 'easy/generators/deployment_generator'
require 'easy/generators/stage_generator'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Abletech
module Easy
module Deployment
VERSION = "0.0.7"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# To load this capistrano configuration, require 'abletech/deployment/backup' from deploy.rb
# To load this capistrano configuration, require 'easy/deployment/backup' from deploy.rb
Capistrano::Configuration.instance(:must_exist).load do
namespace :abletech do
namespace :easy do
namespace :backup do
desc "Creates the shared folders that backup requires"
task :setup, :except => { :no_release => true } do
run "mkdir -p #{shared_path}/backup/data"
end

desc "Adds a symbolic link from the s3.yml file in the shared/backup into the current/config folder"
task :symlink_s3_config do
run "ln -sf #{shared_path}/backup/s3.yml #{current_path}/config/s3.yml"
end
end
end
after 'deploy:setup', 'abletech:backup:setup'
after 'deploy:symlink', 'abletech:backup:symlink_s3_config'

after 'deploy:setup', 'easy:backup:setup'
after 'deploy:symlink', 'easy:backup:symlink_s3_config'
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Define some defaults for capistrano deploys.
# To load this capistrano configuraiton, require 'abletech/deployment/capistrano' from deploy.rb
# To load this capistrano configuraiton, require 'easy/deployment/capistrano' from deploy.rb

Capistrano::Configuration.instance(:must_exist).load do

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# To load this capistrano configuration, require 'abletech/deployment/logrotate' from deploy.rb
# To load this capistrano configuration, require 'easy/deployment/logrotate' from deploy.rb
Capistrano::Configuration.instance(:must_exist).load do
namespace :abletech do
namespace :easy do
namespace :logrotate do
desc "Copies the application logrotate file into /etc/logrotate.d"
task :setup, :except => { :no_release => true } do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
# To load this capistrano configuration, require 'abletech/deployment/whenever' from deploy.rb
# To load this capistrano configuration, require 'easy/deployment/whenever' from deploy.rb
Capistrano::Configuration.instance(:must_exist).load do
namespace :abletech do
namespace :easy do
namespace :whenever do
desc "Removes this application's entries from the user's crontab file"
task :clear_crontab do
run "cd #{release_path} && #{bundle_cmd} exec whenever -f #{release_path}/config/deploy/#{rails_env}/whenever.rb --clear-crontab #{application}"
end

desc "Updates this application's crontab file entries"
task :update_crontab do
run "cd #{current_path} && #{bundle_cmd} exec whenever -f #{current_path}/config/deploy/#{rails_env}/whenever.rb --update-crontab #{application} --set \"current_path=#{current_path}&bundle_cmd=#{fetch(:bundle_cmd, 'bundle')}&rails_env=#{rails_env}&application=#{application}\""
end
end
end
end

after "deploy:update_code", "abletech:whenever:clear_crontab"
after "deploy:symlink", "abletech:whenever:update_crontab"
after "deploy:rollback", "abletech:whenever:update_crontab"
after "deploy:update_code", "easy:whenever:clear_crontab"
after "deploy:symlink", "easy:whenever:update_crontab"
after "deploy:rollback", "easy:whenever:update_crontab"
end
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'rails/generators'
require 'optparse'

module Abletech
module Easy
class DeploymentGenerator < Rails::Generators::Base
source_root File.join(File.dirname(__FILE__), "templates") # Where templates are copied from

Expand All @@ -14,7 +14,7 @@ def application_name
def create_deployment_files
options = parse_options(ARGV)

# If there was a deploy.rb initially, let the generator prompt to handle conflicts. Otherwise remove the default capistrano one, so we can override it silently with our template without being prompted
# If there was a deploy.rb initially, let the generator prompt to handle conflicts. Otherwise remove the default capistrano one, so we can override it silently with our template without being prompted
deploy_file_already_existed = File.exist?(File.join(destination_root, "config", "deploy.rb"))
capify!
remove_file("config/deploy.rb") unless deploy_file_already_existed # Removing this means we aren't prompted to overwrite if we only have the default capistrano deploy.rb
Expand All @@ -24,15 +24,15 @@ def create_deployment_files
# Generate all stages specified
options[:stages] ||= %w(staging production)
options[:stages].each do |stage|
generate("abletech:stage", stage)
generate("easy:stage", stage)
end

info = %{
Abletech Deployment Config now setup!
Easy Deployment Config now setup!
TODO:
* Set the correct git repository in config/deploy.rb
}
}
options[:stages].each do |stage|
info += " * Set the ip address for staging in config/deploy/#{stage}.rb && the apache config in config/deploy/#{stage}/apache/#{application_name}"
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'rails/generators'

module Abletech
module Easy
class LogrotateGenerator < Rails::Generators::NamedBase
source_root File.join(File.dirname(__FILE__), "templates") # Where templates are copied from

desc %{Generate a new logrotate.conf file for the given environment name\ne.g. rails g abletech:logrotate workshop}
desc %{Generate a new logrotate.conf file for the given environment name\ne.g. rails g easy:logrotate workshop}

def generate_stage
# directory("stage", "config/#{name}")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
require 'rails/generators'

module Abletech
module Easy
class StageGenerator < Rails::Generators::NamedBase
source_root File.join(File.dirname(__FILE__), "templates") # Where templates are copied from

desc %{Generate a new deployment script for the given environment name\ne.g. rails g abletech:stage workshop}
desc %{Generate a new deployment script for the given environment name\ne.g. rails g easy:stage workshop}

def generate_stage
directory("stage", "config/deploy/#{name}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ require "capistrano/ext/multistage"
require "capistrano_colors"
require "bundler/capistrano"
begin
require "abletech/deployment/capistrano"
require "easy/deployment/capistrano"
rescue LoadError
$stderr.puts "couldn't load abletech-deployment gem, try `bundle install` and running again with `bundle exec cap <stage> deploy`"
$stderr.puts "couldn't load easy-deployment gem, try `bundle install` and running again with `bundle exec cap <stage> deploy`"
exit(1)
end

Expand All @@ -15,7 +15,7 @@ set :application, "<%= application_name %>" # TODO: edit application name
set :deploy_to, "/var/apps/#{application}"

# TODO: fill in git repo
# set :repository, "[email protected]:AbleTech/abletech-deployment.git"
# set :repository, "[email protected]:AbleTech/easy-deployment.git"
set :scm, :git
set :deploy_via, :remote_cache
set :git_shallow_clone, 1
Expand Down
File renamed without changes.
7 changes: 7 additions & 0 deletions spec/easy_deployment_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'spec_helper.rb'

describe Easy::Deployment do
it "has a version number" do
Easy::Deployment::VERSION.should be_present
end
end
15 changes: 15 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# Require this file using `require "spec_helper.rb"` to ensure that it is only
# loaded once.
#
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration

require 'rubygems'
require 'bundler'

require 'easy-deployment'

RSpec.configure do |config|
config.mock_with :rspec
end
19 changes: 0 additions & 19 deletions test/helper.rb

This file was deleted.

7 changes: 0 additions & 7 deletions test/test_abletech_deployment.rb

This file was deleted.

0 comments on commit 08390d2

Please sign in to comment.