flash_flow 1.4.8 → 1.4.9

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
  SHA1:
3
- metadata.gz: ab463512263ea658c6333055b40843e6bf750774
4
- data.tar.gz: 8934a6e867ecb14a17bc94f055058adac0d546eb
3
+ metadata.gz: 2ff14ebe3a079bc64c495fbe66f528e08f6c9114
4
+ data.tar.gz: d50b3136f470ffc95cd2120c5b3db0035a4f81cd
5
5
  SHA512:
6
- metadata.gz: bb3bd57682a03a359a4b984625e3f3ac24a13e938101aeb4a6ca5d0bf89cb2032cf682fdcf65803724d7462ac7ed0d3f044578020de28181eeda09d0df380ad6
7
- data.tar.gz: dcb89112e10b385d05aa959474e4e71c1049633a3da291ffb15462a6c5a1abcf3cebf1ea1734bfc81065ed14012a82613f8c5a5dcf8202958ee332f4e573e354
6
+ metadata.gz: b28bf44030d7ce604b797b198f0c7b1bde4636e360a69da26494360c8096635ee7184dc35e66035c632caf8468a259b9b46cc4609e1deeea4377f3e8d57417b3
7
+ data.tar.gz: a6a37d3ff1fe2ec6bc41ce96ac82e48fa43c0406e3a145239853e3c5185b19f9dafa69f0f2d14961b3005e4cd0f48f00b4174ab4bcdf227edeca3b1e50da73a2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flash_flow (1.4.8)
4
+ flash_flow (1.4.9)
5
5
  hipchat (~> 1.5)
6
6
  mail
7
7
  octokit (~> 4.1)
@@ -94,7 +94,7 @@ branch_info_file: 'your/random/file'
94
94
  #smtp:
95
95
  # settings:
96
96
  # domain: 'yourdomain.com'
97
- # address: <%= ENV['SMTP_ADDRESS'] %>
97
+ # address: <%= ENV['SMTP_HOST'] %>
98
98
  # user_name: <%= ENV['SMTP_USERNAME'] %>
99
99
  # password: <%= ENV['SMTP_PASSWORD'] %>
100
100
  # port: 587
@@ -60,12 +60,12 @@ module FlashFlow
60
60
  end
61
61
 
62
62
  def branch_contains?(branch, ref)
63
- run("branch --contains #{ref}", log: CmdRunner::LOG_CMD)
63
+ run("branch -a --contains #{ref}", log: CmdRunner::LOG_CMD)
64
64
  last_stdout.split("\n").detect { |str| str[2..-1] == branch }
65
65
  end
66
66
 
67
- def master_branch_contains?(ref)
68
- branch_contains?(master_branch, ref)
67
+ def master_branch_contains?(sha)
68
+ branch_contains?("remotes/#{remote}/#{master_branch}", sha)
69
69
  end
70
70
 
71
71
  def in_original_merge_branch
@@ -213,8 +213,12 @@ module FlashFlow
213
213
  "flash_flow/#{merge_branch}"
214
214
  end
215
215
 
216
- def get_sha(branch)
217
- run("rev-parse #{branch}")
216
+ def get_sha(branch, opts={})
217
+ if opts[:short]
218
+ run("rev-parse --short #{branch}")
219
+ else
220
+ run("rev-parse #{branch}")
221
+ end
218
222
  last_stdout.strip if last_success?
219
223
  end
220
224
 
@@ -12,8 +12,8 @@ module FlashFlow
12
12
  configure!(config['settings'])
13
13
  end
14
14
 
15
- def deliver!(data={})
16
- delivery_info = Config.configuration.smtp["emails"]
15
+ def deliver!(type, data={})
16
+ delivery_info = get_delivery_info(type)
17
17
 
18
18
  if delivery_info
19
19
  delivery_info["body_html"] = body_html(data, delivery_info["body_file"])
@@ -40,6 +40,10 @@ module FlashFlow
40
40
  erb_template.result(binding)
41
41
  end
42
42
 
43
+ def get_delivery_info(email_type)
44
+ Config.configuration.smtp.dig("emails", email_type.to_s)
45
+ end
46
+
43
47
  end
44
48
  end
45
49
  end
@@ -77,7 +77,7 @@ module FlashFlow
77
77
 
78
78
  def release_ahead_of_master
79
79
  @git.branch_exists?("#{@git.remote}/#{@git.release_branch}") &&
80
- !@git.branch_contains?(@git.master_branch, @git.get_sha("#{@git.remote}/#{@git.release_branch}"))
80
+ !@git.master_branch_contains?(@git.get_sha("#{@git.remote}/#{@git.release_branch}"))
81
81
  end
82
82
 
83
83
  def write_data(commit_msg)
@@ -1,4 +1,5 @@
1
1
  require 'flash_flow/merge/base'
2
+ require 'flash_flow/release'
2
3
 
3
4
  module FlashFlow
