mina 0.3.8 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +16 -0
  3. data/.gitignore +0 -1
  4. data/.rubocop.yml +1156 -0
  5. data/Gemfile +2 -8
  6. data/{CHANGELOG.md → PRE_1_CHANGELOG.md} +0 -0
  7. data/Rakefile +2 -18
  8. data/Readme.md +39 -1116
  9. data/bin/mina +1 -62
  10. data/data/deploy.rb +19 -46
  11. data/data/deploy.sh.erb +22 -23
  12. data/docs/Readme.md +8 -0
  13. data/docs/command_line_options.md +33 -0
  14. data/docs/deploying.md +97 -0
  15. data/docs/faq.md +1 -0
  16. data/docs/getting_started.md +44 -0
  17. data/docs/migrating.md +30 -0
  18. data/docs/writing_your_own_tasks.md +117 -0
  19. data/lib/Minafile +3 -0
  20. data/lib/mina.rb +30 -18
  21. data/lib/mina/application.rb +74 -0
  22. data/lib/mina/backend/local.rb +22 -0
  23. data/lib/mina/backend/remote.rb +42 -0
  24. data/lib/mina/commands.rb +45 -0
  25. data/lib/mina/configuration.rb +36 -0
  26. data/lib/mina/dsl.rb +47 -0
  27. data/lib/mina/helpers/internal.rb +29 -0
  28. data/lib/mina/helpers/output.rb +42 -0
  29. data/lib/mina/runner.rb +39 -0
  30. data/lib/mina/runner/exec.rb +15 -0
  31. data/lib/mina/runner/pretty.rb +53 -0
  32. data/lib/mina/runner/printer.rb +17 -0
  33. data/lib/mina/runner/system.rb +15 -0
  34. data/lib/mina/version.rb +1 -3
  35. data/mina.gemspec +27 -16
  36. data/spec/lib/mina/application_spec.rb +39 -0
  37. data/spec/lib/mina/backend/local_spec.rb +16 -0
  38. data/spec/lib/mina/backend/remote_spec.rb +17 -0
  39. data/spec/lib/mina/commands_spec.rb +93 -0
  40. data/spec/lib/mina/configuration_spec.rb +52 -0
  41. data/spec/lib/mina/helpers/internal_spec.rb +50 -0
  42. data/spec/lib/mina/helpers/output_spec.rb +48 -0
  43. data/spec/lib/mina/runner_spec.rb +36 -0
  44. data/spec/lib/mina_spec.rb +7 -0
  45. data/spec/spec_helper.rb +13 -21
  46. data/spec/support/run_helper.rb +36 -0
  47. data/tasks/mina/bundler.rb +15 -0
  48. data/tasks/mina/chruby.rb +19 -0
  49. data/tasks/mina/default.rb +36 -0
  50. data/tasks/mina/deploy.rb +85 -0
  51. data/tasks/mina/git.rb +36 -0
  52. data/tasks/mina/install.rb +18 -0
  53. data/tasks/mina/rails.rb +108 -0
  54. data/tasks/mina/rbenv.rb +15 -0
  55. data/tasks/mina/rvm.rb +39 -0
  56. data/tasks/mina/ry.rb +26 -0
  57. data/test_env/config/deploy.rb +44 -72
  58. metadata +82 -59
  59. data/.travis.yml +0 -21
  60. data/CONTRIBUTING.md +0 -124
  61. data/HISTORY.md +0 -394
  62. data/Makefile +0 -32
  63. data/Notes.md +0 -70
  64. data/lib/mina/bundler.rb +0 -49
  65. data/lib/mina/chruby.rb +0 -49
  66. data/lib/mina/default.rb +0 -158
  67. data/lib/mina/deploy.rb +0 -160
  68. data/lib/mina/deploy_helpers.rb +0 -34
  69. data/lib/mina/exec_helpers.rb +0 -111
  70. data/lib/mina/foreman.rb +0 -83
  71. data/lib/mina/git.rb +0 -69
  72. data/lib/mina/helpers.rb +0 -408
  73. data/lib/mina/local_helpers.rb +0 -97
  74. data/lib/mina/npm.rb +0 -89
  75. data/lib/mina/output_helpers.rb +0 -92
  76. data/lib/mina/rails.rb +0 -245
  77. data/lib/mina/rake.rb +0 -10
  78. data/lib/mina/rbenv.rb +0 -47
  79. data/lib/mina/rvm.rb +0 -88
  80. data/lib/mina/ry.rb +0 -55
  81. data/lib/mina/settings.rb +0 -32
  82. data/lib/mina/ssh_helpers.rb +0 -125
  83. data/lib/mina/tools.rb +0 -20
  84. data/lib/mina/whenever.rb +0 -51
  85. data/manual/index.md +0 -15
  86. data/manual/modules.md +0 -2
  87. data/spec/command_helper.rb +0 -52
  88. data/spec/commands/cleanup_spec.rb +0 -16
  89. data/spec/commands/command_spec.rb +0 -71
  90. data/spec/commands/custom_config_spec.rb +0 -20
  91. data/spec/commands/deploy_spec.rb +0 -40
  92. data/spec/commands/outside_project_spec.rb +0 -35
  93. data/spec/commands/real_deploy_spec.rb +0 -56
  94. data/spec/commands/ssh_spec.rb +0 -14
  95. data/spec/commands/verbose_spec.rb +0 -21
  96. data/spec/dsl/invoke_spec.rb +0 -49
  97. data/spec/dsl/queue_spec.rb +0 -49
  98. data/spec/dsl/settings_in_rake_spec.rb +0 -39
  99. data/spec/dsl/settings_spec.rb +0 -61
  100. data/spec/dsl/to_spec.rb +0 -20
  101. data/spec/fixtures/custom_file_env/custom_deploy.rb +0 -15
  102. data/spec/fixtures/empty_env/config/deploy.rb +0 -15
  103. data/spec/helpers/exec_helper_spec.rb +0 -19
  104. data/spec/helpers/local_helper_spec.rb +0 -70
  105. data/spec/helpers/output_helper_spec.rb +0 -38
  106. data/support/Readme-footer.md +0 -31
  107. data/support/Readme-header.md +0 -16
  108. data/support/guide.md +0 -297
  109. data/support/index.html +0 -53
  110. data/support/third_party_modules.md +0 -23
  111. data/support/to_md.rb +0 -11
