recap 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.travis.yml +2 -1
- data/Rakefile +1 -1
- data/Vagrantfile +2 -2
- data/features/steps/capistrano_steps.rb +3 -3
- data/features/support/project.rb +0 -1
- data/features/support/server.rb +30 -14
- data/lib/recap/recipes/ruby.rb +1 -0
- data/lib/recap/support/capistrano_extensions.rb +14 -2
- data/lib/recap/tasks/bundler.rb +2 -2
- data/lib/recap/tasks/deploy.rb +11 -0
- data/lib/recap/tasks/foreman.rb +2 -2
- data/lib/recap/tasks/rails.rb +20 -9
- data/lib/recap/tasks/ruby.rb +23 -0
- data/lib/recap/version.rb +1 -1
- data/recap.gemspec +0 -2
- data/spec/tasks/bundler_spec.rb +8 -8
- data/spec/tasks/deploy_spec.rb +8 -0
- data/spec/tasks/foreman_spec.rb +4 -4
- data/spec/tasks/rails_spec.rb +33 -10
- data/spec/tasks/ruby_spec.rb +67 -0
- data/test-vm/manifests/base.pp +5 -0
- metadata +8 -63
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MWUzNWEyMGYyMjA1NGRjZWIyNmUzZDEzZTI5OTZlOWJhOWVkNmM3OA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZTM3MTU4NmUxY2I3M2JmOTNmZDYxODRmNzYyNjYyMTk4NDlmMDA3ZQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MmZlMDUxZjMzOTJjNTc5NTE2YzU5NjhmYjhhN2IxYTY4YTIxODU2ZWU3YjQ3
|
10
|
+
NGRiYTNlZmIwYTc0ZjFkYjlhZmQ0NzJiNmFkZDE4YmZiY2I2N2Y5MGI2MzQy
|
11
|
+
OTMxYjg0YTQ2YzRhMTE5OTRiMzg0Y2UxMGM2ZWUzYjhkZWU1MmI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OTlmZWI1MTM1Yzc1MTgyZjgxYTM2OWRiOWJkYWU4NGU1ZTk2Y2I3ZDQ1ZDdh
|
14
|
+
NGM3YmZhYzFjODEzYzk1MWM0MjcwNDU2YTY2OGNhOTIxODVkNWZiMGUxM2Ix
|
15
|
+
MjExZGYxYzM4ZTg3MTQ3Y2I0YjRhZmM4NGY4ZWFiMzI2YzJkYTc=
|
data/.travis.yml
CHANGED
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ task :doc do
|
|
7
7
|
FileUtils.cd('lib') do
|
8
8
|
files = Dir['**/*.rb']
|
9
9
|
files.each do |source_file|
|
10
|
-
rocco = Rocco.new(source_file, files.to_a, {})
|
10
|
+
rocco = Rocco.new(source_file, files.to_a, {:stylesheet => "http://gofreerange.com/stylesheets/rocco.css"})
|
11
11
|
dest_file = '../doc/' + source_file.sub(Regexp.new("#{File.extname(source_file)}$"), '.html')
|
12
12
|
FileUtils.mkdir_p(File.dirname(dest_file))
|
13
13
|
File.open(dest_file, 'wb') { |fd| fd.write(rocco.to_html) }
|
data/Vagrantfile
CHANGED
@@ -7,11 +7,11 @@ Vagrant::Config.run do |config|
|
|
7
7
|
# please see the online documentation at vagrantup.com.
|
8
8
|
|
9
9
|
# Every Vagrant virtual environment requires a box to build off of.
|
10
|
-
config.vm.box = "
|
10
|
+
config.vm.box = "precise64_vmware_fusion"
|
11
11
|
|
12
12
|
# The url from where the 'config.vm.box' box will be fetched if it
|
13
13
|
# doesn't already exist on the user's system.
|
14
|
-
config.vm.box_url = "http://files.vagrantup.com/
|
14
|
+
config.vm.box_url = "http://files.vagrantup.com/precise64_vmware_fusion.box"
|
15
15
|
|
16
16
|
# Boot with a GUI so you can see the screen. (Default is headless)
|
17
17
|
# config.vm.boot_mode = :gui
|
@@ -77,7 +77,7 @@ Then /^the previous project version should be deployed$/ do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
Then /^the deployed project should include version "([^"]*)" of "([^"]*)"$/ do |version, gem|
|
80
|
-
project.run_on_server("bin/#{gem} --version").strip.should eql(version)
|
80
|
+
project.run_on_server("ruby bin/#{gem} --version").strip.should eql(version)
|
81
81
|
end
|
82
82
|
|
83
83
|
Then /^the variable "([^"]*)" should be set (?:back )?to "([^"]*)"$/ do |name, value|
|
@@ -85,7 +85,7 @@ Then /^the variable "([^"]*)" should be set (?:back )?to "([^"]*)"$/ do |name, v
|
|
85
85
|
end
|
86
86
|
|
87
87
|
Then /^the variable "([^"]*)" should be set to the application's PATH$/ do |name|
|
88
|
-
path = project.run_on_server("echo $PATH", ".").strip
|
88
|
+
path = project.run_on_server("sudo su - #{project.name} -c 'echo $PATH'", ".").strip
|
89
89
|
project.run_on_server("sudo su - #{project.name} -c 'env | grep #{name}'", ".").strip.should eql("#{name}=#{path}")
|
90
90
|
end
|
91
91
|
|
@@ -99,4 +99,4 @@ end
|
|
99
99
|
|
100
100
|
Then /^the running application process should know that "([^"]*)" is set to "([^"]*)"$/ do |name, value|
|
101
101
|
project.run_on_server("/usr/bin/curl localhost:3500/env | grep #{name}").strip.should eql("#{name}=#{value}")
|
102
|
-
end
|
102
|
+
end
|
data/features/support/project.rb
CHANGED
data/features/support/server.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
require '
|
1
|
+
require 'net/ssh'
|
2
|
+
require 'tempfile'
|
2
3
|
|
3
4
|
module ServerSupport
|
4
5
|
def server
|
@@ -13,15 +14,7 @@ module ServerSupport
|
|
13
14
|
end
|
14
15
|
|
15
16
|
def private_key_path
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
def run(command, user = 'vagrant')
|
20
|
-
output = nil
|
21
|
-
env.primary_vm.channel.sudo("su - #{user} -c '#{command}'") do |type, data|
|
22
|
-
output = data if type == :stdout
|
23
|
-
end
|
24
|
-
output
|
17
|
+
ssh_config[:keys].first
|
25
18
|
end
|
26
19
|
|
27
20
|
def has_user?(name)
|
@@ -41,13 +34,36 @@ module ServerSupport
|
|
41
34
|
end
|
42
35
|
|
43
36
|
def test?(command)
|
44
|
-
|
37
|
+
run(command)
|
38
|
+
run('echo $?').to_i == 0
|
39
|
+
end
|
40
|
+
|
41
|
+
def run(command)
|
42
|
+
stdout = ''
|
43
|
+
ssh.exec!("PATH=/opt/ruby/bin:$PATH #{command}") do |channel, stream, data|
|
44
|
+
stdout << data if stream == :stdout
|
45
|
+
end
|
46
|
+
stdout
|
45
47
|
end
|
46
48
|
|
47
|
-
def
|
48
|
-
|
49
|
+
def ssh_config
|
50
|
+
Net::SSH.configuration_for('default', ssh_config_file.path)
|
51
|
+
end
|
52
|
+
|
53
|
+
private
|
54
|
+
|
55
|
+
def ssh
|
56
|
+
@ssh ||= Net::SSH.start 'default', nil, config: ssh_config_file.path
|
57
|
+
end
|
58
|
+
|
59
|
+
def ssh_config_file
|
60
|
+
@config_file ||= begin
|
61
|
+
file = Tempfile.new('ssh-config')
|
62
|
+
`vagrant ssh-config > #{file.path}`
|
63
|
+
file
|
64
|
+
end
|
49
65
|
end
|
50
66
|
end
|
51
67
|
end
|
52
68
|
|
53
|
-
World(ServerSupport)
|
69
|
+
World(ServerSupport)
|
data/lib/recap/recipes/ruby.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Require `recap/recipes/ruby` in your `Capfile` to use the default recap recipies for deploying a
|
2
2
|
# Ruby application.
|
3
3
|
require 'recap/tasks/deploy'
|
4
|
+
require 'recap/tasks/ruby'
|
4
5
|
|
5
6
|
# If your application uses Bundler, `bundle install` will be run automatically when deploying
|
6
7
|
# any changes to your `Gemfile`.
|
@@ -65,11 +65,23 @@ module Recap::Support::CapistranoExtensions
|
|
65
65
|
end
|
66
66
|
|
67
67
|
# Has the given path been created or changed since the previous deployment? During the first
|
68
|
-
# successful deployment this will always return true.
|
68
|
+
# successful deployment this will always return true if the file exists.
|
69
69
|
def deployed_file_changed?(path)
|
70
|
-
return
|
70
|
+
return deployed_file_exists?(path) unless latest_tag
|
71
71
|
exit_code("cd #{deploy_to} && git diff --exit-code #{latest_tag} origin/#{branch} #{path}") == "1"
|
72
72
|
end
|
73
73
|
|
74
|
+
def changed_files
|
75
|
+
@changed_files ||= if latest_tag
|
76
|
+
capture_git("diff --name-only #{latest_tag} origin/#{branch} | cat").split
|
77
|
+
else
|
78
|
+
capture_git("ls-files | cat").split
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def trigger_update?(path)
|
83
|
+
force_full_deploy || changed_files.detect {|p| p[0, path.length] == path}
|
84
|
+
end
|
85
|
+
|
74
86
|
Capistrano::Configuration.send :include, self
|
75
87
|
end
|
data/lib/recap/tasks/bundler.rb
CHANGED
@@ -7,7 +7,7 @@ module Recap::Tasks::Bundler
|
|
7
7
|
|
8
8
|
namespace :bundle do
|
9
9
|
# Each bundle is declared in a `Gemfile`, by default in the root of the application directory.
|
10
|
-
set(:bundle_gemfile) { "
|
10
|
+
set(:bundle_gemfile) { "Gemfile" }
|
11
11
|
|
12
12
|
# As well as a `Gemfile`, application repositories should also contain a `Gemfile.lock`.
|
13
13
|
set(:bundle_gemfile_lock) { "#{bundle_gemfile}.lock" }
|
@@ -28,7 +28,7 @@ module Recap::Tasks::Bundler
|
|
28
28
|
# After cloning or updating the code, we only install the bundle if the `Gemfile` or `Gemfile.lock` have changed.
|
29
29
|
desc "Install the latest gem bundle only if Gemfile or Gemfile.lock have changed"
|
30
30
|
task :if_changed do
|
31
|
-
if
|
31
|
+
if trigger_update?(bundle_gemfile) || trigger_update?(bundle_gemfile_lock)
|
32
32
|
top.bundle.install.default
|
33
33
|
end
|
34
34
|
end
|
data/lib/recap/tasks/deploy.rb
CHANGED
@@ -49,6 +49,9 @@ module Recap::Tasks::Deploy
|
|
49
49
|
# deployments have been made, this will be `nil`.
|
50
50
|
set(:latest_tag) { latest_tag_from_repository }
|
51
51
|
|
52
|
+
# Force a complete deploy, even if no trigger files have changed
|
53
|
+
set(:force_full_deploy, false)
|
54
|
+
|
52
55
|
# To authenticate with github or other git servers, it is easier (and cleaner) to forward the
|
53
56
|
# deploying user's ssh key than manage keys on deployment servers.
|
54
57
|
ssh_options[:forward_agent] = true
|
@@ -92,6 +95,14 @@ module Recap::Tasks::Deploy
|
|
92
95
|
restart
|
93
96
|
end
|
94
97
|
|
98
|
+
# `deploy:full` rung a standard deploy, but sets the `force_full_deploy` flag
|
99
|
+
# first. Any parts of the deploy that would normally only be triggered if
|
100
|
+
# a file changes will always run.
|
101
|
+
task :full do
|
102
|
+
set(:force_full_deploy, true)
|
103
|
+
default
|
104
|
+
end
|
105
|
+
|
95
106
|
# Fetch the latest changes, then update `HEAD` to the deployment branch.
|
96
107
|
task :update_code, :except => {:no_release => true} do
|
97
108
|
on_rollback { git "reset --hard #{latest_tag}" if latest_tag }
|
data/lib/recap/tasks/foreman.rb
CHANGED
@@ -7,7 +7,7 @@ module Recap::Tasks::Foreman
|
|
7
7
|
|
8
8
|
namespace :foreman do
|
9
9
|
# Processes are declared in a `Procfile`, by default in the root of the application directory.
|
10
|
-
set(:procfile) { "
|
10
|
+
set(:procfile) { "Procfile" }
|
11
11
|
|
12
12
|
# Foreman startup scripts are exported in `upstart` format by default.
|
13
13
|
set(:foreman_export_format, "upstart")
|
@@ -24,7 +24,7 @@ module Recap::Tasks::Foreman
|
|
24
24
|
namespace :export do
|
25
25
|
# After each deployment, the startup scripts are exported if the `Procfile` has changed.
|
26
26
|
task :if_changed do
|
27
|
-
if
|
27
|
+
if trigger_update?(procfile)
|
28
28
|
top.foreman.export.default
|
29
29
|
end
|
30
30
|
end
|
data/lib/recap/tasks/rails.rb
CHANGED
@@ -15,6 +15,13 @@ module Recap::Tasks::Rails
|
|
15
15
|
# `env:edit` tasks.
|
16
16
|
set_default_env :RAILS_ENV, 'production'
|
17
17
|
|
18
|
+
# Rails asset precompilation can be slow, and isn't required on every
|
19
|
+
# deploy. Unfortunately though, it's hard to tell which deploys need
|
20
|
+
# assets to be compiled, and which don't. By default, recap will watch
|
21
|
+
# the following files and directories and compile assets if they change
|
22
|
+
# between deploys.
|
23
|
+
set(:asset_precompilation_triggers, %w(app/assets vendor/assets Gemfile.lock config))
|
24
|
+
|
18
25
|
namespace :db do
|
19
26
|
task :load_schema do
|
20
27
|
if deployed_file_exists?("db/schema.rb")
|
@@ -23,7 +30,7 @@ module Recap::Tasks::Rails
|
|
23
30
|
end
|
24
31
|
|
25
32
|
task :migrate do
|
26
|
-
if deployed_file_exists?("db/schema.rb") &&
|
33
|
+
if deployed_file_exists?("db/schema.rb") && trigger_update?("db/schema.rb")
|
27
34
|
as_app './bin/rake db:migrate'
|
28
35
|
end
|
29
36
|
end
|
@@ -34,17 +41,21 @@ module Recap::Tasks::Rails
|
|
34
41
|
# and from individual gems) it's not easy to determine whether compilation is
|
35
42
|
# required, so it is done on every deploy.
|
36
43
|
namespace :assets do
|
37
|
-
|
38
|
-
|
44
|
+
namespace :precompile do
|
45
|
+
task :if_changed do
|
46
|
+
if asset_precompilation_triggers.detect {|path| trigger_update?(path)}
|
47
|
+
top.rails.assets.precompile.default
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
task :default do
|
52
|
+
as_app "./bin/rake RAILS_GROUPS=assets assets:precompile"
|
53
|
+
end
|
39
54
|
end
|
40
55
|
end
|
41
56
|
|
42
|
-
# After the code is first cloned (during `deploy:setup`) load the schema into
|
43
|
-
# the database.
|
44
|
-
after "deploy:clone_code", "rails:db:load_schema"
|
45
|
-
|
46
57
|
# On every deploy, after the code is updated, run the database migrations
|
47
58
|
# and precompile the assets.
|
48
|
-
after "deploy:update_code", "rails:db:migrate", "rails:assets:precompile"
|
59
|
+
after "deploy:update_code", "rails:db:migrate", "rails:assets:precompile:if_changed"
|
49
60
|
end
|
50
|
-
end
|
61
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Recap::Tasks::Ruby
|
2
|
+
extend Recap::Support::Namespace
|
3
|
+
|
4
|
+
namespace :ruby do
|
5
|
+
set(:skip_rails_recipe_not_used_warning, false)
|
6
|
+
|
7
|
+
task :preflight do
|
8
|
+
if exit_code("grep rails #{deploy_to}/Gemfile") == "0"
|
9
|
+
unless skip_rails_recipe_not_used_warning || Recap::Tasks.const_defined?(:Rails)
|
10
|
+
logger.important %{
|
11
|
+
Warning: it looks like you're using the recap ruby recipe on a rails project.
|
12
|
+
This will prevent some rails specific features such as asset compilation and
|
13
|
+
database migrations from working correctly.
|
14
|
+
To fix this, require 'recap/recipes/rails' from within your Capfile. To
|
15
|
+
suppress this warning, set :skip_rails_recipe_not_used_warning to true.
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
after "preflight:check", "ruby:preflight"
|
22
|
+
end
|
23
|
+
end
|
data/lib/recap/version.rb
CHANGED
data/recap.gemspec
CHANGED
@@ -23,8 +23,6 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_development_dependency('fl-rocco', '~>1.0.0')
|
24
24
|
s.add_development_dependency('rspec', '~>2.7.0')
|
25
25
|
s.add_development_dependency('mocha', '~>0.10.0')
|
26
|
-
s.add_development_dependency('vagrant', '~>0.9.7')
|
27
|
-
s.add_development_dependency('sahara', '~>0.0.10')
|
28
26
|
s.add_development_dependency('cucumber', '~>1.1.4')
|
29
27
|
s.add_development_dependency('faker', '~>1.0.1')
|
30
28
|
end
|
data/spec/tasks/bundler_spec.rb
CHANGED
@@ -21,8 +21,8 @@ describe Recap::Tasks::Bundler do
|
|
21
21
|
|
22
22
|
describe 'Settings' do
|
23
23
|
describe '#bundle_gemfile' do
|
24
|
-
it 'defaults to
|
25
|
-
config.bundle_gemfile.should eql(
|
24
|
+
it 'defaults to Gemfile' do
|
25
|
+
config.bundle_gemfile.should eql('Gemfile')
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -103,22 +103,22 @@ describe Recap::Tasks::Bundler do
|
|
103
103
|
|
104
104
|
describe 'bundle:install:if_changed' do
|
105
105
|
it 'calls bundle:install:default if the Gemfile.lock has changed' do
|
106
|
-
namespace.stubs(:
|
107
|
-
namespace.stubs(:
|
106
|
+
namespace.stubs(:trigger_update?).with(config.bundle_gemfile).returns(false)
|
107
|
+
namespace.stubs(:trigger_update?).with(config.bundle_gemfile_lock).returns(true)
|
108
108
|
namespace.install.expects(:default)
|
109
109
|
config.find_and_execute_task('bundle:install:if_changed')
|
110
110
|
end
|
111
111
|
|
112
112
|
it 'calls bundle:install:default if the Gemfile has changed' do
|
113
|
-
namespace.stubs(:
|
114
|
-
namespace.stubs(:
|
113
|
+
namespace.stubs(:trigger_update?).with(config.bundle_gemfile).returns(true)
|
114
|
+
namespace.stubs(:trigger_update?).with(config.bundle_gemfile_lock).returns(false)
|
115
115
|
namespace.install.expects(:default)
|
116
116
|
config.find_and_execute_task('bundle:install:if_changed')
|
117
117
|
end
|
118
118
|
|
119
119
|
it 'skips bundle_install if neither Gemfile nor Gemfile.lock have changed' do
|
120
|
-
namespace.stubs(:
|
121
|
-
namespace.stubs(:
|
120
|
+
namespace.stubs(:trigger_update?).with(config.bundle_gemfile).returns(false)
|
121
|
+
namespace.stubs(:trigger_update?).with(config.bundle_gemfile_lock).returns(false)
|
122
122
|
namespace.install.expects(:default).never
|
123
123
|
config.find_and_execute_task('bundle:install:if_changed')
|
124
124
|
end
|
data/spec/tasks/deploy_spec.rb
CHANGED
@@ -189,6 +189,14 @@ describe Recap::Tasks::Deploy do
|
|
189
189
|
end
|
190
190
|
end
|
191
191
|
|
192
|
+
describe 'deploy:full' do
|
193
|
+
it 'sets force_full_deploy and calls the default deployment task' do
|
194
|
+
namespace.expects(:default)
|
195
|
+
config.find_and_execute_task('deploy:full')
|
196
|
+
namespace.force_full_deploy.should be_true
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
192
200
|
describe 'deploy:update_code' do
|
193
201
|
it 'fetches latest changes, then resets to repository branch' do
|
194
202
|
config.set :branch, 'release-branch'
|
data/spec/tasks/foreman_spec.rb
CHANGED
@@ -27,8 +27,8 @@ describe Recap::Tasks::Foreman do
|
|
27
27
|
|
28
28
|
describe 'Settings' do
|
29
29
|
describe '#procfile' do
|
30
|
-
it 'defaults
|
31
|
-
config.procfile.should eql(
|
30
|
+
it 'defaults Procfile' do
|
31
|
+
config.procfile.should eql('Procfile')
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -85,13 +85,13 @@ describe Recap::Tasks::Foreman do
|
|
85
85
|
describe 'Tasks' do
|
86
86
|
describe 'foreman:export:if_changed' do
|
87
87
|
it 'calls foreman:export if the Procfile has changed' do
|
88
|
-
namespace.stubs(:
|
88
|
+
namespace.stubs(:trigger_update?).with(config.procfile).returns(true)
|
89
89
|
namespace.export.expects(:default)
|
90
90
|
config.find_and_execute_task('foreman:export:if_changed')
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'skips foreman:export if the Procfile has not changed' do
|
94
|
-
namespace.stubs(:
|
94
|
+
namespace.stubs(:trigger_update?).with(config.procfile).returns(false)
|
95
95
|
namespace.export.expects(:default).never
|
96
96
|
config.find_and_execute_task('foreman:export:if_changed')
|
97
97
|
end
|
data/spec/tasks/rails_spec.rb
CHANGED
@@ -20,6 +20,17 @@ describe Recap::Tasks::Rails do
|
|
20
20
|
Recap::Tasks::Rails.load_into(config)
|
21
21
|
end
|
22
22
|
|
23
|
+
describe 'Settings' do
|
24
|
+
describe '#asset_precompilation_triggers' do
|
25
|
+
it 'includes app/assets, vendor/assets, Gemfile.lock and config' do
|
26
|
+
namespace.asset_precompilation_triggers.include?('app/assets').should be_true
|
27
|
+
namespace.asset_precompilation_triggers.include?('vendor/assets').should be_true
|
28
|
+
namespace.asset_precompilation_triggers.include?('Gemfile.lock').should be_true
|
29
|
+
namespace.asset_precompilation_triggers.include?('config').should be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
23
34
|
describe 'Tasks' do
|
24
35
|
describe 'rails:db:load_schema' do
|
25
36
|
it 'loads the schema if db/schema.rb exists' do
|
@@ -38,26 +49,43 @@ describe Recap::Tasks::Rails do
|
|
38
49
|
describe 'rails:db:migrate' do
|
39
50
|
it 'runs migrations if the schema has changed' do
|
40
51
|
namespace.stubs(:deployed_file_exists?).with('db/schema.rb').returns(true)
|
41
|
-
namespace.stubs(:
|
52
|
+
namespace.stubs(:trigger_update?).with('db/schema.rb').returns(true)
|
42
53
|
namespace.expects(:as_app).with('./bin/rake db:migrate')
|
43
54
|
config.find_and_execute_task('rails:db:migrate')
|
44
55
|
end
|
45
56
|
|
46
57
|
it 'does nothing if the schema has not changed' do
|
47
58
|
namespace.stubs(:deployed_file_exists?).with('db/schema.rb').returns(true)
|
48
|
-
namespace.stubs(:
|
59
|
+
namespace.stubs(:trigger_update?).with('db/schema.rb').returns(false)
|
49
60
|
namespace.expects(:as_app).never
|
50
61
|
config.find_and_execute_task('rails:db:migrate')
|
51
62
|
end
|
52
63
|
|
53
64
|
it 'does nothing if the schema does not exist' do
|
54
65
|
namespace.stubs(:deployed_file_exists?).with('db/schema.rb').returns(false)
|
55
|
-
namespace.stubs(:
|
66
|
+
namespace.stubs(:trigger_update?).with('db/schema.rb').returns(true)
|
56
67
|
namespace.expects(:as_app).never
|
57
68
|
config.find_and_execute_task('rails:db:migrate')
|
58
69
|
end
|
59
70
|
end
|
60
71
|
|
72
|
+
describe 'assets:precompile:if_changed' do
|
73
|
+
it 'calls assets:precompileassets:precompile if any of the triggers have changed' do
|
74
|
+
config.set(:asset_precompilation_triggers, ['trigger-one', 'trigger-two'])
|
75
|
+
namespace.stubs(:trigger_update?).with('trigger-one').returns(false)
|
76
|
+
namespace.stubs(:trigger_update?).with('trigger-two').returns(true)
|
77
|
+
namespace.assets.precompile.expects(:default)
|
78
|
+
config.find_and_execute_task('rails:assets:precompile:if_changed')
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'skips assets:precompile if none of the triggers have changed' do
|
82
|
+
config.set(:asset_precompilation_triggers, ['trigger-one', 'trigger-two'])
|
83
|
+
namespace.stubs(:trigger_update?).returns(false)
|
84
|
+
namespace.assets.expects(:default).never
|
85
|
+
config.find_and_execute_task('rails:assets:precompile:if_changed')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
61
89
|
describe 'assets:precompile' do
|
62
90
|
it 'compiles assets on the server' do
|
63
91
|
namespace.expects(:as_app).with('./bin/rake RAILS_GROUPS=assets assets:precompile')
|
@@ -71,11 +99,6 @@ describe Recap::Tasks::Rails do
|
|
71
99
|
Recap::Tasks::Deploy.load_into(config)
|
72
100
|
end
|
73
101
|
|
74
|
-
it 'runs `rails:db:load_schema` after `deploy:clone_code`' do
|
75
|
-
config.expects(:find_and_execute_task).with('rails:db:load_schema')
|
76
|
-
config.trigger :after, config.find_task('deploy:clone_code')
|
77
|
-
end
|
78
|
-
|
79
102
|
it 'runs `rails:db:migrate` after `deploy:update_code`' do
|
80
103
|
config.stubs(:find_and_execute_task)
|
81
104
|
config.expects(:find_and_execute_task).with('rails:db:migrate')
|
@@ -84,8 +107,8 @@ describe Recap::Tasks::Rails do
|
|
84
107
|
|
85
108
|
it 'runs `rails:assets:precompile` after `deploy:update_code`' do
|
86
109
|
config.stubs(:find_and_execute_task)
|
87
|
-
config.expects(:find_and_execute_task).with('rails:assets:precompile')
|
110
|
+
config.expects(:find_and_execute_task).with('rails:assets:precompile:if_changed')
|
88
111
|
config.trigger :after, config.find_task('deploy:update_code')
|
89
112
|
end
|
90
113
|
end
|
91
|
-
end
|
114
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'recap/tasks/ruby'
|
3
|
+
|
4
|
+
describe Recap::Tasks::Ruby do
|
5
|
+
let :config do
|
6
|
+
Capistrano::Configuration.new
|
7
|
+
end
|
8
|
+
|
9
|
+
let :namespace do
|
10
|
+
config.ruby
|
11
|
+
end
|
12
|
+
|
13
|
+
let :deploy_to do
|
14
|
+
'path/to/deploy/to'
|
15
|
+
end
|
16
|
+
|
17
|
+
before do
|
18
|
+
config.set :deploy_to, deploy_to
|
19
|
+
Recap::Tasks::Ruby.load_into(config)
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'Tasks' do
|
23
|
+
describe 'ruby:preflight' do
|
24
|
+
before do
|
25
|
+
namespace.stubs(:exit_code).with('grep rails path/to/deploy/to/Gemfile').returns("0")
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'warns user if rails tasks not loaded for rails project' do
|
29
|
+
namespace.logger.expects(:important)
|
30
|
+
Recap::Tasks.stubs(:const_defined?).with(:Rails).returns(false)
|
31
|
+
config.find_and_execute_task('ruby:preflight')
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'skips warning if rails tasks have been loaded' do
|
35
|
+
namespace.logger.expects(:important).never
|
36
|
+
Recap::Tasks.stubs(:const_defined?).with(:Rails).returns(true)
|
37
|
+
config.find_and_execute_task('ruby:preflight')
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'skips warning if skip_rails_recipe_not_used_warning set' do
|
41
|
+
namespace.logger.expects(:important).never
|
42
|
+
Recap::Tasks.stubs(:const_defined?).with(:Rails).returns(false)
|
43
|
+
config.set :skip_rails_recipe_not_used_warning, true
|
44
|
+
config.find_and_execute_task('ruby:preflight')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'skips warning if rails project not detected' do
|
48
|
+
namespace.logger.expects(:important).never
|
49
|
+
namespace.stubs(:exit_code).with('grep rails path/to/deploy/to/Gemfile').returns("1")
|
50
|
+
Recap::Tasks.stubs(:const_defined?).with(:Rails).returns(false)
|
51
|
+
config.set :skip_rails_recipe_not_used_warning, true
|
52
|
+
config.find_and_execute_task('ruby:preflight')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe 'Callbacks' do
|
58
|
+
before do
|
59
|
+
Recap::Tasks::Preflight.load_into(config)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'runs `ruby:preflight` after `preflight:check`' do
|
63
|
+
config.expects(:find_and_execute_task).with('ruby:preflight')
|
64
|
+
config.trigger :after, config.find_task('preflight:check')
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/test-vm/manifests/base.pp
CHANGED
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: recap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.0.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Tom Ward
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-05-04 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: capistrano
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: thor
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ! '>='
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ! '>='
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: open4
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ! '>='
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ! '>='
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rake
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: fl-rocco
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: rspec
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ~>
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ~>
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -110,7 +97,6 @@ dependencies:
|
|
110
97
|
- !ruby/object:Gem::Dependency
|
111
98
|
name: mocha
|
112
99
|
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
100
|
requirements:
|
115
101
|
- - ~>
|
116
102
|
- !ruby/object:Gem::Version
|
@@ -118,47 +104,13 @@ dependencies:
|
|
118
104
|
type: :development
|
119
105
|
prerelease: false
|
120
106
|
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
107
|
requirements:
|
123
108
|
- - ~>
|
124
109
|
- !ruby/object:Gem::Version
|
125
110
|
version: 0.10.0
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: vagrant
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ~>
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: 0.9.7
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ~>
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: 0.9.7
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: sahara
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ~>
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: 0.0.10
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ~>
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: 0.0.10
|
158
111
|
- !ruby/object:Gem::Dependency
|
159
112
|
name: cucumber
|
160
113
|
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
114
|
requirements:
|
163
115
|
- - ~>
|
164
116
|
- !ruby/object:Gem::Version
|
@@ -166,7 +118,6 @@ dependencies:
|
|
166
118
|
type: :development
|
167
119
|
prerelease: false
|
168
120
|
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
121
|
requirements:
|
171
122
|
- - ~>
|
172
123
|
- !ruby/object:Gem::Version
|
@@ -174,7 +125,6 @@ dependencies:
|
|
174
125
|
- !ruby/object:Gem::Dependency
|
175
126
|
name: faker
|
176
127
|
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
128
|
requirements:
|
179
129
|
- - ~>
|
180
130
|
- !ruby/object:Gem::Version
|
@@ -182,7 +132,6 @@ dependencies:
|
|
182
132
|
type: :development
|
183
133
|
prerelease: false
|
184
134
|
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
135
|
requirements:
|
187
136
|
- - ~>
|
188
137
|
- !ruby/object:Gem::Version
|
@@ -237,6 +186,7 @@ files:
|
|
237
186
|
- lib/recap/tasks/multistage.rb
|
238
187
|
- lib/recap/tasks/preflight.rb
|
239
188
|
- lib/recap/tasks/rails.rb
|
189
|
+
- lib/recap/tasks/ruby.rb
|
240
190
|
- lib/recap/version.rb
|
241
191
|
- recap.gemspec
|
242
192
|
- spec/models/capistrano_extensions_spec.rb
|
@@ -250,37 +200,31 @@ files:
|
|
250
200
|
- spec/tasks/env_spec.rb
|
251
201
|
- spec/tasks/foreman_spec.rb
|
252
202
|
- spec/tasks/rails_spec.rb
|
203
|
+
- spec/tasks/ruby_spec.rb
|
253
204
|
- test-vm/manifests/base.pp
|
254
205
|
- test-vm/share/.gitkeep
|
255
206
|
homepage: http://gofreerange.com/recap
|
256
207
|
licenses: []
|
208
|
+
metadata: {}
|
257
209
|
post_install_message:
|
258
210
|
rdoc_options: []
|
259
211
|
require_paths:
|
260
212
|
- lib
|
261
213
|
required_ruby_version: !ruby/object:Gem::Requirement
|
262
|
-
none: false
|
263
214
|
requirements:
|
264
215
|
- - ! '>='
|
265
216
|
- !ruby/object:Gem::Version
|
266
217
|
version: '0'
|
267
|
-
segments:
|
268
|
-
- 0
|
269
|
-
hash: 2476123254273941007
|
270
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
271
|
-
none: false
|
272
219
|
requirements:
|
273
220
|
- - ! '>='
|
274
221
|
- !ruby/object:Gem::Version
|
275
222
|
version: '0'
|
276
|
-
segments:
|
277
|
-
- 0
|
278
|
-
hash: 2476123254273941007
|
279
223
|
requirements: []
|
280
224
|
rubyforge_project:
|
281
|
-
rubygems_version:
|
225
|
+
rubygems_version: 2.0.2
|
282
226
|
signing_key:
|
283
|
-
specification_version:
|
227
|
+
specification_version: 4
|
284
228
|
summary: GIT based deployment recipes for Capistrano
|
285
229
|
test_files:
|
286
230
|
- features/bundling-gems.feature
|
@@ -307,3 +251,4 @@ test_files:
|
|
307
251
|
- spec/tasks/env_spec.rb
|
308
252
|
- spec/tasks/foreman_spec.rb
|
309
253
|
- spec/tasks/rails_spec.rb
|
254
|
+
- spec/tasks/ruby_spec.rb
|