4
5
  module Merge
@@ -15,8 +16,10 @@ module FlashFlow
15
16
  def run
16
17
  begin
17
18
  check_version
18
- puts "Merging #{@git.release_branch} into #{@git.master_branch}"
19
- logger.info "\n\n### Beginning merge of #{@git.release_branch} into #{@git.master_branch} ###\n\n"
19
+ # puts "Merging #{@git.release_branch} into #{@git.master_branch}"
20
+ # logger.info "\n\n### Beginning merge of #{@git.release_branch} into #{@git.master_branch} ###\n\n"
21
+ puts "Checking #{@git.release_branch} QA approval"
22
+ logger.info "\n\n### Beginning check of #{@git.release_branch} QA ###\n\n"
20
23
 
21
24
  mergers, errors = [], []
22
25
 
@@ -26,33 +29,12 @@ module FlashFlow
26
29
  raise NothingToMergeError.new("There is no pending release.")
27
30
  elsif !release_ahead_of_master
28
31
  raise NothingToMergeError.new("The release branch '#{@git.release_branch}' has no commits that are not in master")
32
+ elsif !release_qa_approved?
33
+ raise FlashFlow::Release::QAError.new("The release build '#{get_release_sha(short: true)}' has not been approved for release")
29
34
  end
30
35
 
31
- @git.in_original_merge_branch do
32
- @git.initialize_rerere
33
- end
34
-
35
- @git.in_branch(@git.master_branch) do
36
- @git.run("reset --hard origin/master")
37
- merge_branches([Data::Branch.new(@git.release_branch)]) do |branch, merger|
38
- mergers << [branch, merger]
39
- end
40
- end
41
-
42
- errors = mergers.select { |m| m.last.result != :success }
43
-
44
- if errors.empty?
45
- unless @git.push("#{@git.master_branch}:#{@git.master_branch}", true)
46
- raise GitPushFailure.new("Unable to push to #{@git.master_branch}. See log for details.")
47
- end
48
-
49
- released_sha = @git.get_sha(@git.master_branch)
50
-
51
- release['status'] = 'Success'
52
- release['released_sha'] = released_sha
53
-
54
- write_data('Release merged [ci skip]')
55
- end
36
+ # errors = merge_master(release)
37
+ send_release_ready_email(release)
56
38
  end
57
39
 
58
40
  if errors.empty?
@@ -62,7 +44,7 @@ module FlashFlow
62
44
  end
63
45
 
64
46
  logger.info "### Finished merge of #{@git.release_branch} into #{@git.master_branch} ###"
65
- rescue Lock::Error, OutOfSyncWithRemote, UnmergeableBranch, GitPushFailure, NothingToMergeError, VersionError => e
47
+ rescue Lock::Error, OutOfSyncWithRemote, UnmergeableBranch, GitPushFailure, NothingToMergeError, FlashFlow::Release::QAError, VersionError => e
66
48
  puts 'Failure!'
67
49
  puts e.message
68
50
  ensure
@@ -70,6 +52,57 @@ module FlashFlow
70
52
  end
71
53
  end
72
54
 
55
+ def merge_master(release)
56
+ @git.in_original_merge_branch do
57
+ @git.initialize_rerere
58
+ end
59
+
60
+ @git.in_branch(@git.master_branch) do
61
+ @git.run("reset --hard origin/master")
62
+ merge_branches([Data::Branch.new(@git.release_branch)]) do |branch, merger|
63
+ mergers << [branch, merger]
64
+ end
65
+ end
66
+
67
+ errors = mergers.select { |m| m.last.result != :success }
68
+
69
+ if errors.empty?
70
+ unless @git.push("#{@git.master_branch}:#{@git.master_branch}", true)
71
+ raise GitPushFailure.new("Unable to push to #{@git.master_branch}. See log for details.")
72
+ end
73
+
74
+ mark_release_success(release, @git.get_sha(@git.master_branch))
75
+ end
76
+
77
+ errors
78
+ end
79
+
80
+ def mark_release_success(release, sha)
81
+ release['status'] = 'Success'
82
+ release['released_sha'] = sha
83
+
84
+ write_data('Release merged [ci skip]')
85
+ end
86
+
87
+ def release_qa_approved?
88
+ release = FlashFlow::Release::Base.new(FlashFlow::Config.configuration.release)
89
+ release.qa_approved?(get_release_sha)
90
+ end
91
+
92
+ def send_release_ready_email(release)
93
+ begin
94
+ mailer = FlashFlow::Mailer::Base.new(Config.configuration.smtp)
95
+ mailer.deliver!(:release_ready, { approved_sha: get_release_sha(short: true) })
96
+ mark_release_success(release, get_release_sha)
97
+ rescue ArgumentError => e
98
+ raise FlashFlow::Release::QAError.new("Cannot send the email: #{e}")
99
+ end
100
+ end
101
+
102
+ def get_release_sha(opts={})
103
+ @get_release_sha ||= @git.get_sha("#{@git.remote}/#{@git.release_branch}", opts)
104
+ end
105
+
73
106
  end
