mina 1.2.3 → 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.
- checksums.yaml +5 -5
- data/.github/workflows/ci.yml +26 -0
- data/.gitignore +0 -1
- data/.rspec +1 -1
- data/.rubocop.yml +28 -1126
- data/CHANGELOG.md +126 -3
- data/Gemfile +2 -0
- data/Gemfile.lock +73 -0
- data/Rakefile +2 -0
- data/Readme.md +8 -12
- data/bin/mina +2 -0
- data/data/deploy.rb +10 -6
- data/docs/3rd_party_plugins.md +3 -0
- data/docs/assets/images/mina.png +0 -0
- data/docs/cookbook.md +1 -1
- data/docs/default_plugins.md +5 -5
- data/docs/how_mina_works.md +3 -3
- data/lib/Minafile +1 -0
- data/lib/mina/application.rb +45 -35
- data/lib/mina/backend/local.rb +2 -0
- data/lib/mina/backend/remote.rb +3 -1
- data/lib/mina/commands.rb +10 -7
- data/lib/mina/configuration.rb +6 -3
- data/lib/mina/dsl.rb +2 -2
- data/lib/mina/helpers/internal.rb +9 -9
- data/lib/mina/helpers/output.rb +5 -3
- data/lib/mina/runner/exec.rb +2 -0
- data/lib/mina/runner/pretty.rb +25 -19
- data/lib/mina/runner/printer.rb +2 -0
- data/lib/mina/runner/system.rb +2 -0
- data/lib/mina/runner.rb +9 -10
- data/lib/mina/version.rb +3 -1
- data/lib/mina/windows_patches.rb +4 -2
- data/lib/mina.rb +4 -3
- data/mina.gemspec +8 -7
- data/spec/configs/default.rb +8 -0
- data/spec/configs/dsl.rb +55 -0
- data/spec/configs/e2e.rb +25 -0
- data/spec/e2e/docker-compose.yml +21 -0
- data/spec/e2e/e2e_run.sh +11 -0
- data/spec/e2e/e2e_spec.rb +35 -0
- data/spec/e2e/ssh +27 -0
- data/spec/e2e/ssh.pub +1 -0
- data/spec/lib/mina/application_spec.rb +94 -35
- data/spec/lib/mina/backend/local_spec.rb +5 -2
- data/spec/lib/mina/backend/remote_spec.rb +5 -3
- data/spec/lib/mina/commands_spec.rb +7 -7
- data/spec/lib/mina/configuration_spec.rb +63 -3
- data/spec/lib/mina/dsl_spec.rb +94 -0
- data/spec/lib/mina/helpers/internal_spec.rb +89 -11
- data/spec/lib/mina/helpers/output_spec.rb +13 -10
- data/spec/lib/mina/runner/exec_spec.rb +19 -0
- data/spec/lib/mina/runner/pretty_spec.rb +17 -0
- data/spec/lib/mina/runner/printer_spec.rb +19 -0
- data/spec/lib/mina/runner/system_spec.rb +19 -0
- data/spec/lib/mina/runner_spec.rb +6 -10
- data/spec/spec_helper.rb +33 -14
- data/spec/support/outputs/bundle_clean.txt +2 -2
- data/spec/support/outputs/chruby_with_env.txt +7 -0
- data/spec/support/outputs/chruby_without_env.txt +2 -0
- data/spec/support/outputs/debug_configuration_variables.txt +11 -0
- data/spec/support/outputs/dsl_deploy.txt +4 -0
- data/spec/support/outputs/dsl_in_path.txt +1 -0
- data/spec/support/outputs/dsl_local_run.txt +5 -0
- data/spec/support/outputs/dsl_on.txt +6 -0
- data/spec/support/outputs/dsl_remote_run.txt +5 -0
- data/spec/support/outputs/dsl_reset.txt +2 -0
- data/spec/support/outputs/e2e_deploy_after_setup.txt +1 -0
- data/spec/support/outputs/e2e_deploy_without_setup.txt +1 -0
- data/spec/support/outputs/e2e_setup.txt +1 -0
- data/spec/support/outputs/environment.txt +1 -0
- data/spec/support/outputs/git_clone.txt +1 -1
- data/spec/support/outputs/git_clone_commit.txt +1 -1
- data/spec/support/outputs/git_ensure_pushed.txt +15 -0
- data/spec/support/outputs/rails_assets_precompile_force_precompile.txt +2 -0
- data/spec/support/outputs/rails_assets_precompile_outside_deploy_block.txt +1 -0
- data/spec/support/outputs/rails_assets_precompile_with_diff.txt +7 -0
- data/spec/support/outputs/rails_console.txt +1 -0
- data/spec/support/outputs/rails_db_migrate_force_migrate.txt +2 -0
- data/spec/support/outputs/rails_db_migrate_outside_deploy_block.txt +1 -0
- data/spec/support/outputs/rails_db_migrate_with_diff.txt +7 -0
- data/spec/support/outputs/rails_log.txt +1 -0
- data/spec/support/outputs/rails_with_arguments.txt +1 -0
- data/spec/support/outputs/rails_without_arguments.txt +1 -0
- data/spec/support/outputs/rake_with_arguments.txt +1 -0
- data/spec/support/outputs/rake_without_arguments.txt +1 -0
- data/spec/support/outputs/rbenv_load.txt +9 -1
- data/spec/support/outputs/rvm_use_with_env.txt +8 -0
- data/spec/support/outputs/rvm_use_without_env.txt +2 -0
- data/spec/support/outputs/rvm_wrapper_with_arguments.txt +8 -0
- data/spec/support/outputs/rvm_wrapper_without_arguments.txt +2 -0
- data/spec/support/outputs/ry_with_env.txt +13 -0
- data/spec/support/outputs/ry_without_env.txt +13 -0
- data/spec/support/outputs/ssh.txt +1 -0
- data/spec/support/outputs/ssh_keyscan_domain.txt +3 -0
- data/spec/support/rake_example_group.rb +23 -19
- data/spec/tasks/bundler_spec.rb +6 -0
- data/spec/tasks/chruby_spec.rb +29 -0
- data/spec/tasks/default_spec.rb +79 -7
- data/spec/tasks/deploy_spec.rb +6 -0
- data/spec/tasks/git_spec.rb +12 -0
- data/spec/tasks/init_spec.rb +13 -4
- data/spec/tasks/rails_spec.rb +126 -15
- data/spec/tasks/rbenv_spec.rb +15 -0
- data/spec/tasks/rvm_spec.rb +51 -0
- data/spec/tasks/ry_spec.rb +43 -0
- data/tasks/mina/bundler.rb +7 -5
- data/tasks/mina/chruby.rb +7 -5
- data/tasks/mina/default.rb +19 -12
- data/tasks/mina/deploy.rb +27 -25
- data/tasks/mina/git.rb +28 -15
- data/tasks/mina/install.rb +9 -0
- data/tasks/mina/rails.rb +29 -27
- data/tasks/mina/rbenv.rb +8 -6
- data/tasks/mina/rvm.rb +13 -11
- data/tasks/mina/ry.rb +11 -11
- data/test_env/config/deploy.rb +9 -8
- metadata +69 -37
- data/spec/support/outputs/chruby.txt +0 -9
- data/spec/support/outputs/console.txt +0 -1
- data/spec/support/outputs/log.txt +0 -1
- data/spec/support/outputs/rails_db_migrate.txt +0 -1
- data/spec/support/outputs/rvm_use.txt +0 -1
- data/spec/support/outputs/ry.txt +0 -15
- data/spec/tasks/ruby_managers_spec.rb +0 -33
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe Mina::Runner do
|
|
@@ -6,19 +8,13 @@ describe Mina::Runner do
|
|
|
6
8
|
describe '#initialize' do
|
|
7
9
|
it 'raises an error if execution mode is not set' do
|
|
8
10
|
instance.remove(:execution_mode)
|
|
9
|
-
expect {
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it 'raises an error when run on windows and pretty print' do
|
|
13
|
-
instance.set(:execution_mode, :pretty)
|
|
14
|
-
allow(Gem::Platform.local).to receive(:os).and_return(:windows)
|
|
15
|
-
expect { Mina::Runner.new(nil, nil) }.to raise_error('Unsuported execution mode (pretty on windows)')
|
|
11
|
+
expect { described_class.new(nil, nil) }.to raise_error('You must specify execution mode')
|
|
16
12
|
end
|
|
17
13
|
|
|
18
14
|
it 'sets execution mode to printer if simulate is true' do
|
|
19
15
|
instance.set(:execution_mode, :pretty)
|
|
20
|
-
instance.set(:simulate,
|
|
21
|
-
expect(
|
|
16
|
+
instance.set(:simulate, true)
|
|
17
|
+
expect(described_class.new(nil, nil).execution_mode).to eq(:printer)
|
|
22
18
|
instance.remove(:simulate)
|
|
23
19
|
end
|
|
24
20
|
end
|
|
@@ -26,7 +22,7 @@ describe Mina::Runner do
|
|
|
26
22
|
describe '#run' do
|
|
27
23
|
it 'runs the commands on a backend' do
|
|
28
24
|
instance.set(:execution_mode, :printer)
|
|
29
|
-
runner =
|
|
25
|
+
runner = described_class.new(['ls -al'], :local)
|
|
30
26
|
expect { runner.run }.to output("\\[\\\"ls\\ -al\\\"\\]\n").to_stdout
|
|
31
27
|
end
|
|
32
28
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'simplecov'
|
|
2
4
|
|
|
3
|
-
SimpleCov.start
|
|
5
|
+
SimpleCov.start do
|
|
6
|
+
add_filter '/spec/'
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
enable_coverage :branch
|
|
9
|
+
primary_coverage :branch
|
|
10
|
+
end
|
|
7
11
|
|
|
8
12
|
require 'mina'
|
|
9
13
|
require 'rspec'
|
|
10
14
|
require 'pry'
|
|
15
|
+
require 'set'
|
|
11
16
|
|
|
12
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
|
17
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
|
|
13
18
|
Rake.application = Mina::Application.new
|
|
14
|
-
Dir[
|
|
19
|
+
Dir['./tasks/mina/**/*.rb'].sort.each { |f| require f }
|
|
15
20
|
|
|
16
21
|
RSpec.configure do |config|
|
|
17
22
|
config.include RakeExampleGroup, type: :rake
|
|
@@ -19,16 +24,30 @@ RSpec.configure do |config|
|
|
|
19
24
|
config.raise_errors_for_deprecations!
|
|
20
25
|
config.order = 'random'
|
|
21
26
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
Mina::Configuration.instance.
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
initial_task_names = Rake.application.tasks.to_set(&:name)
|
|
28
|
+
initial_variables = Mina::Configuration.instance.variables
|
|
29
|
+
|
|
30
|
+
config.before do
|
|
31
|
+
Mina::Configuration.instance.instance_variable_set(:@variables, initial_variables.clone)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
config.after do
|
|
35
|
+
Rake.application.tasks.each(&:reenable)
|
|
36
|
+
Rake.application.instance_variable_get(:@tasks).keep_if { |task_name, _| initial_task_names.include?(task_name) }
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
config.around(:each, :suppressed_output) do |example|
|
|
40
|
+
original_stdout, $stdout = $stdout, File.open(File::NULL, 'w')
|
|
41
|
+
original_stderr, $stderr = $stderr, File.open(File::NULL, 'w')
|
|
42
|
+
|
|
43
|
+
example.run
|
|
44
|
+
|
|
45
|
+
$stdout, $stderr = original_stdout, original_stderr
|
|
29
46
|
end
|
|
30
47
|
|
|
31
|
-
config.
|
|
32
|
-
|
|
48
|
+
config.around do |example|
|
|
49
|
+
example.run
|
|
50
|
+
rescue SystemExit
|
|
51
|
+
raise "Unhandled system exit (you're probably missing a raise_error(SystemExit) matcher somewhere)"
|
|
33
52
|
end
|
|
34
53
|
end
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
echo "----->
|
|
2
|
-
bundle clean
|
|
1
|
+
echo "-----> Cleaning up unused gems"
|
|
2
|
+
bundle clean
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
========== Configuration variables ==========
|
|
2
|
+
(.|\n)*
|
|
3
|
+
:bundle_bin => "bundle"
|
|
4
|
+
(.|\n)*
|
|
5
|
+
:releases_path => ".*/releases"
|
|
6
|
+
(.|\n)*
|
|
7
|
+
:keep_releases => "1234"
|
|
8
|
+
(.|\n)*
|
|
9
|
+
:migration_dirs => \["db/migrate"\]
|
|
10
|
+
(.|\n)*
|
|
11
|
+
========== Configuration variables ==========
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
\(cd /path && echo Hello there && cd -\)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(?m)Cloning the Git repository.*Done\. Deployed version 1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
The directory '/app/releases' does not exist on the server\.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Setting up /app
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
environment is DEPRECATED! Please use local_environment and remote_environment
|
|
@@ -1 +1 @@
|
|
|
1
|
-
if\ \[\ !\ \-d\ ".*/deploy/scm/objects"\ \];\ then\s*echo\ "\-\-\-\-\->\ Cloning\ the\ Git\ repository"\s*git\ clone\ ".*"\ ".*/deploy/scm"\ \-\-bare\s*else\s*echo\ "\-\-\-\-\->\ Fetching\ new\ git\ commits"\s*\(cd\ ".*/deploy/scm"\ &&\ git\ fetch\ ".*"\ "master:master"\ \-\-force\)\s*fi\ &&\s*echo\ "\-\-\-\-\->\ Using\ git\ branch\ 'master'"\ &&\s*git\ clone\ ".*/deploy/scm"\ \.\ \-\-recursive\ \-\-branch\ "master"\necho\ "\-\-\-\-\->\ Using\ this\ git\ commit"\ngit\ rev\-parse\ HEAD\ >\ \.mina_git_revision\ngit\ \-\-no\-pager\ log\ \-\-format="%aN\ \(%h\):%n>\ %s"\ \-n\ 1\nrm\ \-rf\ \.git
|
|
1
|
+
if\ \[\ !\ \-d\ ".*/deploy/scm/objects"\ \];\ then\s*echo\ "\-\-\-\-\->\ Cloning\ the\ Git\ repository"\s*git\ clone\ ".*"\ ".*/deploy/scm"\ \-\-bare\s*else\s*echo\ "\-\-\-\-\->\ Fetching\ new\ git\ commits"\s*\(cd\ ".*/deploy/scm"\ &&\ git\ fetch\ ".*"\ "master:master"\ \-\-force\)\s*fi\ &&\s*echo\ "\-\-\-\-\->\ Using\ git\ branch\ 'master'"\ &&\s*git\ clone\ ".*/deploy/scm"\ \.\ \-\-recursive\ \-\-branch\ "master"\necho\ "\-\-\-\-\->\ Updating\ submodules"\ngit\ submodule\ update\necho\ "\-\-\-\-\->\ Using\ this\ git\ commit"\ngit\ rev\-parse\ HEAD\ >\ \.mina_git_revision\ngit\ \-\-no\-pager\ log\ \-\-format="%aN\ \(%h\):%n>\ %s"\ \-n\ 1\nrm\ \-rf\ \.git
|
|
@@ -1 +1 @@
|
|
|
1
|
-
echo\ "\-\-\-\-\->\ Using\ git\ commit\ \\"123456\\""\ngit\ clone\ ".*"\ \.\ \-\-recursive\ngit\ checkout\ \-b\ current_release\ "123456"\ \-\-force\necho\ "\-\-\-\-\->\ Using\ this\ git\ commit"\ngit\ rev\-parse\ HEAD\ >\ \.mina_git_revision\ngit\ \-\-no\-pager\ log\ \-\-format="%aN\ \(%h\):%n>\ %s"\ \-n\ 1\nrm\ \-rf\ \.git
|
|
1
|
+
echo\ "\-\-\-\-\->\ Using\ git\ commit\ \\"123456\\""\ngit\ clone\ ".*"\ \.\ \-\-recursive\ngit\ checkout\ \-b\ current_release\ "123456"\ \-\-force\necho\ "\-\-\-\-\->\ Updating\ submodules"\ngit\ submodule\ update\necho\ "\-\-\-\-\->\ Using\ this\ git\ commit"\ngit\ rev\-parse\ HEAD\ >\ \.mina_git_revision\ngit\ \-\-no\-pager\ log\ \-\-format="%aN\ \(%h\):%n>\ %s"\ \-n\ 1\nrm\ \-rf\ \.git
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
echo "-----> Ensuring everything is pushed to git"
|
|
2
|
+
if \[ \$\(git branch --list master \| wc -l\) -eq 0 \]; then
|
|
3
|
+
echo "! Branch master doesn't exist"
|
|
4
|
+
exit 1
|
|
5
|
+
fi
|
|
6
|
+
|
|
7
|
+
if \[ \$\(git branch -r --list origin/master \| wc -l\) -eq 0 \]; then
|
|
8
|
+
echo "! Branch origin/master doesn't exist"
|
|
9
|
+
exit 1
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
if \[ \$\(git log origin/master..master \| wc -l\) -ne 0 \]; then
|
|
13
|
+
echo "! Your branch master needs to be pushed to origin before deploying"
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Can't be run outside deploy do block. Please use mina 'rake\[assets_precompile\]' instead
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
if diff -qrN ".*/deploy/current/vendor/assets/" "\./vendor/assets/" 2>/dev/null && diff -qrN ".*/deploy/current/app/assets/" "\./app/assets/" 2>/dev/null
|
|
2
|
+
then
|
|
3
|
+
echo "-----> Skipping asset precompilation"
|
|
4
|
+
else
|
|
5
|
+
echo "-----> Precompiling asset files"
|
|
6
|
+
RAILS_ENV="production" bundle exec rake assets:precompile
|
|
7
|
+
fi
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
\(cd .*/deploy/current && RAILS_ENV="production" bundle exec rails console && cd -\)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Can't be run outside deploy do block\. Please use mina 'rake\[db_migrate\]' instead
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
\(cd .*/deploy/shared/log && tail -f production\.log && cd -\)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
\(cd .*/deploy/current && RAILS_ENV="production" bundle exec rails db:rollback STEP=2 && cd -\)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
You need to provide arguments. Try: mina "rails\[console\]"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
\(cd .*/deploy/current && RAILS_ENV="production" bundle exec rake db:primary:migrate && cd -\)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
You need to provide arguments. Try: mina "rake\[db:migrate\]"
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
echo
|
|
1
|
+
echo "-----> Loading rbenv"
|
|
2
|
+
export RBENV_ROOT="\$HOME/\.rbenv"
|
|
3
|
+
export PATH="\$HOME/\.rbenv/bin:\$PATH"
|
|
4
|
+
if ! which rbenv >/dev/null; then
|
|
5
|
+
echo "! rbenv not found"
|
|
6
|
+
echo "! If rbenv is installed, check your :rbenv_path setting\."
|
|
7
|
+
exit 1
|
|
8
|
+
fi
|
|
9
|
+
eval "\$\(rbenv init -\)"
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
echo "-----> Using RVM environment \\"3\.0\.0\\""
|
|
2
|
+
if \[\[ ! -s "\$HOME/\.rvm/scripts/rvm" \]\]; then
|
|
3
|
+
echo "! Ruby Version Manager not found"
|
|
4
|
+
echo "! If RVM is installed, check your :rvm_use_path setting\."
|
|
5
|
+
exit 1
|
|
6
|
+
fi
|
|
7
|
+
source \$HOME/\.rvm/scripts/rvm
|
|
8
|
+
rvm use "3\.0\.0" --create
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
echo "-----> creating RVM wrapper "myapp_unicorn" using \\"3\.0\.0\\""
|
|
2
|
+
if \[\[ ! -s "\$HOME/\.rvm/scripts/rvm" \]\]; then
|
|
3
|
+
echo "! Ruby Version Manager not found"
|
|
4
|
+
echo "! If RVM is installed, check your :rvm_use_path setting\."
|
|
5
|
+
exit 1
|
|
6
|
+
fi
|
|
7
|
+
source \$HOME/\.rvm/scripts/rvm
|
|
8
|
+
rvm wrapper 3\.0\.0 myapp unicorn \|\| exit 1
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
echo "-----> ry to version: \\\"3\.0\.0\\\""
|
|
2
|
+
echo "-----> Loading ry"
|
|
3
|
+
if \[\[ ! -e "\$HOME/\.local/bin" \]\]; then
|
|
4
|
+
echo "! ry not found"
|
|
5
|
+
echo "! If ry is installed, check your :ry_path setting."
|
|
6
|
+
exit 1
|
|
7
|
+
fi
|
|
8
|
+
export PATH="\$HOME/\.local/bin:\$PATH"
|
|
9
|
+
eval "\$\(ry setup\)"
|
|
10
|
+
RY_RUBY="3\.0\.0"
|
|
11
|
+
if \[ -n "\$RY_RUBY" \]; then
|
|
12
|
+
ry use \$RY_RUBY \|\| exit 1
|
|
13
|
+
fi
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
echo "-----> ry to version: \\"\*\*not specified\*\*\\""
|
|
2
|
+
echo "-----> Loading ry"
|
|
3
|
+
if \[\[ ! -e "\$HOME/\.local/bin" \]\]; then
|
|
4
|
+
echo "! ry not found"
|
|
5
|
+
echo "! If ry is installed, check your :ry_path setting."
|
|
6
|
+
exit 1
|
|
7
|
+
fi
|
|
8
|
+
export PATH="\$HOME/\.local/bin:\$PATH"
|
|
9
|
+
eval "\$\(ry setup\)"
|
|
10
|
+
RY_RUBY=""
|
|
11
|
+
if \[ -n "\$RY_RUBY" \]; then
|
|
12
|
+
ry use \$RY_RUBY \|\| exit 1
|
|
13
|
+
fi
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cd .*/deploy && exec \$SHELL
|
|
@@ -1,25 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module RakeExampleGroup
|
|
2
|
-
extend RSpec::
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
extend RSpec::SharedContext
|
|
5
|
+
|
|
6
|
+
subject(:task) { rake[task_name] }
|
|
7
|
+
|
|
8
|
+
let(:rake) { Rake.application }
|
|
9
|
+
let(:task_name) { self.class.description }
|
|
10
|
+
let(:run_commands) { rake['run_commands'] }
|
|
11
|
+
let(:reset!) { rake['reset!'] }
|
|
12
|
+
|
|
13
|
+
after do
|
|
14
|
+
reset!.invoke
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def load_default_config
|
|
18
|
+
load_config 'default'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def load_config(config_name)
|
|
22
|
+
Rake.load_rakefile(Dir.pwd + "/spec/configs/#{config_name}.rb")
|
|
19
23
|
end
|
|
20
24
|
|
|
21
|
-
def invoke_all(args
|
|
22
|
-
|
|
25
|
+
def invoke_all(*args)
|
|
26
|
+
task.invoke(*args)
|
|
23
27
|
run_commands.invoke
|
|
24
28
|
end
|
|
25
29
|
|
data/spec/tasks/bundler_spec.rb
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
RSpec.describe 'bundler', type: :rake do
|
|
6
|
+
before do
|
|
7
|
+
load_default_config
|
|
8
|
+
end
|
|
9
|
+
|
|
4
10
|
describe 'bundle:install' do
|
|
5
11
|
it 'bundle install' do
|
|
6
12
|
expect { invoke_all }.to output(output_file('bundle_install')).to_stdout
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'chruby', type: :rake do
|
|
6
|
+
before do
|
|
7
|
+
load_default_config
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe 'chruby' do
|
|
11
|
+
let(:task_name) { 'chruby' }
|
|
12
|
+
|
|
13
|
+
context 'without an argument' do
|
|
14
|
+
it 'exits with an error message' do
|
|
15
|
+
expect do
|
|
16
|
+
invoke_all
|
|
17
|
+
end.to raise_error(SystemExit).and output(output_file('chruby_without_env')).to_stdout
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context 'with an argument' do
|
|
22
|
+
it 'sets ruby version' do
|
|
23
|
+
expect do
|
|
24
|
+
invoke_all('123')
|
|
25
|
+
end.to output(output_file('chruby_with_env')).to_stdout
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/spec/tasks/default_spec.rb
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
RSpec.describe 'default', type: :rake do
|
|
6
|
+
before do
|
|
7
|
+
load_default_config
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe 'environment' do
|
|
11
|
+
it 'outputs a deprecation warning' do
|
|
12
|
+
expect { invoke_all }.to output(output_file('environment')).to_stdout
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
4
16
|
describe 'ssh_keyscan_repo' do
|
|
5
17
|
it 'scans ssh' do
|
|
6
18
|
Mina::Configuration.instance.set(:repository, 'git@github.com/exapmle')
|
|
@@ -8,29 +20,89 @@ RSpec.describe 'default', type: :rake do
|
|
|
8
20
|
end
|
|
9
21
|
end
|
|
10
22
|
|
|
23
|
+
describe 'ssh_keyscan_domain' do
|
|
24
|
+
let(:task_name) { 'ssh_keyscan_domain' }
|
|
25
|
+
|
|
26
|
+
context "when domain isn't set" do
|
|
27
|
+
before do
|
|
28
|
+
Mina::Configuration.instance.remove(:domain)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'exits with an error message' do
|
|
32
|
+
expect do
|
|
33
|
+
invoke_all
|
|
34
|
+
end.to raise_error(SystemExit)
|
|
35
|
+
.and output(/domain must be defined!/).to_stdout
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context "when port isn't set" do
|
|
40
|
+
before do
|
|
41
|
+
Mina::Configuration.instance.remove(:port)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'exits with an error message' do
|
|
45
|
+
expect do
|
|
46
|
+
invoke_all
|
|
47
|
+
end.to raise_error(SystemExit)
|
|
48
|
+
.and output(/port must be defined!/).to_stdout
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
context 'when conditions are met' do
|
|
53
|
+
it 'scans ssh' do
|
|
54
|
+
expect do
|
|
55
|
+
invoke_all
|
|
56
|
+
end.to output(output_file('ssh_keyscan_domain')).to_stdout
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
11
61
|
describe 'run' do
|
|
12
62
|
it 'runs command' do
|
|
13
|
-
|
|
63
|
+
task.invoke('ls -al')
|
|
14
64
|
expect { run_commands.invoke }.to output(output_file('run')).to_stdout
|
|
15
65
|
end
|
|
16
66
|
|
|
17
67
|
it 'exits if no command given' do
|
|
18
|
-
expect {
|
|
68
|
+
expect { task.invoke }.to raise_error(SystemExit)
|
|
69
|
+
.and output(/You need to provide a command/).to_stdout
|
|
19
70
|
end
|
|
20
71
|
end
|
|
21
72
|
|
|
22
73
|
describe 'ssh' do
|
|
23
|
-
it '
|
|
24
|
-
|
|
25
|
-
|
|
74
|
+
it 'opens an SSH connection when :deploy_to exists' do
|
|
75
|
+
expect do
|
|
76
|
+
invoke_all
|
|
77
|
+
end.to change { Mina::Configuration.instance.fetch(:execution_mode) }.to(:exec)
|
|
78
|
+
.and output(output_file('ssh')).to_stdout
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "exits with an error message when :deploy_to isn't set" do
|
|
82
|
+
Mina::Configuration.instance.remove(:deploy_to)
|
|
83
|
+
|
|
84
|
+
expect do
|
|
85
|
+
invoke_all
|
|
86
|
+
end.to raise_error(SystemExit)
|
|
87
|
+
.and output(/deploy_to must be defined!/).to_stdout
|
|
26
88
|
end
|
|
27
89
|
end
|
|
28
90
|
|
|
29
91
|
describe 'debug_configuration_variables' do
|
|
30
|
-
|
|
92
|
+
before do
|
|
31
93
|
Mina::Configuration.instance.set(:debug_configuration_variables, true)
|
|
32
|
-
|
|
94
|
+
ENV['keep_releases'] = '1234'
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
after do
|
|
33
98
|
Mina::Configuration.instance.remove(:debug_configuration_variables)
|
|
99
|
+
ENV.delete('keep_releases')
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it 'prints configuration variables' do
|
|
103
|
+
expect do
|
|
104
|
+
invoke_all
|
|
105
|
+
end.to output(output_file('debug_configuration_variables')).to_stdout
|
|
34
106
|
end
|
|
35
107
|
end
|
|
36
108
|
end
|
data/spec/tasks/deploy_spec.rb
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
RSpec.describe 'deploy', type: :rake do
|
|
6
|
+
before do
|
|
7
|
+
load_default_config
|
|
8
|
+
end
|
|
9
|
+
|
|
4
10
|
describe 'deploy:force_unlock' do
|
|
5
11
|
it 'deploy force_unlock' do
|
|
6
12
|
expect { invoke_all }.to output(output_file('deploy_force_unlock')).to_stdout
|
data/spec/tasks/git_spec.rb
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
RSpec.describe 'git', type: :rake do
|
|
6
|
+
before do
|
|
7
|
+
load_default_config
|
|
8
|
+
end
|
|
9
|
+
|
|
4
10
|
describe 'git:clone' do
|
|
5
11
|
it 'git clone' do
|
|
6
12
|
expect { invoke_all }.to output(output_file('git_clone')).to_stdout
|
|
@@ -18,4 +24,10 @@ RSpec.describe 'git', type: :rake do
|
|
|
18
24
|
expect { invoke_all }.to output(output_file('git_revision')).to_stdout
|
|
19
25
|
end
|
|
20
26
|
end
|
|
27
|
+
|
|
28
|
+
describe 'git:ensure_pushed' do
|
|
29
|
+
it 'git ensure pushed' do
|
|
30
|
+
expect { invoke_all }.to output(output_file('git_ensure_pushed')).to_stdout
|
|
31
|
+
end
|
|
32
|
+
end
|
|
21
33
|
end
|
data/spec/tasks/init_spec.rb
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
RSpec.describe 'init', type: :rake do
|
|
6
|
+
before do
|
|
7
|
+
load_default_config
|
|
8
|
+
end
|
|
9
|
+
|
|
4
10
|
it 'creates new deploy rb' do
|
|
5
11
|
allow(File).to receive(:exist?).and_return(true)
|
|
6
|
-
|
|
7
|
-
|
|
12
|
+
allow(File).to receive(:exist?).with('./config/deploy.rb').and_return(false)
|
|
13
|
+
allow(FileUtils).to receive(:mkdir_p).and_return(true)
|
|
14
|
+
allow(FileUtils).to receive(:cp).and_return(true)
|
|
8
15
|
|
|
9
|
-
expect
|
|
16
|
+
expect do
|
|
17
|
+
task.invoke
|
|
18
|
+
end.to output("-----> Created ./config/deploy.rb\nEdit this file, then run `mina setup` after.\n").to_stdout
|
|
10
19
|
end
|
|
11
20
|
|
|
12
21
|
it 'doesnt create deploy rb if already exists' do
|
|
13
22
|
allow(File).to receive(:exist?).and_return(false)
|
|
14
|
-
expect {
|
|
23
|
+
expect { task.invoke }.to raise_error(SystemExit).and output(/You already have/).to_stdout
|
|
15
24
|
end
|
|
16
25
|
end
|