mina 0.3.0 → 0.3.1
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.
- data/.gitignore +2 -0
- data/.travis.yml +14 -5
- data/HISTORY.md +45 -1
- data/LICENSE +1 -1
- data/Makefile +29 -0
- data/Notes.md +70 -0
- data/Readme.md +1009 -0
- data/bin/mina +1 -1
- data/data/deploy.rb +13 -7
- data/lib/mina/bundler.rb +6 -1
- data/lib/mina/chruby.rb +49 -0
- data/lib/mina/default.rb +1 -0
- data/lib/mina/deploy.rb +17 -1
- data/lib/mina/deploy_helpers.rb +4 -4
- data/lib/mina/exec_helpers.rb +26 -19
- data/lib/mina/foreman.rb +5 -1
- data/lib/mina/git.rb +1 -1
- data/lib/mina/helpers.rb +22 -13
- data/lib/mina/rails.rb +6 -6
- data/lib/mina/rbenv.rb +1 -0
- data/lib/mina/rvm.rb +2 -4
- data/lib/mina/ssh_helpers.rb +2 -1
- data/lib/mina/version.rb +1 -1
- data/lib/mina/whenever.rb +6 -6
- data/mina.gemspec +2 -2
- data/spec/command_helper.rb +1 -1
- data/spec/commands/cleanup_spec.rb +16 -0
- data/spec/commands/command_spec.rb +18 -18
- data/spec/commands/custom_config_spec.rb +2 -2
- data/spec/commands/deploy_spec.rb +7 -7
- data/spec/commands/outside_project_spec.rb +7 -7
- data/spec/commands/real_deploy_spec.rb +21 -21
- data/spec/commands/verbose_spec.rb +2 -2
- data/spec/dsl/invoke_spec.rb +17 -2
- data/spec/dsl/queue_spec.rb +4 -4
- data/spec/dsl/settings_in_rake_spec.rb +6 -6
- data/spec/dsl/settings_spec.rb +16 -10
- data/spec/dsl/to_spec.rb +2 -2
- data/spec/helpers/exec_helper_spec.rb +19 -0
- data/spec/spec_helper.rb +6 -0
- data/support/Readme-footer.md +32 -0
- data/support/Readme-header.md +16 -0
- data/support/guide.md +297 -0
- data/support/index.html +53 -0
- data/support/to_md.rb +11 -0
- data/test_env/config/deploy.rb +2 -0
- metadata +96 -61
- checksums.yaml +0 -7
- data/README.md +0 -114
@@ -12,25 +12,25 @@ describe "Invoking the 'mina' command in a project" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it "should take care of the lockfile" do
|
15
|
-
stdout.
|
16
|
-
stdout.
|
17
|
-
stdout.
|
15
|
+
expect(stdout).to match(/ERROR: another deployment is ongoing/)
|
16
|
+
expect(stdout).to match(/touch ".*deploy\.lock"/)
|
17
|
+
expect(stdout).to match(/rm -f ".*deploy\.lock"/)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should honor releases_path" do
|
21
|
-
stdout.
|
21
|
+
expect(stdout).to include "releases/"
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should symlink the current_path" do
|
25
|
-
stdout.
|
25
|
+
expect(stdout).to match(/ln .*current/)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should include deploy directives" do
|
29
|
-
stdout.
|
29
|
+
expect(stdout).to include "bundle exec rake db:migrate"
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should include 'to :launch' directives" do
|
33
|
-
stdout.
|
33
|
+
expect(stdout).to include "touch tmp/restart.txt"
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
@@ -12,22 +12,22 @@ describe "Invoking the 'mina' command outside a project" do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'should print standard help tasks' do
|
15
|
-
stdout.
|
16
|
-
stdout.
|
17
|
-
stdout.
|
15
|
+
expect(stdout).to include('mina help')
|
16
|
+
expect(stdout).to include('mina init')
|
17
|
+
expect(stdout).to include('mina tasks')
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should not print project-specific tasks" do
|
21
|
-
stdout.
|
22
|
-
stdout.
|
23
|
-
stdout.
|
21
|
+
expect(stdout).not_to include('mina deploy')
|
22
|
+
expect(stdout).not_to include('mina restart')
|
23
|
+
expect(stdout).not_to include('mina setup')
|
24
24
|
end
|
25
25
|
|
26
26
|
%w[-h --help].each do |arg|
|
27
27
|
it "should have the same output as 'mina #{arg}'" do
|
28
28
|
@previous_output = stdout
|
29
29
|
mina arg
|
30
|
-
stdout.
|
30
|
+
expect(stdout).to eq(@previous_output)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -21,33 +21,33 @@ describe "Invoking the 'mina' command in a project", :ssh => true do
|
|
21
21
|
it 'should set up and deploy fine' do
|
22
22
|
print "[setup]" if ENV['verbose']
|
23
23
|
mina 'setup', '--verbose'
|
24
|
-
File.directory?('deploy').
|
25
|
-
File.directory?('deploy/releases').
|
26
|
-
File.directory?('deploy/shared').
|
27
|
-
File.exists?('deploy/last_version').
|
28
|
-
File.exists?('deploy/deploy.lock').
|
24
|
+
expect(File.directory?('deploy')).to be_truthy
|
25
|
+
expect(File.directory?('deploy/releases')).to be_truthy
|
26
|
+
expect(File.directory?('deploy/shared')).to be_truthy
|
27
|
+
expect(File.exists?('deploy/last_version')).to be_falsey
|
28
|
+
expect(File.exists?('deploy/deploy.lock')).to be_falsey
|
29
29
|
|
30
30
|
print "[deploy 1]" if ENV['verbose']
|
31
31
|
mina 'deploy', '--verbose'
|
32
|
-
stdout.
|
33
|
-
stdout.
|
34
|
-
stdout.
|
35
|
-
File.exists?('deploy/last_version').
|
36
|
-
File.exists?('deploy/deploy.lock').
|
37
|
-
File.directory?('deploy/releases').
|
38
|
-
File.directory?('deploy/releases/1').
|
39
|
-
File.exists?('deploy/releases/1/README.md').
|
40
|
-
File.directory?('deploy/releases/2').
|
41
|
-
File.exists?('deploy/current').
|
42
|
-
File.read('deploy/last_version').strip.
|
43
|
-
File.exists?('deploy/current/tmp/restart.txt').
|
32
|
+
expect(stdout).to include "-----> Creating a temporary build path"
|
33
|
+
expect(stdout).to include "rm -rf .git"
|
34
|
+
expect(stdout).to include "mkdir -p"
|
35
|
+
expect(File.exists?('deploy/last_version')).to be_truthy
|
36
|
+
expect(File.exists?('deploy/deploy.lock')).to be_falsey
|
37
|
+
expect(File.directory?('deploy/releases')).to be_truthy
|
38
|
+
expect(File.directory?('deploy/releases/1')).to be_truthy
|
39
|
+
expect(File.exists?('deploy/releases/1/README.md')).to be_truthy
|
40
|
+
expect(File.directory?('deploy/releases/2')).to be_falsey
|
41
|
+
expect(File.exists?('deploy/current')).to be_truthy
|
42
|
+
expect(File.read('deploy/last_version').strip).to eq('1')
|
43
|
+
expect(File.exists?('deploy/current/tmp/restart.txt')).to be_truthy
|
44
44
|
|
45
45
|
# And again, to test out sequential versions and stuff
|
46
46
|
print "[deploy 2]" if ENV['verbose']
|
47
47
|
mina 'deploy'
|
48
|
-
stdout.
|
49
|
-
stdout.
|
50
|
-
File.directory?('deploy/releases/2').
|
51
|
-
File.read('deploy/last_version').strip.
|
48
|
+
expect(stdout).not_to include "rm -rf .git"
|
49
|
+
expect(stdout).not_to include "mkdir -p"
|
50
|
+
expect(File.directory?('deploy/releases/2')).to be_truthy
|
51
|
+
expect(File.read('deploy/last_version').strip).to eq('2')
|
52
52
|
end
|
53
53
|
end
|
@@ -10,12 +10,12 @@ describe "Invoking the 'mina' command in a project" do
|
|
10
10
|
it 'should echo commands in verbose mode' do
|
11
11
|
mina 'deploy', '--verbose', '--simulate'
|
12
12
|
|
13
|
-
stdout.
|
13
|
+
expect(stdout).to include %[echo #{Shellwords.escape('$ git')}]
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should not echo commands when not in verbose mode' do
|
17
17
|
mina 'deploy', '--simulate'
|
18
18
|
|
19
|
-
stdout.
|
19
|
+
expect(stdout).not_to include %[echo #{Shellwords.escape('$ git')}]
|
20
20
|
end
|
21
21
|
end
|
data/spec/dsl/invoke_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe 'Mina' do
|
|
13
13
|
rake { invoke :clone }
|
14
14
|
}
|
15
15
|
|
16
|
-
rake.commands.
|
16
|
+
expect(rake.commands).to eq(['git clone'])
|
17
17
|
end
|
18
18
|
|
19
19
|
it '#invoke should work with :reenable option' do
|
@@ -28,6 +28,21 @@ describe 'Mina' do
|
|
28
28
|
rake { invoke :pull, :reenable => true }
|
29
29
|
}
|
30
30
|
|
31
|
-
rake.commands.
|
31
|
+
expect(rake.commands).to eq(['git pull', 'git pull'])
|
32
|
+
end
|
33
|
+
|
34
|
+
it '#invoke with task arguments should work with :reenable option' do
|
35
|
+
|
36
|
+
rake {
|
37
|
+
task :hello, [:world] do |t, args|
|
38
|
+
queue "echo Hello #{args[:world]}"
|
39
|
+
end
|
40
|
+
}
|
41
|
+
|
42
|
+
%w(World Pirate).each { |name|
|
43
|
+
rake { invoke :"hello[#{name}]", :reenable => true }
|
44
|
+
}
|
45
|
+
|
46
|
+
expect(rake.commands).to eq(['echo Hello World', 'echo Hello Pirate'])
|
32
47
|
end
|
33
48
|
end
|
data/spec/dsl/queue_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe 'Mina' do
|
|
8
8
|
end
|
9
9
|
invoke :hello
|
10
10
|
}
|
11
|
-
rake.instance_variable_get(:@hello).
|
11
|
+
expect(rake.instance_variable_get(:@hello)).to eq('world')
|
12
12
|
end
|
13
13
|
|
14
14
|
it '#queue should work' do
|
@@ -16,7 +16,7 @@ describe 'Mina' do
|
|
16
16
|
queue 'sudo service nginx restart'
|
17
17
|
}
|
18
18
|
|
19
|
-
rake.commands.
|
19
|
+
expect(rake.commands).to eq(['sudo service nginx restart'])
|
20
20
|
end
|
21
21
|
|
22
22
|
it '#queue should work with multiple commands' do
|
@@ -25,7 +25,7 @@ describe 'Mina' do
|
|
25
25
|
queue 'sudo service nginx restart'
|
26
26
|
}
|
27
27
|
|
28
|
-
rake.commands.
|
28
|
+
expect(rake.commands).to eq(['echo Restarting', 'sudo service nginx restart'])
|
29
29
|
end
|
30
30
|
|
31
31
|
it '#queue should work inside tasks' do
|
@@ -44,6 +44,6 @@ describe 'Mina' do
|
|
44
44
|
|
45
45
|
rake { invoke :restart }
|
46
46
|
|
47
|
-
rake.commands.
|
47
|
+
expect(rake.commands).to eq(['echo Restarting', 'touch tmp/restart.txt'])
|
48
48
|
end
|
49
49
|
end
|
@@ -4,8 +4,8 @@ describe 'Settings in rake tasks' do
|
|
4
4
|
it '#set should work' do
|
5
5
|
rake { set :domain, 'localhost' }
|
6
6
|
|
7
|
-
rake.domain.
|
8
|
-
rake.settings.domain.
|
7
|
+
expect(rake.domain).to eq('localhost')
|
8
|
+
expect(rake.settings.domain).to eq('localhost')
|
9
9
|
end
|
10
10
|
|
11
11
|
it '#settings ||= should work' do
|
@@ -14,8 +14,8 @@ describe 'Settings in rake tasks' do
|
|
14
14
|
settings.version ||= '3'
|
15
15
|
}
|
16
16
|
|
17
|
-
rake.settings.version.
|
18
|
-
rake.version.
|
17
|
+
expect(rake.settings.version).to eq('2')
|
18
|
+
expect(rake.version).to eq('2')
|
19
19
|
end
|
20
20
|
|
21
21
|
it '#settings with lambdas should work' do
|
@@ -24,8 +24,8 @@ describe 'Settings in rake tasks' do
|
|
24
24
|
set :path, lambda { "/var/www/#{version}" }
|
25
25
|
}
|
26
26
|
|
27
|
-
rake.path.
|
28
|
-
rake.path
|
27
|
+
expect(rake.path).to eq("/var/www/42")
|
28
|
+
expect(rake.path?).to be_truthy
|
29
29
|
end
|
30
30
|
|
31
31
|
it '#settings with a bang should work' do
|
data/spec/dsl/settings_spec.rb
CHANGED
@@ -8,38 +8,43 @@ describe 'Settings' do
|
|
8
8
|
|
9
9
|
it 'setting/getting should work' do
|
10
10
|
@settings.domain = '192.168.1.1'
|
11
|
-
|
11
|
+
|
12
|
+
expect(@settings.domain).to eq('192.168.1.1')
|
12
13
|
end
|
13
14
|
|
14
15
|
it 'question mark should work' do
|
15
16
|
@settings.deploy_to = '/var/www/there'
|
16
|
-
|
17
|
-
@settings.
|
17
|
+
|
18
|
+
expect(@settings.deploy_to?).to be_truthy
|
19
|
+
expect(@settings.foobar?).to be_falsey
|
18
20
|
end
|
19
21
|
|
20
22
|
it 'question mark should work with nils' do
|
21
23
|
@settings.deploy_to = nil
|
22
|
-
|
23
|
-
@settings.
|
24
|
+
|
25
|
+
expect(@settings.deploy_to?).to be_truthy
|
26
|
+
expect(@settings.foobar?).to be_falsey
|
24
27
|
end
|
25
28
|
|
26
29
|
it '||= should work (1)' do
|
27
30
|
@settings.x = 2
|
28
31
|
@settings.x ||= 3
|
29
|
-
|
32
|
+
|
33
|
+
expect(@settings.x).to eq(2)
|
30
34
|
end
|
31
35
|
|
32
36
|
it '||= should work (2)' do
|
33
37
|
@settings.x ||= 3
|
34
|
-
|
38
|
+
|
39
|
+
expect(@settings.x).to eq(3)
|
35
40
|
end
|
36
41
|
|
37
42
|
it 'lambdas should work' do
|
38
43
|
@settings.path = lambda { "/var/www/#{@settings.version}" }
|
39
44
|
@settings.version = '3'
|
40
45
|
|
41
|
-
@settings.path
|
42
|
-
@settings.path.
|
46
|
+
expect(@settings.path?).to be_truthy
|
47
|
+
expect(@settings.path).to eq("/var/www/3")
|
43
48
|
end
|
44
49
|
|
45
50
|
it 'bangs should check for settings' do
|
@@ -48,7 +53,8 @@ describe 'Settings' do
|
|
48
53
|
|
49
54
|
it 'bangs should return settings' do
|
50
55
|
@settings.version = 4
|
51
|
-
|
56
|
+
|
57
|
+
expect(@settings.version!).to eq(4)
|
52
58
|
end
|
53
59
|
end
|
54
60
|
end
|
data/spec/dsl/to_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe 'Mina' do
|
|
14
14
|
|
15
15
|
rake { invoke :deploy }
|
16
16
|
|
17
|
-
rake.commands.
|
18
|
-
rake.commands(:restart).
|
17
|
+
expect(rake.commands).to eq(['git clone'])
|
18
|
+
expect(rake.commands(:restart)).to eq(['touch tmp/restart.txt'])
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'Exec Helpers' do
|
4
|
+
before :each do
|
5
|
+
@exec = Object.new
|
6
|
+
@exec.send :extend, Mina::ExecHelpers
|
7
|
+
|
8
|
+
allow(@exec).to receive(:print_char)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'pretty_system' do
|
12
|
+
@exec.pretty_system "echo 'Hello there'"
|
13
|
+
|
14
|
+
expect(@exec).to have_received(:print_char).
|
15
|
+
with("e").with("r").with("e").with("h").with("t").
|
16
|
+
with(" ").
|
17
|
+
with("o").with("l").with("l").with("e").with("H")
|
18
|
+
end
|
19
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
require 'mina'
|
2
2
|
require 'rake'
|
3
3
|
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.order = 'random'
|
6
|
+
config.seed = '12345'
|
7
|
+
end
|
8
|
+
|
4
9
|
class RakeScope
|
5
10
|
include Rake::DSL if Rake.const_defined?(:DSL)
|
6
11
|
include Mina::Helpers
|
@@ -19,3 +24,4 @@ end
|
|
19
24
|
def root(*a)
|
20
25
|
File.join File.expand_path('../../', __FILE__), *a
|
21
26
|
end
|
27
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
Acknowledgements
|
3
|
+
----------------
|
4
|
+
|
5
|
+
© 2012-2014, Nadarei. Released under the [MIT
|
6
|
+
License](http://www.opensource.org/licenses/mit-license.php).
|
7
|
+
|
8
|
+
Mina is authored and maintained by [Rico Sta. Cruz][rsc] and [Michael
|
9
|
+
Galero][mg] with help from its [contributors][c]. It is sponsored by our
|
10
|
+
startup, [Nadarei][nd].
|
11
|
+
|
12
|
+
* [Nadarei](http://nadarei.co) (nadarei.co)
|
13
|
+
* [Github](http://github.com/nadarei) (@nadarei)
|
14
|
+
|
15
|
+
Rico:
|
16
|
+
|
17
|
+
* [My website](http://ricostacruz.com) (ricostacruz.com)
|
18
|
+
* [Github](http://github.com/rstacruz) (@rstacruz)
|
19
|
+
* [Twitter](http://twitter.com/rstacruz) (@rstacruz)
|
20
|
+
|
21
|
+
Michael:
|
22
|
+
|
23
|
+
* [My website][mg] (michaelgalero.com)
|
24
|
+
* [Github](http://github.com/mikong) (@mikong)
|
25
|
+
|
26
|
+
[rsc]: http://ricostacruz.com
|
27
|
+
[mg]: http://devblog.michaelgalero.com/
|
28
|
+
[c]: http://github.com/nadarei/mina/contributors
|
29
|
+
[nd]: http://nadarei.co
|
30
|
+
[issues]: https://github.com/nadarei/mina/issues
|
31
|
+
[trello]: https://trello.com/board/mina/4fc8b3023d9c9a4d72e573e6
|
32
|
+
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Mina
|
2
|
+
|
3
|
+
Really fast deployer and server automation tool.
|
4
|
+
|
5
|
+
Mina works really fast because it's a deploy Bash script generator. It
|
6
|
+
generates an entire procedure as a Bash script and runs it remotely in the
|
7
|
+
server.
|
8
|
+
|
9
|
+
Compare this to the likes of Vlad or Capistrano, where each command
|
10
|
+
is run separately on their own SSH sessions. Mina only creates *one* SSH
|
11
|
+
session per deploy, minimizing the SSH connection overhead.
|
12
|
+
|
13
|
+
$ gem install mina
|
14
|
+
$ mina
|
15
|
+
|
16
|
+
[](https://travis-ci.org/mina-deploy/mina) [](http://badge.fury.io/rb/mina)
|