heroku_deployer 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/amitree/heroku_deployer.rb +95 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb31a9bd48882e4894ea3c8b70405ec84cb06fc2
|
4
|
+
data.tar.gz: 0e2f7e0eab12937811ba389ff87b87aaac59ad2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6e21998496816bd791fa51735bcc8132ea24979baffef9d958360881b8bcc03e73a717a79e5dbf09f30152dde5e13d169c79e138837916ccb6e44b044c15425
|
7
|
+
data.tar.gz: 667b014a95b164736998ca71f8770b4ecad8d1790c7c5d2465c50e45c507b2732333e523043776bdd8fbe9a5189e1d9e52453b13131ca494b06630ef6832fb3e
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'amitree/git_client'
|
2
|
+
require 'amitree/heroku_client'
|
3
|
+
require 'pivotal-tracker'
|
4
|
+
|
5
|
+
module Amitree
|
6
|
+
class HerokuDeployer
|
7
|
+
class ReleaseDetails
|
8
|
+
attr_accessor :production_release, :staging_release_to_deploy, :stories
|
9
|
+
attr_writer :production_promoted_from_staging
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@stories = []
|
13
|
+
end
|
14
|
+
|
15
|
+
def production_promoted_from_staging?
|
16
|
+
@production_promoted_from_staging
|
17
|
+
end
|
18
|
+
|
19
|
+
class Story < DelegateClass(PivotalTracker::Story)
|
20
|
+
attr_accessor :deliverable
|
21
|
+
attr_reader :blocked_by
|
22
|
+
|
23
|
+
def initialize(tracker_story)
|
24
|
+
super(tracker_story)
|
25
|
+
@deliverable = false
|
26
|
+
@blocked_by = []
|
27
|
+
end
|
28
|
+
|
29
|
+
def blocked_by=(blocked_by)
|
30
|
+
@blocked_by = blocked_by
|
31
|
+
if @blocked_by.length > 0
|
32
|
+
@deliverable = false
|
33
|
+
else
|
34
|
+
@deliverable = true
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize(options={})
|
41
|
+
@heroku = options[:heroku] || Amitree::HerokuClient.new(options[:heroku_api_key], options[:heroku_staging_app], options[:heroku_production_app])
|
42
|
+
@git = options[:git] || Amitree::GitClient.new(options[:github_repo], options[:github_username], options[:github_password])
|
43
|
+
PivotalTracker::Client.token = options[:tracker_token]
|
44
|
+
@tracker_project = PivotalTracker::Project.find(options[:tracker_project_id])
|
45
|
+
@tracker_cache = {}
|
46
|
+
end
|
47
|
+
|
48
|
+
def compute_release(options={})
|
49
|
+
result = ReleaseDetails.new
|
50
|
+
|
51
|
+
result.production_release = @heroku.last_promoted_production_release
|
52
|
+
result.production_promoted_from_staging = @heroku.promoted_from_staging?(result.production_release)
|
53
|
+
staging_releases = @heroku.staging_releases_since(@heroku.staging_release_name(result.production_release))
|
54
|
+
|
55
|
+
prod_commit = result.production_release['commit']
|
56
|
+
puts "Production release is #{prod_commit}" if options[:verbose]
|
57
|
+
|
58
|
+
@git.stories_worked_on_between(prod_commit, 'HEAD').each do |story_id|
|
59
|
+
result.stories << ReleaseDetails::Story.new(tracker_data(story_id))
|
60
|
+
end
|
61
|
+
|
62
|
+
staging_releases.reverse.each do |staging_release|
|
63
|
+
staging_commit = staging_release['commit']
|
64
|
+
story_ids = @git.stories_worked_on_between(prod_commit, staging_commit).map(&:to_i)
|
65
|
+
stories = result.stories.select{|story| story_ids.include?(story.id)}
|
66
|
+
|
67
|
+
puts "- Trying staging release #{staging_release['name']} with commit #{staging_commit}" if options[:verbose]
|
68
|
+
puts " - Stories: #{story_ids.inspect}" if options[:verbose]
|
69
|
+
|
70
|
+
unaccepted_story_ids = story_ids.select { |story| get_tracker_status(story) != 'accepted' }
|
71
|
+
stories.each do |story|
|
72
|
+
story.blocked_by = unaccepted_story_ids
|
73
|
+
end
|
74
|
+
|
75
|
+
if unaccepted_story_ids.length > 0
|
76
|
+
puts " - Some stories are not yet accepted: #{unaccepted_story_ids.inspect}" if options[:verbose]
|
77
|
+
else
|
78
|
+
puts " - This release is good to go!" if options[:verbose]
|
79
|
+
result.staging_release_to_deploy = staging_release
|
80
|
+
break
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
return result
|
85
|
+
end
|
86
|
+
|
87
|
+
def get_tracker_status(story_id)
|
88
|
+
tracker_data(story_id).current_state
|
89
|
+
end
|
90
|
+
|
91
|
+
def tracker_data(story_id)
|
92
|
+
@tracker_cache[story_id] ||= @tracker_project.stories.find(story_id)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku_deployer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Wargnier
|
@@ -90,6 +90,7 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- lib/amitree/git_client.rb
|
92
92
|
- lib/amitree/heroku_client.rb
|
93
|
+
- lib/amitree/heroku_deployer.rb
|
93
94
|
- lib/heroku/new_api.rb
|
94
95
|
homepage: http://rubygems.org/gems/heroku_deployer
|
95
96
|
licenses:
|