soyuz 0.0.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 +7 -0
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Guardfile +24 -0
- data/LICENSE.txt +22 -0
- data/README.md +78 -0
- data/Rakefile +1 -0
- data/bin/soyuz +29 -0
- data/lib/soyuz.rb +7 -0
- data/lib/soyuz/command.rb +17 -0
- data/lib/soyuz/command_choice.rb +17 -0
- data/lib/soyuz/config.rb +63 -0
- data/lib/soyuz/deploy.rb +49 -0
- data/lib/soyuz/environment.rb +43 -0
- data/lib/soyuz/version.rb +3 -0
- data/soyuz.gemspec +29 -0
- data/spec/files/soyuz_example.yml +22 -0
- data/spec/soyuz/command_choice_spec.rb +28 -0
- data/spec/soyuz/command_spec.rb +43 -0
- data/spec/soyuz/config_spec.rb +20 -0
- data/spec/soyuz/deploy_spec.rb +46 -0
- data/spec/soyuz/environment_spec.rb +52 -0
- data/spec/spec_helper.rb +23 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 616e95ef8698ce943bed2b8ea5c090654e625f5f
|
4
|
+
data.tar.gz: 9236257f9c10d961fa5fea4eee69049958b4bfec
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b5d7efa525dcd88fdbe0d2d25d79f48660d5ef530011f07045c8a8f39c11a7800ae6f605332bdc9f339311ae9caeb7dfc8142b3cffa97f773589b6e875e75df7
|
7
|
+
data.tar.gz: eb661d95bc03183e48836092c902e92b0b06933788c352db0ddb60db74cc3c4d5523d3efe894f78b4dfba42cc460132ccc63b13e31e2338166c0f9ea19786f0a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
soyuz
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :rspec do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Andy Fleener
|
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,78 @@
|
|
1
|
+
# Soyuz
|
2
|
+
|
3
|
+
The trusty old deployment tool kit that glues all of your deployment tool chain together.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'soyuz'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install soyuz
|
18
|
+
|
19
|
+
## Configure
|
20
|
+
|
21
|
+
```yaml
|
22
|
+
# .soyuz.yml in the app you want to deploy with soyuz
|
23
|
+
default:
|
24
|
+
deploy_cmd: 'opsicle deploy $SOYUZ_ENVIRONMENT'
|
25
|
+
|
26
|
+
|
27
|
+
environments:
|
28
|
+
-
|
29
|
+
production:
|
30
|
+
deploy_cmd:
|
31
|
+
-
|
32
|
+
display: "Deploy"
|
33
|
+
cmd: "cap $SOYUZ_ENVIRONMENT deploy:rolling"
|
34
|
+
-
|
35
|
+
display: "Deploy with Migrations"
|
36
|
+
cmd: "cap $SOYUZ_ENVIRONMENT deploy:rolling_migrations"
|
37
|
+
|
38
|
+
before_deploy_cmds:
|
39
|
+
- accept-pull
|
40
|
+
- tag-release
|
41
|
+
after_deploy_cmds:
|
42
|
+
- post-deploy-notes
|
43
|
+
-
|
44
|
+
staging: {}
|
45
|
+
|
46
|
+
```
|
47
|
+
|
48
|
+
## Usage
|
49
|
+
|
50
|
+
```bash
|
51
|
+
bundle exec soyuz deploy
|
52
|
+
# => 1. production
|
53
|
+
# => 2. staging
|
54
|
+
1
|
55
|
+
# soyuz calls the before_deploy_cmds in the order they are defined
|
56
|
+
accept-pull
|
57
|
+
# script to merge your pull request grom github
|
58
|
+
# ...
|
59
|
+
tag-release
|
60
|
+
# script to build a new release for deployment
|
61
|
+
# ...
|
62
|
+
# soyuz call the deploy command for the given environment
|
63
|
+
1. Deploy
|
64
|
+
2. Deploy with Migrations
|
65
|
+
2
|
66
|
+
cap production deploy:rolling_migrations
|
67
|
+
# soyuz calls the after_deploy_cmds in the order they are defined
|
68
|
+
post-deploy-notes
|
69
|
+
# post all of your deploy notes somewhere useful
|
70
|
+
```
|
71
|
+
|
72
|
+
## Contributing
|
73
|
+
|
74
|
+
1. Fork it ( http://github.com/sportngin/soyuz/fork )
|
75
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
76
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
77
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
78
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/soyuz
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'commander/import'
|
4
|
+
require 'soyuz'
|
5
|
+
|
6
|
+
# :name is optional, otherwise uses the basename of this executable
|
7
|
+
program :name, 'soyuz'
|
8
|
+
program :version, Soyuz::VERSION
|
9
|
+
program :description, 'The trusty old deployment tool-kit'
|
10
|
+
default_command :help
|
11
|
+
global_option('-c', '--config FILE', 'soyuz config file')
|
12
|
+
|
13
|
+
command :check do |c|
|
14
|
+
c.syntax = "soyuz check [options]"
|
15
|
+
c.description = "Check your config file to ensure it's valid"
|
16
|
+
c.action do |args, options|
|
17
|
+
options.default config: ".soyuz.yml"
|
18
|
+
Soyuz::Config.new(options.config).check
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
command :deploy do |c|
|
23
|
+
c.syntax = "soyuz deploy [options]"
|
24
|
+
c.description = "Deploy your application"
|
25
|
+
c.action do |args, options|
|
26
|
+
options.default config: ".soyuz.yml"
|
27
|
+
Soyuz::Deploy.new(options.config).execute
|
28
|
+
end
|
29
|
+
end
|
data/lib/soyuz.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'command_choice'
|
2
|
+
module Soyuz
|
3
|
+
class Command
|
4
|
+
def initialize(cmd)
|
5
|
+
raise ArgumentError, "Command must be a string" unless cmd.is_a?(String)
|
6
|
+
@cmd = cmd
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.build(cmd)
|
10
|
+
cmd.is_a?(Array) ? CommandChoice.new(cmd) : new(cmd)
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
system(@cmd)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "command"
|
2
|
+
module Soyuz
|
3
|
+
class CommandChoice
|
4
|
+
def initialize(choices)
|
5
|
+
raise ArgumentError, "Choices must be an array" unless choices.is_a?(Array)
|
6
|
+
@choices = choices
|
7
|
+
end
|
8
|
+
|
9
|
+
def run
|
10
|
+
@choices.each_with_index do |choice, index|
|
11
|
+
say "#{index+1}) #{choice[:display]}"
|
12
|
+
end
|
13
|
+
choice = ask("? ", Integer) { |q| q.in = 1..@choices.length }
|
14
|
+
Command.new(@choices[choice-1][:cmd]).run
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/soyuz/config.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'safe_yaml'
|
2
|
+
require_relative 'environment'
|
3
|
+
module Soyuz
|
4
|
+
class Config
|
5
|
+
def initialize(config_file)
|
6
|
+
@config_file = config_file
|
7
|
+
end
|
8
|
+
|
9
|
+
def check
|
10
|
+
validate!
|
11
|
+
puts "Config file is valid. We are go for launch."
|
12
|
+
end
|
13
|
+
|
14
|
+
def validate!
|
15
|
+
raise InvalidConfig, "Your config file is invalid" unless valid?
|
16
|
+
end
|
17
|
+
|
18
|
+
def environments
|
19
|
+
@environments ||= config_data[:environments].map{|attributes| Environment.new(attributes, defaults) } if config_data[:environments]
|
20
|
+
@environments ||= []
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def defaults
|
26
|
+
config_data[:defaults] || {}
|
27
|
+
end
|
28
|
+
|
29
|
+
def config_data
|
30
|
+
@config_data ||= load_config
|
31
|
+
end
|
32
|
+
|
33
|
+
def load_config
|
34
|
+
symbolize_keys(SafeYAML.load_file(@config_file))
|
35
|
+
end
|
36
|
+
|
37
|
+
def valid?
|
38
|
+
begin
|
39
|
+
File.exists?(@config_file) && config_data.is_a?(Hash)
|
40
|
+
rescue StandardError
|
41
|
+
false
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def symbolize_keys(hash)
|
46
|
+
return hash unless hash.is_a?(Hash)
|
47
|
+
hash.inject({}){|result, (key, value)|
|
48
|
+
new_key = case key
|
49
|
+
when String then key.to_sym
|
50
|
+
else key
|
51
|
+
end
|
52
|
+
new_value = case value
|
53
|
+
when Hash then symbolize_keys(value)
|
54
|
+
when Array then value.map{|el| symbolize_keys(el) }
|
55
|
+
else value
|
56
|
+
end
|
57
|
+
result[new_key] = new_value
|
58
|
+
result
|
59
|
+
}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
InvalidConfig = Class.new(StandardError)
|
63
|
+
end
|
data/lib/soyuz/deploy.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require_relative 'config'
|
2
|
+
module Soyuz
|
3
|
+
class Deploy
|
4
|
+
def initialize(config_file)
|
5
|
+
@config = Config.new(config_file)
|
6
|
+
@config.validate!
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def execute
|
11
|
+
choose_environment
|
12
|
+
before_callbacks
|
13
|
+
deploy
|
14
|
+
after_callbacks
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
def environment
|
19
|
+
@environment || raise(EnvironmentNotSelected, "Please Select an Environment")
|
20
|
+
end
|
21
|
+
def environments
|
22
|
+
@config.environments
|
23
|
+
end
|
24
|
+
|
25
|
+
def choose_environment
|
26
|
+
say "Choose an Environment: \n"
|
27
|
+
environments.each_with_index do |environment, index|
|
28
|
+
say "#{index+1}) #{environment.name}"
|
29
|
+
end
|
30
|
+
choice = ask("? ", Integer) { |q| q.in = 1..environments.length }
|
31
|
+
@environment = environments[choice-1]
|
32
|
+
ENV['SOYUZ_ENVIRONMENT'] = @environment.name.to_s
|
33
|
+
end
|
34
|
+
|
35
|
+
def deploy
|
36
|
+
environment.deploy
|
37
|
+
end
|
38
|
+
|
39
|
+
def before_callbacks
|
40
|
+
environment.before_callbacks
|
41
|
+
end
|
42
|
+
|
43
|
+
def after_callbacks
|
44
|
+
environment.after_callbacks
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
EnvironmentNotSelected = Class.new(StandardError)
|
49
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative 'command'
|
2
|
+
module Soyuz
|
3
|
+
class Environment
|
4
|
+
def initialize(attributes={}, defaults={})
|
5
|
+
set_attributes(attributes, defaults)
|
6
|
+
build
|
7
|
+
end
|
8
|
+
|
9
|
+
def before_callbacks
|
10
|
+
@before_callbacks.each do|cmd|
|
11
|
+
cmd.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def after_callbacks
|
16
|
+
@after_callbacks.each do|cmd|
|
17
|
+
cmd.run
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def deploy
|
22
|
+
@deploy_cmd.run
|
23
|
+
end
|
24
|
+
|
25
|
+
def name
|
26
|
+
@name
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def set_attributes(attributes={}, defaults={})
|
32
|
+
@name = attributes.keys.first
|
33
|
+
@attributes = defaults.merge(attributes[name])
|
34
|
+
end
|
35
|
+
|
36
|
+
def build
|
37
|
+
@deploy_cmd = Command.build(@attributes[:deploy_cmd])
|
38
|
+
@before_callbacks = Array(@attributes[:before_deploy_cmds]).compact.map{|cmd| Command.build(cmd) }
|
39
|
+
@after_callbacks = Array(@attributes[:after_deploy_cmds]).compact.map{|cmd| Command.build(cmd) }
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/soyuz.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'soyuz/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "soyuz"
|
8
|
+
spec.version = Soyuz::VERSION
|
9
|
+
spec.authors = ["Andy Fleener"]
|
10
|
+
spec.email = ["andrew.fleener@sportngin.com"]
|
11
|
+
spec.summary = %q{The old trusty deployment toolkit}
|
12
|
+
spec.description = %q{Soyuz is the deployment toolkit that glues all of your deployment pipeline together}
|
13
|
+
spec.homepage = "https://github.com/sportngin/soyuz"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
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_dependency "commander"
|
22
|
+
spec.add_dependency "safe_yaml"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "rspec", "~>3.0.0.beta1 "
|
27
|
+
spec.add_development_dependency "guard"
|
28
|
+
spec.add_development_dependency "guard-rspec"
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# .soyuz.yml in the app you want to deploy with soyuz
|
2
|
+
defaults:
|
3
|
+
deploy_cmd: 'echo default deploy $SOYUZ_ENVIRONMENT'
|
4
|
+
|
5
|
+
environments:
|
6
|
+
-
|
7
|
+
production:
|
8
|
+
deploy_cmd:
|
9
|
+
-
|
10
|
+
display: "Deploy"
|
11
|
+
cmd: "echo deploying $SOYUZ_ENVIRONMENT "
|
12
|
+
-
|
13
|
+
display: "Deploy with Migrations"
|
14
|
+
cmd: "echo deploying with migrations $SOYUZ_ENVIRONMENT"
|
15
|
+
|
16
|
+
before_deploy_cmds:
|
17
|
+
- "echo before deploy callback"
|
18
|
+
after_deploy_cmds:
|
19
|
+
- "echo after deploy callback"
|
20
|
+
-
|
21
|
+
staging: {}
|
22
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "soyuz/command_choice"
|
3
|
+
module Soyuz
|
4
|
+
describe CommandChoice do
|
5
|
+
let(:choices){ [{display: "choice1", cmd: "echo choice1"}, {display: "choice2", cmd: "echo choice2" }] }
|
6
|
+
let(:command_double){ instance_double("Command", :run => true) }
|
7
|
+
subject { CommandChoice.new(choices) }
|
8
|
+
|
9
|
+
context "choices isn't an array" do
|
10
|
+
let(:choices) { "I'm a command" }
|
11
|
+
subject { CommandChoice }
|
12
|
+
it "raises an error" do
|
13
|
+
expect{ subject.new(choices) }.to raise_error(ArgumentError)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "#run" do
|
18
|
+
it "creates a command for the given choice" do
|
19
|
+
expect(subject).to receive(:say).with("1) choice1").once
|
20
|
+
expect(subject).to receive(:say).with("2) choice2").once
|
21
|
+
expect(subject).to receive(:ask).with(instance_of(String), Integer).and_return(1).once
|
22
|
+
expect(Command).to receive(:new).with("echo choice1").and_return(command_double)
|
23
|
+
subject.run
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "soyuz/command"
|
3
|
+
module Soyuz
|
4
|
+
describe Command do
|
5
|
+
let(:cmd){ "echo derp" }
|
6
|
+
subject { Command.new(cmd) }
|
7
|
+
|
8
|
+
context "cmd isn't a string" do
|
9
|
+
let(:cmd) { 1234 }
|
10
|
+
subject { Command }
|
11
|
+
it "raises an error" do
|
12
|
+
expect{ subject.new(cmd) }.to raise_error(ArgumentError)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "#run" do
|
17
|
+
it "to make a system call" do
|
18
|
+
expect(subject).to receive(:system)
|
19
|
+
subject.run
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context ".build" do
|
24
|
+
context "cmd is an array" do
|
25
|
+
let(:cmd) { [{display: "DERP", cmd: "echo derp"}, {display: "HERP", cmd: "echo herp"}] }
|
26
|
+
subject { Command }
|
27
|
+
it "to create a new command choice if the command argument is an array" do
|
28
|
+
expect(CommandChoice).to receive(:new).with(cmd)
|
29
|
+
subject.build(cmd)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "cmd is a string" do
|
34
|
+
let(:cmd) { "echo derp" }
|
35
|
+
subject { Command }
|
36
|
+
it "to create a new command object if the command argument is a string" do
|
37
|
+
expect(Command).to receive(:new).with(cmd)
|
38
|
+
subject.build(cmd)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "soyuz/config"
|
3
|
+
module Soyuz
|
4
|
+
describe Config do
|
5
|
+
let(:valid_config){ "files/soyuz_example.yml" }
|
6
|
+
subject { Config.new(valid_config) }
|
7
|
+
|
8
|
+
context "#check" do
|
9
|
+
it "to raise an InvalidConfig error if the config is invalid" do
|
10
|
+
allow(subject).to receive(:valid?) { false }
|
11
|
+
expect{ subject.check }.to raise_error(InvalidConfig)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "to not raise an error if the config is valid" do
|
15
|
+
allow(subject).to receive(:valid?) { true }
|
16
|
+
expect{ subject.check }.to_not raise_error
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "soyuz/deploy"
|
3
|
+
module Soyuz
|
4
|
+
describe Deploy do
|
5
|
+
let(:valid_config){ "files/soyuz_example.yml" }
|
6
|
+
subject { Deploy.new(valid_config) }
|
7
|
+
|
8
|
+
before do
|
9
|
+
allow_any_instance_of(Config).to receive(:validate!)
|
10
|
+
end
|
11
|
+
|
12
|
+
context "#execute" do
|
13
|
+
it "to ask for an environment" do
|
14
|
+
allow(subject).to receive(:before_callbacks)
|
15
|
+
allow(subject).to receive(:deploy)
|
16
|
+
allow(subject).to receive(:after_callbacks)
|
17
|
+
expect(subject).to receive(:choose_environment)
|
18
|
+
subject.execute
|
19
|
+
end
|
20
|
+
|
21
|
+
it "to call before callbacks" do
|
22
|
+
allow(subject).to receive(:choose_environment)
|
23
|
+
allow(subject).to receive(:deploy)
|
24
|
+
allow(subject).to receive(:after_callbacks)
|
25
|
+
expect(subject).to receive(:before_callbacks)
|
26
|
+
subject.execute
|
27
|
+
end
|
28
|
+
|
29
|
+
it "to call deploy" do
|
30
|
+
allow(subject).to receive(:choose_environment)
|
31
|
+
allow(subject).to receive(:before_callbacks)
|
32
|
+
allow(subject).to receive(:after_callbacks)
|
33
|
+
expect(subject).to receive(:deploy)
|
34
|
+
subject.execute
|
35
|
+
end
|
36
|
+
|
37
|
+
it "to call after callbacks" do
|
38
|
+
allow(subject).to receive(:choose_environment)
|
39
|
+
allow(subject).to receive(:before_callbacks)
|
40
|
+
allow(subject).to receive(:deploy)
|
41
|
+
expect(subject).to receive(:after_callbacks)
|
42
|
+
subject.execute
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'soyuz/environment'
|
3
|
+
module Soyuz
|
4
|
+
describe Environment do
|
5
|
+
let(:attributes){ {environment: {deploy_cmd: "echo derp", before_deploy_cmds: ['echo before', 'echo more before'], after_deploy_cmds: ['echo after', 'echo another after']}} }
|
6
|
+
subject{ Environment.new(attributes) }
|
7
|
+
let(:cmd){ double("Command") }
|
8
|
+
|
9
|
+
context ".new" do
|
10
|
+
subject{ Environment }
|
11
|
+
it "sets the environment name" do
|
12
|
+
expect(subject.name).to_not be_nil
|
13
|
+
subject.new(attributes)
|
14
|
+
end
|
15
|
+
it "sets the attributes" do
|
16
|
+
allow_any_instance_of(subject).to receive(:build)
|
17
|
+
expect_any_instance_of(subject).to receive(:set_attributes)
|
18
|
+
subject.new(attributes)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "builds the environment" do
|
22
|
+
allow_any_instance_of(subject).to receive(:set_attributes)
|
23
|
+
expect_any_instance_of(subject).to receive(:build)
|
24
|
+
subject.new(attributes)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "#deploy" do
|
29
|
+
it "runs the deploy command" do
|
30
|
+
allow(Command).to receive(:new).and_return(cmd)
|
31
|
+
expect(cmd).to receive(:run)
|
32
|
+
subject.deploy
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "#before_callbacks" do
|
37
|
+
it "runs all of the before callbacks" do
|
38
|
+
allow(Command).to receive(:new).and_return(cmd)
|
39
|
+
expect(cmd).to receive(:run).twice
|
40
|
+
subject.before_callbacks
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "#after_callbacks" do
|
45
|
+
it "runs all of the after callbacks" do
|
46
|
+
allow(Command).to receive(:new).and_return(cmd)
|
47
|
+
expect(cmd).to receive(:run).twice
|
48
|
+
subject.after_callbacks
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
# Limit the spec run to only specs with the focus metadata. If no specs have
|
9
|
+
# the filtering metadata and `run_all_when_everything_filtered = true` then
|
10
|
+
# all specs will run.
|
11
|
+
#config.filter_run :focus
|
12
|
+
|
13
|
+
# Run all specs when none match the provided filter. This works well in
|
14
|
+
# conjunction with `config.filter_run :focus`, as it will run the entire
|
15
|
+
# suite when no specs have `:filter` metadata.
|
16
|
+
#config.run_all_when_everything_filtered = true
|
17
|
+
|
18
|
+
# Run specs in random order to surface order dependencies. If you find an
|
19
|
+
# order dependency and want to debug it, you can fix the order by providing
|
20
|
+
# the seed, which is printed after each run.
|
21
|
+
# --seed 1234
|
22
|
+
#config.order = 'random'
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soyuz
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andy Fleener
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: safe_yaml
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
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: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
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'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.0.0.beta1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.0.0.beta1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: guard
|
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: guard-rspec
|
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'
|
111
|
+
description: Soyuz is the deployment toolkit that glues all of your deployment pipeline
|
112
|
+
together
|
113
|
+
email:
|
114
|
+
- andrew.fleener@sportngin.com
|
115
|
+
executables:
|
116
|
+
- soyuz
|
117
|
+
extensions: []
|
118
|
+
extra_rdoc_files: []
|
119
|
+
files:
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".ruby-gemset"
|
123
|
+
- ".ruby-version"
|
124
|
+
- ".travis.yml"
|
125
|
+
- Gemfile
|
126
|
+
- Guardfile
|
127
|
+
- LICENSE.txt
|
128
|
+
- README.md
|
129
|
+
- Rakefile
|
130
|
+
- bin/soyuz
|
131
|
+
- lib/soyuz.rb
|
132
|
+
- lib/soyuz/command.rb
|
133
|
+
- lib/soyuz/command_choice.rb
|
134
|
+
- lib/soyuz/config.rb
|
135
|
+
- lib/soyuz/deploy.rb
|
136
|
+
- lib/soyuz/environment.rb
|
137
|
+
- lib/soyuz/version.rb
|
138
|
+
- soyuz.gemspec
|
139
|
+
- spec/files/soyuz_example.yml
|
140
|
+
- spec/soyuz/command_choice_spec.rb
|
141
|
+
- spec/soyuz/command_spec.rb
|
142
|
+
- spec/soyuz/config_spec.rb
|
143
|
+
- spec/soyuz/deploy_spec.rb
|
144
|
+
- spec/soyuz/environment_spec.rb
|
145
|
+
- spec/spec_helper.rb
|
146
|
+
homepage: https://github.com/sportngin/soyuz
|
147
|
+
licenses:
|
148
|
+
- MIT
|
149
|
+
metadata: {}
|
150
|
+
post_install_message:
|
151
|
+
rdoc_options: []
|
152
|
+
require_paths:
|
153
|
+
- lib
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
requirements: []
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 2.2.1
|
167
|
+
signing_key:
|
168
|
+
specification_version: 4
|
169
|
+
summary: The old trusty deployment toolkit
|
170
|
+
test_files:
|
171
|
+
- spec/files/soyuz_example.yml
|
172
|
+
- spec/soyuz/command_choice_spec.rb
|
173
|
+
- spec/soyuz/command_spec.rb
|
174
|
+
- spec/soyuz/config_spec.rb
|
175
|
+
- spec/soyuz/deploy_spec.rb
|
176
|
+
- spec/soyuz/environment_spec.rb
|
177
|
+
- spec/spec_helper.rb
|