flash_flow 1.4.10 → 1.4.11

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: 952e4f7a486fdb5f394ff02c131bf51fac271d54
4
- data.tar.gz: 4c7c524879fcf1902f899609b2e5fd2c53cb208c
3
+ metadata.gz: 1316f7c17ae74bb0938114c027c99eede522883d
4
+ data.tar.gz: cb94a7bd830e1c209e395eaea82bc45daaa9b891
5
5
  SHA512:
6
- metadata.gz: 9303c67f43148c4bbaddf614a16d36bfe14f1f5ed7bad729c9f3916af849fa9a427ffc5159ba3927bdbc9d842530d310ca4e4349c5d3922f70b8a804cf4fa6d7
7
- data.tar.gz: efa60f954abd042a8f714d4d3ee50f1cb5b3f50c401c16bcde11a62f34d9be79904567f9be9772e8c5165e067cedcd1501ea929603dc757c1bf96a1261dbaf2d
6
+ metadata.gz: 2109602b4fce98cba0d82b6b9a69975d5d0ee7cf6d0ed78e88fb4553b76a87216840c7cfd7270b4e666bceb436daff19db230d8c31d1b58b7a54869f19757778
7
+ data.tar.gz: 4d7d02dc133936e0134f4a014db56ece371d1723b2ee84249b8839f681e965e995f775917dbae76ce594f5daa43ca0a2756ae12c6585e585d241a375e601c40d
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- flash_flow (1.4.10)
4
+ flash_flow (1.4.11)
5
5
  google-api-client
6
6
  hipchat (~> 1.5)
7
7
  mail
@@ -76,6 +76,10 @@ module FlashFlow
76
76
  def saved_branches
77
77
  Collection.from_hash(stored_branches).to_a
78
78
  end
79
+
80
+ def pending_release
81
+ releases.detect { |r| r['status'] == 'Pending' }
82
+ end
79
83
  end
80
84
  end
81
85
  end
@@ -227,6 +227,10 @@ module FlashFlow
227
227
  last_success?
228
228
  end
229
229
 
230
+ def ahead_of_master?(branch)
231
+ branch_exists?(branch) && !master_branch_contains?(get_sha(branch))
232
+ end
233
+
230
234
  private
231
235
 
232
236
  def squash_commits(branch, commit_message)
@@ -72,12 +72,11 @@ module FlashFlow
72
72
  end
73
73
 
74
74
  def pending_release
75
- @data.releases.detect { |r| r['status'] == 'Pending' }
75
+ @data.pending_release
76
76
  end
77
77
 
78
- def release_ahead_of_master
79
- @git.branch_exists?("#{@git.remote}/#{@git.release_branch}") &&
80
- !@git.master_branch_contains?(@git.get_sha("#{@git.remote}/#{@git.release_branch}"))
78
+ def release_ahead_of_master?
79
+ @git.ahead_of_master?("#{@git.remote}/#{@git.release_branch}")
81
80
  end
82
81
 
83
82
  def write_data(commit_msg)
@@ -97,4 +96,4 @@ module FlashFlow
97
96
 
98
97
  end
99
98
  end
100
- end
99
+ end
@@ -27,7 +27,7 @@ module FlashFlow
27
27
  release = pending_release
28
28
  if !release
29
29
  raise NothingToMergeError.new("There is no pending release.")
30
- elsif !release_ahead_of_master
30
+ elsif !release_ahead_of_master?
31
31
  raise NothingToMergeError.new("The release branch '#{@git.release_branch}' has no commits that are not in master")
32
32
  elsif !release_qa_approved?
33
33
  raise FlashFlow::Release::QAError.new("The release build '#{get_release_sha(short: true)}' has not been approved for release")
@@ -1,16 +1,22 @@
1
+ require 'flash_flow/data/base'
2
+ require 'flash_flow/git'
1
3
  require 'flash_flow/release/percy_client'
2
4
 
3
5
  module FlashFlow
4
6
  module Release
5
- class QAError < RuntimeError; end
7
+ class QAError < RuntimeError;
8
+ end
6
9
 
7
10
  class Base
8
11
  def initialize(config=nil)
9
12
  release_class_name = config && config['class'] && config['class']['name']
10
13
  return unless release_class_name
11
14
 
15
+ @git = ShadowGit.new(Config.configuration.git, Config.configuration.logger)
16
+ @data = Data::Base.new({}, Config.configuration.branch_info_file, @git, logger: logger)
17
+
12
18
  @release_class = Object.const_get(release_class_name)
13
- @release = @release_class.new(config['class'])
19
+ @release = @release_class.new(config['class'].merge({ 'release_sha' => release_sha }))
14
20
  end
15
21
 
16
22
  def find_latest_by_sha(sha)
@@ -18,7 +24,7 @@ module FlashFlow
18
24
  end
19
25
 
20
26
  def send_compliance_email
21
- @release.send_compliance_email if @release.respond_to?(:send_compliance_email)
27
+ @release.send_compliance_email if @release.respond_to?(:send_compliance_email) && pending_release?
22
28
  end
