mina 1.2.4 → 1.2.5

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.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +11 -3
  3. data/.gitignore +0 -1
  4. data/.rspec +1 -1
  5. data/.rubocop.yml +28 -1126
  6. data/CHANGELOG.md +89 -8
  7. data/Gemfile +2 -0
  8. data/Gemfile.lock +73 -0
  9. data/Rakefile +2 -0
  10. data/Readme.md +8 -12
  11. data/bin/mina +2 -0
  12. data/data/deploy.rb +6 -4
  13. data/docs/3rd_party_plugins.md +1 -0
  14. data/docs/assets/images/mina.png +0 -0
  15. data/docs/default_plugins.md +1 -1
  16. data/docs/how_mina_works.md +2 -2
  17. data/lib/Minafile +1 -0
  18. data/lib/mina/application.rb +45 -35
  19. data/lib/mina/backend/local.rb +2 -0
  20. data/lib/mina/backend/remote.rb +3 -1
  21. data/lib/mina/commands.rb +10 -7
  22. data/lib/mina/configuration.rb +6 -3
  23. data/lib/mina/dsl.rb +2 -2
  24. data/lib/mina/helpers/internal.rb +8 -8
  25. data/lib/mina/helpers/output.rb +5 -3
  26. data/lib/mina/runner/exec.rb +2 -0
  27. data/lib/mina/runner/pretty.rb +25 -19
  28. data/lib/mina/runner/printer.rb +2 -0
  29. data/lib/mina/runner/system.rb +2 -0
  30. data/lib/mina/runner.rb +9 -10
  31. data/lib/mina/version.rb +3 -1
  32. data/lib/mina/windows_patches.rb +4 -2
  33. data/lib/mina.rb +4 -3
  34. data/mina.gemspec +8 -7
  35. data/spec/configs/default.rb +8 -0
  36. data/spec/configs/dsl.rb +55 -0
  37. data/spec/configs/e2e.rb +25 -0
  38. data/spec/e2e/docker-compose.yml +21 -0
  39. data/spec/e2e/e2e_run.sh +11 -0
  40. data/spec/e2e/e2e_spec.rb +35 -0
  41. data/spec/e2e/ssh +27 -0
  42. data/spec/e2e/ssh.pub +1 -0
  43. data/spec/lib/mina/application_spec.rb +94 -35
  44. data/spec/lib/mina/backend/local_spec.rb +5 -2
  45. data/spec/lib/mina/backend/remote_spec.rb +5 -3
  46. data/spec/lib/mina/commands_spec.rb +7 -7
  47. data/spec/lib/mina/configuration_spec.rb +63 -3
  48. data/spec/lib/mina/dsl_spec.rb +94 -0
  49. data/spec/lib/mina/helpers/internal_spec.rb +88 -10
  50. data/spec/lib/mina/helpers/output_spec.rb +13 -10
  51. data/spec/lib/mina/runner/exec_spec.rb +19 -0
  52. data/spec/lib/mina/runner/pretty_spec.rb +17 -0
  53. data/spec/lib/mina/runner/printer_spec.rb +19 -0
  54. data/spec/lib/mina/runner/system_spec.rb +19 -0
  55. data/spec/lib/mina/runner_spec.rb +6 -10
  56. data/spec/spec_helper.rb +33 -14
  57. data/spec/support/outputs/bundle_clean.txt +2 -2
  58. data/spec/support/outputs/chruby_with_env.txt +7 -0
  59. data/spec/support/outputs/chruby_without_env.txt +2 -0
  60. data/spec/support/outputs/debug_configuration_variables.txt +11 -0
  61. data/spec/support/outputs/dsl_deploy.txt +4 -0
  62. data/spec/support/outputs/dsl_in_path.txt +1 -0
  63. data/spec/support/outputs/dsl_local_run.txt +5 -0
  64. data/spec/support/outputs/dsl_on.txt +6 -0
  65. data/spec/support/outputs/dsl_remote_run.txt +5 -0
  66. data/spec/support/outputs/dsl_reset.txt +2 -0
  67. data/spec/support/outputs/e2e_deploy_after_setup.txt +1 -0
  68. data/spec/support/outputs/e2e_deploy_without_setup.txt +1 -0
  69. data/spec/support/outputs/e2e_setup.txt +1 -0
  70. data/spec/support/outputs/environment.txt +1 -0
  71. data/spec/support/outputs/git_ensure_pushed.txt +15 -0
  72. data/spec/support/outputs/rails_assets_precompile_force_precompile.txt +2 -0
  73. data/spec/support/outputs/rails_assets_precompile_outside_deploy_block.txt +1 -0
  74. data/spec/support/outputs/rails_assets_precompile_with_diff.txt +7 -0
  75. data/spec/support/outputs/rails_console.txt +1 -0
  76. data/spec/support/outputs/rails_db_migrate_force_migrate.txt +2 -0
  77. data/spec/support/outputs/rails_db_migrate_outside_deploy_block.txt +1 -0
  78. data/spec/support/outputs/rails_db_migrate_with_diff.txt +7 -0
  79. data/spec/support/outputs/rails_log.txt +1 -0
  80. data/spec/support/outputs/rails_with_arguments.txt +1 -0
  81. data/spec/support/outputs/rails_without_arguments.txt +1 -0
  82. data/spec/support/outputs/rake_with_arguments.txt +1 -0
  83. data/spec/support/outputs/rake_without_arguments.txt +1 -0
  84. data/spec/support/outputs/rbenv_load.txt +9 -1
  85. data/spec/support/outputs/rvm_use_with_env.txt +8 -0
  86. data/spec/support/outputs/rvm_use_without_env.txt +2 -0
  87. data/spec/support/outputs/rvm_wrapper_with_arguments.txt +8 -0
  88. data/spec/support/outputs/rvm_wrapper_without_arguments.txt +2 -0
  89. data/spec/support/outputs/ry_with_env.txt +13 -0
  90. data/spec/support/outputs/ry_without_env.txt +13 -0
  91. data/spec/support/outputs/ssh.txt +1 -0
  92. data/spec/support/outputs/ssh_keyscan_domain.txt +3 -0
  93. data/spec/support/rake_example_group.rb +23 -19
  94. data/spec/tasks/bundler_spec.rb +6 -0
  95. data/spec/tasks/chruby_spec.rb +29 -0
  96. data/spec/tasks/default_spec.rb +79 -7
  97. data/spec/tasks/deploy_spec.rb +6 -0
  98. data/spec/tasks/git_spec.rb +12 -0
  99. data/spec/tasks/init_spec.rb +13 -4
  100. data/spec/tasks/rails_spec.rb +126 -15
  101. data/spec/tasks/rbenv_spec.rb +15 -0
  102. data/spec/tasks/rvm_spec.rb +51 -0
  103. data/spec/tasks/ry_spec.rb +43 -0
  104. data/tasks/mina/bundler.rb +7 -5
  105. data/tasks/mina/chruby.rb +7 -5
  106. data/tasks/mina/default.rb +19 -12
  107. data/tasks/mina/deploy.rb +26 -24
  108. data/tasks/mina/git.rb +28 -16
  109. data/tasks/mina/install.rb +3 -1
  110. data/tasks/mina/rails.rb +29 -27
  111. data/tasks/mina/rbenv.rb +8 -6
  112. data/tasks/mina/rvm.rb +13 -11
  113. data/tasks/mina/ry.rb +11 -11
  114. data/test_env/config/deploy.rb +9 -8
  115. metadata +64 -32
  116. data/spec/support/outputs/chruby.txt +0 -9
  117. data/spec/support/outputs/console.txt +0 -1
  118. data/spec/support/outputs/log.txt +0 -1
  119. data/spec/support/outputs/rails_db_migrate.txt +0 -1
  120. data/spec/support/outputs/rvm_use.txt +0 -1
  121. data/spec/support/outputs/ry.txt +0 -15
  122. data/spec/tasks/ruby_managers_spec.rb +0 -33
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  class Configuration
3
5
  include Singleton
