geordi 3.0.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/CHANGELOG.md +36 -2
  4. data/Gemfile.lock +1 -1
  5. data/README.md +46 -3
  6. data/lib/geordi/COMMAND_TEMPLATE +2 -3
  7. data/lib/geordi/chromedriver_updater.rb +7 -8
  8. data/lib/geordi/cli.rb +0 -1
  9. data/lib/geordi/commands/_setup_vnc.rb +22 -22
  10. data/lib/geordi/commands/bundle_install.rb +1 -1
  11. data/lib/geordi/commands/capistrano.rb +4 -4
  12. data/lib/geordi/commands/clean.rb +6 -5
  13. data/lib/geordi/commands/commit.rb +1 -1
  14. data/lib/geordi/commands/console.rb +11 -3
  15. data/lib/geordi/commands/create_database_yml.rb +2 -2
  16. data/lib/geordi/commands/create_databases.rb +1 -1
  17. data/lib/geordi/commands/cucumber.rb +16 -9
  18. data/lib/geordi/commands/delete_dumps.rb +5 -5
  19. data/lib/geordi/commands/deploy.rb +19 -19
  20. data/lib/geordi/commands/drop_databases.rb +3 -3
  21. data/lib/geordi/commands/dump.rb +8 -9
  22. data/lib/geordi/commands/firefox.rb +2 -2
  23. data/lib/geordi/commands/migrate.rb +3 -3
  24. data/lib/geordi/commands/png_optimize.rb +5 -5
  25. data/lib/geordi/commands/rake.rb +1 -1
  26. data/lib/geordi/commands/remove_executable_flags.rb +2 -2
  27. data/lib/geordi/commands/rspec.rb +5 -5
  28. data/lib/geordi/commands/security_update.rb +76 -19
  29. data/lib/geordi/commands/server.rb +2 -2
  30. data/lib/geordi/commands/setup.rb +3 -3
  31. data/lib/geordi/commands/shell.rb +7 -3
  32. data/lib/geordi/commands/tests.rb +1 -1
  33. data/lib/geordi/commands/unit.rb +2 -2
  34. data/lib/geordi/commands/update.rb +2 -2
  35. data/lib/geordi/commands/with_rake.rb +2 -2
  36. data/lib/geordi/commands/yarn_install.rb +1 -1
  37. data/lib/geordi/cucumber.rb +18 -17
  38. data/lib/geordi/db_cleaner.rb +21 -22
  39. data/lib/geordi/dump_loader.rb +5 -4
  40. data/lib/geordi/firefox_for_selenium.rb +17 -19
  41. data/lib/geordi/gitpt.rb +10 -53
  42. data/lib/geordi/interaction.rb +2 -6
  43. data/lib/geordi/remote.rb +17 -6
  44. data/lib/geordi/settings.rb +155 -0
  45. data/lib/geordi/util.rb +14 -9
  46. data/lib/geordi/version.rb +1 -1
  47. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bcd8074a50a0c81d4e0b7e2beaef07e8508018a494ae9b3cc288bb29c0b9e796
4
- data.tar.gz: a8091353e0d315e6e37f93227688a89d74b7b01abcf4d4a4339271aaaf65e50a
3
+ metadata.gz: e775f88b224275cf01077937ba959b27666c1ae7ac18b58548a62bfa31161a12
4
+ data.tar.gz: 4e0efdb89bbf65b69a9753e8e05978b094915b613b1ded6ef1c1ea4716be0ea7
5
5
  SHA512:
6
- metadata.gz: b6147e0cbddbcba812f1ea87f03544c0cefd6f40f766b6971275ec5c8efb25f307d47623508bb2990b7cdbd88ed540c51de51920faa59236e5a2034b2cfa9d68
7
- data.tar.gz: '078962b0bac78764315e54f2f104354966cc775f18bd9a6d514069c8972bcf3dd4c96cb8b58e0ddf42b233032c12c7d00eb3af24b67970548bb297915d7394b7'
6
+ metadata.gz: 56146e32a18966efbe63a58074d158b888410cf19520150d175f3220be709820b7b05ed6f95df5f80993ed163ba9b59232f1d1f67c3bd43d2055e9b2d66cd812
7
+ data.tar.gz: e8e41bb61713a5f32dd4039cadee5b11a9f08bac20cad738e61975ea741bfd76cdf5e2d64a166579e701eda472f95f4f8ce15da27181fa0a8b11b748f5d222d3
data/.gitignore CHANGED
@@ -3,6 +3,5 @@
3
3
  .idea