data/manual/modules.md DELETED
@@ -1,2 +0,0 @@
1
- Modules
2
- =======
@@ -1,52 +0,0 @@
1
- # Invokes the main 'mina' command.
2
- def run_command(*args)
3
- out = ''
4
- err = ''
5
- @result = nil
6
-
7
- if ENV['rake']
8
- rake_version = "~> #{ENV['rake'] || '0.9'}.0"
9
- script = %[require 'rubygems' unless Object.const_defined?(:Gem);]
10
- script += %[gem 'rake', '#{rake_version}';]
11
- script += %[load '#{root('bin/mina')}']
12
- cmd = ['ruby', '-e', "#{script}", "--", *args]
13
- else
14
- cmd = [root('bin/mina'), *args]
15
- end
16
-
17
- status =
18
- Mina::Tools.popen4(*cmd) do |pid, i, o, e|
19
- out = o.read
20
- err = e.read
21
- end
22
-
23
- @result = status.exitstatus
24
-
25
- @out = out
26
- @err = err
27
-
28
- @result
29
- end
30
-
31
- # Invokes the main 'mina' command and ensures the exit status is success.
32
- def mina(*args)
33
- run_command *args
34
- if exitstatus != 0 && ENV['verbose']
35
- puts stdout
36
- puts stderr
37
- end
38
-
39
- expect(exitstatus).to eq(0)
40
- end
41
-
42
- def stdout
43
- @out
44
- end
45
-
46
- def stderr
47
- @err
48
- end
49
-
50
- def exitstatus
51
- @result
52
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_helper'
3
-
4
- describe "Invoking the 'mina deploy:cleanup' command" do
5
- before :each do
6
- Dir.chdir root('test_env')
7
- end
8
-
9
- it "should cleanup old deployments", :ssh => true do
10
- 3.times { mina 'deploy' }
11
-
12
- mina 'deploy:cleanup'
13
-
14
- expect(Dir["deploy/releases/*"].length).to eq(2)
15
- end
16
- end
@@ -1,71 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_helper'
3
-
4
- describe "Invoking the 'mina' command in a project" do
5
- before :each do
6
- Dir.chdir root('test_env')
7
- end
8
-
9
- it "should think it's 'mina', not 'rake' (1)" do
10
- run_command 'pinkledills'
11
- expect(exitstatus).not_to eq(0)
12
- expect(stderr).to include 'mina aborted'
13
- end
14
-
15
- it "should think it's 'mina', not 'rake' (1)" do
16
- mina '-T'
17
- expect(stdout).to include 'mina help'
18
- expect(stdout).to include 'mina git:clone'
19
- end
20
-
21
- it 'with --version should print the version' do
22
- mina '--version'
23
- expect(stdout).to include Mina.version
24
- end
25
-
26
- it 'with -V should print the version' do
27
- mina '-V'
28
- expect(stdout).to include Mina.version
29
- end
30
-
31
- describe 'without arguments' do
32
- before :each do
33
- mina
34
- end
35
-
36
- it 'should print standard help tasks' do
37
- mina
38
- expect(stdout).to include 'mina help'
39
- expect(stdout).to include 'mina init'
40
- expect(stdout).to include 'mina tasks'
41
- end
42
-
43
- it 'should print project-specific tasks' do
44
- mina
45
- expect(stdout).to include 'mina deploy'
46
- expect(stdout).to include 'mina restart'
47
- expect(stdout).to include 'mina setup'
48
- end
49
-
50
- it "should be the same as running 'help'" do
51
- previous_out = stdout
52
-
53
- mina 'help'
54
- expect(stdout).to eq(previous_out)
55
- end
56
- end
57
-
58
- it "with 'mina -f' on a non-existing file should fail" do
59
- run_command '-f', 'foobar'
60
- expect(stderr).to include 'mina aborted'
61
- expect(stderr).to include 'No Rakefile found'
62
- end
63
-
64
- it "with 'mina tasks' should print tasks" do
65
- mina 'tasks'
66
-
67
- expect(stdout).to include('bundle:install')
68
- expect(stdout).to include('Install gem dependencies using Bundler')
69
- expect(stdout).to include('passenger:restart')
70
- end
71
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_helper'
3
-
4
- describe "Invoking the 'mina' command in a project without a deploy.rb" do
5
- before :each do
6
- Dir.chdir root('spec/fixtures/custom_file_env')
7
- FileUtils.rm_rf 'deploy'
8
- end
9
-
10
- it 'should fail' do
11
- run_command 'deploy', '--simulate'
12
- expect(exitstatus).to be > 0
13
- end
14
-
15
- it 'should pass if you provide a new rakefile' do
16
- mina 'deploy', '--simulate', '-f', 'custom_deploy.rb'
17
- expect(stdout).to include 'Creating a temporary build path'
18
- end
19
- end
20
-
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_helper'
3
-
4
- describe "Invoking the 'mina' command in a project" do
5
- before :each do
6
- Dir.chdir root('test_env')
7
- end
8
-
9
- describe "to do a simulated deploy" do
10
- before :each do
11
- mina 'deploy', 'simulate=1'
12
- end
13
-
14
- it "should take care of the lockfile" do
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
- end
19
-
20
- it "should honor releases_path" do
21
- expect(stdout).to include "releases/"
22
- end
23
-
24
- it "should symlink the current_path" do
25
- expect(stdout).to match(/ln .*current/)
26
- end
27
-
28
- it "should include deploy directives" do
29
- expect(stdout).to include "bundle exec rake db:migrate"
30
- end
31
-
32
- it "should include 'to :build' directives" do
33
- stdout.should include "touch build.txt"
34
- end
35
-
36
- it "should include 'to :launch' directives" do
37
- expect(stdout).to include "touch tmp/restart.txt"
38
- end
39
- end
40
- end
@@ -1,35 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_helper'
3
-
4
- describe "Invoking the 'mina' command outside a project" do
5
- before :each do
6
- Dir.chdir root
7
- end
8
-
9
- describe "without arguments" do
10
- before :each do
11
- mina
12
- end
13
-
14
- it 'should print standard help tasks' do
15
- expect(stdout).to include('mina help')
16
- expect(stdout).to include('mina init')
17
- expect(stdout).to include('mina tasks')
18
- end
19
-
20
- it "should not print project-specific tasks" do
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
- end
25
-
26
- %w[-h --help].each do |arg|
27
- it "should have the same output as 'mina #{arg}'" do
28
- @previous_output = stdout
29
- mina arg
30
- expect(stdout).to eq(@previous_output)
31
- end
32
- end
33
- end
34
- end
35
-
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_helper'
3
- require 'fileutils'
4
- require 'tmpdir'
5
-
6
- describe "Invoking the 'mina' command in a project", :ssh => true do
7
- before :each do
8
- @path = Dir.mktmpdir
9
- Dir.chdir @path
10
-
11
- FileUtils.mkdir_p './config'
12
- FileUtils.cp root('test_env/config/deploy.rb'), './config/deploy.rb'
13
- FileUtils.rm_rf './deploy'
14
- FileUtils.mkdir_p './deploy'
15
- end
16
-
17
- # after :each do
18
- # FileUtils.rm_rf @path
19
- # end
20
-
21
- it 'should set up and deploy fine' do
22
- print "[setup]" if ENV['verbose']
23
- mina 'setup', '--verbose'
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
-
30
- print "[deploy 1]" if ENV['verbose']
31
- mina 'deploy', '--verbose'
32
- expect(stdout).to include "-----> Creating a temporary build path"
33
- expect(stdout).to include "git rev-parse HEAD > .mina_git_revision"
34
- expect(stdout).to include "rm -rf .git"
35
- expect(stdout).to include "mkdir -p"
36
- expect(File.exists?('deploy/last_version')).to be_truthy
37
- expect(File.exists?('deploy/deploy.lock')).to be_falsey
38
- expect(File.directory?('deploy/releases')).to be_truthy
39
- expect(File.directory?('deploy/releases/1')).to be_truthy
40
- expect(File.exists?('deploy/releases/1/README.md')).to be_truthy
41
- expect(File.directory?('deploy/releases/2')).to be_falsey
42
- expect(File.exists?('deploy/current')).to be_truthy
43
- expect(File.read('deploy/last_version').strip).to eq('1')
44
- expect(File.exists?('deploy/current/tmp/restart.txt')).to be_truthy
45
- expect(File.exists?('deploy/current/.mina_git_revision')).to be_truthy
46
-
47
- # And again, to test out sequential versions and stuff
48
- print "[deploy 2]" if ENV['verbose']
49
- mina 'deploy'
50
- expect(stdout).not_to include "rm -rf .git"
51
- expect(stdout).not_to include "mkdir -p"
52
- expect(File.directory?('deploy/releases/2')).to be_truthy
53
- expect(File.read('deploy/last_version').strip).to eq('2')
54
- expect(File.exists?('deploy/current/.mina_git_revision')).to be_truthy
55
- end
56
- end
@@ -1,14 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_helper'
3
-
4
- describe "Invoking the 'mina' command in a project" do
5
-
6
- it "should build ssh command even with frozen String as a domain" do
7
- ENV['simulate'] = 'true'
8
- rake {
9
- set :domain, 'localhost'.freeze
10
- ssh("ls")
11
- }
12
- end
13
-
14
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
- require 'command_helper'
3
- require 'shellwords'
4
-
5
- describe "Invoking the 'mina' command in a project" do
6
- before :each do
7
- Dir.chdir root('test_env')
8
- end
9
-
10
- it 'should echo commands in verbose mode' do
11
- mina 'deploy', '--verbose', '--simulate'
12
-
13
- expect(stdout).to include %[echo #{Shellwords.escape('$ git')}]
14
- end
15
-
16
- it 'should not echo commands when not in verbose mode' do
17
- mina 'deploy', '--simulate'
18
-
19
- expect(stdout).not_to include %[echo #{Shellwords.escape('$ git')}]
20
- end
21
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Mina' do
4
- it '#invoke should work' do
5
-
6
- rake {
7
- task :clone do
8
- queue 'git clone'
9
- end
10
- }
11
-
12
- 2.times {
13
- rake { invoke :clone }
14
- }
15
-
16
- expect(rake.commands).to eq(['git clone'])
17
- end
18
-
19
- it '#invoke should work with :reenable option' do
20
-
21
- rake {
22
- task :pull do
23
- queue 'git pull'
24
- end
25
- }
26
-
27
- 2.times {
28
- rake { invoke :pull, :reenable => true }
29
- }
30
-
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
-
43
- %w(World Pirate).each { |name|
44
- rake { invoke :"hello[#{name}]", :reenable => true }
45
- }
46
-
47
- expect(rake.commands).to eq(['echo Hello World', 'echo Hello Pirate'])
48
- end
49
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Mina' do
4
- it '#invoke should work' do
5
- rake {
6
- task :hello do
7
- @hello = 'world'
8
- end
9
- invoke :hello
10
- }
11
- expect(rake.instance_variable_get(:@hello)).to eq('world')
12
- end
13
-
14
- it '#queue should work' do
15
- rake {
16
- queue 'sudo service nginx restart'
17
- }
18
-
19
- expect(rake.commands).to eq(['sudo service nginx restart'])
20
- end
21
-
22
- it '#queue should work with multiple commands' do
23
- rake {
24
- queue 'echo Restarting'
25
- queue 'sudo service nginx restart'
26
- }
27
-
28
- expect(rake.commands).to eq(['echo Restarting', 'sudo service nginx restart'])
29
- end
30
-
31
- it '#queue should work inside tasks' do
32
- rake {
33
- task :restart do
34
- queue 'echo Restarting'
35
- invoke :'passenger:restart'
36
- end
37
-
38
- namespace :passenger do
39
- task :restart do
40
- queue 'touch tmp/restart.txt'
41
- end
42
- end
43
- }
44
-
45
- rake { invoke :restart }
46
-
47
- expect(rake.commands).to eq(['echo Restarting', 'touch tmp/restart.txt'])
48
- end
49
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'Settings in rake tasks' do
4
- it '#set should work' do
5
- rake { set :domain, 'localhost' }
6
-
7
- expect(rake.domain).to eq('localhost')
8
- expect(rake.settings.domain).to eq('localhost')
9
- end
10
-
11
- it '#settings ||= should work' do
12
- rake {
13
- set :version, '2'
14
- settings.version ||= '3'
15
- }
16
-
17
- expect(rake.settings.version).to eq('2')
18
- expect(rake.version).to eq('2')
19
- end
20
-
21
- it '#settings with lambdas should work' do
22
- rake {
23
- set :version, '42'
24
- set :path, lambda { "/var/www/#{version}" }
25
- }
26
-
27
- expect(rake.path).to eq("/var/www/42")
28
- expect(rake.path?).to be_truthy
29
- end
30
-
31
- it '#settings with a bang should work' do
32
- expect {
33
- rake {
34
- set :path, lambda { "/var/www/#{version!}" }
35
- }
36
- rake.path
37
- }.to raise_error(Mina::Error, /version/)
38
- end
39
- end