geordi 2.6.0 → 2.7.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: 8c2c675109e049fa2e448060119880d0e9efbb42275747e4e7ddce0c205872d3
4
- data.tar.gz: 55a314c7beee03d00fdd7499585929df02acf2ed2c3dccafba40e46470182627
3
+ metadata.gz: 17516fcb96c1a27828c5e43eea96d1ca0d8f72df42e467ff842a70a002b86459
4
+ data.tar.gz: 8985476313a0c6ed93e494878e388edd3ba72a8911c7785dfe53cc9f7e17c284
5
5
  SHA512:
6
- metadata.gz: 66fc72c66158d5a6c6ed25e9ab41d3c6537fe479fd4d59f3ec61df338963ef139b15ed43d0deb59fe6423b109e0f050a86baa9e5a7b60bf8cfccfecf330450f4
7
- data.tar.gz: 8ad6e9b7fd187d4e3668d84c5493b4bb7c6179b6d785ad9217f3e7d8dae3dbd0a700f795cd43d59d816e9379fde6ce972010c626f2bbc9307ecaf2e241cdc8b8
6
+ metadata.gz: afcfaace06ff3ee48b5165de088849c537d73dea2ac544807793f59902634e07b879ca6968c12e0df3deb375686ea377fe63fd531724dae7a2125028fa9a0189
7
+ data.tar.gz: 1dbac4ddff4d8c4b505756bd7ea36a2d667141268ebf90f28fd6faec32b6afb092f1f4dc32ff6442f13b07a5bc84398530bd695e1668e23ce42076752a0f7989
data/CHANGELOG.md CHANGED
@@ -5,12 +5,20 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
5
5
 
6
6
 
7
7
  ## Unreleased
8
-
9
8
  ### Compatible changes
10
-
11
9
  ### Breaking changes
12
10
 
13
11
 
12
+ ## Unreleased
13
+
14
+ ### Compatible changes
15
+ - Fixed [#68](https://github.com/makandra/geordi/issues/68): The "cucumber" command now fails early when @solo features fail.
16
+ - Added: The "setup" command now prints the db adapter when prompting db credentials.
17
+ - Fixed [#71](https://github.com/makandra/geordi/issues/71): When used without staged changes, the "commit" command will print a warning and create an empty commit. Any arguments to the command are forwarded to Git.
18
+ - Fixed: The "commit" command will not print the extra message any more.
19
+ - Added: The "commit" command prints a (progress) loading message. The message is removed once loading is done.
20
+
21
+
14
22
  ## 2.6.0 2019-11-04
15
23
 
16
24
  ### Compatible changes
data/Gemfile CHANGED
@@ -8,4 +8,5 @@ gem 'rspec-mocks'
8
8
  gem 'highline'
9
9
  gem 'parallel_tests'
10
10
  gem 'launchy'
11
+ gem 'tracker_api'
11
12
  # gem 'pry' # Not supported for 1.8.7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (2.6.0)
4
+ geordi (2.7.0)
5
5
  thor (>= 0.18.0)
6
6
 
7
7
  GEM
@@ -12,27 +12,50 @@ GEM
12
12
  childprocess (>= 0.3.6)
13
13
  cucumber (>= 1.1.1)
14
14
  rspec-expectations (>= 2.7.0)
15
+ axiom-types (0.1.1)
16
+ descendants_tracker (~> 0.0.4)
17
+ ice_nine (~> 0.11.0)
18
+ thread_safe (~> 0.3, >= 0.3.1)
15
19
  builder (3.2.3)
16
20
  childprocess (1.0.1)
17
21
  rake (< 13.0)
22
+ coercible (1.0.0)
23
+ descendants_tracker (~> 0.0.1)
18
24
  cucumber (1.3.20)
19
25
  builder (>= 2.1.2)
20
26
  diff-lcs (>= 1.1.3)
21
27
  gherkin (~> 2.12)
22
28
  multi_json (>= 1.7.5, < 2.0)
23
29
  multi_test (>= 0.1.2)
30
+ declarative (0.0.10)
31
+ declarative-option (0.1.0)
32
+ descendants_tracker (0.0.4)
33
+ thread_safe (~> 0.3, >= 0.3.1)
24
34
  diff-lcs (1.2.5)
35
+ equalizer (0.0.11)
36
+ excon (0.67.0)
37
+ faraday (0.17.0)
38
+ multipart-post (>= 1.2, < 3)
39
+ faraday_middleware (0.13.1)
40
+ faraday (>= 0.7.4, < 1.0)
25
41
  gherkin (2.12.2)
26
42
  multi_json (~> 1.3)
27
43
  highline (1.6.21)
44
+ ice_nine (0.11.2)
28
45
  launchy (2.4.3)
29
46
  addressable (~> 2.3)
47
+ mimemagic (0.3.3)
30
48
  multi_json (1.13.1)
31
49
  multi_test (0.1.2)
50
+ multipart-post (2.1.1)
32
51
  parallel (0.5.16)
33
52
  parallel_tests (0.6.18)
34
53
  parallel
35
54
  rake (10.5.0)
55
+ representable (3.0.4)
56
+ declarative (< 0.1.0)
57
+ declarative-option (< 0.2.0)
58
+ uber (< 0.2.0)
36
59
  rspec-expectations (3.4.0)
37
60
  diff-lcs (>= 1.2.0, < 2.0)
38
61
  rspec-support (~> 3.4.0)
@@ -41,6 +64,23 @@ GEM
41
64
  rspec-support (~> 3.4.0)
42
65
  rspec-support (3.4.1)
43
66
  thor (0.20.3)
67
+ thread_safe (0.3.6)
68
+ tracker_api (1.10.0)
69
+ addressable
70
+ equalizer
71
+ excon
72
+ faraday
73
+ faraday_middleware
74
+ mimemagic
75
+ multi_json
76
+ representable
77
+ virtus
78
+ uber (0.1.0)
79
+ virtus (1.0.5)
80
+ axiom-types (~> 0.1)
81
+ coercible (~> 1.0)
82
+ descendants_tracker (~> 0.0, >= 0.0.3)
83
+ equalizer (~> 0.0, >= 0.0.9)
44
84
 
45
85
  PLATFORMS
46
86
  ruby
@@ -52,6 +92,7 @@ DEPENDENCIES
52
92
  launchy
53
93
  parallel_tests
54
94
  rspec-mocks
95
+ tracker_api
55
96
 
56
97
  BUNDLED WITH
57
98
  1.17.3
@@ -0,0 +1,17 @@
1
+ @announce-output
2
+ Feature: Creating a git commit from a Pivotal Tracker story
3
+
4
+ Scenario: Extra arguments are forwarded to "git commit"
5
+ Given I have staged changes
6
+
7
+ When I run `geordi commit --extra-option` interactively
8
+ # No optional message
9
+ And I type ""
10
+ Then the output should contain "Util.system! git, commit, --allow-empty, -m, [#12] Test Story, --extra-option"
11
+
12
+
13
+ Scenario: With no staged changes, a warning is printed
14
+ When I run `geordi commit --allow-empty` interactively
15
+ # No optional message
16
+ And I type ""
17
+ Then the output should contain "> No staged changes. Will create an empty commit."
@@ -18,6 +18,7 @@ Feature: The cucumber command
18
18
  When I run `geordi cucumber features/single.feature`
19
19
  Then the output should contain "# Running features"
20
20
  And the output should contain "> Only: features/single.feature"
21
+ And the output should contain "Features green."
21
22
  But the output should not contain "parallel"
22
23
 
23
24
 
@@ -60,6 +61,7 @@ Feature: The cucumber command
60
61
  And the output should contain "Rerunning failed scenarios"
61
62
  And the output should contain "Using the rerun profile"
62
63
  And the exit status should be 1
64
+ And the output should contain "Features failed."
63
65
 
64
66
 
65
67
  Scenario: Running all features in a given subfolder
@@ -96,10 +98,10 @@ Feature: The cucumber command
96
98
  """
97
99
 
98
100
  When I run `geordi cucumber --verbose features`
99
- Then the output should contain "# Running features"
100
- And the output should match /^> .*cucumber .*--tags \"~@solo\"/
101
- And the output should contain "# Running @solo features"
101
+ Then the output should contain "# Running @solo features"
102
102
  And the output should match /^> .*cucumber .*--tags @solo/
103
+ And the output should contain "# Running features"
104
+ And the output should match /^> .*cucumber .*--tags \"~@solo\"/
103
105
 
104
106
 
105
107
  Scenario: When there are no scenarios tagged @solo, the extra run is skipped
@@ -146,6 +148,28 @@ Feature: The cucumber command
146
148
  And the output should not contain "No such file or directory"
147
149
 
148
150
 
151
+ Scenario: It does not start the full test run when the @solo run fails
152
+ Given a file named "features/step_definitions/test_steps.rb" with:
153
+ """
154
+ Given 'this test fails' do
155
+ raise
156
+ end
157
+ """
158
+ And a file named "features/failing.feature" with:
159
+ """
160
+ Feature: Failing feature
161
+ @solo
162
+ Scenario: Failing scenario
163
+ And this test fails
164
+ Scenario: Other scenario
165
+ """
166
+
167
+ When I run `geordi cucumber`
168
+ Then the output should contain "# Running @solo features"
169
+ And the output should contain "Features failed."
170
+ But the output should not contain "# Running features"
171
+
172
+
149
173
  Scenario: Specifying a firefox version to use
150
174
  Given a file named "features/sub/one.feature" with:
151
175
  """
@@ -6,7 +6,7 @@ Feature: The firefox/chrome command
6
6
  Given a file named "testfile" with "testcontent"
7
7
 
8
8
  When I run `geordi firefox cat testfile`
9
- Then the output should contain "> VNC is ready to hold Selenium test browsers. Use `geordi vnc` to view them."
9
+ Then the output should contain "> Run `geordi vnc` to view the Selenium test browsers"
10
10
  And the output should contain "testcontent"
11
11
  But the output should not contain "Firefox for Selenium"
12
12
 
@@ -15,7 +15,7 @@ Feature: The firefox/chrome command
15
15
  Given a file named "testfile" with "testcontent"
16
16
 
17
17
  When I run `geordi chrome cat testfile`
18
- Then the output should contain "> VNC is ready to hold Selenium test browsers. Use `geordi vnc` to view them."
18
+ Then the output should contain "> Run `geordi vnc` to view the Selenium test browsers"
19
19
  And the output should contain "testcontent"
20
20
 
21
21
 
@@ -48,7 +48,7 @@ Feature: The firefox/chrome command
48
48
  And a file named "testfile" with "testcontent"
49
49
 
50
50
  When I run `geordi firefox cat testfile`
51
- Then the output should contain "> VNC is ready"
51
+ Then the output should contain "> Run `geordi vnc`"
52
52
  And the output should contain "testcontent"
53
53
  But the output should not contain "Firefox for Selenium"
54
54
 
@@ -1,3 +1,11 @@
1
1
  When /^I wait for (\d+) seconds?$/ do |seconds|
2
2
  sleep seconds.to_i
3
3
  end
4
+
5
+ Given 'I have staged changes' do
6
+ ENV['GEORDI_TESTING_STAGED_CHANGES'] = 'true'
7
+ end
8
+
9
+ After do
10
+ ENV['GEORDI_TESTING_STAGED_CHANGES'] = 'false'
11
+ end
@@ -3,17 +3,22 @@ desc 'commit', 'Commit using a story title from Pivotal Tracker'
3
3
  long_desc <<-LONGDESC
4
4
  Example: `geordi commit`
5
5
 
6
+ Any extra arguments are forwarded to `git commit -m <message>`.
7
+
8
+ If there are no staged changes, prints a warning but will continue to create
9
+ an empty commit.
10
+
6
11
  On the first execution we ask for your Pivotal Tracker API token. It will be
7
12
  stored in `~/.gitpt`.
8
13
  LONGDESC
9
14
 
10
- def commit
15
+ def commit(*git_args)
11
16
  raise <<-TEXT if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.1')
12
- Unsupported Ruby Version #{RUBY_VERSION}. `geordi commit` does not work with a Ruby version < 2.1.
17
+ Unsupported Ruby Version #{RUBY_VERSION}. `geordi commit` requires Ruby 2.1+.
13
18
  TEXT
14
19
 
15
20
  require 'geordi/gitpt'
16
21
 
17
- Gitpt.new.run
22
+ Gitpt.new.run(git_args)
18
23
  end
19
24
 
@@ -6,10 +6,12 @@ def create_database_yml
6
6
  if File.exists?(sample_yml) and not File.exists?(real_yml)
7
7
  announce 'Creating ' + real_yml
8
8
 
9
- print 'Please enter your DB password: '
9
+ sample = File.read(sample_yml)
10
+ adapter = sample.match(/adapter: (\w+)\n/).captures.first
11
+
12
+ print "Please enter your #{adapter} password: "
10
13
  db_password = STDIN.gets.strip
11
14
 
12
- sample = File.read(sample_yml)
13
15
  real = sample.gsub(/password:.*$/, "password: #{db_password}")
14
16
  File.open(real_yml, 'w') { |f| f.write(real) }
15
17
 
@@ -54,9 +54,7 @@ def cucumber(*args)
54
54
  cmd_opts, files = args.partition { |f| f.start_with? '-' }
55
55
  cmd_opts << '--format' << 'pretty' << '--backtrace' if options.debug
56
56
 
57
- announce 'Running features'
58
-
59
- # Serial run of @solo scenarios
57
+ # Serial run of @solo scenarios ############################################
60
58
  if files.any? { |f| f.include? ':' }
61
59
  note '@solo run skipped when called with line numbers' if options.verbose
62
60
  else
@@ -73,16 +71,20 @@ def cucumber(*args)
73
71
  solo_cmd_opts << '--tags' << '@solo'
74
72
 
75
73
  announce 'Running @solo features'
76
- Geordi::Cucumber.new.run files, solo_cmd_opts, :verbose => options.verbose, :parallel => false
74
+ solo_success = Geordi::Cucumber.new.run files, solo_cmd_opts, :verbose => options.verbose, :parallel => false
75
+ solo_success or fail 'Features failed.'
77
76
  end
78
77
  end
79
78
 
80
- # Normal run
81
- unless Geordi::Cucumber.new.run(files, cmd_opts, :verbose => options.verbose)
79
+ # Parallel run of all given features + reruns ##############################
80
+ announce 'Running features'
81
+ normal_run_successful = Geordi::Cucumber.new.run(files, cmd_opts, :verbose => options.verbose)
82
+
83
+ unless normal_run_successful
82
84
  cmd_opts << '--profile' << 'rerun'
83
85
 
84
86
  # Reruns
85
- (1 + options.rerun).times do |i|
87
+ (options.rerun + 1).times do |i|
86
88
  fail 'Features failed.' if (i == options.rerun) # All reruns done?
87
89
 
88
90
  announce "Rerun ##{ i + 1 } of #{ options.rerun }"
@@ -90,6 +92,8 @@ def cucumber(*args)
90
92
  end
91
93
  end
92
94
 
95
+ success 'Features green.'
96
+
93
97
  else
94
98
  note 'Cucumber not employed.'
95
99
  end
@@ -2,9 +2,9 @@ desc 'tests', 'Run all employed tests'
2
2
  def tests
3
3
  rake_result = invoke_cmd 'with_rake'
4
4
 
5
+ # Since `rake` usually is configured to run all tests, only run them if `rake`
6
+ # did not perform
5
7
  if rake_result == :did_not_perform
6
- # Since `rake` usually runs all tests, only run them here if `rake` did not
7
- # perform
8
8
  invoke_cmd 'unit'
9
9
  invoke_cmd 'rspec'
10
10
  invoke_cmd 'cucumber'
@@ -60,7 +60,7 @@ module Geordi
60
60
  ENV["BROWSER"] = ENV["LAUNCHY_BROWSER"] = File.expand_path('../../../bin/launchy_browser', __FILE__)
61
61
  ENV["DISPLAY"] = VNC_DISPLAY
62
62
 
63
- note 'VNC is ready to hold Selenium test browsers. Use `geordi vnc` to view them.'
63
+ note 'Run `geordi vnc` to view the Selenium test browsers'
64
64
  end
65
65
  end
66
66
 
data/lib/geordi/gitpt.rb CHANGED
@@ -9,22 +9,23 @@ class Gitpt
9
9
 
10
10
  def initialize
11
11
  self.highline = HighLine.new
12
+ self.client = build_client(read_settings)
12
13
  end
13
14
 
14
- def run
15
- settings = read_settings
16
- client = build_client(settings)
15
+ def run(git_args)
16
+ warn <<-WARNING if !Geordi::Util.staged_changes?
17
+ No staged changes. Will create an empty commit.
18
+ WARNING
17
19
 
18
- puts 'Connecting to Pivotal Tracker...'
19
-
20
- projects = load_projects(client)
21
- applicable_stories = load_applicable_stories(projects)
22
- choose_story(client.me, applicable_stories)
20
+ story = choose_story
21
+ if story
22
+ create_commit "[##{story.id}] #{story.name}", *git_args
23
+ end
23
24
  end
24
25
 
25
26
  private
26
27
 
27
- attr_accessor :highline
28
+ attr_accessor :highline, :client
28
29
 
29
30
  def read_settings
30
31
  file_path = File.join(ENV['HOME'], SETTINGS_FILE_NAME)
@@ -51,9 +52,8 @@ class Gitpt
51
52
  TrackerApi::Client.new(:token => settings.fetch(:token))
52
53
  end
53
54
 
54
- def load_projects(client)
55
+ def load_projects
55
56
  project_ids = read_project_ids
56
-
57
57
  project_ids.collect { |project_id| client.project(project_id) }
58
58
  end
59
59
 
@@ -76,19 +76,32 @@ class Gitpt
76
76
  end
77
77
  end
78
78
 
79
- def load_applicable_stories(projects)
80
- projects.collect { |project| project.stories(:filter => 'state:started,finished,rejected') }.flatten
79
+ def applicable_stories
80
+ projects = load_projects
81
+ projects.collect do |project|
82
+ project.stories(:filter => 'state:started,finished,rejected')
83
+ end.flatten
81
84
  end
82
85
 
83
- def choose_story(me, applicable_stories)
84
- selected_story = nil
86
+ def choose_story
87
+ if Geordi::Util.testing?
88
+ return OpenStruct.new(:id => 12, :name => 'Test Story')
89
+ end
90
+
91
+ loading_message = 'Connecting to Pivotal Tracker ...'
92
+ print(loading_message)
93
+ stories = applicable_stories
94
+ reset_loading_message = "\r#{ ' ' * (loading_message.length + stories.length)}\r"
85
95
 
86
96
  highline.choose do |menu|
87
- menu.header = "Choose a story"
88
- applicable_stories.each do |story|
97
+ menu.header = 'Choose a story'
98
+
99
+ stories.each do |story|
100
+ print '.' # Progress
101
+
89
102
  state = story.current_state
90
103
  owners = story.owners
91
- owner_is_me = owners.collect(&:id).include?(me.id)
104
+ owner_is_me = owners.collect(&:id).include?(client.me.id)
92
105
 
93
106
  if state == 'started'
94
107
  state = HighLine::GREEN + state + HighLine::RESET
@@ -100,22 +113,22 @@ class Gitpt
100
113
 
101
114
  label = "(#{owners.collect(&:name).join(', ')}, #{state}) #{story.name}"
102
115
  label = bold(label) if owner_is_me
103
- menu.choice(label) { selected_story = story }
116
+
117
+ menu.choice(label) { return story }
104
118
  end
119
+
105
120
  menu.hidden ''
121
+ print reset_loading_message # Once menu is build
106
122
  end
107
123
 
108
- if selected_story
109
- message = highline.ask("\nAdd an optional message")
110
- highline.say message
124
+ nil # Return nothing
125
+ end
111
126
 
112
- commit_message = "[##{selected_story.id}] #{selected_story.name}"
113
- if message.strip != ''
114
- commit_message << ' - '<< message.strip
115
- end
127
+ def create_commit(message, *git_args)
128
+ extra = highline.ask("\nAdd an optional message").strip
129
+ message << ' - ' << extra if (extra != "")
116
130
 
117
- exec('git', 'commit', '-m', commit_message)
118
- end
131
+ Geordi::Util.system! 'git', 'commit', '--allow-empty', '-m', message, *git_args
119
132
  end
120
133
 
121
134
  def bold(string)
data/lib/geordi/util.rb CHANGED
@@ -80,6 +80,15 @@ module Geordi
80
80
  end
81
81
  end
82
82
 
83
+ def staged_changes?
84
+ if testing?
85
+ ENV['GEORDI_TESTING_STAGED_CHANGES'] == 'true'
86
+ else
87
+ statuses = `git status --porcelain`.split("\n")
88
+ statuses.any? { |l| l.start_with? 'A' }
89
+ end
90
+ end
91
+
83
92
  def deploy_targets
84
93
  Dir['config/deploy/*'].map do |f|
85
94
  File.basename f, '.rb' # Filename without .rb extension
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '2.6.0'
2
+ VERSION = '2.7.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geordi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0
4
+ version: 2.7.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: 2019-11-04 00:00:00.000000000 Z
11
+ date: 2019-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -77,6 +77,7 @@ files:
77
77
  - bin/run_tests
78
78
  - bin/shell-for
79
79
  - bin/tests
80
+ - features/commit.feature
80
81
  - features/console.feature
81
82
  - features/cucumber.feature
82
83
  - features/deploy.feature