heroploy 0.0.2 → 0.0.3

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: c2596af30153567d6c7fff7dd776b944029034b6
4
- data.tar.gz: a1ff270a3b794fb801bc226331c5277059a9b918
3
+ metadata.gz: 356baf2c9b896ba5dddc86702c4b549e7af81824
4
+ data.tar.gz: 79fb1cea8d3206b14e22c37f087bf967702bcd99
5
5
  SHA512:
6
- metadata.gz: 35de3c056e9eff9e0f0cb2a463f20bdce9265ba9247086939e8a0fc1a4f9533d6244aa67cd55c04b342c538f5b65e92bafe1343dca99dfbeac12d1aff9613804
7
- data.tar.gz: b369f61be1d4bd0f4caa0d5524125494be8204a2a9b504baf19db95c7a717efe080bc2f47fd3bdf5a3947198109827e3823f1a3c8a534bf07fde0c685b3de390
6
+ metadata.gz: c0963dd5196fffa11e2307f5481dbd02bd0d75b794bba7427a487fa2657a5154c524fa1d7639c080862d29da35bc199dca2c7007fdcde3df1cf26444c7458960
7
+ data.tar.gz: 14460f37d4ebe158c98d8a3c4dce756f83064a1b9d96cd8dc10658a1a0cf5d763ffe4fc846fdbc5771542066dfe9e88aa5ba8a6d76aa23c175b3271fe0a69c3e
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/README.md CHANGED
@@ -3,6 +3,7 @@
3
3
  [![Build Status](https://travis-ci.org/jbrunton/heroploy.png?branch=master)](https://travis-ci.org/jbrunton/heroploy)
4
4
  [![Dependency Status](https://gemnasium.com/jbrunton/heroploy.png)](https://gemnasium.com/jbrunton/heroploy)
5
5
  [![Code Climate](https://codeclimate.com/github/jbrunton/heroploy.png)](https://codeclimate.com/github/jbrunton/heroploy)
6
+ [![Coverage Status](https://coveralls.io/repos/jbrunton/heroploy/badge.png?branch=master)](https://coveralls.io/r/jbrunton/heroploy?branch=master)
6
7
 
7
8
  A few helpful rake tasks to manage deploying Rails apps to development, staging and production Heroku servers.
8
9
 
@@ -24,21 +25,25 @@ Or install it yourself as:
24
25
 
25
26
  Add a ```heroploy.yml``` file to your application's config directory which describes the Heroku apps you will deploy to, and the checks you would like when deploying to each.
26
27
 
27
- For example:
28
+ If you're running Rails, you can use this generator to add an example config file:
29
+
30
+ rails generate heroploy:install
31
+
32
+ Here's an example ```heroploy.yml``` file:
28
33
 
29
34
  ```yaml
30
35
  environments:
31
36
  development:
32
- heroku: my-development-app
37
+ app: my-development-app
33
38
 
34
39
  staging:
35
- heroku: my-staging-app
40
+ app: my-staging-app
36
41
  checks:
37
42
  pushed: true
38
43
  branch: master
39
44
 
40
45
  production:
41
- heroku: my-production-app
46
+ app: my-production-app
42
47
  tag: 'RELEASE_%Y%m%dT%H%M%S%z'
43
48
  checks:
44
49
  pushed: true
data/heroploy.gemspec CHANGED
@@ -20,6 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.add_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rails"
23
24
  spec.add_development_dependency "rspec"
24
25
  spec.add_development_dependency "factory_girl"
26
+ spec.add_development_dependency "generator_spec"
27
+ spec.add_development_dependency "coveralls"
25
28
  end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Installs a heroploy config file
3
+
4
+ Example:
5
+ rails generate heroploy:install
6
+
7
+ This will create:
8
+ config/heroploy.yml
@@ -0,0 +1,9 @@
1
+ module Heroploy
2
+ class InstallGenerator < Rails::Generators::Base
3
+ source_root File.expand_path('../templates', __FILE__)
4
+
5
+ def copy_config
6
+ copy_file "config/heroploy.yml"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,35 @@
1
+ environments:
2
+
3
+ # Add a development environment, to which you can deploy anything:
4
+ #
5
+ # development:
6
+ # app: my-development-app
7
+
8
+ # You may also want a staging environment, to which you can only deploy pushed
9
+ # commits from master:
10
+ #
11
+ # staging:
12
+ # app: my-staging-app
13
+ # checks:
14
+ # pushed: true
15
+ # branch: master
16
+
17
+ # And here's a possible production app, which requires changes to have first
18
+ # been staged:
19
+
20
+ # production:
21
+ # app: my-production-app
22
+ # tag: 'RELEASE_%Y%m%dT%H%M%S%z'
23
+ # checks:
24
+ # pushed: true
25
+ # branch: master
26
+ # staged: true
27
+
28
+ # Finally, if you have a single Heroku app, this should work for now:
29
+
30
+ heroku:
31
+ app: my-heroku-app-name
32
+ tag: 'RELEASE_%Y%m%dT%H%M%S%z'
33
+ checks:
34
+ pushed: true
35
+ branch: master
@@ -3,7 +3,7 @@ require 'heroploy/config/checks_config'
3
3
  class EnvConfig
4
4
  attr_accessor :name
5
5
  attr_accessor :remote
6
- attr_accessor :heroku
6
+ attr_accessor :app
7
7
  attr_accessor :tag
8
8
  attr_accessor :checks
9
9
 
@@ -12,7 +12,7 @@ class EnvConfig
12
12
 
13
13
  config.name = name
14
14
  config.remote = attrs['remote'] || name
15
- config.heroku = attrs['heroku']
15
+ config.app = attrs['app']
16
16
  config.tag = attrs['tag']
17
17
  config.checks = ChecksConfig.parse(attrs['checks'])
18
18
 
@@ -1,7 +1,7 @@
1
- require 'rails'
2
-
3
1
  module Heroploy
4
- class Railtie < Rails::Railtie
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Heroploy
4
+
5
5
  rake_tasks do
6
6
  load 'heroploy/tasks/tasks.rake'
7
7
  end
@@ -14,43 +14,70 @@ module Heroploy
14
14
  include Commands::Heroku
15
15
  include Commands::Checks
16
16
 
17
+ attr_accessor :deploy_config
18
+ attr_accessor :env_config
19
+ attr_accessor :defined_tasks
20
+
17
21
  def initialize(deploy_config, env_config)
22
+ @deploy_config = deploy_config
23
+ @env_config = env_config
24
+ @defined_tasks = []
25
+ define
26
+ end
27
+
28
+ def define
29
+ define_remote_check
30
+ define_pushed_check
31
+ define_branch_check
32
+ define_staged_check
33
+ define_all_check
34
+ end
35
+
36
+ def define_remote_check
18
37
  desc "check remote exists for #{env_config.name}"
19
38
  task :remote do
20
39
  remote = env_config.remote
21
40
  check_remote(remote)
22
41
  end
23
42
 
24
- all_tasks = [:remote]
25
-
43
+ @defined_tasks << :remote
44
+ end
45
+
46
+ def define_pushed_check
26
47
  if env_config.checks.pushed then
27
48
  desc "check changes have been pushed to origin"
28
49
  task :pushed do
29
50
  check_pushed(current_branch)
30
51
  end
31
- all_tasks << :pushed
52
+ @defined_tasks << :pushed
32
53
  end
33
-
54
+ end
55
+
56
+ def define_branch_check
34
57
  if env_config.checks.branch then
35
58
  desc "check we can deploy to #{env_config.name} from the current branch"
36
59
  task :branch do
37
60
  valid_branch = env_config.checks.branch
38
61
  check_branch(current_branch, valid_branch, env_config.name)
39
62
  end
40
- all_tasks << :branch
63
+ @defined_tasks << :branch
41
64
  end
42
-
65
+ end
66
+
67
+ def define_staged_check
43
68
  if env_config.checks.staged then
44
69
  desc "check the changes have already been staged"
45
70
  task :staged do
46
71
  staging_env_config = deploy_config[env_config.checks.staged]
47
72
  check_staged(staging_env_config.remote, current_branch, staging_env_config.name)
48
73
  end
49
- all_tasks << :staged
74
+ @defined_tasks << :staged
50
75
  end
51
-
76
+ end
77
+
78
+ def define_all_check
52
79
  desc "do all the checks for #{env_config.name}"
53
- task :all => all_tasks
80
+ task :all => @defined_tasks
54
81
  end
55
82
  end
56
83
  end
@@ -11,12 +11,26 @@ module Heroploy
11
11
  class DeployTaskLib < ::Rake::TaskLib
12
12
  include ::Rake::DSL if defined?(::Rake::DSL)
13
13
 
14
+ attr_accessor :deploy_config
15
+
14
16
  def initialize(deploy_config)
17
+ @deploy_config = deploy_config
18
+ define
19
+ end
20
+
21
+ def define
22
+ define_fetch_task
23
+ define_env_tasks
24
+ end
25
+
26
+ def define_fetch_task
15
27
  desc 'do a git fetch'
16
28
  task :fetch do
17
29
  git_fetch
18
30
  end
19
-
31
+ end
32
+
33
+ def define_env_tasks
20
34
  deploy_config.environments.each do |env_config|
21
35
  EnvTaskLib.new(deploy_config, env_config)
22
36
  end
@@ -15,34 +15,53 @@ module Heroploy
15
15
  include Commands::Heroku
16
16
  include Commands::Checks
17
17
 
18
+ attr_accessor :deploy_config
19
+ attr_accessor :env_config
20
+
18
21
  def initialize(deploy_config, env_config)
19
- namespace env_config.name do
20
- namespace :check do
21
- CheckTaskLib.new(deploy_config, env_config)
22
- end
23
-
24
- desc "push the current branch to master on #{env_config.name}"
25
- task :push do
26
- git_push_to_master(env_config.remote, current_branch)
27
- end
22
+ @deploy_config = deploy_config
23
+ @env_config = env_config
24
+ define
25
+ end
28
26
 
29
- desc "run database migrations on #{env_config.name}"
30
- task :migrate do
31
- heroku_migrate(env_config.heroku)
32
- end
27
+ def define
28
+ namespace env_config.name do
29
+ define_check_tasks
30
+ define_git_tasks
31
+ define_heroku_tasks
32
+ end
33
+ end
34
+
35
+ def define_check_tasks
36
+ namespace :check do
37
+ CheckTaskLib.new(deploy_config, env_config)
38
+ end
39
+ end
40
+
41
+ def define_git_tasks
42
+ desc "push the current branch to master on #{env_config.name}"
43
+ task :push do
44
+ git_push_to_master(env_config.remote, current_branch)
45
+ end
33
46
 
34
- desc "tag the deployment to #{env_config.name}"
35
- task :tag do
36
- if env_config.tag then
37
- tag = DateTime.now.strftime(env_config.tag)
38
- git_tag(tag, "Deployed #{current_branch} to #{env_config.name}")
39
- git_push_tag(tag)
40
- end
47
+ desc "tag the deployment to #{env_config.name}"
48
+ task :tag do
49
+ if env_config.tag then
50
+ tag = DateTime.now.strftime(env_config.tag)
51
+ git_tag(tag, "Deployed #{current_branch} to #{env_config.name}")
52
+ git_push_tag(tag)
41
53
  end
42
-
43
- desc "deploy to #{env_config.name}"
44
- task :deploy => ['check:all', :push, :migrate, :tag]
45
54
  end
46
55
  end
56
+
57
+ def define_heroku_tasks
58
+ desc "run database migrations on #{env_config.name}"
59
+ task :migrate do
60
+ heroku_migrate(env_config.app)
61
+ end
62
+
63
+ desc "deploy to #{env_config.name}"
64
+ task :deploy => ['check:all', :push, :migrate, :tag]
65
+ end
47
66
  end
48
67
  end
@@ -1,6 +1,10 @@
1
1
  require 'heroploy/tasks/deploy_task_lib'
2
2
 
3
3
  namespace :heroploy do
4
- deploy_config = DeployConfig.load
5
- Heroploy::DeployTaskLib.new(deploy_config)
4
+ begin
5
+ deploy_config = DeployConfig.load
6
+ Heroploy::DeployTaskLib.new(deploy_config)
7
+ rescue Errno::ENOENT
8
+ puts "Warning: no config file present for Heroploy. Run 'rails generate heroploy:install' or add a heroploy.yml file to your project."
9
+ end
6
10
  end
@@ -1,3 +1,3 @@
1
1
  module Heroploy
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/heroploy.rb CHANGED
@@ -1,5 +1,7 @@
1
+ require "rails"
2
+
1
3
  require "heroploy/version"
2
- require File.join(File.dirname(__FILE__), 'railtie.rb') if defined?(Rails) && Rails::VERSION::MAJOR >= 3
4
+ require "heroploy/engine" if defined?(Rails) && Rails::VERSION::MAJOR >= 3
3
5
 
4
6
  module Heroploy
5
7
  def self.root
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+ require File.expand_path('../../../../../lib/generators/heroploy/install/install_generator', __FILE__)
3
+
4
+ describe Heroploy::InstallGenerator do
5
+ include_context "generator"
6
+
7
+ it "copies the heroploy.yml template" do
8
+ destination_root.should have_structure {
9
+ directory 'config' do
10
+ file 'heroploy.yml'
11
+ end
12
+ }
13
+ end
14
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,25 @@
1
+ require 'coveralls'
2
+ Coveralls.wear! do
3
+ add_filter '/spec/'
4
+ end
5
+
1
6
  require 'factory_girl'
7
+ require 'rails/generators'
8
+
9
+ require "generator_spec/test_case"
10
+ require "generator_spec/matcher"
2
11
 
3
12
  require 'heroploy'
4
13
  require 'heroploy/tasks/deploy_task_lib'
5
14
 
6
15
  require 'support/shell_support'
7
16
  require 'support/shared_contexts/rake'
17
+ require 'support/shared_contexts/generator'
8
18
 
9
19
  FactoryGirl.find_definitions
10
20
 
21
+ TMP_ROOT = Pathname.new(File.expand_path('../tmp', __FILE__))
22
+
11
23
  RSpec.configure do |config|
12
24
  config.color_enabled = true
13
25
 
@@ -0,0 +1,17 @@
1
+ shared_context "generator" do
2
+ include GeneratorSpec::TestCase
3
+ destination TMP_ROOT
4
+
5
+ before(:all) do
6
+ prepare_destination
7
+
8
+ APP_CONFIG_PATH = TMP_ROOT.join('config')
9
+ FileUtils.mkpath APP_CONFIG_PATH
10
+
11
+ run_generator
12
+ end
13
+
14
+ after(:all) do
15
+ FileUtils.rm_rf TMP_ROOT
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Brunton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-28 00:00:00.000000000 Z
11
+ date: 2014-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rspec
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,34 @@ dependencies:
66
80
  - - '>='
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: generator_spec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
69
111
  description: Helpful rake tasks to manage deploying to development, staging and production
70
112
  Heroku servers
71
113
  email:
@@ -74,6 +116,7 @@ executables: []
74
116
  extensions: []
75
117
  extra_rdoc_files: []
76
118
  files:
119
+ - .coveralls.yml
77
120
  - .gitignore
78
121
  - .travis.yml
79
122
  - Gemfile
@@ -81,6 +124,9 @@ files:
81
124
  - README.md
82
125
  - Rakefile
83
126
  - heroploy.gemspec
127
+ - lib/generators/heroploy/install/USAGE
128
+ - lib/generators/heroploy/install/install_generator.rb
129
+ - lib/generators/heroploy/install/templates/config/heroploy.yml
84
130
  - lib/heroploy.rb
85
131
  - lib/heroploy/commands/checks.rb
86
132
  - lib/heroploy/commands/git.rb
@@ -89,13 +135,14 @@ files:
89
135
  - lib/heroploy/config/checks_config.rb
90
136
  - lib/heroploy/config/deploy_config.rb
91
137
  - lib/heroploy/config/env_config.rb
138
+ - lib/heroploy/engine.rb
92
139
  - lib/heroploy/tasks/check_task_lib.rb
93
140
  - lib/heroploy/tasks/deploy_task_lib.rb
94
141
  - lib/heroploy/tasks/env_task_lib.rb
95
142
  - lib/heroploy/tasks/tasks.rake
96
143
  - lib/heroploy/version.rb
97
- - lib/railtie.rb
98
144
  - spec/factories.rb
145
+ - spec/lib/generators/heroploy/install_generator_spec.rb
99
146
  - spec/lib/heroploy/commands/checks_spec.rb
100
147
  - spec/lib/heroploy/commands/git_spec.rb
101
148
  - spec/lib/heroploy/commands/heroku_spec.rb
@@ -107,6 +154,7 @@ files:
107
154
  - spec/lib/heroploy/tasks/check_staged_spec.rb
108
155
  - spec/spec_helper.rb
109
156
  - spec/support/helpers/deploy_config_helper.rb
157
+ - spec/support/shared_contexts/generator.rb
110
158
  - spec/support/shared_contexts/rake.rb
111
159
  - spec/support/shell_support.rb
112
160
  homepage: ''
@@ -135,6 +183,7 @@ specification_version: 4
135
183
  summary: Helpful rake tasks for deploying to Heroku
136
184
  test_files:
137
185
  - spec/factories.rb
186
+ - spec/lib/generators/heroploy/install_generator_spec.rb
138
187
  - spec/lib/heroploy/commands/checks_spec.rb
139
188
  - spec/lib/heroploy/commands/git_spec.rb
140
189
  - spec/lib/heroploy/commands/heroku_spec.rb
@@ -146,5 +195,6 @@ test_files:
146
195
  - spec/lib/heroploy/tasks/check_staged_spec.rb
147
196
  - spec/spec_helper.rb
148
197
  - spec/support/helpers/deploy_config_helper.rb
198
+ - spec/support/shared_contexts/generator.rb
149
199
  - spec/support/shared_contexts/rake.rb
150
200
  - spec/support/shell_support.rb