jumpup-deis 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/CONTRIBUTING.md +31 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +129 -0
- data/Rakefile +14 -0
- data/jumpup-heroku.gemspec +25 -0
- data/lib/jumpup/deis.rb +13 -0
- data/lib/jumpup/deis/configuration.rb +55 -0
- data/lib/jumpup/deis/env.rb +27 -0
- data/lib/jumpup/deis/errors.rb +8 -0
- data/lib/jumpup/deis/integrate.rb +187 -0
- data/lib/jumpup/deis/version.rb +5 -0
- data/lib/tasks/integrate.rake +32 -0
- data/spec/jumpup/deis/configuration_spec.rb +290 -0
- data/spec/jumpup/deis/env_spec.rb +73 -0
- data/spec/spec_helper.rb +11 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 531635c07a6aca428890cf81e5064d314aed711e
|
4
|
+
data.tar.gz: ac2100e82b07ea06fe6ca263ad6230cb0ba088ce
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7a23ca29e78880aa80d07819a3767e21a23add1bf79cd72852a59e872c528742bd36e795922fe77da2522f10dd5777bb9961e90fcec78cedcfa2fd1117e7644
|
7
|
+
data.tar.gz: cb8a33efc40d34042473cc2eba5ef4755ea03eea0cb079db7b893b3ae7147a3afb18b9e448d3b77919ec870952691c0fa554271fba5a7fac36f6754cb22ce299
|
data/.gitignore
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jumpup-deis
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.0
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
We love pull requests. Here's a quick guide:
|
4
|
+
|
5
|
+
1. Fork the repo.
|
6
|
+
|
7
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
8
|
+
|
9
|
+
3. Run the tests. We only take pull requests with passing tests, and it's great
|
10
|
+
to know that you have a clean slate: `bundle && rake`
|
11
|
+
|
12
|
+
4. Add a test for your change. Only refactoring and documentation changes
|
13
|
+
require no new tests. If you are adding functionality or fixing a bug, we need
|
14
|
+
a test!
|
15
|
+
|
16
|
+
5. Make the test pass.
|
17
|
+
|
18
|
+
6. Update [CHANGELOG.md](https://github.com/Helabs/jumpup-deis/blob/master/CHANGELOG.md) with a brief description of your changes under the `unreleased` heading.
|
19
|
+
|
20
|
+
7. Commit your changes (`git commit -am 'Added some feature'`)
|
21
|
+
|
22
|
+
8. Push to the branch (`git push origin my-new-feature`)
|
23
|
+
|
24
|
+
9. Create new Pull Request
|
25
|
+
|
26
|
+
At this point you're waiting on us. We like to at least comment on, if not
|
27
|
+
accept, pull requests within three business days (and, typically, one business
|
28
|
+
day). We may suggest some changes or improvements or alternatives.
|
29
|
+
|
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/).
|
31
|
+
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 HE:labs
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# Jumpup-deis
|
2
|
+
[![RubyGems][gem_version_badge]][ruby_gems]
|
3
|
+
[![Code Climate](https://codeclimate.com/github/Helabs/jumpup-deis.png)](https://codeclimate.com/github/Helabs/jumpup-deis)
|
4
|
+
[![Dependency Status](https://gemnasium.com/Helabs/jumpup-deis.svg)](https://gemnasium.com/Helabs/jumpup-deis)
|
5
|
+
|
6
|
+
Rake tasks to deploy any Rails application to [Deis](http://deis.io/) using [Jumpup](https://github.com/Helabs/jumpup).
|
7
|
+
|
8
|
+
## Instalation
|
9
|
+
|
10
|
+
Add to your gem file.
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'jumpup-deis'
|
14
|
+
```
|
15
|
+
|
16
|
+
Without groups on Gemfile as this gem makes use of an initializer.
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
1. Create the initializer on `config/initializers/jumpup-deis.rb`
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
# config/initializers/jumpup-deis.rb
|
24
|
+
Jumpup::Deis.configure do |config|
|
25
|
+
config.host = 'deis.mycompany.com'
|
26
|
+
config.app = 'myapp'
|
27
|
+
end if Rails.env.development?
|
28
|
+
```
|
29
|
+
|
30
|
+
2. Add to the tasks on jumpup.rake the tasks to deploy to Deis:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
# lib/tasks/jumpup.rake
|
34
|
+
|
35
|
+
INTEGRATION_TASKS = %w(
|
36
|
+
jumpup:deis:start
|
37
|
+
jumpup:start
|
38
|
+
jumpup:bundle_install
|
39
|
+
db:migrate
|
40
|
+
spec
|
41
|
+
jumpup:finish
|
42
|
+
jumpup:deis:finish
|
43
|
+
)
|
44
|
+
```
|
45
|
+
|
46
|
+
### Production and staging apps
|
47
|
+
|
48
|
+
Have production and staging app? Do like this:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
Jumpup::Deis.configure do |config|
|
52
|
+
config.host = 'deis.mycompany.com'
|
53
|
+
config.staging_app = 'myapp-staging'
|
54
|
+
config.production_app = 'myapp'
|
55
|
+
end if Rails.env.development?
|
56
|
+
```
|
57
|
+
The branch send to staging app is `master` and the branch send to production is the `production`.
|
58
|
+
|
59
|
+
### Deploy to production
|
60
|
+
|
61
|
+
#### When I have a single app
|
62
|
+
|
63
|
+
Run ```rake jumpup:deis:deploy:production``` or as an alias ```rake integrate:production```
|
64
|
+
|
65
|
+
#### When I have staging and production apps
|
66
|
+
|
67
|
+
We have the following config
|
68
|
+
|
69
|
+
| Branch | App Environment |
|
70
|
+
| ------------- |-----------------|
|
71
|
+
| master | staging |
|
72
|
+
| production | production |
|
73
|
+
|
74
|
+
So to send to production we need to
|
75
|
+
|
76
|
+
```bash
|
77
|
+
$ git checkout production
|
78
|
+
$ git merge master
|
79
|
+
$ git push -u origin production
|
80
|
+
```
|
81
|
+
|
82
|
+
And send to Deis with ```rake jumpup:deis:deploy:production``` or as an alias ```rake integrate:production```
|
83
|
+
|
84
|
+
## Versioning
|
85
|
+
|
86
|
+
Jumpup-deis follow the [Semantic Versioning](http://semver.org/).
|
87
|
+
|
88
|
+
## Issues
|
89
|
+
|
90
|
+
If you have problems, please create a [Github Issue](https://github.com/Helabs/jumpup-deis/issues).
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
|
94
|
+
Please see [CONTRIBUTING.md](https://github.com/Helabs/jumpup-deis/blob/master/CONTRIBUTING.md) for details.
|
95
|
+
|
96
|
+
## Maintainers
|
97
|
+
|
98
|
+
- [Anézio Campos](https://github.com/aneziocampos)
|
99
|
+
- [Rafael Fiuza](https://github.com/guiloyins)
|
100
|
+
|
101
|
+
## Release
|
102
|
+
|
103
|
+
Follow this steps to release a new version of the gem.
|
104
|
+
|
105
|
+
1. Test if everything is running ok;
|
106
|
+
1. Change version of the gem on `VERSION` constant;
|
107
|
+
1. Add the release date on the `CHANGELOG`;
|
108
|
+
1. Do a commit "Bump version x.x.x", follow the semantic version;
|
109
|
+
1. Run `$ rake release`, this will send the gem to the rubygems;
|
110
|
+
1. Check if the gem is on the rubygems and the tags are correct on the github;
|
111
|
+
|
112
|
+
## Credits
|
113
|
+
|
114
|
+
Jumpup-deis is maintained and funded by [HE:labs](http://helabs.com.br/opensource/).
|
115
|
+
Thank you to all the [contributors](https://github.com/Helabs/jumpup-deis/graphs/contributors).
|
116
|
+
|
117
|
+
## License
|
118
|
+
|
119
|
+
Jumpup-deis is Copyright © 2014 HE:labs. It is free software, and may be redistributed under the terms specified in the LICENSE file.
|
120
|
+
|
121
|
+
[gem_version_badge]: https://badge.fury.io/rb/jumpup-deis.png
|
122
|
+
[ruby_gems]: http://rubygems.org/gems/jumpup-deis
|
123
|
+
|
124
|
+
|
125
|
+
## Made with love by HE:labs
|
126
|
+
|
127
|
+
![HE:labs](http://helabs.com.br/images/logo.png)
|
128
|
+
|
129
|
+
This gem was created and is maintained by [HE:labs](https://github.com/Helabs).
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rspec/core'
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
6
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
7
|
+
end
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
10
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
11
|
+
spec.rcov = true
|
12
|
+
end
|
13
|
+
|
14
|
+
task :default => :spec
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'jumpup/deis/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "jumpup-deis"
|
8
|
+
spec.version = Jumpup::Deis::VERSION
|
9
|
+
spec.authors = ["HE:labs"]
|
10
|
+
spec.email = ["tech@helabs.com.br"]
|
11
|
+
spec.description = %q{Rake tasks to deploy on deis}
|
12
|
+
spec.summary = %q{Rake tasks to deploy on deis}
|
13
|
+
spec.homepage = "https://github.com/Helabs/jumpup-deis"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.1.0"
|
24
|
+
spec.add_development_dependency "pry", "0.9.12.4"
|
25
|
+
end
|
data/lib/jumpup/deis.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require "jumpup/deis/version"
|
2
|
+
|
3
|
+
module Jumpup
|
4
|
+
module Deis
|
5
|
+
require 'jumpup/deis/errors'
|
6
|
+
require 'jumpup/deis/configuration'
|
7
|
+
require 'jumpup/deis/env'
|
8
|
+
require 'jumpup/deis/integrate'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
gem_path = Gem::Specification.find_by_name('jumpup-deis').full_gem_path
|
13
|
+
Dir["#{gem_path}/lib/tasks/*.rake"].each { |ext| load ext } if defined?(Rake)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Jumpup
|
2
|
+
module Deis
|
3
|
+
|
4
|
+
class << self
|
5
|
+
attr_accessor :configuration
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.configure
|
9
|
+
self.configuration ||= Configuration.new
|
10
|
+
yield(configuration)
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
class Configuration
|
15
|
+
attr_accessor :app, :staging_app, :production_app, :run_database_tasks, :host
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
@run_database_tasks ||= true
|
19
|
+
end
|
20
|
+
|
21
|
+
def valid?
|
22
|
+
host_is_set? &&
|
23
|
+
boolean_run_database_tasks? &&
|
24
|
+
(only_app? || only_production_and_staging_apps?)
|
25
|
+
end
|
26
|
+
|
27
|
+
def deploy_branch
|
28
|
+
'master'
|
29
|
+
end
|
30
|
+
|
31
|
+
def deploy_to_production_branch
|
32
|
+
return 'production' if production_app
|
33
|
+
'master'
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def host_is_set?
|
39
|
+
not host.nil?
|
40
|
+
end
|
41
|
+
|
42
|
+
def only_app?
|
43
|
+
app && staging_app.nil? && production_app.nil?
|
44
|
+
end
|
45
|
+
|
46
|
+
def only_production_and_staging_apps?
|
47
|
+
staging_app && production_app && app.nil?
|
48
|
+
end
|
49
|
+
|
50
|
+
def boolean_run_database_tasks?
|
51
|
+
run_database_tasks.is_a?(TrueClass) || run_database_tasks.is_a?(FalseClass)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Jumpup
|
2
|
+
module Deis
|
3
|
+
|
4
|
+
class Env
|
5
|
+
|
6
|
+
def self.all
|
7
|
+
if Jumpup::Deis.configuration.valid?
|
8
|
+
{
|
9
|
+
app: Jumpup::Deis.configuration.app,
|
10
|
+
staging_app: Jumpup::Deis.configuration.staging_app,
|
11
|
+
production_app: Jumpup::Deis.configuration.production_app,
|
12
|
+
run_database_tasks: Jumpup::Deis.configuration.run_database_tasks,
|
13
|
+
host: Jumpup::Deis.configuration.host,
|
14
|
+
deploy_branch: Jumpup::Deis.configuration.deploy_branch,
|
15
|
+
deploy_to_production_branch: Jumpup::Deis.configuration.deploy_to_production_branch,
|
16
|
+
}.delete_if { |k, v| v.nil? }
|
17
|
+
else
|
18
|
+
error_message = 'Check your `/config/initializers/jumpup-deis.rb` and ' \
|
19
|
+
'confirm you have defined the `host` and that you have defined ' \
|
20
|
+
'only `app` or `staging_app` and `production_app` together ' \
|
21
|
+
'more info here https://github.com/Helabs/jumpup-deis'
|
22
|
+
raise ConfigurationError, error_message
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,187 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
|
3
|
+
module Jumpup
|
4
|
+
module Deis
|
5
|
+
|
6
|
+
class Integrate
|
7
|
+
|
8
|
+
attr_reader :app
|
9
|
+
|
10
|
+
def self.deploy
|
11
|
+
message = "Starting to deploy on Deis app #{integrate.app}"
|
12
|
+
integrate.when_branch_send_to_deis(message) do
|
13
|
+
integrate.deploy
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.deploy_to_production
|
18
|
+
app = Env.all[:production_app]
|
19
|
+
integrate = new(app)
|
20
|
+
message = "Starting to deploy to production on Deis app #{integrate.app}"
|
21
|
+
integrate.when_branch_send_to_deis(message) do
|
22
|
+
integrate.deploy_to_production
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.add_remote
|
27
|
+
message = "Adding Deis git remotes for app #{integrate.app}"
|
28
|
+
integrate.when_branch_send_to_deis(message) do
|
29
|
+
integrate.add_remote
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.check
|
34
|
+
message = "Checking if there's already someone integrating to #{integrate.app}"
|
35
|
+
integrate.when_branch_send_to_deis(message) do
|
36
|
+
integrate.check
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.integrate
|
41
|
+
envs = Env.all
|
42
|
+
app = envs[:app] || envs[:staging_app]
|
43
|
+
new(app)
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize(app)
|
47
|
+
@app = app
|
48
|
+
@envs = Env.all
|
49
|
+
end
|
50
|
+
|
51
|
+
def when_branch_send_to_deis(message, &block)
|
52
|
+
puts "--> #{message}"
|
53
|
+
if branches_that_send_to_deis.include?(actual_branch)
|
54
|
+
block.call
|
55
|
+
else
|
56
|
+
puts "----> Skipping since you are in a feature branch [#{actual_branch}]"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def branches_that_send_to_deis
|
61
|
+
[Env.all[:deploy_branch], Env.all[:deploy_to_production_branch]]
|
62
|
+
end
|
63
|
+
|
64
|
+
def deploy
|
65
|
+
run_database_checks if run_database_tasks?
|
66
|
+
|
67
|
+
push(Env.all[:deploy_branch])
|
68
|
+
migrate if run_database_tasks?
|
69
|
+
seed if run_database_tasks?
|
70
|
+
end
|
71
|
+
|
72
|
+
def deploy_to_production
|
73
|
+
run_database_checks if run_database_tasks?
|
74
|
+
|
75
|
+
confirm_deploy
|
76
|
+
spec
|
77
|
+
tag
|
78
|
+
push(Env.all[:deploy_to_production_branch])
|
79
|
+
migrate if run_database_tasks?
|
80
|
+
seed if run_database_tasks?
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_remote
|
84
|
+
remote = run_with_clean_env("git remote | grep deis").strip
|
85
|
+
exec_with_clean_env("git remote add deis ssh://git@#{host}:2222/#{app}.git") if remote.blank?
|
86
|
+
end
|
87
|
+
|
88
|
+
private
|
89
|
+
attr_reader :envs
|
90
|
+
|
91
|
+
def check_if_migration_is_needed
|
92
|
+
files_changed = run_with_clean_env("git diff HEAD #{latest_remote_sha} --name-only -- db/migrate | wc -l").strip.to_i
|
93
|
+
@migrations_changed = files_changed > 0
|
94
|
+
end
|
95
|
+
|
96
|
+
def check_if_seed_is_needed
|
97
|
+
files_changed = run_with_clean_env("git diff HEAD #{latest_remote_sha} --name-only -- db/seeds* | wc -l").strip.to_i
|
98
|
+
@seeds_changed = files_changed > 0
|
99
|
+
end
|
100
|
+
|
101
|
+
def latest_remote_sha
|
102
|
+
@latest_remote_sha ||= run_with_clean_env("git ls-remote ssh://git@#{host}:2222/#{app}.git HEAD 2>/dev/null | awk '{ print $1 }'").strip
|
103
|
+
end
|
104
|
+
|
105
|
+
def run_with_clean_env(command)
|
106
|
+
Bundler.with_clean_env { `#{command}` }
|
107
|
+
end
|
108
|
+
|
109
|
+
def exec_with_clean_env(command)
|
110
|
+
Bundler.with_clean_env do
|
111
|
+
unless system(command)
|
112
|
+
raise "Error while running #{command}"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def confirm(message)
|
118
|
+
print "\n#{message}\nAre you sure? [yN] "
|
119
|
+
raise 'Ok. Bye...' unless STDIN.gets.chomp.downcase == 'y'
|
120
|
+
end
|
121
|
+
|
122
|
+
def run_database_tasks?
|
123
|
+
@envs[:run_database_tasks]
|
124
|
+
end
|
125
|
+
|
126
|
+
def migrate
|
127
|
+
if @migrations_changed
|
128
|
+
output "Migrating"
|
129
|
+
exec_with_clean_env("deis run rake db:migrate --app #{app}")
|
130
|
+
else
|
131
|
+
output "Skipping migrations"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def seed
|
136
|
+
if @seeds_changed
|
137
|
+
output "Seeding"
|
138
|
+
exec_with_clean_env("deis run rake db:seed --app #{app}")
|
139
|
+
else
|
140
|
+
output "Skipping seeds"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def push(branch)
|
145
|
+
output "Pushing to #{host} from branch [#{branch}]"
|
146
|
+
exec_with_clean_env("git push ssh://git@#{host}:2222/#{app}.git #{branch}:master")
|
147
|
+
end
|
148
|
+
|
149
|
+
def confirm_deploy
|
150
|
+
confirm("[#{app}] Deploying to production using branch [#{Env.all[:deploy_to_production_branch]}]")
|
151
|
+
end
|
152
|
+
|
153
|
+
def spec
|
154
|
+
puts "----> Running all specs"
|
155
|
+
Rake::Task['spec'].invoke
|
156
|
+
end
|
157
|
+
|
158
|
+
def tag
|
159
|
+
iso_date = Time.now.strftime('%Y-%m-%dT%H%M%S')
|
160
|
+
tag_name = "production-#{iso_date}"
|
161
|
+
|
162
|
+
puts "----> Tagging as #{tag_name}"
|
163
|
+
exec_with_clean_env("git tag #{tag_name} master")
|
164
|
+
|
165
|
+
puts "----> Pushing to origin"
|
166
|
+
exec_with_clean_env("git push origin #{tag_name}")
|
167
|
+
end
|
168
|
+
|
169
|
+
def host
|
170
|
+
Env.all[:host]
|
171
|
+
end
|
172
|
+
|
173
|
+
def actual_branch
|
174
|
+
run_with_clean_env("git rev-parse --abbrev-ref HEAD").strip
|
175
|
+
end
|
176
|
+
|
177
|
+
def output(message)
|
178
|
+
puts "----> [#{app}] #{message}"
|
179
|
+
end
|
180
|
+
|
181
|
+
def run_database_checks
|
182
|
+
check_if_migration_is_needed
|
183
|
+
check_if_seed_is_needed
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
namespace :jumpup do
|
2
|
+
namespace :deis do
|
3
|
+
|
4
|
+
task :start => ["add_remote"]
|
5
|
+
task :finish => ["deploy"]
|
6
|
+
|
7
|
+
desc "Add Deis git remotes"
|
8
|
+
task add_remote: :environment do
|
9
|
+
Jumpup::Deis::Integrate.add_remote
|
10
|
+
end
|
11
|
+
|
12
|
+
desc "Deploy to deis"
|
13
|
+
task deploy: :environment do
|
14
|
+
Jumpup::Deis::Integrate.deploy
|
15
|
+
end
|
16
|
+
|
17
|
+
namespace :deploy do
|
18
|
+
desc "Deploy to production"
|
19
|
+
task production: :environment do
|
20
|
+
Jumpup::Deis::Integrate.deploy_to_production
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
namespace :integrate do
|
27
|
+
desc 'Alias to jumpup:deis:deploy:production'
|
28
|
+
task production: :environment do
|
29
|
+
Rake.application.invoke_task('jumpup:deis:deploy:production')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
@@ -0,0 +1,290 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jumpup::Deis::Configuration do
|
4
|
+
|
5
|
+
before do
|
6
|
+
Jumpup::Deis.configuration = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".configure" do
|
10
|
+
describe "without configuration" do
|
11
|
+
before do
|
12
|
+
Jumpup::Deis.configure { |config| nil }
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { Jumpup::Deis.configuration }
|
16
|
+
|
17
|
+
describe '#app' do
|
18
|
+
subject { super().app }
|
19
|
+
it { is_expected.to be_nil }
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#staging_app' do
|
23
|
+
subject { super().staging_app }
|
24
|
+
it { is_expected.to be_nil }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#production_app' do
|
28
|
+
subject { super().production_app }
|
29
|
+
it { is_expected.to be_nil }
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#run_database_tasks' do
|
33
|
+
subject { super().run_database_tasks }
|
34
|
+
it { is_expected.to be_truthy }
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#host' do
|
38
|
+
subject { super().host }
|
39
|
+
it { is_expected.to be_nil }
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#deploy_branch' do
|
43
|
+
subject { super().deploy_branch }
|
44
|
+
it { is_expected.to eq('master') }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#deploy_to_production_branch' do
|
48
|
+
subject { super().deploy_to_production_branch }
|
49
|
+
it { is_expected.to eq('master') }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "with configurations" do
|
54
|
+
before do
|
55
|
+
Jumpup::Deis.configure do |config|
|
56
|
+
config.app = 'myapp'
|
57
|
+
config.production_app = 'myapp-production'
|
58
|
+
config.staging_app = 'myapp-staging'
|
59
|
+
config.run_database_tasks = false
|
60
|
+
config.host = 'myhost.com'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
subject { Jumpup::Deis.configuration }
|
65
|
+
|
66
|
+
describe '#app' do
|
67
|
+
subject { super().app }
|
68
|
+
it { is_expected.to eq('myapp') }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#staging_app' do
|
72
|
+
subject { super().staging_app }
|
73
|
+
it { is_expected.to eq('myapp-staging')}
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '#production_app' do
|
77
|
+
subject { super().production_app }
|
78
|
+
it { is_expected.to eq('myapp-production') }
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#run_database_tasks' do
|
82
|
+
subject { super().run_database_tasks }
|
83
|
+
it { is_expected.to be_falsey }
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#host' do
|
87
|
+
subject { super().host }
|
88
|
+
it { is_expected.to eq('myhost.com') }
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#deploy_branch' do
|
92
|
+
subject { super().deploy_branch }
|
93
|
+
it { is_expected.to eq('master') }
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#deploy_to_production_branch' do
|
97
|
+
subject { super().deploy_to_production_branch }
|
98
|
+
it { is_expected.to eq('production') }
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
describe "#valid?" do
|
104
|
+
describe 'app configs' do
|
105
|
+
describe "with app" do
|
106
|
+
before do
|
107
|
+
Jumpup::Deis.configure do |config|
|
108
|
+
config.app = 'myapp'
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
it "is invalid" do
|
113
|
+
expect(Jumpup::Deis.configuration).to_not be_valid
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
describe "with app and host" do
|
118
|
+
before do
|
119
|
+
Jumpup::Deis.configure do |config|
|
120
|
+
config.host = 'host.com'
|
121
|
+
config.app = 'myapp'
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
it "is valid" do
|
126
|
+
expect(Jumpup::Deis.configuration).to be_valid
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "with staging_app and production_app" do
|
131
|
+
before do
|
132
|
+
Jumpup::Deis.configure do |config|
|
133
|
+
config.production_app = 'myapp-production'
|
134
|
+
config.staging_app = 'myapp-staging'
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
it "is invalid" do
|
139
|
+
expect(Jumpup::Deis.configuration).to_not be_valid
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe "with host, staging_app and production_app" do
|
144
|
+
before do
|
145
|
+
Jumpup::Deis.configure do |config|
|
146
|
+
config.host = 'host.com'
|
147
|
+
config.production_app = 'myapp-production'
|
148
|
+
config.staging_app = 'myapp-staging'
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
it "is valid" do
|
153
|
+
expect(Jumpup::Deis.configuration).to be_valid
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
describe "with host, app, staging_app and production_app" do
|
158
|
+
before do
|
159
|
+
Jumpup::Deis.configure do |config|
|
160
|
+
config.host = 'host.com'
|
161
|
+
config.app = 'myapp'
|
162
|
+
config.production_app = 'myapp-production'
|
163
|
+
config.staging_app = 'myapp-staging'
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'is invalid' do
|
168
|
+
expect(Jumpup::Deis.configuration).to_not be_valid
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe "with host and staging_app" do
|
173
|
+
before do
|
174
|
+
Jumpup::Deis.configure do |config|
|
175
|
+
config.host = 'host.com'
|
176
|
+
config.staging_app = 'myapp-staging'
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'is invalid' do
|
181
|
+
expect(Jumpup::Deis.configuration).to_not be_valid
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe "with host and production_app" do
|
186
|
+
before do
|
187
|
+
Jumpup::Deis.configure do |config|
|
188
|
+
config.host = 'host.com'
|
189
|
+
config.production_app = 'myapp-production'
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'is invalid' do
|
194
|
+
expect(Jumpup::Deis.configuration).to_not be_valid
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
describe "with host, app and production_app" do
|
199
|
+
before do
|
200
|
+
Jumpup::Deis.configure do |config|
|
201
|
+
config.host = 'host.com'
|
202
|
+
config.app = 'myapp'
|
203
|
+
config.production_app = 'myapp-production'
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
it 'is invalid' do
|
208
|
+
expect(Jumpup::Deis.configuration).to_not be_valid
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
describe "with host, app and staging_app" do
|
213
|
+
before do
|
214
|
+
Jumpup::Deis.configure do |config|
|
215
|
+
config.host = 'host.com'
|
216
|
+
config.app = 'myapp'
|
217
|
+
config.staging_app = 'myapp-staging'
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'is not valid' do
|
222
|
+
expect(Jumpup::Deis.configuration).to_not be_valid
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
describe 'run_database_tasks configs' do
|
228
|
+
describe "with true run_database_tasks" do
|
229
|
+
before do
|
230
|
+
Jumpup::Deis.configure do |config|
|
231
|
+
config.host = 'host.com'
|
232
|
+
config.app = 'myapp'
|
233
|
+
config.run_database_tasks = true
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
it 'is valid' do
|
238
|
+
expect(Jumpup::Deis.configuration).to be_valid
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
describe "with false run_database_tasks" do
|
243
|
+
before do
|
244
|
+
Jumpup::Deis.configure do |config|
|
245
|
+
config.host = 'host.com'
|
246
|
+
config.app = 'myapp'
|
247
|
+
config.run_database_tasks = false
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
it 'is valid' do
|
252
|
+
expect(Jumpup::Deis.configuration).to be_valid
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
describe "with invalid run_database_tasks" do
|
257
|
+
before do
|
258
|
+
Jumpup::Deis.configure do |config|
|
259
|
+
config.host = 'host.com'
|
260
|
+
config.app = 'myapp'
|
261
|
+
config.run_database_tasks = 'a'
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
it 'is invalid' do
|
266
|
+
expect(Jumpup::Deis.configuration).to_not be_valid
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
describe "without configuration" do
|
272
|
+
before do
|
273
|
+
Jumpup::Deis.configure { |config| nil }
|
274
|
+
end
|
275
|
+
|
276
|
+
it 'is invalid' do
|
277
|
+
expect(Jumpup::Deis.configuration).to_not be_valid
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
describe "with configuration nil" do
|
282
|
+
before { Jumpup::Deis.configuration = nil }
|
283
|
+
|
284
|
+
it 'is invalid' do
|
285
|
+
pending "The bug is raised when have no config/initialier/deis-deploy.rb file"
|
286
|
+
expect(Jumpup::Deis.configuration).to_not be_valid
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Jumpup::Deis::Env do
|
4
|
+
before do
|
5
|
+
Jumpup::Deis.configuration = nil
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "with app" do
|
9
|
+
before do
|
10
|
+
Jumpup::Deis.configure do |config|
|
11
|
+
config.host = 'host.com'
|
12
|
+
config.app = 'myapp'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "have correct env info" do
|
17
|
+
config = { app: 'myapp', run_database_tasks: true, host: 'host.com',
|
18
|
+
deploy_branch: 'master', deploy_to_production_branch: 'master'}
|
19
|
+
expect(Jumpup::Deis::Env.all).to eq(config)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "with staging_app and production_app" do
|
24
|
+
before do
|
25
|
+
Jumpup::Deis.configure do |config|
|
26
|
+
config.host = 'host.com'
|
27
|
+
config.production_app = 'myapp-production'
|
28
|
+
config.staging_app = 'myapp-staging'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it "have correct env info" do
|
33
|
+
config = { production_app: 'myapp-production', staging_app: 'myapp-staging',
|
34
|
+
run_database_tasks: true, host: 'host.com',
|
35
|
+
deploy_branch: 'master', deploy_to_production_branch: 'production'}
|
36
|
+
expect(Jumpup::Deis::Env.all).to eq(config)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "with run_database_tasks" do
|
41
|
+
before do
|
42
|
+
Jumpup::Deis.configure do |config|
|
43
|
+
config.host = 'host.com'
|
44
|
+
config.app = 'myapp'
|
45
|
+
config.run_database_tasks = false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
it "have correct env info" do
|
50
|
+
result = { app: 'myapp', run_database_tasks: false, host: 'host.com',
|
51
|
+
deploy_branch: 'master', deploy_to_production_branch: 'master' }
|
52
|
+
expect(Jumpup::Deis::Env.all).to eq(result)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "with a invalid config env" do
|
57
|
+
before do
|
58
|
+
Jumpup::Deis.configure do |config|
|
59
|
+
config.host = 'host.com'
|
60
|
+
config.app = 'myapp'
|
61
|
+
config.production_app = 'myapp-production'
|
62
|
+
config.staging_app = 'myapp-staging'
|
63
|
+
config.run_database_tasks = 'a'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'raise error' do
|
68
|
+
expect do
|
69
|
+
Jumpup::Deis::Env.all
|
70
|
+
end.to raise_error(Jumpup::Deis::ConfigurationError, %r{/config/initializers/jumpup-deis.rb})
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jumpup-deis
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- HE:labs
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.9.12.4
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.9.12.4
|
69
|
+
description: Rake tasks to deploy on deis
|
70
|
+
email:
|
71
|
+
- tech@helabs.com.br
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".ruby-gemset"
|
78
|
+
- ".ruby-version"
|
79
|
+
- CHANGELOG.md
|
80
|
+
- CONTRIBUTING.md
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- jumpup-heroku.gemspec
|
86
|
+
- lib/jumpup/deis.rb
|
87
|
+
- lib/jumpup/deis/configuration.rb
|
88
|
+
- lib/jumpup/deis/env.rb
|
89
|
+
- lib/jumpup/deis/errors.rb
|
90
|
+
- lib/jumpup/deis/integrate.rb
|
91
|
+
- lib/jumpup/deis/version.rb
|
92
|
+
- lib/tasks/integrate.rake
|
93
|
+
- spec/jumpup/deis/configuration_spec.rb
|
94
|
+
- spec/jumpup/deis/env_spec.rb
|
95
|
+
- spec/spec_helper.rb
|
96
|
+
homepage: https://github.com/Helabs/jumpup-deis
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.2.2
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Rake tasks to deploy on deis
|
120
|
+
test_files:
|
121
|
+
- spec/jumpup/deis/configuration_spec.rb
|
122
|
+
- spec/jumpup/deis/env_spec.rb
|
123
|
+
- spec/spec_helper.rb
|