jumpup-heroku 0.0.3 → 0.0.4

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: cf991ff339b56efcc4409daa1ac095316681651b
4
- data.tar.gz: 90f2a0d694367ac749ff7185d6132e27e3d79c56
3
+ metadata.gz: 118a1d1cc65a278d3ec2a5c3b74ffaf3a67a8209
4
+ data.tar.gz: 9dcc7fb2c844f5499f70ef72516be88a1b436e4a
5
5
  SHA512:
6
- metadata.gz: 33d61d74d911d8debbdfa11f5cb8e4929ee7ff462cc1388deea4d39a7db36347b5b6c8b63b448581cb6c5b3ff7a40e02d266335384fb95016b9e4d0af595c008
7
- data.tar.gz: 3e41ca498967a2dbfd875936a346c33a899db1b73355c52ed9e7b98b588a6ff6b4936dca021a52c49fa58ec729c95d04a71e306d97a78062c7c96f0ac6a229c3
6
+ metadata.gz: d4e8cc321ff6d3be90ebbaed0528ba24b7031ec8bceed934c2943e8b30e73ead58dc2100f6e7fae0b5a8dd6a49c04019e3bafced352d5541553f841f98c8fa20
7
+ data.tar.gz: d4f9ad4f84115ca9abef1d6f1dcc85cfae9e23b290912c1f6c03bceed48680c91668651fa429b329ac10e34e2f3bb96ab91c0f7c21aeec9397db96b99a8c7f42
data/CHANGELOG.md CHANGED
@@ -1,6 +1,43 @@
1
1
  # Changelog
2
2
 
3
- ## 0.0.1 (Unreleased)
3
+ ## 0.0.4 (February 21, 2014)
4
+
5
+ ### features
6
+
7
+ ### improvements
8
+ - `rake integrate` now fails if a push to heroku fails [[GH-21](https://github.com/Helabs/jumpup-heroku/pull/21)]
9
+ - Make integrate:production as an alias to jumpup:heroku:deploy:production
10
+ - Add info about how release the gem
11
+ - Add info about best practices
12
+ - More info on README
13
+ - Do not set INTEGRATING_BY again if you're already there
14
+ - Add info about current branch when git push
15
+ - Make sure that git name is setup
16
+
17
+ ### bug fixes
18
+
19
+ ## 0.0.3 (January 20, 2014)
20
+
21
+ ### features
22
+
23
+ ### improvements
24
+
25
+ ### bug fixes
26
+ - Fix bug on heroku-account
27
+
28
+ ## 0.0.2 (January 16, 2014)
29
+
30
+ ### features
31
+
32
+ ### improvements
33
+ - Better README
34
+ - Make Rake spec as default Rake
35
+ - Compacted some tasks into start and finish tasks
36
+ - Add heroku-accounts support
37
+
38
+ ### bug fixes
39
+
40
+ ## 0.0.1 (January 07, 2014)
4
41
 
5
42
  ### features
6
43
 
data/CONTRIBUTING.md CHANGED
@@ -27,21 +27,5 @@ At this point you're waiting on us. We like to at least comment on, if not
27
27
  accept, pull requests within three business days (and, typically, one business
28
28
  day). We may suggest some changes or improvements or alternatives.
29
29
 
30
- Some things that will increase the chance that your pull request is accepted,
31
- taken straight from the Ruby on Rails guide:
30
+ Some things that will increase the chance that your pull request is accepted is to follow the practices described on [Ruby style guide](https://github.com/bbatsov/ruby-style-guide), [Rails style guide](https://github.com/bbatsov/rails-style-guide) and [Better Specs](http://betterspecs.org/).
32
31
 
33
- * Use Rails idioms and helpers
34
- * Include tests that fail without your code, and pass with it
35
- * Update the documentation, the surrounding one, examples elsewhere, guides,
36
- whatever is affected by your contribution
37
-
38
- Syntax:
39
-
40
- * Two spaces, no tabs.
41
- * No trailing whitespace. Blank lines should not have any space.
42
- * Prefer &&/|| over and/or.
43
- * my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
44
- * a = b and not a=b.
45
- * Follow the conventions you see used in the source already.
46
-
47
- And in case we didn't emphasize it enough: we love tests!
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # Jumpup-heroku
2
+ [![RubyGems][gem_version_badge]][ruby_gems]
2
3
 
3
4
  Rake tasks to deploy any Rails application on [Heroku](http://heroku.com) using [Jumpup](https://github.com/Helabs/jumpup).
4
5
 
@@ -7,7 +8,7 @@ Rake tasks to deploy any Rails application on [Heroku](http://heroku.com) using
7
8
  Add to your gem file.
8
9
 
9
10
  ```ruby
10
- gem 'jumpup-heroku', github: 'Helabs/jumpup-heroku'
11
+ gem 'jumpup-heroku'
11
12
  ```
12
13
 
13
14
  Without groups on Gemfile, because of initializer.
@@ -20,7 +21,7 @@ Without groups on Gemfile, because of initializer.
20
21
  # config/initializers/jumpup-heroku.rb
21
22
  Jumpup::Heroku.configure do |config|
22
23
  config.app = 'myapp'
23
- end
24
+ end if Rails.env.development?
24
25
  ```
25
26
 
26
27
  If you use [Heroku Accounts](https://github.com/ddollar/heroku-accounts)
@@ -35,7 +36,7 @@ Without groups on Gemfile, because of initializer.
35
36
  account2.app = 'myapp2'
36
37
  account2.run_database_tasks = false # Default: true
37
38
  end
38
- end
39
+ end if Rails.env.development?
39
40
  ```
40
41
 
41
42
  Have production and staging app? Do like this:
@@ -44,7 +45,7 @@ Without groups on Gemfile, because of initializer.
44
45
  Jumpup::Heroku.configure do |config|
45
46
  config.staging_app = 'myapp-staging'
46
47
  config.production_app = 'myapp'
47
- end
48
+ end if Rails.env.development?
48
49
  ```
49
50
 
50
51
  If you need to disable remote database tasks (backup, migrate and seed):
@@ -53,7 +54,7 @@ Without groups on Gemfile, because of initializer.
53
54
  Jumpup::Heroku.configure do |config|
54
55
  config.app = 'myapp'
55
56
  config.run_database_tasks = false # Default: true
56
- end
57
+ end if Rails.env.development?
57
58
  ```
58
59
 
59
60
  2. Add to the tasks on jumpup.rake the tasks to deploy on Heroku:
@@ -73,6 +74,10 @@ Without groups on Gemfile, because of initializer.
73
74
  )
74
75
  ```
75
76
 
77
+ ### Deploy to production
78
+
79
+ Run ```rake jumpup:heroku:deploy:production``` or as an alias ```rake integrate:production```
80
+
76
81
  ## Versioning
77
82
 
78
83
  Jumpup-heroku follow the [Semantic Versioning](http://semver.org/).
@@ -85,6 +90,17 @@ If you have problems, please create a [Github Issue](https://github.com/Helabs/j
85
90
 
86
91
  Please see [CONTRIBUTING.md](https://github.com/Helabs/jumpup-heroku/blob/master/CONTRIBUTING.md) for details.
87
92
 
93
+ ## Release
94
+
95
+ Follow this steps to release a new version of the gem.
96
+
97
+ 1. Test if everything is running ok;
98
+ 1. Change version of the gem on `VERSION` constant;
99
+ 1. Add the release date on the `CHANGELOG`;
100
+ 1. Do a commit "Bump version x.x.x", follow the semantic version;
101
+ 1. Run `$ rake release`, this will send the gem to the rubygems;
102
+ 1. Check if the gem is on the rubygems and the tags are correct on the github;
103
+
88
104
  ## Credits
89
105
 
90
106
  Jumpup-heroku is maintained and funded by [HE:labs](http://helabs.com.br/opensource/).
@@ -92,4 +108,7 @@ Thank you to all the [contributors](https://github.com/Helabs/jumpup-heroku/grap
92
108
 
93
109
  ## License
94
110
 
95
- Jumpup-heroku is Copyright © 2013-2014 HE:labs. It is free software, and may be redistributed under the terms specified in the LICENSE file.
111
+ Jumpup-heroku is Copyright © 2013-2014 HE:labs. It is free software, and may be redistributed under the terms specified in the LICENSE file.
112
+
113
+ [gem_version_badge]: https://badge.fury.io/rb/jumpup-heroku.png
114
+ [ruby_gems]: http://rubygems.org/gems/jumpup-heroku
@@ -7,7 +7,7 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "jumpup-heroku"
8
8
  spec.version = Jumpup::Heroku::VERSION
9
9
  spec.authors = ["HE:labs"]
10
- spec.email = ["contato@helabs.com.br"]
10
+ spec.email = ["tech@helabs.com.br"]
11
11
  spec.description = %q{Rake tasks to deploy on heroku}
12
12
  spec.summary = %q{Rake tasks to deploy on heroku}
13
13
  spec.homepage = "https://github.com/Helabs/jumpup-heroku"
data/lib/jumpup/heroku.rb CHANGED
@@ -9,9 +9,5 @@ module Jumpup
9
9
  end
10
10
  end
11
11
 
12
- def gem_path
13
- Gem::Specification.find_by_name('jumpup-heroku').full_gem_path
14
- end
15
-
12
+ gem_path = Gem::Specification.find_by_name('jumpup-heroku').full_gem_path
16
13
  Dir["#{gem_path}/lib/tasks/*.rake"].each { |ext| load ext } if defined?(Rake)
17
-
@@ -40,6 +40,12 @@ module Jumpup
40
40
  end
41
41
 
42
42
  def deploy
43
+ if run_database_tasks?
44
+ run_with_clean_env('git fetch heroku')
45
+ check_if_migration_is_needed
46
+ check_if_seed_is_needed
47
+ end
48
+
43
49
  backup
44
50
  push
45
51
  migrate
@@ -48,6 +54,12 @@ module Jumpup
48
54
  end
49
55
 
50
56
  def deploy_to_production
57
+ if run_database_tasks?
58
+ run_with_clean_env('git fetch heroku')
59
+ check_if_migration_is_needed
60
+ check_if_seed_is_needed
61
+ end
62
+
51
63
  confirm_deploy
52
64
  spec
53
65
  confirm_maintenance
@@ -63,43 +75,79 @@ module Jumpup
63
75
 
64
76
  def add_remote
65
77
  puts "--> Adding Heroku git remotes for app #{app}"
66
- remote = run_with_clean_env("git remote | grep heroku", true).strip
67
- run_with_clean_env("git remote add heroku git@heroku.com:#{app}.git") if remote.blank?
78
+ remote = run_with_clean_env("git remote | grep heroku").strip
79
+ exec_with_clean_env("git remote add heroku git@heroku.com:#{app}.git") if remote.blank?
68
80
  end
69
81
 
70
82
  def check
71
83
  puts "--> Checking if there's already someone integrating to #{app}"
72
84
 
73
- var = run_with_clean_env("heroku config -s --app #{app} | grep INTEGRATING_BY", true).strip
74
- integrating_by = var.split('=')[1]
85
+ return if can_start_integration?(user)
75
86
 
76
- integrating_by.strip! unless integrating_by.blank?
77
-
78
- if integrating_by != user and not integrating_by.blank?
79
- puts "--> Project is already being integrated by '#{integrating_by}', halting"
80
- exit
81
- end
87
+ puts "--> Project is already being integrated by '#{integrating_by}', halting"
88
+ exit 1
82
89
  end
83
90
 
84
91
  def lock
92
+ return if integrating_by?(user)
93
+
85
94
  puts "--> Locking Heroku integration for you (#{user})"
86
- run_with_clean_env("heroku config:set INTEGRATING_BY='#{user}' --app #{app}")
95
+ exec_with_clean_env("heroku config:set INTEGRATING_BY='#{user}' --app #{app}")
87
96
  end
88
97
 
89
98
  def unlock
90
99
  puts "--> Unlocking Heroku integration"
91
- run_with_clean_env("heroku config:unset INTEGRATING_BY --app #{app}")
100
+ exec_with_clean_env("heroku config:unset INTEGRATING_BY --app #{app}")
92
101
  end
93
102
 
94
103
  private
95
104
  attr_reader :app, :envs, :maintenance_mode
96
105
 
106
+ def check_if_migration_is_needed
107
+ files_changed = run_with_clean_env("git diff HEAD heroku/master --name-only -- db/migrate | wc -l").strip.to_i
108
+ @migrations_changed = files_changed > 0
109
+ end
110
+
111
+ def check_if_seed_is_needed
112
+ files_changed = run_with_clean_env("git diff HEAD heroku/master --name-only -- db/seeds* | wc -l").strip.to_i
113
+ @seeds_changed = files_changed > 0
114
+ end
115
+
116
+ def can_start_integration?(user)
117
+ integrating_by.blank? || integrating_by?(user)
118
+ end
119
+
120
+ def integrating_by?(user)
121
+ integrating_by == user
122
+ end
123
+
124
+ def integrating_by
125
+ @integrating_by ||= run_with_clean_env("heroku config:get INTEGRATING_BY --app #{app}").strip
126
+ end
127
+
97
128
  def user
98
- @user ||= run_with_clean_env("git config --get user.name", true).strip
129
+ @user ||= validate_username
130
+ end
131
+
132
+ def validate_username
133
+ user = run_with_clean_env("git config --get user.name").strip
134
+ if user.blank?
135
+ puts "--> You must setup your git user name. Use: git config --global user.name 'your name'"
136
+ exit 1
137
+ end
138
+ user
139
+ end
140
+
141
+ def run_with_clean_env(command)
142
+ Bundler.with_clean_env { `#{command}` }
99
143
  end
100
144
 
101
- def run_with_clean_env(command, capture_output = false)
102
- Bundler.with_clean_env { capture_output ? `#{command}` : system(command) }
145
+ def exec_with_clean_env(command)
146
+ Bundler.with_clean_env do
147
+ unless system(command)
148
+ raise "Error while running #{command}"
149
+ end
150
+ end
103
151
  end
104
152
 
105
153
  def confirm(message)
@@ -114,33 +162,43 @@ module Jumpup
114
162
  def backup
115
163
  return unless run_database_tasks?
116
164
  puts "--> [#{app}] Backing up database"
117
- run_with_clean_env("heroku pgbackups:capture --expire --app #{app}")
165
+ exec_with_clean_env("heroku pgbackups:capture --expire --app #{app}")
118
166
  end
119
167
 
120
168
  def migrate
121
169
  return unless run_database_tasks?
122
- puts "--> [#{app}] Migrating"
123
- run_with_clean_env("heroku run rake db:migrate --app #{app}")
170
+
171
+ if @migrations_changed
172
+ puts "--> [#{app}] Migrating"
173
+ exec_with_clean_env("heroku run rake db:migrate --app #{app}")
174
+ else
175
+ puts "--> [#{app}] Skipping migrations"
176
+ end
124
177
  end
125
178
 
126
179
  def seed
127
180
  return unless run_database_tasks?
128
- puts "--> [#{app}] Seeding"
129
- run_with_clean_env("heroku run rake db:seed --app #{app}")
181
+
182
+ if @seeds_changed
183
+ puts "--> [#{app}] Seeding"
184
+ exec_with_clean_env("heroku run rake db:seed --app #{app}")
185
+ else
186
+ puts "--> [#{app}] Skipping seeds"
187
+ end
130
188
  end
131
189
 
132
190
  def restart
133
191
  puts "--> [#{app}] Restarting"
134
- run_with_clean_env("heroku restart --app #{app}")
192
+ exec_with_clean_env("heroku restart --app #{app}")
135
193
  end
136
194
 
137
195
  def push
138
- puts "--> [#{app}] Pushing to #{host}"
139
- run_with_clean_env("git push git@#{host}:#{app}.git HEAD:master")
196
+ puts "--> [#{app}] Pushing to #{host} from branch [#{actual_branch}]"
197
+ exec_with_clean_env("git push git@#{host}:#{app}.git HEAD:master")
140
198
  end
141
199
 
142
200
  def confirm_deploy
143
- confirm("Going deploy to production [#{app}]...")
201
+ confirm("[#{app}] Deploying to production using brach [#{actual_branch}]")
144
202
  end
145
203
 
146
204
  def spec
@@ -160,7 +218,7 @@ module Jumpup
160
218
  def maintenance
161
219
  if maintenance?
162
220
  puts "--> [#{app}] Setting Maintenance on"
163
- run_with_clean_env("heroku maintenance:on --app #{app}")
221
+ exec_with_clean_env("heroku maintenance:on --app #{app}")
164
222
  restart
165
223
  puts "--> [#{app}] Waiting 20 seconds to app come back (in maintenance mode)"
166
224
  sleep(20)
@@ -172,22 +230,26 @@ module Jumpup
172
230
  tag_name = "production-#{iso_date}"
173
231
 
174
232
  puts "--> Tagging as #{tag_name}"
175
- run_with_clean_env("git tag #{tag_name} master")
233
+ exec_with_clean_env("git tag #{tag_name} master")
176
234
 
177
235
  puts "--> Pushing to origin"
178
- run_with_clean_env("git push origin #{tag_name}")
236
+ exec_with_clean_env("git push origin #{tag_name}")
179
237
  end
180
238
 
181
239
  def close_maintenance
182
240
  if maintenance?
183
241
  puts "Setting Maintenance off"
184
- run_with_clean_env("heroku maintenance:off --app #{app}")
242
+ exec_with_clean_env("heroku maintenance:off --app #{app}")
185
243
  end
186
244
  end
187
245
 
188
246
  def host
189
247
  Env.all[:host]
190
248
  end
249
+
250
+ def actual_branch
251
+ run_with_clean_env("git rev-parse --abbrev-ref HEAD").strip
252
+ end
191
253
  end
192
254
  end
193
255
  end
@@ -1,5 +1,5 @@
1
1
  module Jumpup
2
2
  module Heroku
3
- VERSION = "0.0.3"
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
@@ -30,7 +30,6 @@ namespace :jumpup do
30
30
  end
31
31
 
32
32
  namespace :deploy do
33
-
34
33
  desc "Deploy to production"
35
34
  task production: :environment do
36
35
  Jumpup::Heroku::Integrate.deploy_to_production
@@ -39,3 +38,10 @@ namespace :jumpup do
39
38
  end
40
39
  end
41
40
 
41
+ namespace :integrate do
42
+ desc 'Alias to jumpup:heroku:deploy:production'
43
+ task production: :environment do
44
+ Rake.application.invoke_task('jumpup:heroku:deploy:production')
45
+ end
46
+ end
47
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jumpup-heroku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - HE:labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-23 00:00:00.000000000 Z
11
+ date: 2014-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -68,7 +68,7 @@ dependencies:
68
68
  version: 0.9.12.4
69
69
  description: Rake tasks to deploy on heroku
70
70
  email:
71
- - contato@helabs.com.br
71
+ - tech@helabs.com.br
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  version: '0'
114
114
  requirements: []
115
115
  rubyforge_project:
116
- rubygems_version: 2.0.3
116
+ rubygems_version: 2.0.5
117
117
  signing_key:
118
118
  specification_version: 4
119
119
  summary: Rake tasks to deploy on heroku