foreplay 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
+ *.TMP
1
2
  *.rbc
2
3
  *.sassc
3
4
  .sass-cache
@@ -17,7 +18,7 @@ pickle-email-*.html
17
18
 
18
19
  *.gem
19
20
  .bundle
20
- .config
21
+ /config
21
22
  .yardoc
22
23
  Gemfile.lock
23
24
  InstalledFiles
@@ -31,4 +32,3 @@ spec/reports
31
32
  test/tmp
32
33
  test/version_tmp
33
34
  tmp
34
- config
data/.rvmrc ADDED
@@ -0,0 +1,5 @@
1
+ rvm_trust_rvmrcs_flag=1
2
+ rvm_install_on_use_flag=1
3
+ rvm_gem_options="--no-rdoc --no-ri"
4
+ rvm_gemset_create_on_use_flag=1
5
+ rvm 1.9.3@foreplay
data/README.md CHANGED
@@ -52,9 +52,9 @@ defaults: # global defaults for all environments
52
52
  servers: [server1, server2, server3] # which servers to deploy the app on
53
53
  user: # The username to connect with (must have SSH permissions)
54
54
  password: # The password to use to connect (not necessary if you've set up SSH keys)
55
- keyfile: # ...or a file containing a private key that allows the named user access to the server
55
+ keyfile: # or a file containing a private key that allows the named user access to the server
56
56
  key: # ...or a private key that allows the named user access to the server
57
- path: # absolute path to deploy the app on each server. %s will be translated to the application name
57
+ path: # absolute path to deploy the app on each server. %s will substitute to the app name
58
58
  database: # the database.yml elements to write to the config folder
59
59
  env: # contents of the .env file
60
60
  key: value # will go into the .env file as key=value
@@ -62,7 +62,7 @@ defaults: # global defaults for all environments
62
62
  key: value # will go into the .foreman file as key: value
63
63
  production: # deployment configuration for the production environment
64
64
  defaults: # defaults for all roles in this environment (structure same as global defaults)
