geordi 2.10.1 → 3.0.3
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/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/.travis.yml +8 -2
- data/CHANGELOG.md +46 -0
- data/Gemfile +2 -5
- data/Gemfile.lock +10 -10
- data/README.md +11 -6
- data/Rakefile +6 -10
- data/{bin → exe}/b +0 -0
- data/{bin → exe}/cap-all +0 -0
- data/{bin → exe}/console-for +0 -0
- data/{bin → exe}/cuc +0 -0
- data/{bin → exe}/cuc-show +0 -0
- data/{bin → exe}/cuc-vnc-setup +0 -0
- data/{bin → exe}/deploy-to-production +0 -0
- data/{bin → exe}/dump-for +0 -0
- data/{bin → exe}/dumple +0 -0
- data/{bin → exe}/geordi +0 -0
- data/{bin → exe}/gitpt +0 -0
- data/{bin → exe}/launchy_browser +0 -0
- data/{bin → exe}/load-dump +0 -0
- data/{bin → exe}/migrate-all +0 -0
- data/{bin → exe}/rs +0 -0
- data/{bin → exe}/run_tests +0 -0
- data/{bin → exe}/shell-for +0 -0
- data/{bin → exe}/tests +0 -0
- data/geordi.gemspec +23 -20
- data/lib/geordi/COMMAND_TEMPLATE +4 -6
- data/lib/geordi/capistrano_config.rb +20 -17
- data/lib/geordi/chromedriver_updater.rb +9 -10
- data/lib/geordi/cli.rb +5 -2
- data/lib/geordi/commands/_setup_vnc.rb +23 -23
- data/lib/geordi/commands/apache_site.rb +3 -3
- data/lib/geordi/commands/bundle_install.rb +3 -3
- data/lib/geordi/commands/capistrano.rb +5 -6
- data/lib/geordi/commands/chromedriver_update.rb +0 -9
- data/lib/geordi/commands/clean.rb +5 -6
- data/lib/geordi/commands/commit.rb +0 -1
- data/lib/geordi/commands/console.rb +4 -4
- data/lib/geordi/commands/create_database_yml.rb +4 -4
- data/lib/geordi/commands/create_databases.rb +3 -3
- data/lib/geordi/commands/cucumber.rb +25 -25
- data/lib/geordi/commands/delete_dumps.rb +12 -12
- data/lib/geordi/commands/deploy.rb +27 -28
- data/lib/geordi/commands/drop_databases.rb +13 -15
- data/lib/geordi/commands/dump.rb +12 -13
- data/lib/geordi/commands/eurest.rb +2 -2
- data/lib/geordi/commands/firefox.rb +4 -4
- data/lib/geordi/commands/migrate.rb +3 -3
- data/lib/geordi/commands/png_optimize.rb +15 -14
- data/lib/geordi/commands/rake.rb +3 -3
- data/lib/geordi/commands/remove_executable_flags.rb +3 -3
- data/lib/geordi/commands/rspec.rb +11 -11
- data/lib/geordi/commands/security_update.rb +25 -25
- data/lib/geordi/commands/server.rb +6 -6
- data/lib/geordi/commands/setup.rb +8 -8
- data/lib/geordi/commands/shell.rb +3 -3
- data/lib/geordi/commands/tests.rb +1 -1
- data/lib/geordi/commands/unit.rb +3 -3
- data/lib/geordi/commands/update.rb +7 -7
- data/lib/geordi/commands/vnc.rb +1 -1
- data/lib/geordi/commands/with_rake.rb +3 -3
- data/lib/geordi/commands/yarn_install.rb +3 -3
- data/lib/geordi/cucumber.rb +35 -36
- data/lib/geordi/db_cleaner.rb +40 -41
- data/lib/geordi/dump_loader.rb +6 -5
- data/lib/geordi/firefox_for_selenium.rb +26 -29
- data/lib/geordi/gitpt.rb +14 -15
- data/lib/geordi/interaction.rb +2 -6
- data/lib/geordi/remote.rb +9 -10
- data/lib/geordi/util.rb +28 -25
- data/lib/geordi/version.rb +1 -1
- metadata +27 -39
- data/features/commit.feature +0 -17
- data/features/console.feature +0 -7
- data/features/cucumber.feature +0 -261
- data/features/deploy.feature +0 -66
- data/features/dump.feature +0 -34
- data/features/firefox.feature +0 -44
- data/features/server.feature +0 -31
- data/features/setup.feature +0 -11
- data/features/shell.feature +0 -78
- data/features/support/env.rb +0 -8
- data/features/support/step_definitions/aruba_backport_steps.rb +0 -5
- data/features/support/step_definitions/miscellaneous_steps.rb +0 -11
data/lib/geordi/cli.rb
CHANGED
@@ -5,10 +5,13 @@ require 'geordi/util'
|
|
5
5
|
|
6
6
|
module Geordi
|
7
7
|
class CLI < Thor
|
8
|
-
|
8
|
+
|
9
|
+
def self.exit_on_failure?
|
10
|
+
true
|
11
|
+
end
|
9
12
|
|
10
13
|
# load all tasks defined in lib/geordi/commands
|
11
|
-
Dir[File.expand_path '
|
14
|
+
Dir[File.expand_path 'commands/*.rb', __dir__].each do |file|
|
12
15
|
class_eval File.read(file), file
|
13
16
|
end
|
14
17
|
|
@@ -1,34 +1,34 @@
|
|
1
|
-
desc '-setup-vnc', 'Setup VNC for running Selenium tests there', :
|
1
|
+
desc '-setup-vnc', 'Setup VNC for running Selenium tests there', hide: true
|
2
2
|
def _setup_vnc
|
3
3
|
`clear`
|
4
4
|
|
5
|
-
note 'This script will help you install a VNC server and a VNC viewer.'
|
5
|
+
Interaction.note 'This script will help you install a VNC server and a VNC viewer.'
|
6
6
|
puts
|
7
|
-
puts strip_heredoc <<-TEXT
|
7
|
+
puts Util.strip_heredoc <<-TEXT
|
8
8
|
With those you will be able to use our cucumber script without being
|
9
9
|
disturbed by focus-stealing Selenium windows. Instead, they will open
|
10
10
|
inside a VNC session.
|
11
11
|
|
12
12
|
You can still inspect everything with:
|
13
13
|
TEXT
|
14
|
-
note_cmd 'geordi vnc'
|
14
|
+
Interaction.note_cmd 'geordi vnc'
|
15
15
|
puts
|
16
|
-
note 'Please open a second shell to execute instructions.'
|
17
|
-
prompt 'Continue ...'
|
16
|
+
Interaction.note 'Please open a second shell to execute instructions.'
|
17
|
+
Interaction.prompt 'Continue ...'
|
18
18
|
|
19
|
-
announce 'Setup VNC server'
|
19
|
+
Interaction.announce 'Setup VNC server'
|
20
20
|
|
21
21
|
vnc_server_installed = system('which vncserver > /dev/null 2>&1')
|
22
22
|
if vnc_server_installed
|
23
|
-
success 'It appears you already have a VNC server installed. Good job!'
|
23
|
+
Interaction.success 'It appears you already have a VNC server installed. Good job!'
|
24
24
|
else
|
25
25
|
puts 'Please run:'
|
26
|
-
note_cmd 'sudo apt-get install vnc4server'
|
27
|
-
prompt 'Continue ...'
|
26
|
+
Interaction.note_cmd 'sudo apt-get install vnc4server'
|
27
|
+
Interaction.prompt 'Continue ...'
|
28
28
|
|
29
29
|
puts
|
30
|
-
note 'We will now set a password for your VNC server.'
|
31
|
-
puts strip_heredoc <<-TEXT
|
30
|
+
Interaction.note 'We will now set a password for your VNC server.'
|
31
|
+
puts Util.strip_heredoc <<-TEXT
|
32
32
|
When running our cucumber script, you will not actually need this
|
33
33
|
password, and there is no security risk. However, if you start a vncserver
|
34
34
|
without our cucumber script, a user with your password can connect to
|
@@ -36,31 +36,31 @@ def _setup_vnc
|
|
36
36
|
|
37
37
|
TEXT
|
38
38
|
puts 'Please run:'
|
39
|
-
note_cmd 'vncserver :20'
|
40
|
-
warn 'Enter a secure password!'
|
41
|
-
prompt 'Continue ...'
|
39
|
+
Interaction.note_cmd 'vncserver :20'
|
40
|
+
Interaction.warn 'Enter a secure password!'
|
41
|
+
Interaction.prompt 'Continue ...'
|
42
42
|
|
43
43
|
puts 'Now stop the server again. Please run:'
|
44
|
-
note_cmd 'vncserver -kill :20'
|
45
|
-
prompt 'Continue ...'
|
44
|
+
Interaction.note_cmd 'vncserver -kill :20'
|
45
|
+
Interaction.prompt 'Continue ...'
|
46
46
|
end
|
47
47
|
|
48
|
-
announce 'Setup VNC viewer'
|
48
|
+
Interaction.announce 'Setup VNC viewer'
|
49
49
|
|
50
50
|
vnc_viewer_installed = system('which vncviewer > /dev/null 2>&1')
|
51
51
|
if vnc_viewer_installed
|
52
|
-
success 'It appears you already have a VNC viewer installed. Good job!'
|
52
|
+
Interaction.success 'It appears you already have a VNC viewer installed. Good job!'
|
53
53
|
else
|
54
54
|
puts 'Please run:'
|
55
|
-
note_cmd 'sudo apt-get install xtightvncviewer'
|
56
|
-
prompt 'Continue ...'
|
55
|
+
Interaction.note_cmd 'sudo apt-get install xtightvncviewer'
|
56
|
+
Interaction.prompt 'Continue ...'
|
57
57
|
end
|
58
58
|
|
59
59
|
puts
|
60
|
-
puts strip_heredoc <<-TEXT
|
60
|
+
puts Util.strip_heredoc <<-TEXT
|
61
61
|
All done. Our cucumber script will now automatically run Selenium features
|
62
62
|
in VNC.
|
63
63
|
TEXT
|
64
64
|
|
65
|
-
success 'Happy cuking!'
|
65
|
+
Interaction.success 'Happy cuking!'
|
66
66
|
end
|
@@ -10,13 +10,13 @@ def apache_site(*args)
|
|
10
10
|
puts 'Please call: apache-site my-site'
|
11
11
|
puts
|
12
12
|
puts 'Available sites:'
|
13
|
-
Dir.new(
|
13
|
+
Dir.new('.').each do |file|
|
14
14
|
puts "- #{file}" if file != '.' && file != '..'
|
15
15
|
end
|
16
16
|
exit
|
17
17
|
end
|
18
18
|
|
19
|
-
has_default = File.
|
20
|
-
exec "sudo a2dissite \*; sudo a2ensite #{
|
19
|
+
has_default = File.exist?('default')
|
20
|
+
exec "sudo a2dissite \*; sudo a2ensite #{'default ' if has_default}#{site} && sudo apache2ctl restart"
|
21
21
|
Dir.chdir old_cwd
|
22
22
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
desc 'bundle-install', 'Run bundle install if required', :
|
1
|
+
desc 'bundle-install', 'Run bundle install if required', hide: true
|
2
2
|
def bundle_install
|
3
|
-
if File.
|
4
|
-
announce 'Bundling'
|
3
|
+
if File.exist?('Gemfile') && !system('bundle check > /dev/null 2>&1')
|
4
|
+
Interaction.announce 'Bundling'
|
5
5
|
Util.system! 'bundle install'
|
6
6
|
end
|
7
7
|
end
|
@@ -6,18 +6,17 @@ LONGDESC
|
|
6
6
|
def capistrano(*args)
|
7
7
|
targets = Dir['config/deploy/*.rb'].map { |file| File.basename(file, '.rb') }.sort
|
8
8
|
|
9
|
-
note 'Found the following deploy targets:'
|
9
|
+
Interaction.note 'Found the following deploy targets:'
|
10
10
|
puts targets
|
11
|
-
prompt('Continue?', 'n', /y|yes/)
|
11
|
+
Interaction.prompt('Continue?', 'n', /y|yes/) || Interaction.fail('Cancelled.')
|
12
12
|
|
13
13
|
targets << nil if targets.empty? # default target
|
14
14
|
targets.each do |stage|
|
15
|
-
announce 'Target: ' + (stage || '(default)')
|
15
|
+
Interaction.announce 'Target: ' + (stage || '(default)')
|
16
16
|
|
17
17
|
command = "bundle exec cap #{stage} " + args.join(' ')
|
18
|
-
note_cmd command
|
18
|
+
Interaction.note_cmd command
|
19
19
|
|
20
|
-
Util.system!(command, :
|
20
|
+
Util.system!(command, fail_message: 'Capistrano failed. Have a look!')
|
21
21
|
end
|
22
|
-
|
23
22
|
end
|
@@ -9,14 +9,5 @@ LONGDESC
|
|
9
9
|
def chromedriver_update
|
10
10
|
require 'geordi/chromedriver_updater'
|
11
11
|
|
12
|
-
# Ruby 1.9.3 introduces #capture3 in open3
|
13
|
-
supported_ruby_version = '1.9.2'
|
14
|
-
|
15
|
-
# We do not want to backport this command to Ruby 1.8.7, a user can just use a newer Ruby version to run it. For all
|
16
|
-
# other commands it still is necessary to have a proper Ruby 1.8.7 support.
|
17
|
-
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new(supported_ruby_version)
|
18
|
-
raise("Unsupported ruby version #{RUBY_VERSION}, please use at least #{supported_ruby_version} to run this command!")
|
19
|
-
end
|
20
|
-
|
21
12
|
ChromedriverUpdater.new.run
|
22
13
|
end
|
@@ -1,16 +1,15 @@
|
|
1
1
|
desc 'clean', 'Remove unneeded files from the current directory'
|
2
2
|
def clean
|
3
3
|
|
4
|
-
announce 'Removing tempfiles'
|
4
|
+
Interaction.announce 'Removing tempfiles'
|
5
5
|
for pattern in %w[ webrat-* capybara-* tmp/webrat-* tmp/capybara-* tmp/rtex/* log/*.log ]
|
6
|
-
note pattern
|
6
|
+
Interaction.note pattern
|
7
7
|
puts `rm -vfR #{pattern}`
|
8
8
|
end
|
9
9
|
|
10
|
-
announce 'Finding recursively and removing backup files'
|
11
|
-
|
12
|
-
note pattern
|
10
|
+
Interaction.announce 'Finding recursively and removing backup files'
|
11
|
+
%w[*~].each do |pattern|
|
12
|
+
Interaction.note pattern
|
13
13
|
`find . -name #{pattern} -exec rm {} ';'`
|
14
14
|
end
|
15
|
-
|
16
15
|
end
|
@@ -6,19 +6,19 @@ Open a Rails console on `staging`: `geordi console staging`
|
|
6
6
|
LONGDESC
|
7
7
|
|
8
8
|
|
9
|
-
option :select_server, :
|
9
|
+
option :select_server, default: false, type: :boolean, aliases: '-s'
|
10
10
|
|
11
|
-
def console(target = 'development', *
|
11
|
+
def console(target = 'development', *_args)
|
12
12
|
require 'geordi/remote'
|
13
13
|
|
14
14
|
if target == 'development'
|
15
15
|
invoke_cmd 'yarn_install'
|
16
16
|
|
17
|
-
announce 'Opening a local Rails console'
|
17
|
+
Interaction.announce 'Opening a local Rails console'
|
18
18
|
|
19
19
|
Util.system! Util.console_command(target)
|
20
20
|
else
|
21
|
-
announce 'Opening a Rails console on ' + target
|
21
|
+
Interaction.announce 'Opening a Rails console on ' + target
|
22
22
|
|
23
23
|
Geordi::Remote.new(target).console(options)
|
24
24
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
desc 'create-database-yml', '[sic]', :
|
1
|
+
desc 'create-database-yml', '[sic]', hide: true
|
2
2
|
def create_database_yml
|
3
3
|
real_yml = 'config/database.yml'
|
4
4
|
sample_yml = 'config/database.sample.yml'
|
5
5
|
|
6
|
-
if File.
|
7
|
-
announce 'Creating ' + real_yml
|
6
|
+
if File.exist?(sample_yml) && !File.exist?(real_yml)
|
7
|
+
Interaction.announce 'Creating ' + real_yml
|
8
8
|
|
9
9
|
sample = File.read(sample_yml)
|
10
10
|
adapter = sample.match(/adapter: (\w+)\n/).captures.first
|
@@ -15,6 +15,6 @@ def create_database_yml
|
|
15
15
|
real = sample.gsub(/password:.*$/, "password: #{db_password}")
|
16
16
|
File.open(real_yml, 'w') { |f| f.write(real) }
|
17
17
|
|
18
|
-
note "Created #{real_yml}."
|
18
|
+
Interaction.note "Created #{real_yml}."
|
19
19
|
end
|
20
20
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
desc 'create-databases', 'Create all databases', :
|
1
|
+
desc 'create-databases', 'Create all databases', hide: true
|
2
2
|
def create_databases
|
3
3
|
invoke_cmd 'create_database_yml'
|
4
4
|
invoke_cmd 'bundle_install'
|
5
5
|
|
6
|
-
announce 'Creating databases'
|
6
|
+
Interaction.announce 'Creating databases'
|
7
7
|
|
8
|
-
if File.
|
8
|
+
if File.exist?('config/database.yml')
|
9
9
|
command = 'bundle exec rake db:create:all'
|
10
10
|
command << ' parallel:create' if Util.file_containing?('Gemfile', /parallel_tests/)
|
11
11
|
|
@@ -17,30 +17,30 @@ or `-d`.
|
|
17
17
|
e.g. `--format pretty`.
|
18
18
|
LONGDESC
|
19
19
|
|
20
|
-
option :modified, :
|
21
|
-
:
|
22
|
-
option :containing, :
|
23
|
-
:
|
24
|
-
option :verbose, :
|
25
|
-
:
|
26
|
-
option :debug, :
|
27
|
-
:
|
28
|
-
option :rerun, :
|
29
|
-
:
|
20
|
+
option :modified, aliases: '-m', type: :boolean,
|
21
|
+
desc: 'Run all modified features'
|
22
|
+
option :containing, aliases: '-c', banner: 'STRING',
|
23
|
+
desc: 'Run all features that contain STRING'
|
24
|
+
option :verbose, aliases: '-v', type: :boolean,
|
25
|
+
desc: 'Print the testrun command'
|
26
|
+
option :debug, aliases: '-d', type: :boolean,
|
27
|
+
desc: 'Run with `-f pretty -b` which helps hunting down bugs'
|
28
|
+
option :rerun, aliases: '-r', type: :numeric, default: 0,
|
29
|
+
desc: 'Rerun features up to N times while failing'
|
30
30
|
|
31
31
|
def cucumber(*args)
|
32
32
|
if args.empty?
|
33
33
|
# This is not testable as there is no way to stub `git` :(
|
34
34
|
if options.modified?
|
35
|
-
modified_features = `git status --short`.split(
|
35
|
+
modified_features = `git status --short`.split($INPUT_RECORD_SEPARATOR).map do |line|
|
36
36
|
indicators = line.slice!(0..2) # Remove leading indicators
|
37
|
-
line if line.include?('.feature')
|
37
|
+
line if line.include?('.feature') && !indicators.include?('D')
|
38
38
|
end.compact
|
39
39
|
args = modified_features
|
40
40
|
end
|
41
41
|
|
42
42
|
if options.containing
|
43
|
-
matching_features = `grep -lri '#{options.containing}' --include=*.feature features/`.split(
|
43
|
+
matching_features = `grep -lri '#{options.containing}' --include=*.feature features/`.split($INPUT_RECORD_SEPARATOR)
|
44
44
|
args = matching_features.uniq
|
45
45
|
end
|
46
46
|
end
|
@@ -56,7 +56,7 @@ def cucumber(*args)
|
|
56
56
|
|
57
57
|
# Serial run of @solo scenarios ############################################
|
58
58
|
if files.any? { |f| f.include? ':' }
|
59
|
-
note '@solo run skipped when called with line numbers' if options.verbose
|
59
|
+
Interaction.note '@solo run skipped when called with line numbers' if options.verbose
|
60
60
|
else
|
61
61
|
solo_files = if files.empty?
|
62
62
|
'features' # Proper grepping
|
@@ -64,37 +64,37 @@ def cucumber(*args)
|
|
64
64
|
files.join(' ')
|
65
65
|
end
|
66
66
|
|
67
|
-
solo_tag_usages = `grep -r '@solo' #{
|
67
|
+
solo_tag_usages = `grep -r '@solo' #{solo_files}`.split("\n")
|
68
68
|
|
69
69
|
if solo_tag_usages.any?
|
70
70
|
solo_cmd_opts = cmd_opts.dup
|
71
71
|
solo_cmd_opts << '--tags' << '@solo'
|
72
72
|
|
73
|
-
announce 'Running @solo features'
|
74
|
-
solo_success = Geordi::Cucumber.new.run files, solo_cmd_opts, :
|
75
|
-
solo_success
|
73
|
+
Interaction.announce 'Running @solo features'
|
74
|
+
solo_success = Geordi::Cucumber.new.run files, solo_cmd_opts, verbose: options.verbose, parallel: false
|
75
|
+
solo_success || Interaction.fail('Features failed.')
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
79
|
# Parallel run of all given features + reruns ##############################
|
80
|
-
announce 'Running features'
|
81
|
-
normal_run_successful = Geordi::Cucumber.new.run(files, cmd_opts, :
|
80
|
+
Interaction.announce 'Running features'
|
81
|
+
normal_run_successful = Geordi::Cucumber.new.run(files, cmd_opts, verbose: options.verbose)
|
82
82
|
|
83
83
|
unless normal_run_successful
|
84
84
|
cmd_opts << '--profile' << 'rerun'
|
85
85
|
|
86
86
|
# Reruns
|
87
87
|
(options.rerun + 1).times do |i|
|
88
|
-
fail 'Features failed.' if
|
88
|
+
Interaction.fail 'Features failed.' if i == options.rerun # All reruns done?
|
89
89
|
|
90
|
-
announce "Rerun ##{
|
91
|
-
break if Geordi::Cucumber.new.run([], cmd_opts, :
|
90
|
+
Interaction.announce "Rerun ##{i + 1} of #{options.rerun}"
|
91
|
+
break if Geordi::Cucumber.new.run([], cmd_opts, verbose: options.verbose, parallel: false)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
success 'Features green.'
|
95
|
+
Interaction.success 'Features green.'
|
96
96
|
|
97
97
|
else
|
98
|
-
note 'Cucumber not employed.'
|
98
|
+
Interaction.note 'Cucumber not employed.'
|
99
99
|
end
|
100
100
|
end
|
@@ -12,32 +12,32 @@ LONGDESC
|
|
12
12
|
|
13
13
|
def delete_dumps(dump_directory = nil)
|
14
14
|
deletable_dumps = []
|
15
|
-
if dump_directory.nil?
|
16
|
-
|
15
|
+
dump_directories = if dump_directory.nil?
|
16
|
+
[
|
17
17
|
File.join(Dir.home, 'dumps'),
|
18
|
-
Dir.pwd
|
18
|
+
Dir.pwd,
|
19
19
|
]
|
20
20
|
else
|
21
|
-
|
21
|
+
[dump_directory]
|
22
22
|
end
|
23
|
-
announce 'Looking for *.dump in ' << dump_directories.join(',')
|
23
|
+
Interaction.announce 'Looking for *.dump in ' << dump_directories.join(',')
|
24
24
|
dump_directories.each do |d|
|
25
|
-
|
26
|
-
unless File.directory? File.realdirpath(
|
27
|
-
warn "Directory #{
|
25
|
+
d_2 = File.expand_path(d)
|
26
|
+
unless File.directory? File.realdirpath(d_2)
|
27
|
+
Interaction.warn "Directory #{d_2} does not exist"
|
28
28
|
next
|
29
29
|
end
|
30
|
-
deletable_dumps.concat(Dir.glob("#{
|
30
|
+
deletable_dumps.concat(Dir.glob("#{d_2}/**/*.dump"))
|
31
31
|
end
|
32
32
|
if deletable_dumps.empty?
|
33
|
-
success 'No dumps to delete' if deletable_dumps.empty?
|
33
|
+
Interaction.success 'No dumps to delete' if deletable_dumps.empty?
|
34
34
|
exit 0
|
35
35
|
end
|
36
36
|
deletable_dumps.uniq!.sort!
|
37
|
-
note 'The following dumps can be deleted:'
|
37
|
+
Interaction.note 'The following dumps can be deleted:'
|
38
38
|
puts
|
39
39
|
puts deletable_dumps
|
40
|
-
prompt
|
40
|
+
Interaction.prompt('Delete those dumps', 'n', /y|yes/) || raise('Cancelled.')
|
41
41
|
deletable_dumps.each do |dump|
|
42
42
|
File.delete dump unless File.directory? dump
|
43
43
|
end
|
@@ -30,25 +30,25 @@ instead of `cap deploy:migrations`. You can force using `deploy` by passing the
|
|
30
30
|
-M option: `geordi deploy -M staging`.
|
31
31
|
LONGDESC
|
32
32
|
|
33
|
-
option :no_migrations, :
|
34
|
-
:
|
35
|
-
option :current_branch, :
|
36
|
-
:
|
33
|
+
option :no_migrations, aliases: '-M', type: :boolean,
|
34
|
+
desc: 'Run cap deploy instead of cap deploy:migrations'
|
35
|
+
option :current_branch, aliases: '-c', type: :boolean,
|
36
|
+
desc: 'Set DEPLOY_BRANCH to the current branch during deploy'
|
37
37
|
|
38
38
|
def deploy(target_stage = nil)
|
39
39
|
# Set/Infer default values
|
40
|
-
branch_stage_map = { 'master' => 'staging', 'production' => 'production'}
|
41
|
-
if target_stage
|
40
|
+
branch_stage_map = { 'master' => 'staging', 'production' => 'production' }
|
41
|
+
if target_stage && !Util.deploy_targets.include?(target_stage)
|
42
42
|
# Target stage autocompletion from available stages
|
43
43
|
target_stage = Util.deploy_targets.find { |t| t.start_with? target_stage }
|
44
|
-
target_stage || warn('Given deployment stage not found')
|
44
|
+
target_stage || Interaction.warn('Given deployment stage not found')
|
45
45
|
end
|
46
46
|
|
47
47
|
# Ask for required information
|
48
|
-
target_stage ||= prompt 'Deployment stage:', branch_stage_map.fetch(Util.current_branch, 'staging')
|
48
|
+
target_stage ||= Interaction.prompt 'Deployment stage:', branch_stage_map.fetch(Util.current_branch, 'staging')
|
49
49
|
if options.current_branch
|
50
50
|
stage_file = "config/deploy/#{target_stage}.rb"
|
51
|
-
Util.file_containing?
|
51
|
+
Util.file_containing?(stage_file, 'DEPLOY_BRANCH') || Interaction.fail(<<-ERROR)
|
52
52
|
To deploy from the current branch, configure #{stage_file} to respect the
|
53
53
|
environment variable DEPLOY_BRANCH. Example:
|
54
54
|
|
@@ -57,38 +57,38 @@ set :branch, ENV['DEPLOY_BRANCH'] || 'master'
|
|
57
57
|
|
58
58
|
source_branch = target_branch = Util.current_branch
|
59
59
|
else
|
60
|
-
source_branch = prompt 'Source branch:', Util.current_branch
|
61
|
-
target_branch = prompt 'Deploy branch:', branch_stage_map.invert.fetch(target_stage, 'master')
|
60
|
+
source_branch = Interaction.prompt 'Source branch:', Util.current_branch
|
61
|
+
target_branch = Interaction.prompt 'Deploy branch:', branch_stage_map.invert.fetch(target_stage, 'master')
|
62
62
|
end
|
63
63
|
|
64
64
|
merge_needed = (source_branch != target_branch)
|
65
65
|
push_needed = merge_needed || `git cherry -v | wc -l`.strip.to_i > 0
|
66
66
|
push_needed = false if Util.testing? # Hard to test
|
67
67
|
|
68
|
-
announce "Checking whether your #{source_branch} branch is ready" ############
|
68
|
+
Interaction.announce "Checking whether your #{source_branch} branch is ready" ############
|
69
69
|
Util.system! "git checkout #{source_branch}"
|
70
|
-
if `git status -s | wc -l`.strip != '0'
|
71
|
-
warn "Your #{source_branch} branch holds uncommitted changes."
|
72
|
-
prompt('Continue anyway?', 'n', /y|yes/)
|
70
|
+
if (`git status -s | wc -l`.strip != '0') && !Util.testing?
|
71
|
+
Interaction.warn "Your #{source_branch} branch holds uncommitted changes."
|
72
|
+
Interaction.prompt('Continue anyway?', 'n', /y|yes/) || raise('Cancelled.')
|
73
73
|
else
|
74
|
-
note 'All good.'
|
74
|
+
Interaction.note 'All good.'
|
75
75
|
end
|
76
76
|
|
77
77
|
if merge_needed
|
78
|
-
announce "Checking what's in your #{target_branch} branch right now" #######
|
78
|
+
Interaction.announce "Checking what's in your #{target_branch} branch right now" #######
|
79
79
|
Util.system! "git checkout #{target_branch} && git pull"
|
80
80
|
end
|
81
81
|
|
82
|
-
announce 'You are about to:' #################################################
|
83
|
-
note "Merge branch #{source_branch} into #{target_branch}" if merge_needed
|
82
|
+
Interaction.announce 'You are about to:' #################################################
|
83
|
+
Interaction.note "Merge branch #{source_branch} into #{target_branch}" if merge_needed
|
84
84
|
if push_needed
|
85
|
-
note 'Push these commits:' if push_needed
|
85
|
+
Interaction.note 'Push these commits:' if push_needed
|
86
86
|
Util.system! "git --no-pager log origin/#{target_branch}..#{source_branch} --oneline"
|
87
87
|
end
|
88
|
-
note "Deploy to #{target_stage}"
|
89
|
-
note "From current branch #{source_branch}" if options.current_branch
|
88
|
+
Interaction.note "Deploy to #{target_stage}"
|
89
|
+
Interaction.note "From current branch #{source_branch}" if options.current_branch
|
90
90
|
|
91
|
-
if prompt('Go ahead with the deployment?', 'n', /y|yes/)
|
91
|
+
if Interaction.prompt('Go ahead with the deployment?', 'n', /y|yes/)
|
92
92
|
puts
|
93
93
|
git_call = []
|
94
94
|
git_call << "git merge #{source_branch}" if merge_needed
|
@@ -100,17 +100,16 @@ set :branch, ENV['DEPLOY_BRANCH'] || 'master'
|
|
100
100
|
capistrano_call = "DEPLOY_BRANCH=#{source_branch} #{capistrano_call}" if options.current_branch
|
101
101
|
|
102
102
|
if git_call.any?
|
103
|
-
Util.system! git_call.join(' && '), :
|
103
|
+
Util.system! git_call.join(' && '), show_cmd: true
|
104
104
|
end
|
105
105
|
|
106
106
|
invoke_cmd 'bundle_install'
|
107
107
|
|
108
|
-
Util.system! capistrano_call, :
|
108
|
+
Util.system! capistrano_call, show_cmd: true
|
109
109
|
|
110
|
-
success 'Deployment complete.'
|
110
|
+
Interaction.success 'Deployment complete.'
|
111
111
|
else
|
112
112
|
Util.system! "git checkout #{source_branch}"
|
113
|
-
fail 'Deployment cancelled.'
|
113
|
+
Interaction.fail 'Deployment cancelled.'
|
114
114
|
end
|
115
|
-
|
116
115
|
end
|