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.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +11 -3
- data/.gitignore +0 -1
- data/.rspec +1 -1
- data/.rubocop.yml +28 -1126
- data/CHANGELOG.md +89 -8
- 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 +6 -4
- data/docs/3rd_party_plugins.md +1 -0
- data/docs/assets/images/mina.png +0 -0
- data/docs/default_plugins.md +1 -1
- data/docs/how_mina_works.md +2 -2
- 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 +8 -8
- 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 +88 -10
- 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_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 +26 -24
- data/tasks/mina/git.rb +28 -16
- data/tasks/mina/install.rb +3 -1
- 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 +64 -32
- 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
|
@@ -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
|
|
@@ -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
|
data/spec/tasks/rails_spec.rb
CHANGED
|
@@ -1,23 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
RSpec.describe 'rails', type: :rake do
|
|
6
|
+
before do
|
|
7
|
+
load_default_config
|
|
8
|
+
end
|
|
9
|
+
|
|
4
10
|
describe 'console' do
|
|
5
11
|
it 'starts console' do
|
|
6
|
-
expect { invoke_all }.to output(output_file('
|
|
12
|
+
expect { invoke_all }.to output(output_file('rails_console')).to_stdout
|
|
7
13
|
end
|
|
8
14
|
end
|
|
9
15
|
|
|
10
16
|
describe 'log' do
|
|
11
17
|
it 'tails log' do
|
|
12
|
-
expect { invoke_all }.to output(output_file('
|
|
18
|
+
expect { invoke_all }.to output(output_file('rails_log')).to_stdout
|
|
13
19
|
end
|
|
14
20
|
end
|
|
15
21
|
|
|
16
22
|
describe 'rails:db_migrate' do
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
23
|
+
let(:task_name) { 'rails:db_migrate' }
|
|
24
|
+
|
|
25
|
+
context 'when outside deploy block' do
|
|
26
|
+
before do
|
|
27
|
+
Mina::Configuration.instance.remove(:deploy_block)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'exits with an error message' do
|
|
31
|
+
expect do
|
|
32
|
+
invoke_all
|
|
33
|
+
end.to raise_error(SystemExit)
|
|
34
|
+
.and output(output_file('rails_db_migrate_outside_deploy_block')).to_stdout
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context 'with force_migrate flag' do
|
|
39
|
+
before do
|
|
40
|
+
Mina::Configuration.instance.set(:force_migrate, true)
|
|
41
|
+
Mina::Configuration.instance.set(:deploy_block, true)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it 'runs rails db:migrate' do
|
|
45
|
+
expect do
|
|
46
|
+
invoke_all
|
|
47
|
+
end.to output(output_file('rails_db_migrate_force_migrate')).to_stdout
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
context 'without force_migrate flag' do
|
|
52
|
+
before do
|
|
53
|
+
Mina::Configuration.instance.set(:deploy_block, true)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'runs rails db:migrate but checks for changes first' do
|
|
57
|
+
expect do
|
|
58
|
+
invoke_all
|
|
59
|
+
end.to output(output_file('rails_db_migrate_with_diff')).to_stdout
|
|
60
|
+
end
|
|
21
61
|
end
|
|
22
62
|
end
|
|
23
63
|
|
|
@@ -34,10 +74,44 @@ RSpec.describe 'rails', type: :rake do
|
|
|
34
74
|
end
|
|
35
75
|
|
|
36
76
|
describe 'rails:assets_precompile' do
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
77
|
+
let(:task_name) { 'rails:assets_precompile' }
|
|
78
|
+
|
|
79
|
+
context 'when outside deploy block' do
|
|
80
|
+
before do
|
|
81
|
+
Mina::Configuration.instance.remove(:deploy_block)
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'exits with an error message' do
|
|
85
|
+
expect do
|
|
86
|
+
invoke_all
|
|
87
|
+
end.to raise_error(SystemExit)
|
|
88
|
+
.and output(output_file('rails_assets_precompile_outside_deploy_block')).to_stdout
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
context 'with force_asset_precompile flag' do
|
|
93
|
+
before do
|
|
94
|
+
Mina::Configuration.instance.set(:force_asset_precompile, true)
|
|
95
|
+
Mina::Configuration.instance.set(:deploy_block, true)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'runs rails assets:precompile' do
|
|
99
|
+
expect do
|
|
100
|
+
invoke_all
|
|
101
|
+
end.to output(output_file('rails_assets_precompile_force_precompile')).to_stdout
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
context 'without force_asset_precompile flag' do
|
|
106
|
+
before do
|
|
107
|
+
Mina::Configuration.instance.set(:deploy_block, true)
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'runs rails assets:precompile but checks for changes first' do
|
|
111
|
+
expect do
|
|
112
|
+
invoke_all
|
|
113
|
+
end.to output(output_file('rails_assets_precompile_with_diff')).to_stdout
|
|
114
|
+
end
|
|
41
115
|
end
|
|
42
116
|
end
|
|
43
117
|
|
|
@@ -52,9 +126,46 @@ RSpec.describe 'rails', type: :rake do
|
|
|
52
126
|
expect { invoke_all }.to output(output_file('rails_db_schema_load')).to_stdout
|
|
53
127
|
end
|
|
54
128
|
end
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
129
|
+
|
|
130
|
+
describe 'rails' do
|
|
131
|
+
let(:task_name) { 'rails' }
|
|
132
|
+
|
|
133
|
+
context 'without arguments' do
|
|
134
|
+
it 'exits with an error message' do
|
|
135
|
+
expect do
|
|
136
|
+
invoke_all
|
|
137
|
+
end.to raise_error(SystemExit)
|
|
138
|
+
.and output(output_file('rails_without_arguments')).to_stdout
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
context 'with arguments' do
|
|
143
|
+
it 'executes the arguments' do
|
|
144
|
+
expect do
|
|
145
|
+
invoke_all('db:rollback STEP=2')
|
|
146
|
+
end.to output(output_file('rails_with_arguments')).to_stdout
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
describe 'rake' do
|
|
152
|
+
let(:task_name) { 'rake' }
|
|
153
|
+
|
|
154
|
+
context 'without arguments' do
|
|
155
|
+
it 'exits with an error message' do
|
|
156
|
+
expect do
|
|
157
|
+
invoke_all
|
|
158
|
+
end.to raise_error(SystemExit)
|
|
159
|
+
.and output(output_file('rake_without_arguments')).to_stdout
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
context 'with arguments' do
|
|
164
|
+
it 'executes the arguments' do
|
|
165
|
+
expect do
|
|
166
|
+
invoke_all('db:primary:migrate')
|
|
167
|
+
end.to output(output_file('rake_with_arguments')).to_stdout
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
end
|
|
60
171
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
RSpec.describe 'rbenv', type: :rake do
|
|
6
|
+
before do
|
|
7
|
+
load_default_config
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
describe 'rbenv:load' do
|
|
11
|
+
it 'loads rbenv' do
|
|
12
|
+
expect { invoke_all }.to output(output_file('rbenv_load')).to_stdout
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|