@@ -6,7 +8,7 @@ module Mina
6
8
  module DSL
7
9
  def self.included(base)
8
10
  [:set, :fetch, :remove, :set?, :ensure!, :reset!].each do |method|
9
- base.send :define_method, method do |*args, &block|
11
+ base.send :define_method, method do |*args, &block|
10
12
  Configuration.instance.send(method, *args, &block)
11
13
  end
12
14
  end
@@ -16,7 +18,7 @@ module Mina
16
18
  attr_reader :variables
17
19
 
18
20
  def initialize
19
- @variables ||= {}
21
+ @variables = {}
20
22
  end
21
23
 
22
24
  def set(key, value = nil, &block)
@@ -33,11 +35,12 @@ module Mina
33
35
  end
34
36
 
35
37
  def set?(key)
36
- ENV.has_key?(key.to_s) || !variables.fetch(key, nil).nil?
38
+ ENV.key?(key.to_s) || !variables.fetch(key, nil).nil?
37
39
  end
38
40
 
39
41
  def ensure!(key, message: nil)
40
42
  return if set?(key)
43
+
41
44
  message ||= "#{key} must be defined!"
42
45
  error! message
43
46
  end
data/lib/mina/dsl.rb CHANGED
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  module DSL
3
- attr_reader :commands
4
-
5
5
  extend Forwardable
