mina 1.2.3 → 1.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ci.yml +26 -0
  3. data/.gitignore +0 -1
  4. data/.rspec +1 -1
  5. data/.rubocop.yml +28 -1126
  6. data/CHANGELOG.md +126 -3
  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 +10 -6
  13. data/docs/3rd_party_plugins.md +3 -0
  14. data/docs/assets/images/mina.png +0 -0
  15. data/docs/cookbook.md +1 -1
  16. data/docs/default_plugins.md +5 -5
  17. data/docs/how_mina_works.md +3 -3
  18. data/lib/Minafile +1 -0
  19. data/lib/mina/application.rb +45 -35
  20. data/lib/mina/backend/local.rb +2 -0
  21. data/lib/mina/backend/remote.rb +3 -1
  22. data/lib/mina/commands.rb +10 -7
  23. data/lib/mina/configuration.rb +6 -3
  24. data/lib/mina/dsl.rb +2 -2
  25. data/lib/mina/helpers/internal.rb +9 -9
  26. data/lib/mina/helpers/output.rb +5 -3
  27. data/lib/mina/runner/exec.rb +2 -0
  28. data/lib/mina/runner/pretty.rb +25 -19
  29. data/lib/mina/runner/printer.rb +2 -0
  30. data/lib/mina/runner/system.rb +2 -0
  31. data/lib/mina/runner.rb +9 -10
  32. data/lib/mina/version.rb +3 -1
  33. data/lib/mina/windows_patches.rb +4 -2
  34. data/lib/mina.rb +4 -3
  35. data/mina.gemspec +8 -7
  36. data/spec/configs/default.rb +8 -0
  37. data/spec/configs/dsl.rb +55 -0
  38. data/spec/configs/e2e.rb +25 -0
  39. data/spec/e2e/docker-compose.yml +21 -0
  40. data/spec/e2e/e2e_run.sh +11 -0
  41. data/spec/e2e/e2e_spec.rb +35 -0
  42. data/spec/e2e/ssh +27 -0
  43. data/spec/e2e/ssh.pub +1 -0
  44. data/spec/lib/mina/application_spec.rb +94 -35
  45. data/spec/lib/mina/backend/local_spec.rb +5 -2
  46. data/spec/lib/mina/backend/remote_spec.rb +5 -3
  47. data/spec/lib/mina/commands_spec.rb +7 -7
  48. data/spec/lib/mina/configuration_spec.rb +63 -3
  49. data/spec/lib/mina/dsl_spec.rb +94 -0
  50. data/spec/lib/mina/helpers/internal_spec.rb +89 -11
  51. data/spec/lib/mina/helpers/output_spec.rb +13 -10
  52. data/spec/lib/mina/runner/exec_spec.rb +19 -0
  53. data/spec/lib/mina/runner/pretty_spec.rb +17 -0
  54. data/spec/lib/mina/runner/printer_spec.rb +19 -0
  55. data/spec/lib/mina/runner/system_spec.rb +19 -0
  56. data/spec/lib/mina/runner_spec.rb +6 -10
  57. data/spec/spec_helper.rb +33 -14
  58. data/spec/support/outputs/bundle_clean.txt +2 -2
  59. data/spec/support/outputs/chruby_with_env.txt +7 -0
  60. data/spec/support/outputs/chruby_without_env.txt +2 -0
  61. data/spec/support/outputs/debug_configuration_variables.txt +11 -0
  62. data/spec/support/outputs/dsl_deploy.txt +4 -0
  63. data/spec/support/outputs/dsl_in_path.txt +1 -0
  64. data/spec/support/outputs/dsl_local_run.txt +5 -0
  65. data/spec/support/outputs/dsl_on.txt +6 -0
  66. data/spec/support/outputs/dsl_remote_run.txt +5 -0
  67. data/spec/support/outputs/dsl_reset.txt +2 -0
  68. data/spec/support/outputs/e2e_deploy_after_setup.txt +1 -0
  69. data/spec/support/outputs/e2e_deploy_without_setup.txt +1 -0
  70. data/spec/support/outputs/e2e_setup.txt +1 -0
  71. data/spec/support/outputs/environment.txt +1 -0
  72. data/spec/support/outputs/git_clone.txt +1 -1
  73. data/spec/support/outputs/git_clone_commit.txt +1 -1
  74. data/spec/support/outputs/git_ensure_pushed.txt +15 -0
  75. data/spec/support/outputs/rails_assets_precompile_force_precompile.txt +2 -0
  76. data/spec/support/outputs/rails_assets_precompile_outside_deploy_block.txt +1 -0
  77. data/spec/support/outputs/rails_assets_precompile_with_diff.txt +7 -0
  78. data/spec/support/outputs/rails_console.txt +1 -0
  79. data/spec/support/outputs/rails_db_migrate_force_migrate.txt +2 -0
  80. data/spec/support/outputs/rails_db_migrate_outside_deploy_block.txt +1 -0
  81. data/spec/support/outputs/rails_db_migrate_with_diff.txt +7 -0
  82. data/spec/support/outputs/rails_log.txt +1 -0
  83. data/spec/support/outputs/rails_with_arguments.txt +1 -0
  84. data/spec/support/outputs/rails_without_arguments.txt +1 -0
  85. data/spec/support/outputs/rake_with_arguments.txt +1 -0
  86. data/spec/support/outputs/rake_without_arguments.txt +1 -0
  87. data/spec/support/outputs/rbenv_load.txt +9 -1
  88. data/spec/support/outputs/rvm_use_with_env.txt +8 -0
  89. data/spec/support/outputs/rvm_use_without_env.txt +2 -0
  90. data/spec/support/outputs/rvm_wrapper_with_arguments.txt +8 -0
  91. data/spec/support/outputs/rvm_wrapper_without_arguments.txt +2 -0
  92. data/spec/support/outputs/ry_with_env.txt +13 -0
  93. data/spec/support/outputs/ry_without_env.txt +13 -0
  94. data/spec/support/outputs/ssh.txt +1 -0
  95. data/spec/support/outputs/ssh_keyscan_domain.txt +3 -0
  96. data/spec/support/rake_example_group.rb +23 -19
  97. data/spec/tasks/bundler_spec.rb +6 -0
  98. data/spec/tasks/chruby_spec.rb +29 -0
  99. data/spec/tasks/default_spec.rb +79 -7
  100. data/spec/tasks/deploy_spec.rb +6 -0
  101. data/spec/tasks/git_spec.rb +12 -0
  102. data/spec/tasks/init_spec.rb +13 -4
  103. data/spec/tasks/rails_spec.rb +126 -15
  104. data/spec/tasks/rbenv_spec.rb +15 -0
  105. data/spec/tasks/rvm_spec.rb +51 -0
  106. data/spec/tasks/ry_spec.rb +43 -0
  107. data/tasks/mina/bundler.rb +7 -5
  108. data/tasks/mina/chruby.rb +7 -5
  109. data/tasks/mina/default.rb +19 -12
  110. data/tasks/mina/deploy.rb +27 -25
  111. data/tasks/mina/git.rb +28 -15
  112. data/tasks/mina/install.rb +9 -0
  113. data/tasks/mina/rails.rb +29 -27
  114. data/tasks/mina/rbenv.rb +8 -6
  115. data/tasks/mina/rvm.rb +13 -11
  116. data/tasks/mina/ry.rb +11 -11
  117. data/test_env/config/deploy.rb +9 -8
  118. metadata +69 -37
  119. data/spec/support/outputs/chruby.txt +0 -9
  120. data/spec/support/outputs/console.txt +0 -1
  121. data/spec/support/outputs/log.txt +0 -1
  122. data/spec/support/outputs/rails_db_migrate.txt +0 -1
  123. data/spec/support/outputs/rvm_use.txt +0 -1
  124. data/spec/support/outputs/ry.txt +0 -15
  125. data/spec/tasks/ruby_managers_spec.rb +0 -33