23
29
 
24
30
  def send_release_email
@@ -33,6 +39,17 @@ module FlashFlow
33
39
  @release.qa_approved?(sha) if @release.respond_to?(:qa_approved?)
34
40
  end
35
41
 
42
+ private
43
+
44
+ def pending_release?
45
+ pending_release = @data.pending_release
46
+ !pending_release.nil? && @git.ahead_of_master?("#{@git.remote}/#{@git.release_branch}")
47
+ end
48
+
49
+ def release_sha
50
+ @git.get_sha("#{@git.remote}/#{@git.release_branch}")
51
+ end
52
+
36
53
  end
37
54
  end
38
55
  end
@@ -1,5 +1,4 @@
1
1
  require 'percy'
2
- require 'flash_flow/git'
3
2
  require 'flash_flow/mailer'
4
3
  require 'flash_flow/release/pdf_diff_generator'
5
4
  require 'flash_flow/google_drive'
@@ -10,8 +9,8 @@ module FlashFlow
10
9
 
11
10
  def initialize(config={})
12
11
  @client = initialize_connection!(config)
13
- @git = ShadowGit.new(Config.configuration.git, Config.configuration.logger)
14
12
  @compliance_config = config['compliance']
13
+ @release_sha = config['release_sha']
15
14
  end
16
15
 
17
16
  def find_latest_by_sha(sha)
@@ -23,7 +22,7 @@ module FlashFlow
23
22
  def send_compliance_email
24
23
  max_wait_time = @compliance_config['max_wait_time'] || 0
25
24
  delay = @compliance_config['delay'] || 1
26
- build = find_completed_build_by_sha(get_latest_sha, max_wait_time, delay)
25
+ build = find_completed_build_by_sha(@release_sha, max_wait_time, delay)
27
26
 
28
27
  unless build_approved?(build)
29
28
  gen_compliance_pdf_file(build)
@@ -31,7 +30,7 @@ module FlashFlow
31
30
  end
32
31
 
33
32
  def send_release_email
34
- build = find_latest_by_sha(get_latest_sha)
33
+ build = find_latest_by_sha(@release_sha)
35
34
 
36
35
  unless build_approved?(build)
37
36
  mailer.deliver!(:compliance, { percy_build_url: build['web-url'] })
@@ -45,7 +44,7 @@ module FlashFlow
45
44
  end
46
45
 
47
46
  def qa_approved?(sha=nil)
48
- build = find_latest_by_sha(sha || get_latest_sha)
47
+ build = find_latest_by_sha(sha || @release_sha)
49
48
  !build['approved-at'].nil?
50
49
  end
51
50
 
@@ -92,7 +91,7 @@ module FlashFlow
92
91
  end
93
92
 
94
93
  def get_build_id(sha=nil)
95
- build = find_latest_by_sha(sha || get_latest_sha)
94
+ build = find_latest_by_sha(sha || @release_sha)
96
95
  extract_build_id(build)
97
96
  end
98
97
 
@@ -151,10 +150,6 @@ module FlashFlow
151
150
  build['state'] == 'finished';
152
151
  end
153
152
 
154
- def get_latest_sha
155
- @git.get_sha(@git.release_branch)
156
- end
157
-
158
153
  def mailer
159
154
  @mailer ||= FlashFlow::Mailer::Base.new(Config.configuration.smtp)
160
155
  end
@@ -1,3 +1,3 @@
1
1
  module FlashFlow
2
- VERSION = '1.4.10'
2
+ VERSION = '1.4.11'
3
3
  end
@@ -12,7 +12,7 @@ module FlashFlow
12
12
  reset_config!
13
13
  config!(configuration)
14
14
 
15
- @percy_client = Release::PercyClient.new({'token' => ''})
15
+ @percy_client = Release::PercyClient.new({'token' => '', 'release_sha' => 'bbbbb'})
16
16
  end
17
17
 
18
18
  def test_find_latest_by_sha
@@ -25,21 +25,15 @@ module FlashFlow
25
25
  end
26
26
 
27
27
  def test_send_release_email
28
- @git = Minitest::Mock.new
29
- .expect(:release_branch, 'release')
30
- .expect(:get_sha, 'bbbbb', ['release'])
31
-
32
28
  @mailer = Minitest::Mock.new
33
29
  @mailer.expect(:deliver!, true, [:compliance, {percy_build_url: 'https://percy.io/repo/builds/1111'}])
34
30
 
35
- @percy_client.instance_variable_set('@git'.to_sym, @git)
36
31
  @percy_client.instance_variable_set('@mailer'.to_sym, @mailer)
37
32
 
38
33
  @percy_client.stub(:get_builds, sample_response) do
39
34
  @percy_client.send_release_email
40
35
  end
41
36
 
42
- @git.verify
43
37
  @mailer.verify
44
38
  end
45
39
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flash_flow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.10
4
+ version: 1.4.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flashfunders
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-19 00:00:00.000000000 Z
11
+ date: 2016-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit