dpl 1.4.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0cecca7ef24d3f361ec9223717864de564b32774
4
- data.tar.gz: 72503b1ab9b7fcc3ce7cd62978e66cd8c06df987
3
+ metadata.gz: 478f6fafe432230c66b9452ba5072588ea0f9dc1
4
+ data.tar.gz: 45db3d5e7a930300a7a8779e084976c29548929d
5
5
  SHA512:
6
- metadata.gz: fae71f0cced6af6138be71f8e3b4aeb2740f408a1a6aa853448ae8ddd7a6a55747fd56d3895fbd85ee97cdc2a2f27865843c2656ddc8f4925615f39347143b6d
7
- data.tar.gz: e7329ad282929d20b658605bd545c2cf890a31a2df5b9fd8cca0f552cf5d3267c89eed3844fb08baf336f5b4edd744ebcb852eceee5c7beda59fbb2f5898eded
6
+ metadata.gz: bc6991fc24f3249decd6ceb3bd5fb584e14f5dce4304411b188222153702310c5fc0edfd162887ffd8fdf02630c9a50fc4a78fc48c502b2bede6da03ba9f4a6b
7
+ data.tar.gz: 7b3045f1eaabb9bf25f5706cc46d2aa2df5b63b3fd498868e226d4f45ddc1d2bc9344ec5f4534101c52f4bc2bb5e3b2489df75550f63d983f246ed709c0c8354
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ gemspec
4
4
  group :heroku do
5
5
  gem 'rendezvous'
6
6
  gem 'heroku-api'
7
+ gem 'anvil-cli'
7
8
  end
8
9
 
9
10
  group :openshift do
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.add_development_dependency 'rspec'
20
20
  s.add_development_dependency 'rake'
21
21
  s.add_development_dependency 'simplecov'
22
+ s.add_development_dependency 'json'
22
23
  end
@@ -64,37 +64,47 @@ module DPL
64
64
  end
65
65
  end
66
66
 
67
+ def should_deploy?
68
+ (not options[:tags_only] or has_tag?)
69
+ end
70
+
71
+ def has_tag?
72
+ context.shell('git describe --exact-match')
73
+ $?.success?
74
+ end
75
+
67
76
  def deploy
68
77
  rm_rf ".dpl"
69
78
  mkdir_p ".dpl"
70
-
71
- context.fold("Preparing deploy") do
72
- check_auth
73
- check_app
74
-
75
- if needs_key?
76
- create_key(".dpl/id_rsa")
77
- setup_key(".dpl/id_rsa.pub")
78
- setup_git_ssh(".dpl/git-ssh", ".dpl/id_rsa")
79
+ if should_deploy?
80
+ context.fold("Preparing deploy") do
81
+ check_auth
82
+ check_app
83
+
84
+ if needs_key?
85
+ create_key(".dpl/id_rsa")
86
+ setup_key(".dpl/id_rsa.pub")
87
+ setup_git_ssh(".dpl/git-ssh", ".dpl/id_rsa")
88
+ end
89
+
90
+ cleanup
79
91
  end
80
92
 
81
- cleanup
82
- end
83
-
84
- context.fold("Deploying application") { push_app }
93
+ context.fold("Deploying application") { push_app }
85
94
 
86
- Array(options[:run]).each do |command|
87
- if command == 'restart'
88
- context.fold("Restarting application") { restart }
89
- else
90
- context.fold("Running %p" % command) { run(command) }
95
+ Array(options[:run]).each do |command|
96
+ if command == 'restart'
97
+ context.fold("Restarting application") { restart }
98
+ else
99
+ context.fold("Running %p" % command) { run(command) }
100
+ end
91
101
  end
92
102
  end
93
- ensure
94
- if needs_key?
95
- remove_key rescue nil
103
+ ensure
104
+ if needs_key?
105
+ remove_key rescue nil
106
+ end
96
107
  end
97
- end
98
108
 
99
109
  def sha
100
110
  @sha ||= ENV['TRAVIS_COMMIT'] || `git rev-parse HEAD`.strip
@@ -2,6 +2,8 @@ module DPL
2
2
  class Provider
3
3
  module Heroku
4
4
  class Anvil < Git
5
+ HEROKU_BUILDPACKS = ['ruby', 'nodejs', 'clojure', 'python', 'java', 'gradle', 'grails', 'scala', 'play']
6
+ HEROKU_BUILDPACK_PREFIX = "https://github.com/heroku/heroku-buildpack-"
5
7
  requires 'anvil-cli', :load => 'anvil/engine'
6
8
  requires 'excon' # comes with heroku
7
9
  requires 'json'
@@ -40,7 +42,10 @@ module DPL
40
42
  @slug_url ||= begin
41
43
  ::Anvil.headers["X-Heroku-User"] = user
42
44
  ::Anvil.headers["X-Heroku-App"] = option(:app)
43
- ::Anvil::Engine.build "."
45
+ if HEROKU_BUILDPACKS.include? options[:buildpack]
46
+ options[:buildpack] = HEROKU_BUILDPACK_PREFIX + options[:buildpack]
47
+ end
48
+ ::Anvil::Engine.build ".", :buildpack => options[:buildpack]
44
49
  rescue ::Anvil::Builder::BuildError => e
45
50
  raise Error, "deploy failed, anvil build error: #{e.message}"
46
51
  end
@@ -52,4 +57,4 @@ module DPL
52
57
  end
53
58
  end
54
59
  end
