hu 1.3.5 → 1.3.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/hu/deploy.rb +93 -27
  3. data/lib/hu/version.rb +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b6012d2704060ace64f41aed7e2b0b6301888cc
4
- data.tar.gz: 1faabd1f7eb3187c963402251089d6884513c650
3
+ metadata.gz: 61e3b5270bf085d9b7027fba304081beafad7410
4
+ data.tar.gz: f109881ac2f36bb35e04b4d9bb98428d73b3f854
5
5
  SHA512:
6
- metadata.gz: 795cec6ff98f9cd49f161aee6ffe2046d3d6586e60f7a29fb5e9399a8cbbe4c75c9fe08ec44f9b7fc4b2af09d06767418f76df55601a26e6abde6fe3d639d235
7
- data.tar.gz: 07a272210595d6600f665e61cdf3278271c9e5ec16ad6df513b3c3a4a0ddfd83a8b28aa6b18938c78108d1d4f201bc6f69b2a746e52801febe711ba6fb155032
6
+ metadata.gz: adbb4b03a6c2d9159b4e50b6a2717c1c7f55f43833df29fb648ebca76989a3c8e4ab03360684d8f0e9a569489eef852ce87bad556093d659a845963eb82b5a56
7
+ data.tar.gz: 98a39b7b4499614550b9209fa6b4d63005110fc4a638200b3b73b6fbe7eb113c8b1e6240b6f0f99374861e2023247b7bb8ada282f625e81f0a464fcfd47302c9
@@ -13,6 +13,10 @@ require 'tempfile'
13
13
  require 'thread_safe'
14
14
  require 'io/console'
15
15
  require 'rugged'
16
+ require 'pty'
17
+ require 'thread'
18
+ require 'paint'
19
+ require 'lolcat/lol'
16
20
 
17
21
  module Hu
18
22
  class Cli < Optix::Cli
@@ -203,7 +207,7 @@ module Hu
203
207
  puts " If everything looks good, you may proceed and finish the release."
204
208
  puts " If there are problems: Quit, delete the release branch and start fixing."
205
209
  puts
206
- elsif git_revisions[prod_app_name] != git_revisions[stag_app_name]
210
+ elsif git_revisions[prod_app_name] != git_revisions[stag_app_name] and !release_branch_exists and git_revisions[:release] != git_revisions[stag_app_name]
207
211
  puts "Phase 3/3: HEADS UP. This is the last chance to detect problems."
208
212
  puts " The final version of "+"release/#{release_tag}".bright+" is now staged."
209
213
  puts
@@ -263,13 +267,23 @@ module Hu
263
267
  }
264
268
  unless 0 == finish_release(release_tag, env)
265
269
  abort_merge
266
- puts "*** ERROR! Push did not complete. *** ".color(:red)
270
+ puts "*** ERROR! Could not finish release *** ".color(:red)
271
+ puts
272
+ puts "This usually means a merge conflict or"
273
+ puts "something similarly complicated has occured."
274
+ puts
275
+ puts "Please bring the universe into a state"
276
+ puts "where the above command succeeds, then try again."
277
+ puts
278
+ exit 1
267
279
  end
268
280
  ENV['EDITOR'] = old_editor
269
281
  anykey
270
282
  when :push_to_staging
271
- push_command = "git push #{push_url} release/#{release_tag}:master -f"
272
- `#{push_command}`
283
+ run_each <<-EOS.strip_heredoc
284
+ :stream
285
+ git push #{push_url} release/#{release_tag}:master -f
286
+ EOS
273
287
  anykey
274
288
  when :abort_ask
275
289
  puts if delete_branch("release/#{release_tag}")
@@ -292,7 +306,7 @@ module Hu
292
306
 
293
307
  def show_pipeline_status(pipeline_name, stag_app_name, prod_app_name, release_tag, clear=true)