6
6
  def_delegators :configuration, :fetch, :set, :set?, :ensure!
7
7
  def_delegators :commands, :command, :comment
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  module Helpers
3
5
  module Internal
@@ -8,7 +10,7 @@ module Mina
8
10
  erb fetch(:deploy_script)
9
11
  end
10
12
 
11
- def erb(file, b = binding)
13
+ def erb(file, b = binding) # rubocop:disable Naming/MethodParameterName
12
14
  require 'erb'
13
15
  erb = ERB.new(File.read(file))
14
16
  erb.result b
@@ -16,7 +18,7 @@ module Mina
16
18
 
17
19
  def echo_cmd(code, ignore_verbose = false)
18
20
  if fetch(:verbose) && !ignore_verbose
19
- "echo #{Shellwords.escape('$ ' + code)} &&\n#{code}"
21
+ "echo #{Shellwords.escape("$ #{code}")} &&\n#{code}"
20
22
  else
21
23
  code
22
24
  end
@@ -27,9 +29,7 @@ module Mina
27
29
  end
28
30
 
29
31
  def unindent(code)
30
- if code =~ /^\n([ \t]+)/
31
- code = code.gsub(/^#{$1}/, '')
32
- end
32
+ code = code.gsub(/^#{Regexp.last_match(1)}/, '') if code =~ /^\n([ \t]+)/
33
33
 
34
34
  code.strip
35
35
  end
@@ -37,18 +37,18 @@ module Mina
37
37
  def report_time
38
38
  time_start = Time.now
39
39
  output = yield
40
- print_info "Elapsed time: %.2f seconds" % [Time.now - time_start] unless fetch(:skip_report_time)
40
+ print_info format('Elapsed time: %.2f seconds', Time.now - time_start) unless fetch(:skip_report_time)
41
41
  output
42
42
  end
43
43
 
44
44
  def next_version
45
45
  case fetch(:version_scheme)
46
46
  when :datetime
47
- Time.now.utc.strftime("%Y%m%d%H%M%S")
47
+ Time.now.utc.strftime('%Y%m%d%H%M%S')
48
48
  when :sequence
49
49
  "$((`ls -1 #{fetch(:releases_path)} | sort -n | tail -n 1`+1))"
50
50
  else
51
- error! 'Unrecognizes version scheme. Use :datetime or :sequence'
51
+ error! 'Unrecognized version scheme. Use :datetime or :sequence'
52
52
  end
53
53
  end
54
54
 
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  module Helpers
3
5
  module Output
4
6
  def print_line(line)
5
7
  case line
6
- when /^\-+> (.*?)$/
8
+ when /^-+> (.*?)$/
7
9
  print_status Regexp.last_match[1]
8
10
  when /^! (.*?)$/
9
11
  print_error Regexp.last_match[1]
@@ -42,8 +44,8 @@ module Mina
42
44
  puts " #{msg}"
43
45
  end
44
46
 
45
- def color(str, c)
46
- ENV['NO_COLOR'] ? str : "\033[#{c}m#{str}\033[0m"
47
+ def color(str, color)
48
+ ENV['NO_COLOR'] ? str : "\033[#{color}m#{str}\033[0m"
47
49
  end
48
50
  end
49
51
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  class Runner
3
5
  class Exec
@@ -1,45 +1,51 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  class Runner
3
5
  class Pretty
4
6
  include Mina::Helpers::Output
5
7
 
6
- attr_reader :script, :coathooks
8
+ attr_reader :script
7
9
 
8
10
  def initialize(script)
9
11
  @script = Shellwords.shellsplit(script)
10
12
  @coathooks = 0
11
13
  end
12
14
 
13
- def run
14
- status =
15
- Open4.popen4(*script) do |pid, _stdin, stdout, stderr|
16
- # Handle `^C`.
17
- trap('INT') { handle_sigint(pid) }
15
+ def run # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
16
+ exit_status = nil
18
17
 
19
- stdout_thread = Thread.new do
20
- while (line = stdout.gets)
21
- print_line(line)
22
- end
23
- end
18
+ Open3.popen3(*script) do |_stdin, stdout, stderr, wait_thr|
19
+ pid = wait_thr.pid
24
20
 
25
- stderr_thread = Thread.new do
26
- while (line = stderr.gets)
27
- print_stderr(line)
28
- end
21
+ trap('INT') { handle_sigint(pid) }
22
+
23
+ stdout_thread = Thread.new do
24
+ while (line = stdout.gets)
25
+ print_line(line)
29
26
  end
27
+ end
30
28
 
31
- stdout_thread.join
32
- stderr_thread.join
29
+ stderr_thread = Thread.new do
30
+ while (line = stderr.gets)
31
+ print_stderr(line)
32
+ end
33
33
  end
34
34
 
35
- status.exitstatus == 0
35
+ stdout_thread.join
36
+ stderr_thread.join
37
+
38
+ exit_status = wait_thr.value
39
+ end
40
+
41
+ exit_status.success?
36
42
  end
37
43
 
38
44
  private
39
45
 
40
46
  def handle_sigint(pid)
41
47
  puts ''
42
- if coathooks > 1
48
+ if @coathooks > 1
43
49
  print_status 'Mina: SIGINT received again. Force quitting...'
44
50
  Process.kill 'KILL', pid
45
51
  else
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  class Runner
3
5
  class Printer
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  class Runner
3
5
  class System
data/lib/mina/runner.rb CHANGED
@@ -1,11 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  class Runner
3
5
  attr_reader :commands, :backend
6
+
4
7
  include Configuration::DSL
5
8
 
6
9
  def initialize(commands, backend)
7
10
  fail 'You must specify execution mode' if execution_mode.nil?
8
- fail 'Unsuported execution mode (pretty on windows)' if unsuported_execution_mode?
11
+
9
12
  @backend = backend
10
13
  @commands = commands
11
14
  end
@@ -16,11 +19,11 @@ module Mina
16
19
 
17
20
  def execution_mode
18
21
  @execution_mode ||=
19
- if fetch(:simulate)
20
- :printer
21
- else
22
- fetch(:execution_mode)
23
- end
22
+ if fetch(:simulate)
23
+ :printer
24
+ else
25
+ fetch(:execution_mode)
26
+ end
24
27
  end
25
28
 
26
29
  private
@@ -29,10 +32,6 @@ module Mina
29
32
  Mina::Backend.const_get(class_name_for(backend)).new(commands).prepare
30
33
  end
31
34
 
32
- def unsuported_execution_mode?
33
- execution_mode == :pretty && Gem::Platform.local.os == :windows
34
- end
35
-
36
35
  def class_name_for(symbol)
37
36
  symbol.to_s.split('_').map(&:capitalize).join
38
37
  end
data/lib/mina/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
- VERSION = '1.2.4'.freeze
4
+ VERSION = '1.2.5'
3
5
  end
@@ -1,10 +1,12 @@
1
- #if windows os
1
+ # frozen_string_literal: true
2
+
3
+ # if windows os
2
4
  require 'rbconfig'
3
5
  is_windows = (RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/)
4
6
  if is_windows
5
7
  module Shellwords
6
8
  def shellescape(str)
7
- '"' + str.gsub(/\\(?=\\*\")/, "\\\\\\").gsub(/\"/, "\\\"").gsub(/\\$/, "\\\\\\").gsub("%", "%%") + '"'
9
+ "\"#{str.gsub(/\\(?=\\*")/, '\\\\\\').gsub(/"/, '\\"').gsub(/\\$/, '\\\\\\').gsub('%', '%%')}\""
8
10
  end
9
11
 
10
12
  module_function :shellescape
data/lib/mina.rb CHANGED
@@ -1,13 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake'
2
4
  Rake.application.options.trace = true
3
5
 
4
6
  # require 'pry'
5
- # require 'awesome_print'
6
7
 
7
8
  require 'forwardable'
8
9
  require 'shellwords'
9
10
  require 'singleton'
10
- require 'open4'
11
+ require 'open3'
11
12
 
12
13
  require 'mina/version'
13
14
  require 'mina/helpers/output'
@@ -27,6 +28,6 @@ require 'mina/application'
27
28
 
28
29
  module Mina
29
30
  def self.root_path(*args)
30
- File.join File.expand_path('../../', __FILE__), *args
31
+ File.join File.expand_path('..', __dir__), *args
31
32
  end
32
33
  end
data/mina.gemspec CHANGED
@@ -1,7 +1,9 @@
1
- lib = File.expand_path('../lib', __FILE__)
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
 
4
- tasks = File.expand_path('../tasks', __FILE__)
6
+ tasks = File.expand_path('tasks', __dir__)
5
7
  $LOAD_PATH.unshift(tasks) unless $LOAD_PATH.include?(tasks)
6
8
 
7
9
  require 'mina/version'
@@ -20,10 +22,9 @@ Gem::Specification.new do |spec|
20
22
  spec.require_paths = ['lib', 'tasks']
21
23
 
22
24
  spec.add_dependency 'rake'
23
- spec.add_dependency 'open4', '~> 1.3.4'
24
- spec.add_development_dependency 'rspec', '~> 3.5.0'
25
- spec.add_development_dependency 'pry-byebug'
26
- spec.add_development_dependency 'awesome_print'
25
+ spec.add_development_dependency 'pry'
26
+ spec.add_development_dependency 'rspec'
27
+ spec.add_development_dependency 'rubocop'
28
+ spec.add_development_dependency 'rubocop-rspec'
27
29
  spec.add_development_dependency 'simplecov'
28
- spec.add_development_dependency 'codeclimate-test-reporter'
29
30
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ set :simulate, true
4
+ set :domain, 'localhost'
5
+ set :deploy_to, "#{Dir.pwd}/deploy"
6
+ set :repository, Mina.root_path.to_s
7
+ set :shared_paths, ['config/database.yml', 'log']
8
+ set :keep_releases, 2
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ task :reset_task do
4
+ command 'echo Hello there'
5
+ reset!
6
+ command 'echo New command'
7
+ end
8
+
9
+ task :one_run_inside_another do
10
+ run :local do
11
+ run :remote do
12
+ puts "I shouldn't execute"
13
+ end
14
+ end
15
+ end
16
+
17
+ task :local_run do
18
+ run :local do
19
+ comment 'I am a comment'
20
+ command 'echo Hello there'
21
+ end
22
+ end
23
+
24
+ task :remote_run do
25
+ run :remote do
26
+ comment 'I am a comment'
27
+ command 'echo Hello there'
28
+ end
29
+ end
30
+
31
+ task :nonexistent_run do
32
+ run :nonexistent do
33
+ comment "I shouldn't run"
34
+ end
35
+ end
36
+
37
+ task :on_stage_task do
38
+ deploy do
39
+ on :launch do
40
+ command 'echo Hello there'
41
+ end
42
+ end
43
+ end
44
+
45
+ task :in_path_task do
46
+ in_path '/path' do
47
+ command 'echo Hello there'
48
+ end
49
+ end
50
+
51
+ task :deploy_block_task do
52
+ deploy do
53
+ command 'echo Hello there'
54
+ end
55
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'mina/git'
4
+
5
+ set :simulate, false
6
+ set :user, 'mina-ssh'
7
+ set :domain, '0.0.0.0'
8
+ set :port, 2222
9
+ set :deploy_to, '/app'
10
+
11
+ set :repository, 'https://github.com/mina-deploy/mina.git'
12
+ set :branch, 'master'
13
+
14
+ set :identity_file, 'spec/e2e/ssh'
15
+
16
+ set :ssh_options, '-o StrictHostKeyChecking=no'
17
+
18
+ desc 'Deploys to the server'
19
+ task :e2e_deploy do
20
+ deploy do
21
+ invoke :'git:clone'
22
+ invoke :'deploy:link_shared_paths'
23
+ invoke :'deploy:cleanup'
24
+ end
25
+ end
@@ -0,0 +1,21 @@
1
+ version: '3.8'
2
+ services:
3
+ mina-ssh:
4
+ image: ghcr.io/linuxserver/openssh-server
5
+ container_name: mina-ssh
6
+ hostname: mina-ssh
7
+ environment:
8
+ - PUID=1000
9
+ - PGID=1000
10
+ - TZ=UTC
11
+ - PUBLIC_KEY
12
+ - SUDO_ACCESS=true
13
+ - USER_NAME=mina-ssh
14
+ ports:
15
+ - 2222:2222
16
+ command: >
17
+ sh -c "
18
+ apk update && apk add git ruby && gem install bundler &&
19
+ touch /tmp/ready.txt &&
20
+ tail -f /dev/null
21
+ "
@@ -0,0 +1,11 @@
1
+ cd spec/e2e/
2
+ chmod 600 ssh
3
+ PUBLIC_KEY="$(cat ssh.pub)" docker-compose up -d mina-ssh \
4
+ && docker exec mina-ssh sh -c "while [ ! -f /tmp/ready.txt ]; do sleep 2; done"
5
+ cd -
6
+ [[ -z "${CI}" ]] && ssh-keygen -R \[0.0.0.0\]:2222
7
+ bundle exec rspec --tag e2e --order defined
8
+ status=$?
9
+ cd spec/e2e
10
+ docker-compose down
11
+ exit $status
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ # IMPORTANT: run only through e2e_run.sh script
6
+ describe 'E2E tests', :e2e, type: :rake do
7
+ before do
8
+ load_config 'e2e'
9
+ end
10
+
11
+ describe 'deploy without setup' do
12
+ it 'exits with an error message' do
13
+ expect do
14
+ rake.run(['e2e_deploy'])
15
+ end.to raise_error(SystemExit)
16
+ .and output(output_file('e2e_deploy_without_setup')).to_stdout
17
+ end
18
+ end
19
+
20
+ describe 'setup' do
21
+ it 'sets up directories' do
22
+ expect do
23
+ rake.run(['setup'])
24
+ end.to output(output_file('e2e_setup')).to_stdout
25
+ end
26
+ end
27
+
28
+ describe 'deploy after setup' do
29
+ it 'deploys the app' do
30
+ expect do
31
+ rake.run(['e2e_deploy'])
32
+ end.to output(output_file('e2e_deploy_after_setup')).to_stdout
33
+ end
34
+ end
35
+ end
data/spec/e2e/ssh ADDED
@@ -0,0 +1,27 @@
1
+ -----BEGIN OPENSSH PRIVATE KEY-----
2
+ b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABFwAAAAdzc2gtcn
3
+ NhAAAAAwEAAQAAAQEAskzzKcHPV/0n84dIXUKO3q/s4MX8+R+ogsbbEr/XRo0e2BtEmD52
4
+ VLEJczYaxICqTOmlOvyx0oWOSPbim6Cpq6YskbxVaUqYSdzafdRXmc3+6BSXgGZH3dHWYc
5
+ 2vQFx01PVRXdb4EwQBwmCLX7v7+/OxXVq5MHxxXNHblut2c//Udp53F5fVm3WgE3iTIpxL
6
+ 0h/0H25kaE0HyZrFhFdPItAu/owkOhra6yX1PE8vcyQRs7d9uWwd3n+odCjwhTJ3431PFJ
7
+ SyCSTCKbDGMIB44E85e6Vr4EK9Xjrxb6Zrc8ayg4GEX9jqpltjup9vWKhdM7q4vrkEK2uC
8
+ lYGurnfEAwAAA8ilS5nwpUuZ8AAAAAdzc2gtcnNhAAABAQCyTPMpwc9X/Sfzh0hdQo7er+
9
+ zgxfz5H6iCxtsSv9dGjR7YG0SYPnZUsQlzNhrEgKpM6aU6/LHShY5I9uKboKmrpiyRvFVp
10
+ SphJ3Np91FeZzf7oFJeAZkfd0dZhza9AXHTU9VFd1vgTBAHCYItfu/v787FdWrkwfHFc0d
11
+ uW63Zz/9R2nncXl9WbdaATeJMinEvSH/QfbmRoTQfJmsWEV08i0C7+jCQ6GtrrJfU8Ty9z
12
+ JBGzt325bB3ef6h0KPCFMnfjfU8UlLIJJMIpsMYwgHjgTzl7pWvgQr1eOvFvpmtzxrKDgY
13
+ Rf2OqmW2O6n29YqF0zuri+uQQra4KVga6ud8QDAAAAAwEAAQAAAQA7oVyZlIXhqXrZCV98
14
+ QSxC8ZdJPS3zq1DSG+tcg+hdYgj0wXnZaNpuTJ8advfQzC8odeOarLRT8fK6GEeFQOA91d
15
+ +GBfSSuC3iVgiEmKWLfMdJmsloWcyjNPB72SxJXCJ+rmS9+40P3wEvntY9+EK36rJgxFy3
16
+ CIdpQY4tFSaSeGgEWvyhoUjad5OOZhW6zy1D5bOQX9mxCjTIJ+LqIKgUK50gv2zBt8lOTu
17
+ +g4aw4gQoFPoX7tOqD0GAt0Q2NdogugFyWfIumBv6RCeHvxpbwYhIrhucsACbCgjydnLNa
18
+ chcZfR+DNQeezq0l6vpIuCCqWxVXHYQLMizvW9MuIcQhAAAAgAxkO1gv7AiRjL0UJcIxQ9
19
+ Ec9okq+MXgyRJxLL1x1r/sVqkCUXzf95O9fB/uJEQx6V/Uok4NN2m9lhRhSbu2dfrwq3dI
20
+ Xxe0/l7pS0p67nIrvROPBcnQOGGcPVNxwvjD+fC3dBwiFjh08qXA47v8ddu4MujgIWkFaX
21
+ oGxXMr2ijcAAAAgQDbNTsd/YsldmSpRTlPd/tyu+VyZ8afRNpRqTZki3J+LcJ8CoET7DLA
22
+ EHPXqaNWyEuLRjrZx6CdlbVrZvoU4k4TftrRMq177DNP7WBCvha3eZhZg2EA4MVG2j2iP2
23
+ VtXtEjdWHNYwHUBMj6IXDxQuAQvXsQPTQ4h2kt7GG5/Wdw2QAAAIEA0DoKl7jfsQMSn1LR
24
+ csvP3tIfmj6KqboetjFABLloKnxVa/tlJRTJHiuWgUZQ9sCyI4rYAnSfZS2uppDBHvn/9f
25
+ uOV8XPu7N3Vm/jP5E97JUGaJUjnNZWiWHxUAf9VM2r7x2V4VvEn98xDKSObciSz9rosXlJ
26
+ POFxW7iCkxhNkjsAAAANbWluYS1lMmUtdGVzdAECAwQFBg==
27
+ -----END OPENSSH PRIVATE KEY-----
data/spec/e2e/ssh.pub ADDED
@@ -0,0 +1 @@
1
+ ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCyTPMpwc9X/Sfzh0hdQo7er+zgxfz5H6iCxtsSv9dGjR7YG0SYPnZUsQlzNhrEgKpM6aU6/LHShY5I9uKboKmrpiyRvFVpSphJ3Np91FeZzf7oFJeAZkfd0dZhza9AXHTU9VFd1vgTBAHCYItfu/v787FdWrkwfHFc0duW63Zz/9R2nncXl9WbdaATeJMinEvSH/QfbmRoTQfJmsWEV08i0C7+jCQ6GtrrJfU8Ty9zJBGzt325bB3ef6h0KPCFMnfjfU8UlLIJJMIpsMYwgHjgTzl7pWvgQr1eOvFvpmtzxrKDgYRf2OqmW2O6n29YqF0zuri+uQQra4KVga6ud8QD mina-e2e-test
@@ -1,39 +1,98 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Mina::Application do
4
- # let(:app) { Rake.application }
5
- #
6
- # %w(quiet silent dry-run).each do |switch|
7
- # it "doesn't include --#{switch} in help" do
8
- # binding.pry
9
- # expect(out).not_to match(/--#{switch}/)
10
- # end
11
- # end
12
- #
13
- # it 'runs adds two default tasks to the task list' do
14
- # expect(subject.top_level_tasks).to include(:debug_configuration_variables)
15
- # expect(subject.top_level_tasks).to include(:run_commands)
16
- # end
17
- #
18
- # it 'overrides the rake method, but still prints the rake version' do
19
- # out = capture_io do
20
- # flags '--version', '-V'
21
- # end
22
- # expect(out).to match(/\bMina, version\b/)
23
- # expect(out).to match(/\bv#{Mina::VERSION}\b/)
24
- # end
25
- #
26
- # it 'enables simulation mode, and sets the backend Mina::Runner::Printer' do
27
- # capture_io do
28
- # flags '--simulate', '-s'
29
- # end
30
- # expect(Mina::Configuration.instance.fetch(:simulate)).to be true
31
- # end
32
- #
33
- # it 'enables printing all config variables on command line parameter' do
34
- # capture_io do
35
- # flags '--debug-configuration-variables', '-d'
36
- # end
37
- # expect(Mina::Configuration.instance.fetch(:debug_configuration_variables)).to be true
38
- # end
6
+ subject(:application) { described_class.new }
7
+
8
+ describe '#top_level_tasks' do
9
+ let(:default_tasks) { ['debug_configuration_variables', 'run_commands'] }
10
+
11
+ context 'when `init` task is added' do
12
+ it 'removes default tasks' do
13
+ expect do
14
+ application.collect_command_line_tasks(['init'])
15
+ end.to change(application, :top_level_tasks).from(default_tasks).to(['init'])
16
+ end
17
+ end
18
+
19
+ context "when `init` task isn't added" do
20
+ it 'keeps default tasks' do
21
+ expect do
22
+ application.collect_command_line_tasks(['a_task'])
23
+ end.to change(application, :top_level_tasks).from(default_tasks).to(['a_task', *default_tasks])
24
+ end
25
+ end
26
+ end
27
+
28
+ describe 'command-line options' do
29
+ ['--version', '-V'].each do |option|
30
+ describe option do
31
+ it 'prints Mina version and exits' do
32
+ expect do
33
+ application.handle_options([option])
34
+ end.to raise_error(SystemExit)
35
+ .and output("Mina, version v#{Mina::VERSION}\n").to_stdout
36
+ end
37
+ end
38
+ end
39
+
40
+ ['--verbose', '-v'].each do |option|
41
+ describe option do
42
+ it 'sets verbose flag to true' do
43
+ expect do
44
+ application.handle_options([option])
45
+ end.to change { application.fetch(:verbose) }.from(nil).to(true)
46
+ end
47
+ end
48
+ end
49
+
50
+ ['--simulate', '-s'].each do |option|
51
+ describe option do
52
+ it 'sets simulate flag to true' do
53
+ expect do
54
+ application.handle_options([option])
55
+ end.to change { application.fetch(:simulate) }.from(nil).to(true)
56
+ end
57
+ end
58
+ end
59
+
60
+ ['--debug-configuration-variables', '-d'].each do |option|
61
+ describe option do
62
+ it 'sets debug_configuration_variables flag to true' do
63
+ expect do
64
+ application.handle_options([option])
65
+ end.to change { application.fetch(:debug_configuration_variables) }.from(nil).to(true)
66
+ end
67
+ end
68
+ end
69
+
70
+ describe '--no-report-time' do
71
+ it 'sets skip_report_time flag to true' do
72
+ expect do
73
+ application.handle_options(['--no-report-time'])
74
+ end.to change { application.fetch(:skip_report_time) }.from(nil).to(true)
75
+ end
76
+ end
77
+ end
78
+
79
+ describe 'Rake options' do
80
+ let(:options) { application.standard_rake_options }
81
+
82
+ it 'shows --verbose' do
83
+ expect(options.any? { |(switch, *)| switch == '--verbose' }).to eq(true)
84
+ end
85
+
86
+ it "doesn't show --dry-run" do
87
+ expect(options.any? { |(switch, *)| switch == '--dry-run' }).to eq(false)
88
+ end
89
+
90
+ it "doesn't show --quiet" do
91
+ expect(options.any? { |(switch, *)| switch == '--quiet' }).to eq(false)
92
+ end
93
+
94
+ it "doesn't show --silent" do
95
+ expect(options.any? { |(switch, *)| switch == '--silent' }).to eq(false)
96
+ end
97
+ end
39
98
  end