55
- end
60
+ end
@@ -1,3 +1,3 @@
1
1
  module DPL
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  end
@@ -0,0 +1,80 @@
1
+ require 'spec_helper'
2
+ require 'anvil'
3
+ require 'heroku-api'
4
+ require 'excon'
5
+ require 'dpl/provider/heroku'
6
+
7
+ describe DPL::Provider::Heroku do
8
+ subject :provider do
9
+ described_class.new(DummyContext.new, :app => 'example', :api_key => 'foo', :strategy => 'anvil', :buildpack => 'git://some-buildpack.git')
10
+ end
11
+
12
+ describe :api do
13
+ it 'accepts an api key' do
14
+ api = double(:api)
15
+ lambda { provider.api }.should_not raise_error
16
+ end
17
+
18
+ it 'raises an error if an api key is not present' do
19
+ provider.options.delete :api_key
20
+ lambda { provider.api }.should raise_error(DPL::Error)
21
+ end
22
+ end
23
+
24
+ context "with fake api" do
25
+ let :api do
26
+ double "api",
27
+ :get_user => double("get_user", :body => { "email" => "foo@bar.com" }),
28
+ :get_app => double("get_app", :body => { "name" => "example", "git_url" => "GIT URL" })
29
+ end
30
+
31
+ before do
32
+ ::Heroku::API.should_receive(:new).and_return(api)
33
+ provider.api
34
+ end
35
+
36
+ describe :push_app do
37
+ example do
38
+ response = double :response
39
+ response.stub(:status => 202)
40
+ response.stub(:headers => {'Location' => '/blah'})
41
+
42
+ second_response = double :second_response
43
+ second_response.stub(:status => 200)
44
+
45
+ provider.stub(:slug_url => "http://slug-url")
46
+
47
+ ENV.should_receive(:[]).with('TRAVIS_COMMIT').and_return('123')
48
+ ::Excon.should_receive(:post).with(provider.release_url,
49
+ :body => {"slug_url" => "http://slug-url", "description" => "Deploy 123 via Travis CI" }.to_json,
50
+ :headers => {"Content-Type" => 'application/json', 'Accept' => 'application/json'}).and_return(response)
51
+
52
+ ::Excon.should_receive(:get).with("https://:#{provider.options[:api_key]}@cisaurus.heroku.com/blah").and_return(second_response)
53
+ provider.push_app
54
+ end
55
+ end
56
+
57
+ describe :slug_url do
58
+
59
+ before(:each) do
60
+ headers = double(:headers)
61
+ ::Anvil.should_receive(:headers).at_least(:twice).and_return(headers)
62
+ headers.should_receive(:[]=).at_least(:once).with('X-Heroku-User', "foo@bar.com")
63
+ headers.should_receive(:[]=).at_least(:once).with('X-Heroku-App', "example")
64
+ end
65
+
66
+ example "with full buildpack url" do
67
+ ::Anvil::Engine.should_receive(:build).with(".", :buildpack=>"git://some-buildpack.git")
68
+ provider.slug_url
69
+ end
70
+
71
+ example "with buildpack name expansion" do
72
+ DPL::Provider::Heroku::Anvil::HEROKU_BUILDPACKS.each do |b|
73
+ provider.options.update(:buildpack => b)
74
+ ::Anvil::Engine.should_receive(:build).with(".", :buildpack=>described_class::Anvil::HEROKU_BUILDPACK_PREFIX + b)
75
+ provider.slug_url
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -102,4 +102,4 @@ describe DPL::Provider::Heroku do
102
102
  end
103
103
  end
104
104
  end
105
- end
105
+ end
@@ -132,4 +132,19 @@ describe DPL::Provider do
132
132
  expect { provider.error("Foo") }.to raise_error("Foo")
133
133
  end
134
134
  end
135
+
136
+ describe :has_tag? do
137
+ example do
138
+ provider.context.should_receive(:shell).with('git describe --exact-match')
139
+ provider.has_tag?
140
+ end
141
+ end
142
+
143
+ describe :should_deploy? do
144
+ example "tags_only with tag" do
145
+ provider.options[:tags_only] = true
146
+ provider.should_receive(:has_tag?).and_return(true)
147
+ provider.should_deploy?.should be == true
148
+ end
149
+ end
135
150
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dpl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Haase
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-25 00:00:00.000000000 Z
11
+ date: 2013-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: json
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: deploy tool abstraction for clients
56
70
  email: konstantin.mailinglists@googlemail.com
57
71
  executables:
@@ -84,7 +98,8 @@ files:
84
98
  - notes/heroku.md
85
99
  - spec/cli_spec.rb
86
100
  - spec/provider/dotcloud_spec.rb
87
- - spec/provider/heroku_spec.rb
101
+ - spec/provider/heroku_anvil_spec.rb
102
+ - spec/provider/heroku_git_spec.rb
88
103
  - spec/provider/openshift_spec.rb
89
104
  - spec/provider_spec.rb
90
105
  - spec/spec_helper.rb
@@ -115,7 +130,8 @@ summary: deploy tool
115
130
  test_files:
116
131
  - spec/cli_spec.rb
117
132
  - spec/provider/dotcloud_spec.rb
118
- - spec/provider/heroku_spec.rb
133
+ - spec/provider/heroku_anvil_spec.rb
134
+ - spec/provider/heroku_git_spec.rb
119
135
  - spec/provider/openshift_spec.rb
120
136
  - spec/provider_spec.rb
121
137
  - spec/spec_helper.rb