74
107
  end
75
- end
108
+ end
@@ -10,6 +10,7 @@ module FlashFlow
10
10
  def initialize(opts={})
11
11
  super(opts)
12
12
 
13
+ @force = opts[:force]
13
14
  @release_branches = parse_branches(opts[:release_branches])
14
15
 
15
16
  @data = Data::Base.new({}, Config.configuration.branch_info_file, @git, logger: logger)
@@ -73,10 +74,6 @@ module FlashFlow
73
74
  end
74
75
  end
75
76
 
76
- def branch_data
77
-
78
- end
79
-
80
77
  def parse_branches(user_branches)
81
78
  branch_list = user_branches == ['ready'] ? shippable_branch_names : [user_branches].flatten.compact
82
79
 
@@ -86,8 +83,10 @@ module FlashFlow
86
83
  def check_branches
87
84
  raise NothingToMergeError.new("Nothing to merge") if @release_branches.empty?
88
85
 
89
- requested_not_ready_branches = (@release_branches.map(&:ref) - shippable_branch_names)
90
- raise RuntimeError.new("The following branches are not ready to ship:\n#{requested_not_ready_branches.join("\n")}") unless requested_not_ready_branches.empty?
86
+ unless @force
87
+ requested_not_ready_branches = (@release_branches.map(&:ref) - shippable_branch_names)
88
+ raise RuntimeError.new("The following branches are not ready to ship:\n#{requested_not_ready_branches.join("\n")}") unless requested_not_ready_branches.empty?
89
+ end
91
90
  end
92
91
 
93
92
  def shippable_branch_names
@@ -15,7 +15,6 @@ module FlashFlow
15
15
  set_dimensions(*pdf.bounds.top_right)
16
16
  generate_title_page(pdf)
17
17
  info.each do |comparison|
18
- puts comparison.dig('head-screenshot', :url)
19
18
  add_comparison_to_pdf(pdf, comparison)
20
19
  end
21
20
  pdf.number_pages('<page> of <total>', { start_count_at: 1, align: :right, size: 12 })
@@ -13,8 +13,6 @@ module FlashFlow
13
13
  end
14
14
 
15
15
  def find_latest_by_sha(sha)
16
-
17
- require 'byebug'; debugger
18
16
  response = get_builds
19
17
  commit = find_commit_by_sha(response, sha)
20
18
  find_build_by_commit_id(response, commit['id'])
@@ -24,7 +22,7 @@ module FlashFlow
24
22
  build = find_latest_by_sha(get_latest_sha)
25
23
 
26
24
  if has_unapproved_diffs?(build)
27
- mailer.deliver!(percy_build_url: build['web-url'])
25
+ mailer.deliver!(:compliance, { percy_build_url: build['web-url'] })
28
26
  end
29
27
  end
30
28
 
@@ -34,6 +32,11 @@ module FlashFlow
34
32
  PdfDiffGenerator.new.generate(get_comparisons(build_id), output_file, threshold)
35
33
  end
36
34
 
35
+ def qa_approved?(sha=nil)
36
+ build = find_latest_by_sha(sha || get_latest_sha)
37
+ !build['approved-at'].nil?
38
+ end
39
+
37
40
  private
38
41
 
39
42
  def get_build_id(sha=nil)
@@ -88,7 +91,7 @@ module FlashFlow
88
91
  end
89
92
 
90
93
  def get_latest_sha
91
- @git.get_sha("#{@git.remote}/#{@git.release_branch}")
94
+ @git.get_sha(@git.release_branch)
92
95
  end
93
96
 
94
97
  def mailer
@@ -2,6 +2,8 @@ require 'flash_flow/release/percy_client'
2
2
 
3
3
  module FlashFlow
4
4
  module Release
5
+ class QAError < RuntimeError; end
6
+
5
7
  class Base
6
8
  def initialize(config=nil)
7
9
  release_class_name = config && config['class'] && config['class']['name']
@@ -20,7 +22,11 @@ module FlashFlow
20
22
  end
21
23
 
22
24
  def gen_pdf_diffs(output_file, threshold=0.0)
23
- @release.gen_pdf_diffs(output_file, nil, threshold) if @release.respond_to?(:gen_pdf_diffs)
25
+ @release.gen_pdf_diffs(output_file, threshold) if @release.respond_to?(:gen_pdf_diffs)
26
+ end
27
+
28
+ def qa_approved?(sha)
29
+ @release.qa_approved?(sha) if @release.respond_to?(:qa_approved?)
24
30
  end
25
31
 
26
32
  end
@@ -1,3 +1,3 @@
1
1
  module FlashFlow
2
- VERSION = '1.4.8'
2
+ VERSION = '1.4.9'
3
3
  end