65
- role1: # settings for the a particular role (e.g. web, worker, etc.) (structure same as global defaults)
65
+ role1: # settings for the a particular role (e.g. web, worker, etc.)
66
66
  ```
67
67
 
68
68
  ### Environment
@@ -0,0 +1,74 @@
1
+ Feature: check
2
+ In order to check Foreplay
3
+ From the CLI
4
+ I want to be able to check all features
5
+
6
+ Scenario: Check configuration
7
+ When I run `foreplay check`
8
+ Then the output should contain:
9
+ """
10
+ ERROR: foreplay check was called with no arguments
11
+ Usage: "foreplay check ENVIRONMENT".
12
+ """
13
+
14
+ Scenario: Check configuration parameters - invalid parameter
15
+ When I run `foreplay check test --invalid xyz`
16
+ Then the output should contain:
17
+ """
18
+ ERROR: foreplay check was called with arguments ["test", "--invalid", "xyz"]
19
+ Usage: "foreplay check ENVIRONMENT".
20
+ """
21
+
22
+ Scenario: Check configuration parameters - short invalid parameter
23
+ When I run `foreplay check test -x xyz`
24
+ Then the output should contain:
25
+ """
26
+ ERROR: foreplay check was called with arguments ["test", "-x", "xyz"]
27
+ Usage: "foreplay check ENVIRONMENT".
28
+ """
29
+
30
+ Scenario: Check configuration parameters - no config file
31
+ When I run `foreplay check test`
32
+ Then the output should contain "Checking"
33
+ And the output should contain "Can't find configuration file"
34
+
35
+ Scenario: Check configuration parameters
36
+ When I run `foreplay setup`
37
+ And I run `foreplay check test`
38
+ Then the output should contain "create config/foreplay.yml"
39
+ And the output should contain "Checking"
40
+ And the output should contain "test environment"
41
+ And the output should contain "all roles"
42
+ And the output should contain "all servers"
43
+ And the output should contain "No deployment configuration defined for test environment"
44
+ And the output should not contain "Can't find configuration file"
45
+ And the following files should exist:
46
+ | config/foreplay.yml |
47
+
48
+ Scenario: Check configuration parameters - role parameter
49
+ When I run `foreplay check test --role worker`
50
+ Then the output should contain "Checking"
51
+ And the output should contain "test environment"
52
+ And the output should contain "worker role"
53
+ And the output should contain "all servers"
54
+
55
+ Scenario: Check configuration parameters - server parameter
56
+ When I run `foreplay check test --server worker.example.com`
57
+ Then the output should contain "Checking"
58
+ And the output should contain "test environment"
59
+ And the output should contain "all roles"
60
+ And the output should contain "worker.example.com server"
61
+
62
+ Scenario: Check configuration parameters - short role parameter
63
+ When I run `foreplay check test -r worker`
64
+ Then the output should contain "Checking"
65
+ And the output should contain "test environment"
66
+ And the output should contain "worker role"
67
+ And the output should contain "all servers"
68
+
69
+ Scenario: Check configuration parameters - short server parameter
70
+ When I run `foreplay check test -s worker.example.com`
71
+ Then the output should contain "Checking"
72
+ And the output should contain "test environment"
73
+ And the output should contain "all roles"
74
+ And the output should contain "worker.example.com server"
@@ -0,0 +1,96 @@
1
+ Feature: deploy
2
+ In order to deploy my app
3
+ From the CLI
4
+ I want to be able to use all features
5
+
6
+ Scenario: No arguments
7
+ When I run `foreplay deploy`
8
+ Then the output should contain:
9
+ """
10
+ ERROR: foreplay deploy was called with no arguments
11
+ Usage: "foreplay deploy ENVIRONMENT".
12
+ """
13
+
14
+ Scenario: invalid parameter
15
+ When I run `foreplay deploy test --invalid xyz`
16
+ Then the output should contain:
17
+ """
18
+ ERROR: foreplay deploy was called with arguments ["test", "--invalid", "xyz"]
19
+ Usage: "foreplay deploy ENVIRONMENT".
20
+ """
21
+
22
+ Scenario: short invalid parameter
23
+ When I run `foreplay deploy test -x xyz`
24
+ Then the output should contain:
25
+ """
26
+ ERROR: foreplay deploy was called with arguments ["test", "-x", "xyz"]
27
+ Usage: "foreplay deploy ENVIRONMENT".
28
+ """
29
+
30
+ Scenario: no config file
31
+ When I run `foreplay deploy test`
32
+ Then the output should contain "Deploying"
33
+ And the output should contain "test environment"
34
+ And the output should contain "all roles"
35
+ And the output should contain "all servers"
36
+ And the output should contain "Can't find configuration file"
37
+
38
+ Scenario: deploy all roles
39
+ When I run `foreplay setup`
40
+ And I run `foreplay deploy test`
41
+ Then the output should contain "create config/foreplay.yml"
42
+ And the output should contain "Deploying"
43
+ And the output should contain "test environment"
44
+ And the output should contain "all roles"
45
+ And the output should contain "all servers"
46
+ And the output should contain "No deployment configuration defined for test environment"
47
+ And the output should not contain "Can't find configuration file"
48
+ And the following files should exist:
49
+ | config/foreplay.yml |
50
+
51
+ Scenario: deploy one role
52
+ When I run `foreplay deploy test --role worker`
53
+ Then the output should contain "Deploying"
54
+ And the output should contain "test environment"
55
+ And the output should contain "worker role"
56
+ And the output should contain "all servers"
57
+
58
+ Scenario: deploy to one server
59
+ When I run `foreplay deploy test --server worker.example.com`
60
+ Then the output should contain "Deploying"
61
+ And the output should contain "test environment"
62
+ And the output should contain "all roles"
63
+ And the output should contain "worker.example.com server"
64
+
65
+ Scenario: deploy to one role - short role parameter
66
+ When I run `foreplay deploy test -r worker`
67
+ Then the output should contain "Deploying"
68
+ And the output should contain "test environment"
69
+ And the output should contain "worker role"
70
+ And the output should contain "all servers"
71
+
72
+ Scenario: deployto one server - short server parameter
73
+ When I run `foreplay deploy test -s worker.example.com`
74
+ Then the output should contain "Deploying"
75
+ And the output should contain "test environment"
76
+ And the output should contain "all roles"
77
+ And the output should contain "worker.example.com server"
78
+
79
+ Scenario: deploy all roles
80
+ When I run `foreplay setup`
81
+ And I run `foreplay deploy test`
82
+ Then the output should contain "create config/foreplay.yml"
83
+ And the output should contain "Deploying"
84
+ And the output should contain "test environment"
85
+ And the output should contain "all roles"
86
+ And the output should contain "all servers"
87
+ And the output should not contain "Can't find configuration file"
88
+ And the following files should exist:
89
+ | config/foreplay.yml |
90
+
91
+ Scenario: deploy
92
+ When I run `foreplay setup -r git@github.com:Xenapto/foreplay.git -s web.example.com --password "top-secret"`
93
+ And I run `foreplay deploy production`
94
+ Then the output should contain "Deploying aruba to web.example.com in the web role on the production environment"
95
+ And the output should contain "Connecting to web.example.com"
96
+ And the output should contain "There was a problem starting an ssh session on web.example.com"
@@ -0,0 +1,140 @@
1
+ Feature: Setup
2
+ In order to setup Foreplay
3
+ As a CLI user
4
+ I want to be able to create the config scaffold
5
+
6
+ Scenario: Setup with defaults
7
+ When I run `foreplay setup`
8
+ Then the output should contain "create config/foreplay.yml"
9
+ And the following files should exist:
10
+ | config/foreplay.yml |
11
+ And the file "config/foreplay.yml" should contain:
12
+ """
13
+ defaults:
14
+ name: aruba
15
+ repository: TODO Put the git repository path here
16
+ user: TODO Put here the user to logon to the deployment server
17
+ path: TODO Put here the path to deploy to on the deployment server
18
+ port: 50000
19
+ production:
20
+ defaults:
21
+ database:
22
+ adapter: postgresql
23
+ encoding: utf8
24
+ database: TODO Put the database name here
25
+ pool: 5
26
+ host: TODO Put here the database host name
27
+ username: TODO Put here the database user
28
+ password: TODO Put here the database user's password
29
+ web:
30
+ servers: [TODO Put here the name or names of the production web servers]
31
+ foreman:
32
+ concurrency: 'web=1,worker=0,scheduler=0'
33
+ """
34
+
35
+ Scenario: Setup invalid short option
36
+ When I run `foreplay setup -x abc`
37
+ Then the following files should not exist:
38
+ | config/foreplay.yml |
39
+ And the output should contain:
40
+ """
41
+ ERROR: foreplay setup was called with arguments ["-x", "abc"]
42
+ Usage: "foreplay setup".
43
+ """
44
+
45
+ Scenario: Setup invalid option
46
+ When I run `foreplay setup --xyz abc`
47
+ Then the following files should not exist:
48
+ | config/foreplay.yml |
49
+ And the output should contain:
50
+ """
51
+ ERROR: foreplay setup was called with arguments ["--xyz", "abc"]
52
+ Usage: "foreplay setup".
53
+ """
54
+
55
+ Scenario: Setup invalid pool option type
56
+ When I run `foreplay setup --db_pool abc`
57
+ Then the following files should not exist:
58
+ | config/foreplay.yml |
59
+ And the output should contain:
60
+ """
61
+ Expected numeric value for '--db-pool'; got "abc"
62
+ """
63
+
64
+ Scenario: Setup invalid port option type
65
+ When I run `foreplay setup --port abc`
66
+ Then the following files should not exist:
67
+ | config/foreplay.yml |
68
+ And the output should contain:
69
+ """
70
+ Expected numeric value for '--port'; got "abc"
71
+ """
72
+
73
+ Scenario: Setup invalid port short option type
74
+ When I run `foreplay setup -p abc`
75
+ Then the following files should not exist:
76
+ | config/foreplay.yml |
77
+ And the output should contain:
78
+ """
79
+ Expected numeric value for '--port'; got "abc"
80
+ """
81
+
82
+ Scenario: Setup with short options
83
+ When I run `foreplay setup -n string1 -r string2 -u string3 -p 10000 --password string4 -f string5 -s string6a string6b string6c -a string7 -e string8 -d string9 -h string10 --db_pool 23 --db_user string11 --db_password string12`
84
+ Then the output should contain "create config/foreplay.yml"
85
+ And the following files should exist:
86
+ | config/foreplay.yml |
87
+ And the file "config/foreplay.yml" should contain:
88
+ """
89
+ defaults:
90
+ name: string1
91
+ repository: string2
92
+ user: string3
93
+ password: string4
94
+ path: string5
95
+ port: 10000
96
+ production:
97
+ defaults:
98
+ database:
99
+ adapter: string7
100
+ encoding: string8
101
+ database: string9
102
+ pool: 23
103
+ host: string10
104
+ username: string11
105
+ password: string12
106
+ web:
107
+ servers: ["string6a", "string6b", "string6c"]
108
+ foreman:
109
+ concurrency: 'web=1,worker=0,scheduler=0'
110
+ """
111
+
112
+ Scenario: Setup with short options
113
+ When I run `foreplay setup --name string1 --repository string2 --user string3 --port 10000 --password string4 --path string5 --servers string6a string6b string6c --db_adapter string7 --db_encoding string8 --db_name string9 --db_host string10 --db_pool 23 --db_user string11 --db_password string12`
114
+ Then the output should contain "create config/foreplay.yml"
115
+ And the following files should exist:
116
+ | config/foreplay.yml |
117
+ And the file "config/foreplay.yml" should contain:
118
+ """
119
+ defaults:
120
+ name: string1
121
+ repository: string2
122
+ user: string3
123
+ password: string4
124
+ path: string5
125
+ port: 10000
126
+ production:
127
+ defaults:
128
+ database:
129
+ adapter: string7
130
+ encoding: string8
131
+ database: string9
132
+ pool: 23
133
+ host: string10
134
+ username: string11
135
+ password: string12
136
+ web:
137
+ servers: ["string6a", "string6b", "string6c"]
138
+ foreman:
139
+ concurrency: 'web=1,worker=0,scheduler=0'
140
+ """
@@ -0,0 +1,5 @@
1
+ # Initialize simplecov for coverage report.
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+
5
+ require 'aruba/cucumber'
data/foreplay.gemspec CHANGED
@@ -14,12 +14,11 @@ Gem::Specification.new do |spec|
14
14
 
15
15
  spec.files = `git ls-files`.split($/)
16
16
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features|coverage)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency 'activesupport'
21
21
  spec.add_dependency 'colorize'
22
- spec.add_dependency 'hashie'
23
22
  spec.add_dependency 'foreman'
24
23
  spec.add_dependency 'net-ssh-shell'
25
24
  spec.add_dependency 'thor'
@@ -30,4 +29,5 @@ Gem::Specification.new do |spec|
30
29
  spec.add_development_dependency "cucumber"
31
30
  spec.add_development_dependency "aruba"
32
31
  spec.add_development_dependency "gem-release"
32
+ spec.add_development_dependency "simplecov"
33
33
  end
data/lib/foreplay.rb CHANGED
@@ -1,6 +1,4 @@
1
- require "foreplay/version"
2
- require "foreplay/config"
3
-
4
- module Foreplay
5
- # Your code goes here...
6
- end
1
+ require 'foreplay/version'
2
+ require 'foreplay/setup'
3
+ require 'foreplay/deploy'
4
+ require 'foreplay/utility'
data/lib/foreplay/cli.rb CHANGED
@@ -1,23 +1,47 @@
1
1
  require 'thor'
2
2
  require 'foreplay'
3
- require 'foreplay/generators/setup'
4
3
 
5
4
  module Foreplay
6
5
  class CLI < Thor
7
- desc 'check', 'Checks if configuration is OK'
6
+ desc 'deploy ENVIRONMENT', 'Deploys to specified environment'
8
7
 
9
- method_option :environment, :aliases => "-e"
10
- method_option :role, :aliases => "-r"
11
- method_option :server, :aliases => "-s"
8
+ method_option :role, :aliases => '-r'
9
+ method_option :server, :aliases => '-s'
12
10
 
13
- def check
14
- puts Foreplay::Config.check options
11
+ def deploy(environment)
12
+ Foreplay::Deploy.start [:deploy, environment, options]
13
+ end
14
+
15
+ desc 'check ENVIRONMENT', 'Checks if configuration is OK for specified environment'
16
+
17
+ method_option :role, :aliases => '-r'
18
+ method_option :server, :aliases => '-s'
19
+
20
+ def check(environment)
21
+ Foreplay::Deploy.start [:check, environment, options]
15
22
  end
16
23
 
17
24
  desc 'setup', 'Create the Foreplay config file'
18
25
 
26
+ method_option :name, :aliases => '-n'
27
+ method_option :repository, :aliases => '-r'
28
+ method_option :user, :aliases => '-u'
29
+ method_option :password
30
+ method_option :keyfile
31
+ method_option :private_key, :aliases => '-k'
32
+ method_option :path, :aliases => '-f'
33
+ method_option :port, :aliases => '-p', :type => :numeric
34
+ method_option :servers, :aliases => '-s', :type => :array
35
+ method_option :db_adapter, :aliases => '-a'
36
+ method_option :db_encoding, :aliases => '-e'
37
+ method_option :db_name, :aliases => '-d'
38
+ method_option :db_pool , :type => :numeric
39
+ method_option :db_host, :aliases => '-h'
40
+ method_option :db_user
41
+ method_option :db_password
42
+
19
43
  def setup
20
- Foreplay::Generators::Setup.start
44
+ Foreplay::Setup.start
21
45
  end
22
46
  end
23
47
  end