heroku-headless 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +7 -0
- data/heroku-headless.gemspec +3 -0
- data/lib/heroku-headless.rb +23 -0
- data/lib/heroku-headless/deployer.rb +14 -0
- data/lib/heroku-headless/talks_to_heroku.rb +1 -1
- data/lib/heroku-headless/version.rb +1 -1
- data/spec/deploy_spec.rb +36 -0
- data/spec/spec_helper.rb +6 -0
- metadata +55 -4
data/Rakefile
CHANGED
data/heroku-headless.gemspec
CHANGED
data/lib/heroku-headless.rb
CHANGED
@@ -5,3 +5,26 @@ require "heroku-headless/creates_uuids"
|
|
5
5
|
require "heroku-headless/talks_to_heroku"
|
6
6
|
|
7
7
|
require "heroku-headless/deployer"
|
8
|
+
|
9
|
+
module HerokuHeadless
|
10
|
+
class << self
|
11
|
+
attr_accessor :configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
self.configuration ||= Configuration.new
|
16
|
+
yield(configuration)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.heroku
|
20
|
+
@@heroku ||= Heroku::API.new(:mock => HerokuHeadless.configuration.mock_mode)
|
21
|
+
end
|
22
|
+
|
23
|
+
class Configuration
|
24
|
+
attr_accessor :mock_mode, :post_deploy_commands
|
25
|
+
|
26
|
+
def initialize
|
27
|
+
@post_deploy_commands = []
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
require 'tmpdir'
|
3
|
+
require 'rendezvous'
|
3
4
|
|
4
5
|
module HerokuHeadless
|
5
6
|
class Deployer
|
@@ -19,6 +20,7 @@ module HerokuHeadless
|
|
19
20
|
prep_temp_dir
|
20
21
|
setup_ssh_key
|
21
22
|
do_action('push git to heroku'){ push_head_to_app }
|
23
|
+
do_action('post_deploy_hooks'){ run_post_deploy_hooks }
|
22
24
|
|
23
25
|
ensure
|
24
26
|
cleanup
|
@@ -88,6 +90,18 @@ module HerokuHeadless
|
|
88
90
|
system( {'GIT_SSH'=>custom_git_ssh_path.to_s}, "git push git@heroku.com:#{@app_name}.git HEAD:master" )
|
89
91
|
end
|
90
92
|
|
93
|
+
def run_post_deploy_hooks
|
94
|
+
HerokuHeadless.configuration.post_deploy_commands.each do | command |
|
95
|
+
do_action( command ){ run_command(command) }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def run_command(cmd)
|
100
|
+
data = heroku.post_ps(@app_name, cmd, :attach => true).body
|
101
|
+
rendezvous_url = data['rendezvous_url']
|
102
|
+
Rendezvous.start(:url => rendezvous_url) unless rendezvous_url.nil?
|
103
|
+
end
|
104
|
+
|
91
105
|
def custom_git_ssh_path
|
92
106
|
@tmpdir.join('git-ssh')
|
93
107
|
end
|
data/spec/deploy_spec.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'HerokuHeadless' do
|
4
|
+
let(:heroku) { HerokuHeadless.heroku }
|
5
|
+
|
6
|
+
it "should fail to deploy a missing app" do
|
7
|
+
HerokuHeadless::Deployer.deploy('missing_app')
|
8
|
+
$?.exitstatus.should_not eq 0
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should successfully deploy an existing app" do
|
12
|
+
heroku.post_app(:name => 'existing_app')
|
13
|
+
# Creating an app on heroku actually isn't enough to make the git push pass!
|
14
|
+
HerokuHeadless::Deployer.any_instance.should_receive(:push_git)
|
15
|
+
HerokuHeadless::Deployer.deploy('existing_app')
|
16
|
+
$?.exitstatus.should eq 0
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should call post-deploy actions" do
|
20
|
+
heroku.post_app(:name => 'app_with_db')
|
21
|
+
|
22
|
+
HerokuHeadless.configure do | config |
|
23
|
+
config.post_deploy_commands = [
|
24
|
+
'echo hello',
|
25
|
+
'echo success'
|
26
|
+
]
|
27
|
+
end
|
28
|
+
|
29
|
+
HerokuHeadless::Deployer.any_instance.should_receive(:push_git)
|
30
|
+
HerokuHeadless::Deployer.any_instance.should_receive(:run_command).with('echo hello')
|
31
|
+
HerokuHeadless::Deployer.any_instance.should_receive(:run_command).with('echo success')
|
32
|
+
|
33
|
+
HerokuHeadless::Deployer.deploy('app_with_db')
|
34
|
+
$?.exitstatus.should eq 0
|
35
|
+
end
|
36
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku-headless
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: heroku-api
|
@@ -27,6 +27,54 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rendezvous
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: pry
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
30
78
|
description: Push from your git repo to a heroku app without any external configuration.
|
31
79
|
email:
|
32
80
|
- phodgson@thoughtworks.com
|
@@ -48,6 +96,8 @@ files:
|
|
48
96
|
- lib/heroku-headless/documents_actions.rb
|
49
97
|
- lib/heroku-headless/talks_to_heroku.rb
|
50
98
|
- lib/heroku-headless/version.rb
|
99
|
+
- spec/deploy_spec.rb
|
100
|
+
- spec/spec_helper.rb
|
51
101
|
homepage: https://github.com/moredip/heroku-headless
|
52
102
|
licenses: []
|
53
103
|
post_install_message:
|
@@ -73,5 +123,6 @@ signing_key:
|
|
73
123
|
specification_version: 3
|
74
124
|
summary: Heroku's workflow is geared towards pushing to a heroku app from a dev workstation.
|
75
125
|
This gem makes it easy to push to a heroku app as part of a CI/CD setup.
|
76
|
-
test_files:
|
77
|
-
|
126
|
+
test_files:
|
127
|
+
- spec/deploy_spec.rb
|
128
|
+
- spec/spec_helper.rb
|