4
4
  pkg/*
5
5
  .DS_Store
6
- .pt_project_id
7
6
  tmp
8
7
  .byebug_history
@@ -1,4 +1,5 @@
1
1
  # Changelog
2
+
2
3
  All notable changes to this project will be documented in this file.
3
4
 
4
5
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
@@ -7,13 +8,46 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
7
8
  ## Unreleased
8
9
 
9
10
  ### Compatible changes
10
-
11
11
  ### Breaking changes
12
12
 
13
13
 
14
- ## 3.0.0 2020-05-04
14
+ ## 3.2.0 2020-07-15
15
+
16
+ ### Compatible changes
17
+ - Improvement #43: `--select-server` option on `geordi shell` and `geordi console` can take the number of the server to connect to it directly and to skip the menu.
18
+ - Add a `.geordi.yml` file to change multiple settings in the project and `~/.config/geordi/global.yml` for global settings.
19
+ - Deprecated the `.pt_project_id` file in favor of `.geordi.yml`.
20
+ - Deprecated the `~/.gitpt` file in favor of `~/.config/geordi/global.yml`.
21
+ - Add #91: Now there is an option to start cucumber without a VNC session. This is configured by the .geordi.yml file.
22
+ - Fixed `git#staged_changes?` detection on Ruby < 2.5.
23
+
24
+
25
+ ## 3.1.0 2020-06-03
26
+
27
+ ### Compatible changes
28
+ - Update security-update for improved workflow (#89): Deploy staging first and ask user, if application is still running. Then deploy other stages.
29
+
30
+
31
+ ## 3.0.3 2020-05-27
15
32
 
16
33
  ### Compatible changes
34
+ - Fix #98: Changing the `config/database.yml` reader from `YAML.load` to `YAML.safe_load` dropped the support for aliases. We now allow aliases and the classes `Time` and `Symbol`. If we encounter further issues with this approach a revert to `YAML.load` would be an option, too.
35
+
36
+
37
+ ## 3.0.2 2020-05-18
38
+
39
+ ### Compatible changes
40
+ - Fix #95: Method change from `! *.include?` to `*.exclude?` was not valid as we do not have active support in Geordi. Affected commands were `geordi cucumber` and `geordi deploy`.
41
+
42
+
43
+ ## 3.0.1 2020-05-13
44
+
45
+ ### Compatible changes
46
+ - Fix #93: Using `$CHILDSTATUS` instead of `$?` did not work properly. This affected commands like `geordi drop-databases` to fail.
47
+ - Fix #92: Geordi fail messages were converted to exceptions by accident. Now they are printed as red error message without the backtrace again.
48
+
49
+
50
+ ## 3.0.0 2020-05-04
17
51
 
18
52
  ### Breaking changes
19
53
  - Remove support for Ruby 1.8.7 and Ruby 1.9.3. Bug fixes might still be backported to 2.x, but we will not add any features to 2.x anymore. Please consider to upgrade the Ruby version of your project.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (3.0.0)
4
+ geordi (3.2.0)
5
5
  thor (~> 1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -54,8 +54,13 @@ Commit using a story title from Pivotal Tracker.
54
54
 
55
55
  Example: `geordi commit`
56
56
 
57
+ Any extra arguments are forwarded to `git commit -m <message>`.
58
+
59
+ If there are no staged changes, prints a warning but will continue to create
60
+ an empty commit.
61
+
57
62
  On the first execution we ask for your Pivotal Tracker API token. It will be
58
- stored in `~/.gitpt`.
63
+ stored in `~/.config/geordi/global.yml`.
59
64
 
60
65
 
61
66
  ### `geordi console [TARGET]`
@@ -66,6 +71,14 @@ Open a local Rails console: `geordi console`
66
71
 
67
72
  Open a Rails console on `staging`: `geordi console staging`
68
73
 
74
+ Lets you select the server to connect to from a menu when called with `--select-server` or the alias `-s`:
75
+
76
+ geordi console staging -s
77
+
78
+ If you already know the number of the server you want to connect to, just pass it along:
79
+
80
+ geordi console staging -s2
81
+
69
82
 
70
83
  ### `geordi cucumber [FILES and OPTIONS]`
71
84
 
@@ -87,6 +100,12 @@ or `-d`.
87
100
  - *Options:* Any unknown option will be passed through to Cucumber,
88
101
  e.g. `--format pretty`.
89
102
 
103
+ - *VNC:* By default, test browsers will run in a VNC session. When using a
104
+ headless test browser anyway, you can disable VNC by putting the following
105
+ config into `.geordi.yml` in the project root:
106
+
107
+ use_vnc: false
108
+
90
109
 
91
110
  ### `geordi delete-dumps [DIRECTORY]`
92
111
 
@@ -255,10 +274,30 @@ Support for performing security updates.
255
274
 
256
275
  Preparation for security update: `geordi security-update`
257
276
 
277
+ Checks out production and pulls.
278
+
258
279
  After performing the update: `geordi security-update finish`
259
280
 
260
281
  Switches branches, pulls, pushes and deploys as required by our workflow. Tells
261
- what it will do before it does it.
282
+ what it will do before it does it. In detail:
283
+
284
+ 1. Asks user, if tests are green
285
+
286
+ 2. Pushes production
287
+
288
+ 3. Checks out master and pulls
289
+
290
+ 4. Merges production and pushes in master
291
+
292
+ 5. Deploys staging first, if there is a staging environment
293
+
294
+ 6. Asks user, if deployment log is okay and application is still running on staging
295
+
296
+ 7. Deploys other stages
297
+
298
+ 8. Asks user, if deployment log is okay and application is still running on all other stages
299
+
300
+ 9. Informs user about the next steps
262
301
 
263
302
 
264
303
  ### `geordi server [PORT]`
@@ -295,10 +334,14 @@ Open a shell on a Capistrano deploy target.
295
334
 
296
335
  Example: `geordi shell production`
297
336
 
298
- Lets you select the server to connect to when called with `--select-server`:
337
+ Lets you select the server to connect to from a menu when called with `--select-server` or the alias `-s`:
299
338
 
300
339
  geordi shell production -s
301
340
 
341
+ If you already know the number of the server you want to connect to, just pass it along:
342
+
343
+ geordi shell production -s2
344
+
302
345
 
303
346
  ### `geordi tests`
304
347
 
@@ -21,10 +21,9 @@ def example
21
21
  # Invoke other commands like this:
22
22
  invoke_cmd 'other_command', 'argument', an: 'option'
23
23
 
24
- fail 'Option missing' unless options.opt?
24
+ Interaction.fail 'Option missing' unless options.opt?
25
25
 
26
- # For formatted output, see geordi/interaction.rb
27
- success 'Done.'
26
+ Interaction.success 'Done.'
28
27
  end
29
28
 
30
29
  # Command mappings, usually not needed
@@ -4,14 +4,13 @@ require 'tempfile'
4
4
 
5
5
  module Geordi
6
6
  class ChromedriverUpdater
7
- include Geordi::Interaction
8
7
 
9
8
  def run
10
9
  chrome_version = determine_chrome_version
11
10
  chromedriver_version = determine_chromedriver_version
12
11
 
13
12
  if skip_update?(chrome_version, chromedriver_version)
14
- warn("No update required, you are using for both executables the same version #{chrome_version}!")
13
+ Interaction.warn("No update required, you are using for both executables the same version #{chrome_version}!")
15
14
  else
16
15
  chromedriver_zip = download_chromedriver(chrome_version)
17
16
  unzip(chromedriver_zip, File.expand_path('~/bin'))
@@ -19,7 +18,7 @@ module Geordi
19
18
  chromedriver_zip.unlink
20
19
 
21
20
  # We need to determine the version again, as it could be nil in case no chromedriver was installed before
22
- note "Chromedriver updated to version #{determine_chromedriver_version}"
21
+ Interaction.note "Chromedriver updated to version #{determine_chromedriver_version}"
23
22
  end
24
23
  end
25
24
 
@@ -32,7 +31,7 @@ module Geordi
32
31
  end
33
32
 
34
33
  if !status.success? || chrome_version.nil?
35
- raise('Could not determine the current Google Chrome version')
34
+ Interaction.fail('Could not determine the current Google Chrome version')
36
35
  else
37
36
  chrome_version.to_i
38
37
  end
@@ -47,7 +46,7 @@ module Geordi
47
46
  end
48
47
 
49
48
  if !status.success? || chromedriver_version.nil?
50
- raise('Could not determine the current chromedriver version')
49
+ Interaction.fail('Could not determine the current chromedriver version')
51
50
  else
52
51
  chromedriver_version.to_i
53
52
  end
@@ -69,7 +68,7 @@ module Geordi
69
68
 
70
69
  file
71
70
  else
72
- raise("Could not download chromedriver version #{latest_version}")
71
+ Interaction.fail("Could not download chromedriver version #{latest_version}")
73
72
  end
74
73
  end
75
74
 
@@ -80,7 +79,7 @@ module Geordi
80
79
  if response.is_a?(Net::HTTPSuccess)
81
80
  response.body.to_s
82
81
  else
83
- raise("Could not find the latest version for Google Chrome version #{chrome_version}")
82
+ Interaction.fail("Could not find the latest version for Google Chrome version #{chrome_version}")
84
83
  end
85
84
  end
86
85
 
@@ -88,7 +87,7 @@ module Geordi
88
87
  _stdout_str, _error_str, status = Open3.capture3('unzip', '-d', output_dir, '-o', zip.path)
89
88
 
90
89
  unless status.success?
91
- raise("Could not unzip #{zip.path}")
90
+ Interaction.fail("Could not unzip #{zip.path}")
92
91
  end
93
92
  end
94
93
  end
@@ -5,7 +5,6 @@ require 'geordi/util'
5
5
 
6
6
  module Geordi
7
7
  class CLI < Thor
8
- include Geordi::Interaction
9
8
 
10
9
  def self.exit_on_failure?
11
10
  true
@@ -2,33 +2,33 @@ 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
@@ -1,7 +1,7 @@
1
1
  desc 'bundle-install', 'Run bundle install if required', hide: true
2
2
  def bundle_install
3
3
  if File.exist?('Gemfile') && !system('bundle check > /dev/null 2>&1')
4
- announce 'Bundling'
4
+ Interaction.announce 'Bundling'
5
5
  Util.system! 'bundle install'
6
6
  end
7
7
  end
@@ -6,16 +6,16 @@ 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/) || raise('Cancelled.')
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
20
  Util.system!(command, fail_message: 'Capistrano failed. Have a look!')
21
21
  end
@@ -1,14 +1,15 @@
1
1
  desc 'clean', 'Remove unneeded files from the current directory'
2
2
  def clean
3
- announce 'Removing tempfiles'
4
- %w[webrat-* capybara-* tmp/webrat-* tmp/capybara-* tmp/rtex/* log/*.log].each do |pattern|
5
- note pattern
3
+
4
+ Interaction.announce 'Removing tempfiles'
5
+ for pattern in %w[ webrat-* capybara-* tmp/webrat-* tmp/capybara-* tmp/rtex/* log/*.log ]
6
+ Interaction.note pattern
6
7
  puts `rm -vfR #{pattern}`
7
8
  end
8
9
 
9
- announce 'Finding recursively and removing backup files'
10
+ Interaction.announce 'Finding recursively and removing backup files'
10
11
  %w[*~].each do |pattern|
11
- note pattern
12
+ Interaction.note pattern
12
13
  `find . -name #{pattern} -exec rm {} ';'`
13
14
  end
14
15
  end
@@ -9,7 +9,7 @@ If there are no staged changes, prints a warning but will continue to create
9
9
  an empty commit.
10
10
 
11
11
  On the first execution we ask for your Pivotal Tracker API token. It will be
12
- stored in `~/.gitpt`.
12
+ stored in `~/.config/geordi/global.yml`.
13
13
  LONGDESC
14
14
 
15
15
  def commit(*git_args)
@@ -3,10 +3,18 @@ long_desc <<-LONGDESC
3
3
  Open a local Rails console: `geordi console`
4
4
 
5
5
  Open a Rails console on `staging`: `geordi console staging`
6
+
7
+ Lets you select the server to connect to from a menu when called with `--select-server` or the alias `-s`:
8
+
9
+ geordi console staging -s
10
+
11
+ If you already know the number of the server you want to connect to, just pass it along:
12
+
13
+ geordi console staging -s2
6
14
  LONGDESC
7
15
 
8
16
 
9
- option :select_server, default: false, type: :boolean, aliases: '-s'
17
+ option :select_server, type: :string, aliases: '-s'
10
18
 
11
19
  def console(target = 'development', *_args)
12
20
  require 'geordi/remote'
@@ -14,11 +22,11 @@ def console(target = 'development', *_args)
14
22
  if target == 'development'
15
23
  invoke_cmd 'yarn_install'
16
24
 
17
- announce 'Opening a local Rails console'
25
+ Interaction.announce 'Opening a local Rails console'
18
26
 
19
27
  Util.system! Util.console_command(target)
20
28
  else
21
- announce 'Opening a Rails console on ' + target
29
+ Interaction.announce 'Opening a Rails console on ' + target
22
30
 
23
31
  Geordi::Remote.new(target).console(options)
24
32
  end