From 6ac9af787e059648fddf15277b765f06882791d6 Mon Sep 17 00:00:00 2001 From: nilsding Date: Sun, 21 Dec 2014 22:12:59 +0100 Subject: [PATCH] added Capistrano --- .capistrano/metrics | 1 + Capfile | 24 ++++++++++++++ Gemfile | 5 +++ Gemfile.lock | 26 +++++++++++++++ bin/cap | 16 +++++++++ bin/capify | 16 +++++++++ config/deploy.rb | 31 ++++++++++++++++++ config/deploy/production.rb | 7 ++++ config/deploy/staging.rb | 45 ++++++++++++++++++++++++++ lib/{assets => capistrano/tasks}/.keep | 0 spec/factories/notifications.rb | 9 ++++++ spec/models/notification_spec.rb | 5 +++ 12 files changed, 185 insertions(+) create mode 100644 .capistrano/metrics create mode 100644 Capfile create mode 100755 bin/cap create mode 100755 bin/capify create mode 100644 config/deploy.rb create mode 100644 config/deploy/production.rb create mode 100644 config/deploy/staging.rb rename lib/{assets => capistrano/tasks}/.keep (100%) create mode 100644 spec/factories/notifications.rb create mode 100644 spec/models/notification_spec.rb diff --git a/.capistrano/metrics b/.capistrano/metrics new file mode 100644 index 00000000..94a4335e --- /dev/null +++ b/.capistrano/metrics @@ -0,0 +1 @@ +full \ No newline at end of file diff --git a/Capfile b/Capfile new file mode 100644 index 00000000..6e64843e --- /dev/null +++ b/Capfile @@ -0,0 +1,24 @@ +# Load DSL and set up stages +require 'capistrano/setup' + +# Include default deployment tasks +require 'capistrano/deploy' + +# Include tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# https://github.com/capistrano/passenger +# +require 'capistrano/rvm' +require 'capistrano/bundler' +require 'capistrano/rails' +require 'capistrano/console' + +# Load custom tasks from `lib/capistrano/tasks' if you have any defined +Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r } diff --git a/Gemfile b/Gemfile index 3db7a191..af1d4a74 100644 --- a/Gemfile +++ b/Gemfile @@ -48,6 +48,11 @@ gem 'foreman' group :development do gem 'spring' + + # Capistrano for deployment + gem 'capistrano', '~> 3.1' + gem 'capistrano-rvm', group: :rvm + gem 'capistrano-rails', '~> 1.1' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 438e7b2f..c19e111c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,6 +44,21 @@ GEM railties (>= 3.1) buftok (0.2.0) builder (3.2.2) + capistrano (3.3.5) + capistrano-stats (~> 1.1.0) + i18n + rake (>= 10.0.0) + sshkit (~> 1.3) + capistrano-bundler (1.1.3) + capistrano (~> 3.1) + sshkit (~> 1.2) + capistrano-rails (1.1.2) + capistrano (~> 3.1) + capistrano-bundler (~> 1.1) + capistrano-rvm (0.1.2) + capistrano (~> 3.0) + sshkit (~> 1.2) + capistrano-stats (1.1.1) capybara (2.4.4) mime-types (>= 1.16) nokogiri (>= 1.3.3) @@ -60,6 +75,7 @@ GEM coffee-script-source execjs coffee-script-source (1.8.0) + colorize (0.7.5) connection_pool (2.1.0) daemons (1.1.9) database_cleaner (1.3.0) @@ -131,6 +147,9 @@ GEM mysql2 (0.3.17) naught (1.0.0) nested_form (0.3.2) + net-scp (1.2.1) + net-ssh (>= 2.6.5) + net-ssh (2.9.1) nokogiri (1.6.5) mini_portile (~> 0.6.0) nprogress-rails (0.1.6.3) @@ -254,6 +273,10 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) + sshkit (1.6.1) + colorize (>= 0.7.0) + net-scp (>= 1.1.2) + net-ssh (>= 2.8.0) thin (1.6.3) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0) @@ -302,6 +325,9 @@ DEPENDENCIES bootstrap-sass (~> 3.2.0.1) bootstrap_form bootswatch-rails + capistrano (~> 3.1) + capistrano-rails (~> 1.1) + capistrano-rvm capybara coffee-rails (~> 4.1.0) database_cleaner diff --git a/bin/cap b/bin/cap new file mode 100755 index 00000000..30352d4d --- /dev/null +++ b/bin/cap @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'cap' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('capistrano', 'cap') diff --git a/bin/capify b/bin/capify new file mode 100755 index 00000000..0f486e81 --- /dev/null +++ b/bin/capify @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# +# This file was generated by Bundler. +# +# The application 'capify' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'pathname' +ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +require 'rubygems' +require 'bundler/setup' + +load Gem.bin_path('capistrano', 'capify') diff --git a/config/deploy.rb b/config/deploy.rb new file mode 100644 index 00000000..01f44e6d --- /dev/null +++ b/config/deploy.rb @@ -0,0 +1,31 @@ +# config valid only for current version of Capistrano +lock '3.3.5' + +set :application, 'justask' +set :repo_url, 'git@git.rrerr.net:justask/justask.git' +ask :branch, :master +set :deploy_to, '/home/justask/cap/' +set :scm, :git +set :format, :pretty +set :log_level, :debug + +# RVM +set :rvm_type, :user +set :rvm_ruby_version, '2.0.0' + +# Rails +set :conditionally_migrate, true + +namespace :deploy do + + after :updated do + + end + + after :restart, :clear_cache do + on roles(:web), in: :groups, limit: 3, wait: 10 do + + end + end + +end diff --git a/config/deploy/production.rb b/config/deploy/production.rb new file mode 100644 index 00000000..d79adf18 --- /dev/null +++ b/config/deploy/production.rb @@ -0,0 +1,7 @@ +server 'rrerr.net', user: 'justask', roles: %w{web app} + +set :ssh_options, { + keys: %w(~/.ssh/id_rsa), + forward_agent: false, + auth_methods: %w(publickey) +} diff --git a/config/deploy/staging.rb b/config/deploy/staging.rb new file mode 100644 index 00000000..e664a6cd --- /dev/null +++ b/config/deploy/staging.rb @@ -0,0 +1,45 @@ +# Simple Role Syntax +# ================== +# Supports bulk-adding hosts to roles, the primary server in each group +# is considered to be the first unless any hosts have the primary +# property set. Don't declare `role :all`, it's a meta role. + +role :app, %w{deploy@example.com} +role :web, %w{deploy@example.com} +role :db, %w{deploy@example.com} + + +# Extended Server Syntax +# ====================== +# This can be used to drop a more detailed server definition into the +# server list. The second argument is a, or duck-types, Hash and is +# used to set extended properties on the server. + +server 'example.com', user: 'deploy', roles: %w{web app}, my_property: :my_value + + +# Custom SSH Options +# ================== +# You may pass any option but keep in mind that net/ssh understands a +# limited set of options, consult[net/ssh documentation](http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start). +# +# Global options +# -------------- +# set :ssh_options, { +# keys: %w(/home/rlisowski/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(password) +# } +# +# And/or per server (overrides global) +# ------------------------------------ +# server 'example.com', +# user: 'user_name', +# roles: %w{web app}, +# ssh_options: { +# user: 'user_name', # overrides user setting above +# keys: %w(/home/user_name/.ssh/id_rsa), +# forward_agent: false, +# auth_methods: %w(publickey password) +# # password: 'please use keys' +# } diff --git a/lib/assets/.keep b/lib/capistrano/tasks/.keep similarity index 100% rename from lib/assets/.keep rename to lib/capistrano/tasks/.keep diff --git a/spec/factories/notifications.rb b/spec/factories/notifications.rb new file mode 100644 index 00000000..79eaba4b --- /dev/null +++ b/spec/factories/notifications.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + factory :notification do + target_type "MyString" +target_id 1 +recipient_id 1 +new false + end + +end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb new file mode 100644 index 00000000..f79213f9 --- /dev/null +++ b/spec/models/notification_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Notification, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end