@@ -1,7 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  module Backend
3
5
  class Remote
4
6
  attr_reader :commands
7
+
5
8
  include Configuration::DSL
6
9
 
7
10
  def initialize(commands)
@@ -31,7 +34,6 @@ module Mina
31
34
  args += ' -tt'
32
35
  "ssh #{args}"
33
36
  end
34
-
35
37
  end
36
38
  end
37
39
  end
data/lib/mina/commands.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mina
2
4
  class Commands
3
5
  extend Forwardable
@@ -19,11 +21,11 @@ module Mina
19
21
  end
20
22
 
21
23
  def comment(code, indent: nil)
22
- if indent
23
- queue[stage] << indent(indent, %{echo "-----> #{code}"})
24
- else
25
- queue[stage] << %{echo "-----> #{code}"}
26
- end
24
+ queue[stage] << if indent
25
+ indent(indent, %(echo "-----> #{code}"))
26
+ else
27
+ %(echo "-----> #{code}")
28
+ end
27
29
  end
28
30
 
29
31
  def delete(stage)
@@ -34,9 +36,9 @@ module Mina
34
36
  queue[stage] = []
35
37
  end
36
38
 
37
- def process(path = nil)
39
+ def process(path = nil) # rubocop:disable Metrics/AbcSize
38
40
  if path && !queue[stage].empty?
39
- queue[stage].unshift(%{echo "$ cd #{path}"}) if fetch(:verbose)
41
+ queue[stage].unshift(%(echo "$ cd #{path}")) if fetch(:verbose)
40
42
  %{(cd #{path} && #{queue[stage].join(' && ')} && cd -)}
41
43
  else
42
44
  queue[stage].join("\n")
@@ -49,6 +51,7 @@ module Mina
49
51
 
50
52
  def run(backend)
51
53
  return if queue.empty?
54
+
52
55
  report_time do
53
56
  status = Mina::Runner.new(process, backend).run
54
57
  error! 'Run Error' unless status
@@ -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
@@ -5,10 +7,10 @@ module Mina
5
7
 
6
8
  def deploy_script
7
9
  yield
8
- erb Mina.root_path(fetch(:deploy_script))
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.3'.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+uQQra4KVga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