294
308
  table = TTY::Table.new header: %w{location commit tag app_last_modified app_last_modified_by dynos# state}
295
- busy '♪♫♬ elevator music ', :pulse
309
+ busy 'loading', :classic
296
310
  ts = []
297
311
  tpl_row = ['?', '', '', '', '', '', '']
298
312
  revs = ThreadSafe::Hash.new
@@ -415,34 +429,84 @@ module Hu
415
429
  @h ||= PlatformAPI.connect_oauth(Hu::API_TOKEN)
416
430
  end
417
431
 
418
- def run_each(script)
419
- quiet = false
420
- failfast = true
421
- spinner = true
432
+ def run_each(script, opts={})
433
+ opts = {
434
+ quiet: false,
435
+ failfast: true,
436
+ spinner: true,
437
+ stream: false
438
+ }.merge(opts)
439
+
440
+ @spinlock ||= Mutex.new # :P
422
441
  script.lines.each_with_index do |line, i|
423
442
  line.chomp!
424
443
  case line[0]
425
444
  when '#'
426
- puts "\n" + line.bright unless quiet
445
+ puts "\n" + line.bright unless opts[:quiet]
427
446
  when ':'
428
- quiet = true if line == ':quiet'
429
- failfast = false if line == ':return'
430
- spinner = false if line == ':nospinner'
447
+ opts[:quiet] = true if line == ':quiet'
448
+ opts[:failfast] = false if line == ':return'
449
+ opts[:spinner] = false if line == ':nospinner'
450
+ if line == ':stream'
451
+ opts[:stream] = true
452
+ opts[:quiet] = false
453
+ end
431
454
  end
432
455
  next if line.empty? or ['#', ':'].include? line[0]
433
- busy line if spinner
434
- output, status = Open3.capture2e(line)
435
- unbusy if spinner
436
- color = (status.exitstatus == 0) ? :green : :red
437
- if status.exitstatus != 0 or !quiet
438
- puts "\n> ".color(color) + line.color(:black).bright
439
- puts output
456
+
457
+ status = nil
458
+ if opts[:stream]
459
+ puts "\n> ".color(:green) + line.color(:black).bright
460
+ PTY.spawn(line) do |r,w,pid|
461
+ @tspin ||= Thread.new do
462
+ @minispin_last_char = Time.now
463
+ i = 0
464
+ loop do
465
+ break if @minispin_last_char == :end
466
+ if 0.23 > Time.now - @minispin_last_char
467
+ sleep 0.1
468
+ next
469
+ end
470
+ @spinlock.synchronize {
471
+ print "\e[?25l"
472
+ print Paint[' ', '#000', Lol.rainbow(1, i/3.0)]
473
+ sleep 0.12
474
+ print 8.chr
475
+ print ' '
476
+ print 8.chr
477
+ i += 1
478
+ print "\e[?25h"
479
+ }
480
+ end
481
+ end
482
+
483
+ while !r.eof?
484
+ c = r.getc
485
+ @spinlock.synchronize {
486
+ print c
487
+ @minispin_last_char = Time.now
488
+ }
489
+ end
490
+ pid, status = Process.wait2(pid)
491
+ @minispin_last_char = :end
492
+ @tspin.join
493
+ @tspin = nil
494
+ #status = PTY.check(pid)
495
+ end
496
+ else
497
+ busy line if opts[:spinner]
498
+ output, status = Open3.capture2e(line)
499
+ unbusy if opts[:spinner]
500
+ color = (status.exitstatus == 0) ? :green : :red
501
+ if status.exitstatus != 0 or !opts[:quiet]
502
+ puts "\n> ".color(color) + line.color(:black).bright
503
+ puts output
504
+ end
440
505
  end
441
506
  if status.exitstatus != 0
442
- shutdown if failfast
443
- puts "Error on line #{i}: #{line}"
444
- puts "Exit code: #{status.exitstatus}"
445
- exit status.exitstatus if failfast
507
+ shutdown if opts[:failfast]
508
+ puts "Error, exit #{status.exitstatus}: #{line} (L#{i})".color(:red).bright
509
+ exit status.exitstatus if opts[:failfast]
446
510
  return status.exitstatus
447
511
  end
448
512
  end
@@ -621,6 +685,7 @@ module Hu
621
685
 
622
686
  def promote_to_production
623
687
  run_each <<-EOS.strip_heredoc
688
+ :stream
624
689
  :return
625
690
 
626
691
  # Promote staging to production
@@ -641,6 +706,7 @@ module Hu
641
706
  end
642
707
 
643
708
  run_each <<-EOS.strip_heredoc
709
+ :stream
644
710
  :return
645
711
  # Finish release
646
712
  git flow release finish #{release_tag}
@@ -679,10 +745,10 @@ module Hu
679
745
  unbusy
680
746
  end
681
747
 
682
- def busy(msg='', format=:classic)
748
+ def busy(msg='', format=:classic, clear=true)
683
749
  return if @@shutting_down
684
750
  format ||= TTY::Formats::FORMATS.keys.sample
685
- options = {format: format, hide_cursor: true, error_mark: "\e[31;1m✖\e[0m", success_mark: "\e[32;1m✔\e[0m", clear: true}
751
+ options = {format: format, hide_cursor: true, error_mark: "\e[31;1m✖\e[0m", success_mark: "\e[32;1m✔\e[0m", clear: clear}
686
752
  @@spinner = TTY::Spinner.new("\e[0;1m#{msg}#{msg.empty? ? '' : ' '}\e[0m\e[32;1m:spinner\e[0m", options)
687
753
  @@spinner.start
688
754
  end
@@ -713,7 +779,7 @@ module Hu
713
779
  end
714
780
 
715
781
  def safe_abort
716
- @@spinner&.stop
782
+ @spinner&.stop
717
783
  printf "\e[0m\e[?25l"
718
784
  printf '(ヘ・_・)ヘ┳━┳'
719
785
  sleep 0.5
@@ -1,3 +1,3 @@
1
1
  module Hu
2
- VERSION = "1.3.5"
2
+ VERSION = "1.3.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.5
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - moe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-22 00:00:00.000000000 Z
11
+ date: 2016-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler