geordi 2.8.0 → 2.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d495c07776a3b37bbc4a8a631fefc1faef059e39622bbb7d23ea7ae80e422a5d
4
- data.tar.gz: 59e32fcc08b223576f916b32e39f11444474d3815add10cb8df8ea290b4beb49
3
+ metadata.gz: 5ae46d6ac8d8dd9bf53654f65445df1d0c576833db47db589b76e94cbb5784c0
4
+ data.tar.gz: 0034075de2f4f848686463486854cfaaee3980918048ce3480c3d6dc50634f0b
5
5
  SHA512:
6
- metadata.gz: e8090e437315b256f12e64dfff74b52d96734417af94d46dd5303aa74a41d2bf45b47d7abbb9d483f7f8794052e6bebaed336a0320c242b9a1c4eecfdde4cf69
7
- data.tar.gz: bb359062fd81a8129bd48b3548bb4db513e6211bc1740003082e759d6cc5a3ba10abbf0db4e2d9a515c181b9b15b15950eafe9d733104a00e1f0789c20400750
6
+ metadata.gz: c52e541c8204de7e79e2935211251001b9992898770632eca578678eae5b58d4d8edb5c64b2ec82fa4f797109adc76091f9293a4bd2e3a0567c1a65a050791ab
7
+ data.tar.gz: 63bdba922fb2eaccd2edd3fffe233abc67fce88587606fea218685b4ee682181ea5f8c6daf728227dfa736d838327eef6f1ae930f67dec056dcd6c23fb0d6a85
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ pkg/*
5
5
  .DS_Store
6
6
  .pt_project_id
7
7
  tmp
8
+ .byebug_history
@@ -5,10 +5,44 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
5
5
 
6
6
 
7
7
  ## Unreleased
8
+
9
+ ### Compatible changes
10
+
11
+ ### Breaking changes
12
+
13
+
14
+ ## 2.11.0 2020-05-04
15
+
8
16
  ### Compatible changes
17
+ - Added the possibility to change the Rails root for the capistrano config via the environment variable `RAILS_ROOT`. This allows you as a gem developer to run a command like `RAILS_ROOT=~/Projects/my-blog geordi console staging` whereas `geordi` uses the capistrano config from `my-blog`. Otherwise you would need to follow the instructions of [this card](https://makandracards.com/makandra/46617-how-to-use-a-local-gem-in-your-gemfile) to test changes in the gem locally.
18
+ - Bug fix for "no staged changes" even if there are changes present (#83).
19
+ - Fixed deprecation warning for `Thor exit with status 0 on errors` (#84).
20
+ - Replaced `Bundler.with_unbundled_env` with `Bundler.with_original_env` (#77). This is a better replacement than 42cd1c4.
21
+ - Add deprecation warning `Deprecation warning: Ruby 1.8.7 and 1.9.3 support will be dropped in Geordi 3.x.` to Geordi 2.
22
+ - Fix error `thor requires Ruby version >= 2.0.0` for Ruby 1.8.7 and 1.9.3 (https://github.com/makandra/geordi/issues/79#issuecomment-598664191).
23
+
9
24
  ### Breaking changes
10
25
 
11
26
 
27
+ ## 2.10.1 2020-02-17
28
+
29
+ ### Compatible changes
30
+ - Add host parameter to mysql dump loader
31
+
32
+ ## 2.10.0 2020-02-11
33
+
34
+ ### Compatible changes
35
+ - Fixes [#78](https://github.com/makandra/geordi/pull/78): Add compatibility for more than 9 CPU cores in
36
+ `geordi drop-databases`.
37
+
38
+
39
+ ## 2.9.0 2020-01-03
40
+
41
+ ### Compatible changes
42
+ - Fixes [#37](https://github.com/makandra/geordi/issues/37): `geordi cucumber` crashes with `--format=pretty`
43
+ - Fixes [#27](https://github.com/makandra/geordi/issues/27): Cucumber rerun switch does work when passing files
44
+
45
+
12
46
  ## 2.8.0 2020-01-02
13
47
 
14
48
  ### Compatible changes
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source 'http://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'aruba'
7
+ gem 'contracts', '=0.9'
7
8
  gem 'rspec-mocks'
8
9
  gem 'highline'
9
10
  gem 'parallel_tests'
@@ -1,62 +1,65 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (2.8.0)
5
- thor (>= 0.18.0)
4
+ geordi (2.12.0)
5
+ thor (~> 0.18.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  addressable (2.3.8)
11
- aruba (0.6.2)
12
- childprocess (>= 0.3.6)
13
- cucumber (>= 1.1.1)
14
- rspec-expectations (>= 2.7.0)
11
+ aruba (0.8.1)
12
+ childprocess (~> 0.5.6)
13
+ contracts (~> 0.9)
14
+ cucumber (>= 1.3.19)
15
+ rspec-expectations (>= 2.99)
15
16
  axiom-types (0.1.1)
16
17
  descendants_tracker (~> 0.0.4)
17
18
  ice_nine (~> 0.11.0)
18
19
  thread_safe (~> 0.3, >= 0.3.1)
19
- builder (3.2.3)
20
- childprocess (1.0.1)
21
- rake (< 13.0)
22
- coderay (1.1.2)
20
+ builder (3.2.4)
21
+ childprocess (0.5.9)
22
+ ffi (~> 1.0, >= 1.0.11)
23
+ coderay (1.1.3)
23
24
  coercible (1.0.0)
24
25
  descendants_tracker (~> 0.0.1)
26
+ contracts (0.9)
25
27
  cucumber (1.3.20)
26
28
  builder (>= 2.1.2)
27
29
  diff-lcs (>= 1.1.3)
28
30
  gherkin (~> 2.12)
29
31
  multi_json (>= 1.7.5, < 2.0)
30
32
  multi_test (>= 0.1.2)
31
- declarative (0.0.10)
33
+ declarative (0.0.20)
32
34
  declarative-option (0.1.0)
33
35
  descendants_tracker (0.0.4)
34
36
  thread_safe (~> 0.3, >= 0.3.1)
35
37
  diff-lcs (1.2.5)
36
38
  equalizer (0.0.11)
37
- excon (0.67.0)
38
- faraday (0.17.0)
39
+ excon (0.78.0)
40
+ faraday (1.1.0)
39
41
  multipart-post (>= 1.2, < 3)
40
- faraday_middleware (0.13.1)
41
- faraday (>= 0.7.4, < 1.0)
42
+ ruby2_keywords
43
+ faraday_middleware (1.0.0)
44
+ faraday (~> 1.0)
45
+ ffi (1.9.18)
42
46
  gherkin (2.12.2)
43
47
  multi_json (~> 1.3)
44
48
  highline (1.6.21)
45
49
  ice_nine (0.11.2)
46
50
  launchy (2.4.3)
47
51
  addressable (~> 2.3)
48
- method_source (0.9.2)
49
- mimemagic (0.3.3)
50
- multi_json (1.13.1)
52
+ method_source (1.0.0)
53
+ mimemagic (0.3.5)
54
+ multi_json (1.15.0)
51
55
  multi_test (0.1.2)
52
56
  multipart-post (2.1.1)
53
57
  parallel (0.5.16)
54
58
  parallel_tests (0.6.18)
55
59
  parallel
56
- pry (0.12.2)
57
- coderay (~> 1.1.0)
58
- method_source (~> 0.9.0)
59
- rake (10.5.0)
60
+ pry (0.13.1)
61
+ coderay (~> 1.1)
62
+ method_source (~> 1.0)
60
63
  representable (3.0.4)
61
64
  declarative (< 0.1.0)
62
65
  declarative-option (< 0.2.0)
@@ -68,9 +71,10 @@ GEM
68
71
  diff-lcs (>= 1.2.0, < 2.0)
69
72
  rspec-support (~> 3.4.0)
70
73
  rspec-support (3.4.1)
71
- thor (0.20.3)
74
+ ruby2_keywords (0.0.2)
75
+ thor (0.18.1)
72
76
  thread_safe (0.3.6)
73
- tracker_api (1.10.0)
77
+ tracker_api (1.11.0)
74
78
  addressable
75
79
  equalizer
76
80
  excon
@@ -92,6 +96,7 @@ PLATFORMS
92
96
 
93
97
  DEPENDENCIES
94
98
  aruba
99
+ contracts (= 0.9)
95
100
  geordi!
96
101
  highline
97
102
  launchy
data/README.md CHANGED
@@ -54,6 +54,11 @@ 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
63
  stored in `~/.gitpt`.
59
64
 
@@ -135,6 +140,23 @@ instead of `cap deploy:migrations`. You can force using `deploy` by passing the
135
140
  -M option: `geordi deploy -M staging`.
136
141
 
137
142
 
143
+ ### `geordi docker`
144
+
145
+ Manage docker containers for the current project.
146
+
147
+ Manage docker containers to run your project dockerized.
148
+
149
+ It expects a docker-compose file that specifies all services, and a service
150
+ named "main" that opens a shell for the project.
151
+
152
+ There are two subcommands:
153
+
154
+ - geordi docker setup
155
+ Builds all docker containers.
156
+ - geordi docker shell
157
+ Runs the docker service named 'main'.
158
+
159
+
138
160
  ### `geordi drop-databases`
139
161
 
140
162
  Interactively delete local databases.
@@ -385,6 +407,9 @@ calling your local geordi like so (adjust paths to your needs):
385
407
 
386
408
  # @option -I: add directory to load path
387
409
  ruby -I ../geordi/lib ../geordi/bin/geordi <command>
410
+
411
+ # with debugger
412
+ ruby -r byebug -I ../geordi/lib ../geordi/bin/geordi <command>
388
413
 
389
414
  Don't forget to update this README. The whole `geordi` section is auto-generated
390
415
  by `rake readme`. Also remember to add your changes to the CHANGELOG.
data/bin/geordi CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+
3
5
  require 'geordi/util'
4
6
 
5
7
  Geordi::Util.installing_missing_gems do
@@ -64,6 +64,63 @@ Feature: The cucumber command
64
64
  And the output should contain "Features failed."
65
65
 
66
66
 
67
+ Scenario: A rerun should only consider the specified file
68
+ Note that we need a cucumber.yml to write the rerun.txt and read the rerun.txt for the reruns.
69
+
70
+ Given a file named "features/step_definitions/test_steps.rb" with:
71
+ """
72
+ Given /^this test fails$/ do
73
+ raise
74
+ end
75
+
76
+ Given /^I use puts with text "(.*)"$/ do |ann|
77
+ puts(ann)
78
+ end
79
+ """
80
+ And a file named "features/some.feature" with:
81
+ """
82
+ Feature: Failing feature
83
+ Scenario: Passing scenario
84
+ And I use puts with text "Running passing Feature"
85
+
86
+ Scenario: Failing scenario
87
+ And I use puts with text "Running failing Feature"
88
+ And this test fails
89
+ """
90
+ And an empty file named "tmp/rerun.txt"
91
+ And a file named "cucumber.yml" with:
92
+ """
93
+ <%
94
+ rerun_log = 'tmp/rerun.txt'
95
+ rerun_failures = File.file?(rerun_log) ? File.read(rerun_log).gsub("\n", ' ') : ''
96
+ log_failures = "--format=rerun --out=#{rerun_log}"
97
+ %>
98
+ default: features <%= log_failures %>
99
+ rerun: <%= rerun_failures %> <%= log_failures %>
100
+ """
101
+
102
+ When I run `geordi cucumber --rerun=1 features/some.feature`
103
+ Then the output should contain:
104
+ """
105
+ # Rerun #1 of 1
106
+ > Rerunning failed scenarios
107
+ > Run `geordi vnc` to view the Selenium test browsers
108
+
109
+ Using the rerun profile...
110
+
111
+ Running failing Feature
112
+ .F
113
+
114
+ (::) failed steps (::)
115
+
116
+ (RuntimeError)
117
+ features/some.feature:7:in `And this test fails'
118
+
119
+ Failing Scenarios:
120
+ cucumber -p rerun features/some.feature:5 # Scenario: Failing scenario
121
+ """
122
+
123
+
67
124
  Scenario: Running all features in a given subfolder
68
125
  Given a file named "features/sub/one.feature" with:
69
126
  """
@@ -191,3 +248,14 @@ Feature: The cucumber command
191
248
  When I run `geordi cucumber --containing given`
192
249
  Then the output should contain "Only: features/given.feature"
193
250
  But the output should not contain "other.feature"
251
+
252
+
253
+ Scenario: Passing a format argument will skip the default format for a single run
254
+ Given a file named "features/single.feature" with:
255
+ """
256
+ Feature: Running a single feature
257
+ Scenario: A single scenario
258
+ """
259
+
260
+ When I run `geordi cucumber features/single.feature --format=pretty --verbose`
261
+ Then the output should contain "b cucumber features/single.feature --format pretty"
@@ -0,0 +1,59 @@
1
+ @same-process
2
+ Feature: The docker command
3
+
4
+ Scenario: Setup checks for existence of docker
5
+ Given the docker command cannot find the "docker" binary
6
+ When I run `geordi docker setup`
7
+ Then the output should contain "which docker"
8
+ And the output should contain "x You need to install docker first"
9
+
10
+
11
+ Scenario: Setup checks for existence of docker-compose
12
+ Given the docker command cannot find the "docker-compose" binary
13
+ When I run `geordi docker setup`
14
+ Then the output should contain "which docker-compose"
15
+ And the output should contain "x You need to install docker-compose first"
16
+
17
+
18
+ Scenario: Setup checks for existence of docker-compose.yml
19
+ When I run `geordi docker setup`
20
+ Then the output should contain "x Your project does not seem to be properly set up."
21
+
22
+
23
+ Scenario: Setup checks for service named "main"
24
+ Given a file named "docker-compose.yml" with:
25
+ """
26
+ foo: bar
27
+ """
28
+
29
+ When I run `geordi docker setup`
30
+ Then the output should contain "x Your project does not seem to be properly set up."
31
+
32
+
33
+ Scenario: Setup runs docker-compose build
34
+ Given a file named "docker-compose.yml" with:
35
+ """
36
+ services:
37
+ main: foo
38
+ """
39
+
40
+ When I run `geordi docker setup`
41
+ Then the output should contain "docker-compose build"
42
+
43
+
44
+ Scenario: Shell checks for existence of docker
45
+ Given the docker command cannot find the "docker" binary
46
+ When I run `geordi docker shell`
47
+ Then the output should contain "which docker"
48
+ And the output should contain "x You need to install docker first"
49
+
50
+
51
+ Scenario: Shell runs docker-compose run maiun
52
+ Given a file named "docker-compose.yml" with:
53
+ """
54
+ services:
55
+ main: foo
56
+ """
57
+
58
+ When I run `geordi docker shell`
59
+ Then the output should contain "docker-compose run --service-ports main"
@@ -0,0 +1,10 @@
1
+ Given(/the docker command cannot find the "(.*?)" binary/) do |command|
2
+ require 'geordi/docker'
3
+ expect_any_instance_of(Geordi::Docker).to receive(:mock_run).at_least(:once).and_wrap_original do |original, *args|
4
+ if args[0] =~ /which #{Regexp.escape(command)}/
5
+ false
6
+ else
7
+ original.call(*args)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,60 @@
1
+ require 'aruba/cucumber'
2
+ require 'aruba/in_process'
3
+ require 'geordi/cli'
4
+
5
+ # https://github.com/erikhuda/thor/wiki/Integrating-with-Aruba-In-Process-Runs
6
+ class InProcessCliRunner
7
+
8
+ # Allow everything fun to be injected from the outside while defaulting to normal implementations.
9
+ def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
10
+ @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
11
+ end
12
+
13
+ def execute!
14
+ exit_code = begin
15
+ # Thor accesses these streams directly rather than letting them be injected, so we replace them...
16
+ $stderr = @stderr
17
+ $stdin = @stdin
18
+ $stdout = @stdout
19
+
20
+ # Run our normal Thor app the way we know and love.
21
+ previous_program_name = $PROGRAM_NAME
22
+ $PROGRAM_NAME = 'geordi'
23
+ Geordi::CLI.start(@argv)
24
+
25
+ # Thor::Base#start does not have a return value, assume success if no exception is raised.
26
+ 0
27
+ rescue StandardError => e
28
+ # The ruby interpreter would pipe this to STDERR and exit 1 in the case of an unhandled exception
29
+ b = e.backtrace
30
+ @stderr.puts("#{b.shift}: #{e.message} (#{e.class})")
31
+ @stderr.puts(b.map{|s| "\tfrom #{s}"}.join("\n"))
32
+ 1
33
+ rescue SystemExit => e
34
+ e.status
35
+ ensure
36
+ # add additional cleanup code here
37
+
38
+ $stderr = STDERR
39
+ $stdin = STDIN
40
+ $stdout = STDOUT
41
+ $PROGRAM_NAME = previous_program_name
42
+ end
43
+
44
+ # Proxy our exit code back to the injected kernel.
45
+ @kernel.exit(exit_code)
46
+ end
47
+ end
48
+
49
+ Aruba.configure do |config|
50
+ config.main_class = InProcessCliRunner
51
+ config.command_launcher = :spawn
52
+ end
53
+
54
+ Before('@same-process') do
55
+ aruba.config.command_launcher = :in_process
56
+ end
57
+
58
+ Before do
59
+ @aruba_timeout_seconds = 5
60
+ end
@@ -1,4 +1,5 @@
1
- require 'aruba/cucumber'
1
+ require 'cucumber/rspec/doubles'
2
+
2
3
 
3
4
  if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('1.8.7')
4
5
  require 'pry'
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_runtime_dependency 'thor', '>= 0.18.0'
23
+ s.add_runtime_dependency 'thor', '~> 0.18.0'
24
24
 
25
25
  s.post_install_message = <<-ATTENTION
26
26
  * Binary `geordi` installed
@@ -53,18 +53,21 @@ module Geordi
53
53
  end
54
54
 
55
55
  def find_project_root!
56
- current = Dir.pwd
57
- until File.exists?('Capfile')
58
- Dir.chdir '..'
59
- raise <<-ERROR if current == Dir.pwd
60
- Could not locate Capfile.
61
-
62
- Are you calling me from within a Rails project?
63
- Maybe Capistrano is not installed in this project.
64
- ERROR
65
-
66
- current = Dir.pwd
56
+ current = ENV['RAILS_ROOT'] || Dir.pwd
57
+
58
+ until File.exists?(File.join(current, 'Capfile'))
59
+ if current == '/' || current == '/home' || !File.directory?(current)
60
+ raise <<-ERROR
61
+ Could not locate Capfile.
62
+
63
+ Are you calling me from within a Rails project?
64
+ Maybe Capistrano is not installed in this project.
65
+ ERROR
66
+ else
67
+ current = File.dirname(current)
68
+ end
67
69
  end
70
+
68
71
  current
69
72
  end
70
73
 
@@ -5,8 +5,17 @@ require 'geordi/util'
5
5
 
6
6
  module Geordi
7
7
  class CLI < Thor
8
+
9
+ if Geordi::Util.ruby_version <= Gem::Version.new('2.0.0')
10
+ warn "Deprecation warning: Ruby 1.8.7 and 1.9.3 support will be dropped in Geordi 3.x."
11
+ end
12
+
8
13
  include Geordi::Interaction
9
14
 
15
+ def self.exit_on_failure?
16
+ true
17
+ end
18
+
10
19
  # load all tasks defined in lib/geordi/commands
11
20
  Dir[File.expand_path '../commands/*.rb', __FILE__].each do |file|
12
21
  class_eval File.read(file), file
@@ -88,7 +88,7 @@ def cucumber(*args)
88
88
  fail 'Features failed.' if (i == options.rerun) # All reruns done?
89
89
 
90
90
  announce "Rerun ##{ i + 1 } of #{ options.rerun }"
91
- break if Geordi::Cucumber.new.run(files, cmd_opts, :verbose => options.verbose, :parallel => false)
91
+ break if Geordi::Cucumber.new.run([], cmd_opts, :verbose => options.verbose, :parallel => false)
92
92
  end
93
93
  end
94
94
 
@@ -0,0 +1,36 @@
1
+ class DockerCLI < Thor
2
+ desc 'setup', 'Setup docker and build required docker-container for the current project.'
3
+ def setup
4
+ docker.setup
5
+ end
6
+
7
+ desc 'shell', 'Open a shell in the main docker container for the current project.'
8
+ map 'shell' => '_shell'
9
+ def _shell
10
+ docker.shell
11
+ end
12
+
13
+ private
14
+
15
+ def docker
16
+ require 'geordi/docker'
17
+ Geordi::Docker.new
18
+ end
19
+ end
20
+
21
+ desc 'docker', 'Manage docker containers for the current project.'
22
+ long_desc <<-LONGDESC
23
+ Manage docker containers to run your project dockerized.
24
+
25
+ It expects a docker-compose file that specifies all services, and a service
26
+ named "main" that opens a shell for the project.
27
+
28
+ There are two subcommands:
29
+
30
+ - geordi docker setup
31
+ Builds all docker containers.
32
+ - geordi docker shell
33
+ Runs the docker service named 'main'.
34
+
35
+ LONGDESC
36
+ subcommand 'docker', DockerCLI
@@ -11,12 +11,13 @@ module Geordi
11
11
  include Geordi::Interaction
12
12
 
13
13
  VNC_DISPLAY = ':17'
14
- VNC_SERVER_COMMAND = "vncserver #{VNC_DISPLAY} -localhost -nolisten tcp -SecurityTypes None -geometry 1280x1024"
14
+ VNC_SERVER_DEFAULT_OPTIONS = '-localhost -nolisten tcp -SecurityTypes None -geometry 1280x1024'
15
+ VNC_SERVER_COMMAND = "vncserver #{VNC_DISPLAY} #{ENV.fetch('GEORDI_VNC_OPTIONS', VNC_SERVER_DEFAULT_OPTIONS)}"
15
16
  VNC_VIEWER_COMMAND = "vncviewer #{VNC_DISPLAY}"
16
17
  VNC_ENV_VARIABLES = %w[DISPLAY BROWSER LAUNCHY_BROWSER]
17
18
 
18
19
  def run(files, cucumber_options, options = {})
19
- self.argv = files + cucumber_options
20
+ self.argv = files + cucumber_options.map { |option| option.split('=') }.flatten
20
21
 
21
22
  consolidate_rerun_txt_files
22
23
  show_features_to_run
@@ -12,7 +12,7 @@ module Geordi
12
12
  puts ' and `sudo mysql` for MariaDB (which uses PAM auth)'
13
13
  `sudo true`
14
14
  fail 'sudo access is required for database operations as database users' if $? != 0
15
- @derivative_dbname = /_(test\d?|development|cucumber)$/
15
+ @derivative_dbname = /_(test\d*|development|cucumber)$/
16
16
  base_directory = ENV['XDG_CONFIG_HOME']
17
17
  base_directory = "#{Dir.home}" if base_directory.nil?
18
18
  @whitelist_directory = File.join(base_directory, '.config', 'geordi', 'whitelists')
@@ -34,7 +34,7 @@ module Geordi
34
34
  tmp.write <<-HEREDOC
35
35
  # Put each whitelisted database on a new line.
36
36
  # System databases will never be deleted.
37
- # When you whitelist foo, foo_development and foo_test\\d? are whitelisted, too.
37
+ # When you whitelist foo, foo_development and foo_test\\d* are whitelisted, too.
38
38
  # This works even if foo does not exist. Also, you will only see foo in this list.
39
39
  #
40
40
  # Syntax: keep foo
@@ -253,7 +253,7 @@ HEREDOC
253
253
  # Allow explicit whitelisting of derivative databases like projectname_test2
254
254
  if whitelist_content.include? database_name
255
255
  true
256
- # whitelisting `projectname` also whitelists `projectname_test\d+`, `projectname_development`
256
+ # whitelisting `projectname` also whitelists `projectname_test\d*`, `projectname_development`
257
257
  elsif whitelist_content.include? database_name.sub(@derivative_dbname, '')
258
258
  true
259
259
  else
@@ -0,0 +1,71 @@
1
+ require 'geordi/interaction'
2
+ require 'yaml'
3
+
4
+ module Geordi
5
+ class Docker
6
+ DOCKER_COMPOSE_FILE = 'docker-compose.yml'.freeze
7
+
8
+ include Interaction
9
+
10
+ def setup
11
+ check_installation_and_config
12
+ announce('Building containers...')
13
+ if execute(:system, 'docker-compose', 'build')
14
+ success('Build successful.')
15
+ else
16
+ fail('Build failed.')
17
+ end
18
+ end
19
+
20
+ def shell
21
+ check_installation_and_config
22
+ execute(:exec, 'docker-compose', 'run', '--service-ports', 'main')
23
+ end
24
+
25
+ private
26
+
27
+ def execute(kind, *args)
28
+ if ENV['GEORDI_TESTING']
29
+ puts "Stubbed run #{args.join(' ')}"
30
+ mock_run(*args)
31
+ else
32
+ send(kind, *args)
33
+ end
34
+ end
35
+
36
+ def mock_run(*args)
37
+ # exists just to be stubbed in tests
38
+ true
39
+ end
40
+
41
+ def check_installation_and_config
42
+ unless command_exists?('docker')
43
+ fail('You need to install docker first with `sudo apt install docker`. After installation please log out and back in to your system once.')
44
+ end
45
+
46
+ unless command_exists?('docker-compose')
47
+ fail('You need to install docker-compose first with `sudo apt install docker-compose`.')
48
+ end
49
+
50
+ unless docker_compose_config && (services = docker_compose_config['services']) && services.key?('main')
51
+ fail('Your project does not seem to be properly set up. Expected to find a docker-compose.yml which defines a service named "main".')
52
+ end
53
+ end
54
+
55
+ def command_exists?(command)
56
+ execute(:system, "which #{command} > /dev/null")
57
+ end
58
+
59
+ def docker_compose_config
60
+ if File.exists?(DOCKER_COMPOSE_FILE)
61
+ if YAML.respond_to?(:safe_load)
62
+ YAML.safe_load(File.read(DOCKER_COMPOSE_FILE))
63
+ else
64
+ YAML.load(File.read(DOCKER_COMPOSE_FILE))
65
+ end
66
+ end
67
+ rescue
68
+ false
69
+ end
70
+ end
71
+ end
@@ -18,12 +18,13 @@ module Geordi
18
18
  @config['development']
19
19
  end
20
20
  alias_method :config, :development_database_config
21
-
21
+
22
22
  def mysql_command
23
23
  command = 'mysql --silent'
24
24
  command << ' -p' << config['password'].to_s if config['password']
25
25
  command << ' -u' << config['username'].to_s if config['username']
26
26
  command << ' --port=' << config['port'].to_s if config['port']
27
+ command << ' --host=' << config['host'].to_s if config['host']
27
28
  command << ' --default-character-set=utf8'
28
29
  command << ' ' << config['database'].to_s
29
30
  command << ' < ' << dump_file
@@ -51,8 +51,8 @@ module Geordi
51
51
  # Remove Geordi's Bundler environment when running commands.
52
52
  success = if !defined?(Bundler)
53
53
  system(*commands)
54
- elsif Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.1.2')
55
- Bundler.with_unbundled_env do
54
+ elsif Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('1.17.3')
55
+ Bundler.with_original_env do
56
56
  system(*commands)
57
57
  end
58
58
  else
@@ -94,7 +94,7 @@ module Geordi
94
94
  ENV['GEORDI_TESTING_STAGED_CHANGES'] == 'true'
95
95
  else
96
96
  statuses = `git status --porcelain`.split("\n")
97
- statuses.any? { |l| l.start_with? 'A' }
97
+ statuses.any? { |l| l.start_with? /[A-Z]/i }
98
98
  end
99
99
  end
100
100
 
@@ -161,6 +161,10 @@ module Geordi
161
161
  nil
162
162
  end
163
163
 
164
+ def ruby_version
165
+ Gem::Version.new(RUBY_VERSION)
166
+ end
167
+
164
168
  def file_containing?(file, regex)
165
169
  File.exists?(file) and File.read(file).scan(regex).any?
166
170
  end
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '2.8.0'
2
+ VERSION = '2.12.0'
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geordi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-02 00:00:00.000000000 Z
11
+ date: 2020-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.18.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.18.0
27
27
  description: Collection of command line tools we use in our daily work with Ruby,
@@ -81,14 +81,17 @@ files:
81
81
  - features/console.feature
82
82
  - features/cucumber.feature
83
83
  - features/deploy.feature
84
+ - features/docker.feature
84
85
  - features/dump.feature
85
86
  - features/firefox.feature
86
87
  - features/server.feature
87
88
  - features/setup.feature
88
89
  - features/shell.feature
90
+ - features/step_definitions/docker_command_steps.rb
91
+ - features/step_definitions/miscellaneous_steps.rb
92
+ - features/support/aruba.rb
89
93
  - features/support/env.rb
90
94
  - features/support/step_definitions/aruba_backport_steps.rb
91
- - features/support/step_definitions/miscellaneous_steps.rb
92
95
  - geordi.gemspec
93
96
  - lib/geordi.rb
94
97
  - lib/geordi/COMMAND_TEMPLATE
@@ -108,6 +111,7 @@ files:
108
111
  - lib/geordi/commands/cucumber.rb
109
112
  - lib/geordi/commands/delete_dumps.rb
110
113
  - lib/geordi/commands/deploy.rb
114
+ - lib/geordi/commands/docker.rb
111
115
  - lib/geordi/commands/drop_databases.rb
112
116
  - lib/geordi/commands/dump.rb
113
117
  - lib/geordi/commands/eurest.rb
@@ -130,6 +134,7 @@ files:
130
134
  - lib/geordi/commands/yarn_install.rb
131
135
  - lib/geordi/cucumber.rb
132
136
  - lib/geordi/db_cleaner.rb
137
+ - lib/geordi/docker.rb
133
138
  - lib/geordi/dump_loader.rb
134
139
  - lib/geordi/firefox_for_selenium.rb
135
140
  - lib/geordi/gitpt.rb