deep_thought 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +107 -27
- data/deep_thought.gemspec +1 -1
- data/lib/deep_thought/ci_service.rb +5 -1
- data/lib/deep_thought/ci_service/ci_service.rb +25 -0
- data/lib/deep_thought/ci_service/janky.rb +2 -9
- data/lib/deep_thought/deployer.rb +7 -2
- data/lib/deep_thought/deployer/deployer.rb +4 -2
- data/lib/deep_thought/deployer/shell.rb +1 -1
- data/lib/deep_thought/version.rb +1 -1
- data/test/deep_thought_api_test.rb +1 -1
- data/test/deep_thought_app_test.rb +2 -2
- data/test/deep_thought_ci_service_test.rb +10 -2
- data/test/deep_thought_deployer_test.rb +10 -4
- data/test/deep_thought_git_test.rb +1 -1
- data/test/deep_thought_janky_test.rb +1 -1
- data/test/deep_thought_notifier_test.rb +3 -3
- data/test/deep_thought_project_test.rb +1 -1
- data/test/deep_thought_shell_test.rb +3 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0dfbb4db4fd08ad8def952e00cf106b02862d25
|
4
|
+
data.tar.gz: dd56ee449838d5ba4bd0c01f5041f32d3105fdc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 937786d6394d8d5ca34fcaf3cda570cdff45b394c8bb94c4a7f674c9b859c499f53e3b27858e639f2c794adcc230af02274fbeb0dd059b6dbe06784ff2d0b854
|
7
|
+
data.tar.gz: f49fc78d7cf859cf928435ab78bdbaddb56b1d67bad870c9405a1f8e0751e95111d1122754925f71fc90fa7b638375e8a7193b9b4e77832a3f344eeac7464777
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Deep Thought
|
2
2
|
|
3
3
|
Deploy smart, not hard.
|
4
4
|
|
@@ -6,7 +6,7 @@ Deploy smart, not hard.
|
|
6
6
|
|
7
7
|
Deep Thought takes all of the thought out of deploying.
|
8
8
|
|
9
|
-
Want to prevent deployment conflicts? Deep Thought does that. Want to deploy with Hubot? Deep Thought has you covered. Looking to ensure a build is green before it is deployed? Deep Thought yawns at your puny requests. Want a web interface? Got it.
|
9
|
+
Want to prevent deployment conflicts? Deep Thought does that. Want to deploy with Hubot? Deep Thought has you covered. Looking to ensure a build is green before it is deployed? Deep Thought yawns at your puny requests. Want a web interface? Got it. An API? Yep. Security? Totally locked down. Deep Thought is master of your deployments.
|
10
10
|
|
11
11
|
Deep Thought was inspired by GitHub's own Hubot+Heaven workflow. Check out [Zach Holman's talk](http://zachholman.com/talk/unsucking-your-teams-development-environment/) to see the original inspiration.
|
12
12
|
|
@@ -20,7 +20,7 @@ Use [this Gist](https://gist.github.com/redhotvengeance/5746731) to get started:
|
|
20
20
|
|
21
21
|
### Setup
|
22
22
|
|
23
|
-
Deep Thought is designed to be deployed to Heroku:
|
23
|
+
Deep Thought needs an environment with Ruby and Git installed, and also access to a PostgreSQL database. Deep Thought will work fine on any server or VM matching those requirements, though it is largely designed to be deployed to Heroku:
|
24
24
|
|
25
25
|
heroku apps:create [NAME]
|
26
26
|
heroku config:set RACK_ENV=production
|
@@ -54,7 +54,20 @@ Deep Thought requires the use of a background worker for deployments. Normally,
|
|
54
54
|
|
55
55
|
### Add a project
|
56
56
|
|
57
|
-
Once logged in, click the `+ add project` button on the `projects` page. Enter a unique project name and the remote Git repository url for the project. Click `create project`, and
|
57
|
+
Once logged in, click the `+ add project` button on the `projects` page. Enter a unique project name and the remote Git repository url for the project. Click `create project`, and your project will be set up and ready to deploy.
|
58
|
+
|
59
|
+
### Deploy
|
60
|
+
|
61
|
+
Click on a project from the homepage. Select the branch to deploy, and optionally define additional parameters:
|
62
|
+
|
63
|
+
- `environment`: Sets the environment to deploy to (`development`, `staging`, `production`, etc - defaults to `development`)
|
64
|
+
- `box`: Sets a specific server to deploy to (passed as an argument to the shell script - `script/deploy development deploy box=prod`)
|
65
|
+
- `action`: Sets a subtask to deploy (for instance, if "config" is added, then Deep Thought would execute `script/deploy development deploy:config`)
|
66
|
+
- `variable`: Sets additional values that can be passed to the deploy (for instance, if set to `force=true`, Deep Thought would execute `script/deploy development deploy force=true`)
|
67
|
+
|
68
|
+
Click `deploy` - now a deployment is underway!
|
69
|
+
|
70
|
+
Deep Thought will let you know once the deployment is finished. If you'd like to see a log of previous deployments, click the `history` button. Clicking on a subsequent deployment will show you the details of that deployment.
|
58
71
|
|
59
72
|
### .deepthought.yml
|
60
73
|
|
@@ -68,37 +81,28 @@ Here's an example `.deepthought.yml`:
|
|
68
81
|
name: project-name
|
69
82
|
root: script/deploy
|
70
83
|
|
71
|
-
|
84
|
+
Let's break that down. The first line specifies the key name for the deployer this project will use (defaults to `shell`).
|
85
|
+
|
86
|
+
Lines 2-4 specify the continuous integration settings. `enabled` tells Deep Thought to check the CI server for green builds. `name` is the name of the project on the CI server.
|
72
87
|
|
73
|
-
|
88
|
+
Lines 1-4 are common to all projects, but additional data can be added to the config to supply information to a specific deployer. In this case, line 5 tells the shell deployer where to find the shell script it will execute (which defaults to `script/deploy`).
|
89
|
+
|
90
|
+
In addition to the `.deepthought.yml` file, make sure to add any dependencies needed to deploy your project to the project's Gemfile.
|
74
91
|
|
75
92
|
### Add a key
|
76
93
|
|
77
|
-
|
94
|
+
Your project repos may be private, and even if they are not, you still probably need to authenticate via ssh key to access servers for deployment. If you need to add an ssh key to a Deep Thought hosted on Heroku, then you can use the [Deep Thought buildpack](https://github.com/redhotvengeance/heroku-buildpack-deep-thought):
|
78
95
|
|
79
|
-
heroku config:set BUILDPACK_URL=https://github.com/redhotvengeance/heroku-buildpack-deep-thought
|
96
|
+
heroku config:set BUILDPACK_URL=https://github.com/redhotvengeance/heroku-buildpack-deep-thought.git
|
80
97
|
ssh_key=`cat ~/.ssh/your_ssh_key`
|
81
98
|
heroku config:set SSH_KEY="$ssh_key"
|
82
99
|
heroku config:set SSH_HOST=github.com
|
83
100
|
|
84
101
|
Keep in mind that the ssh key shouldn't have a password - otherwise Deep Thought won't be able to use it!
|
85
102
|
|
86
|
-
### Deploy
|
87
|
-
|
88
|
-
Click on a project from the homepage. Select the branch to deploy, and optionally define additional parameters:
|
89
|
-
|
90
|
-
- `environment`: Sets the environment to deploy to (`development`, `staging`, `production`, etc - defaults to `development`).
|
91
|
-
- `box`: Sets a specific server to deploy to (passed as an argument to the shell script - `script/deploy development deploy box=prod`).
|
92
|
-
- `action`: Sets a subtask to deploy (for instance, if "config" is added, then Deep Thought would execute `script/deploy development deploy:config`).
|
93
|
-
- `variable`: Sets additional values that can be passed to the deploy (for instance, if set to `force=true`, Deep Thought would execute `script/deploy development deploy force=true`).
|
94
|
-
|
95
|
-
Click `deploy` - now a deployment is underway!
|
96
|
-
|
97
|
-
Deep Thought will let you know once the deployment is finished. If you'd like to see a log of previous deployments, click the `history` button. Clicking on a subsequent deployment will show you the details of that deployment.
|
98
|
-
|
99
103
|
### Continuous integration
|
100
104
|
|
101
|
-
If you use continuous integration, you can have Deep Thought check to make sure a build is green before deploying. By default,
|
105
|
+
If you use continuous integration, you can have Deep Thought check to make sure a build is green before deploying. By default, Deep Thought supports interfacing with [Janky](https://github.com/github/janky).
|
102
106
|
|
103
107
|
To enable continuous integration, several environment variables must be set:
|
104
108
|
|
@@ -125,16 +129,92 @@ The current API routes are:
|
|
125
129
|
|
126
130
|
Hubot integrates wonderfully with Deep Thought. He communicates via the API, which means he'll need an account with an API generated.
|
127
131
|
|
128
|
-
Once you've setup the Hubot user and have its API key, grab the Deep Thought Hubot script and add it to your Hubot.
|
132
|
+
Once you've setup the Hubot user and have its API key, grab the [Deep Thought Hubot script](https://github.com/redhotvengeance/hubot-scripts/blob/add-deep-thought/src/scripts/deep-thought.coffee) and add it to your Hubot.
|
129
133
|
|
130
134
|
Set the following config variables for your Hubot:
|
131
135
|
|
132
|
-
heroku config:set
|
133
|
-
heroku config:set
|
136
|
+
heroku config:set HUBOT_DEEP_THOUGHT_URL=https://your-deep-thought.herokuapp.com
|
137
|
+
heroku config:set HUBOT_DEEP_THOUGHT_TOKEN=<hubot api key>
|
138
|
+
|
139
|
+
Finally, Deep Thought likes to talk back to Hubot to let him know how deploys have gone. Login to the Hubot account on Deep Thought, head to the `me` page, and set the `notification url` to `http://your.hubot.com/deep-thought/notify/:room_name`, where `:room_name` is the name of the chat room you'd like Hubot to post in.
|
140
|
+
|
141
|
+
To learn more about how to ask Hubot to deploy, check out the [Hubot script](https://github.com/redhotvengeance/hubot-scripts/blob/add-deep-thought/src/scripts/deep-thought.coffee).
|
142
|
+
|
143
|
+
## Plugins
|
144
|
+
|
145
|
+
Deep Thought is architected on a plugin-based system, making it extendable with new deployers and CI service integrations. To see currently available plugins, check out the list of [deployers](https://github.com/redhotvengeance/deep_thought/wiki/Deployers) and [CI services](https://github.com/redhotvengeance/deep_thought/wiki/CI-Services) found in the [wiki](https://github.com/redhotvengeance/deep_thought/wiki).
|
146
|
+
|
147
|
+
### Deployers
|
148
|
+
|
149
|
+
Looking to make a new deployer? Excellent!
|
150
|
+
|
151
|
+
Your custom deployer should live in the `DeepThought::Deployer` namespace. Deep Thought deployers have two required methods: `setup?(project, config)` and `execute?(deploy, config)`. Both are predicate methods, and should return only truthy or falsy values. Your deployer should extend [`DeepThought::Deployer::Deployer`](https://github.com/redhotvengeance/deep_thought/blob/master/lib/deep_thought/deployer/deployer.rb), so it will inherit both of these methods - from there you can overwrite them with custom functionality as needed.
|
152
|
+
|
153
|
+
#### `setup?(project, config)`
|
154
|
+
|
155
|
+
The `setup?` method is called before deploys to ensure the project is setup as needed for the deploy to execute properly. For instance, if your deployer deploys by pushing to a Git remote, you can ensure that the Git remotes exist within `setup?`. Your deployer may have no need of `setup?`, in which case just don't bother overwriting the method.
|
156
|
+
|
157
|
+
A reference to the project is passed to the `setup?` method, as is the project config (which is the hash generated from the project's `.deepthought.yml` file). You can use access to the config to take advantage of any deployer-specfic data that may have been put into the `.deepthought.yml` file.
|
158
|
+
|
159
|
+
The `setup?` method should return `true` when successful and `false` when not.
|
160
|
+
|
161
|
+
#### `execute?(deploy, config)`
|
162
|
+
|
163
|
+
The `execute?` method is where deployment happens.
|
164
|
+
|
165
|
+
This method should start the deploy and return once the deployment is finished. You also have access to the project config in this method, just in case any data from `.deepthought.yml` is necessary for deploying.
|
166
|
+
|
167
|
+
Once the deployment is complete, the output log from the deployment should be stored in `deploy.log`.
|
168
|
+
|
169
|
+
The `execute?` method should return `true` if the deploy was successful and `false` if it was not.
|
170
|
+
|
171
|
+
#### Register
|
172
|
+
|
173
|
+
You will also have to register your deployer with Deep Thought. When you register your deployer, you'll specify a key name and the deployer class. The key name is the same key used to set the `deploy_type` in `.deepthought.yml`.
|
174
|
+
|
175
|
+
Here is an example of how to register a deployer with Deep Thought:
|
176
|
+
|
177
|
+
DeepThought::Deployer.register_adapter('key', DeepThought::Deployer::CustomDeployer)
|
178
|
+
|
179
|
+
Make sure to add your new deployer to the [list of plugins](https://github.com/redhotvengeance/deep_thought/wiki/Deployers) so others can find it and benefit from your contributions!
|
180
|
+
|
181
|
+
### CI Services
|
182
|
+
|
183
|
+
Looking to make a new CI service integration? Fantastic!
|
184
|
+
|
185
|
+
Your custom CI service should live in the `DeepThought::CIService` namespace. Deep Thought CI service integrations have two required methods: `setup?(settings)` and `is_branch_green?(app, branch, hash)`. Both are predicate methods, and should return only truthy or falsy values. Your CI service should extend [`DeepThought::CIService::CIService`](https://github.com/redhotvengeance/deep_thought/tree/master/lib/deep_thought/ci_service/ci_service.rb), so it will inherit both of these methods - from there you can overwrite them with custom functionality as needed.
|
186
|
+
|
187
|
+
#### `setup?(settings)`
|
188
|
+
|
189
|
+
The `setup?` method is called upon application start, and ensures the CI service is properly setup for use during the application lifetime.
|
190
|
+
|
191
|
+
The application environment is passed to the method via the `settings` argument. The abstract method already sets three instance variables from the environment:
|
192
|
+
|
193
|
+
- `@endpoint` - Set from `ENV['CI_SERVICE_ENDPOINT'], and specifies the URI to the CI service being pinged
|
194
|
+
- `@username` - Set from `ENV['CI_SERVICE_USERNAME'], and specifies the username used for authentication with the CI service
|
195
|
+
- `@password` - Set from `ENV['CI_SERVICE_PASSWORD'], and specifies the username used for authentication with the CI service
|
196
|
+
|
197
|
+
It is likely you will not have to overwrite this method since it already sets these common variables.
|
198
|
+
|
199
|
+
The `setup?` method should return `true` when successful and `false` when not.
|
200
|
+
|
201
|
+
#### `is_branch_green?(app, branch, hash)`
|
202
|
+
|
203
|
+
The `is_branch_green?` method is where build status checking happens.
|
204
|
+
|
205
|
+
This method should ensure that for the app/branch/commit hash being deployed, the CI server has done a successful build.
|
206
|
+
|
207
|
+
The `is_branch_green?` method should return `true` if the build was reported successful and `false` if it was not.
|
208
|
+
|
209
|
+
#### Register
|
210
|
+
|
211
|
+
You will also have to register your CI service with Deep Thought. When you register your CI service, you'll specify a key name and the CI service class. The key name is the same key used to set the `CI_SERVICE` environment variable.
|
212
|
+
|
213
|
+
Here is an example of how to register a CI service with Deep Thought:
|
134
214
|
|
135
|
-
|
215
|
+
DeepThought::CIService.register_adapter('key', DeepThought::CIService::CustomCIService)
|
136
216
|
|
137
|
-
|
217
|
+
Make sure to add your new CI service to the [list of plugins](https://github.com/redhotvengeance/deep_thought/wiki/CI-Services) so others can find it and benefit from your contributions!
|
138
218
|
|
139
219
|
## Enjoy
|
140
220
|
|
data/deep_thought.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
gem.email = ["rhv@redhotvengeance.com"]
|
11
11
|
gem.description = "Deploy smart, not hard."
|
12
12
|
gem.summary = "Deploy smart, not hard."
|
13
|
-
gem.homepage = ""
|
13
|
+
gem.homepage = "https://github.com/redhotvengeance/deep_thought"
|
14
14
|
|
15
15
|
gem.files = `git ls-files`.split("\n") - %w[.gitignore]
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module DeepThought
|
2
2
|
module CIService
|
3
3
|
class CIServiceNotFoundError < StandardError; end
|
4
|
+
class CIServiceSetupFailedError < StandardError; end
|
4
5
|
class CIBuildNotGreenError < StandardError; end
|
5
6
|
class CIProjectAccessError < StandardError; end
|
6
7
|
|
@@ -21,7 +22,10 @@ module DeepThought
|
|
21
22
|
if @adapters.keys.include?(settings['CI_SERVICE'])
|
22
23
|
klass = adapters[settings['CI_SERVICE']]
|
23
24
|
@ci_service = klass.new
|
24
|
-
|
25
|
+
|
26
|
+
if !@ci_service.setup?(settings)
|
27
|
+
raise CIServiceSetupFailedError, "CI service setup failed - check the CI service and project settings."
|
28
|
+
end
|
25
29
|
else
|
26
30
|
raise CIServiceNotFoundError, "I don't have a CI service called \"#{settings['CI_SERVICE']}\"."
|
27
31
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module DeepThought
|
2
|
+
module CIService
|
3
|
+
class CIService
|
4
|
+
attr_accessor :endpoint, :username, :password
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
if self.class.name == 'DeepThought::CIService::CIService'
|
8
|
+
raise "#{self.class.name} is abstract, you cannot instantiate it directly."
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def setup?(settings)
|
13
|
+
@endpoint = settings['CI_SERVICE_ENDPOINT']
|
14
|
+
@username = settings['CI_SERVICE_USERNAME']
|
15
|
+
@password = settings['CI_SERVICE_PASSWORD']
|
16
|
+
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def is_branch_green?(app, branch, hash)
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -1,16 +1,9 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'deep_thought/ci_service/ci_service'
|
2
3
|
|
3
4
|
module DeepThought
|
4
5
|
module CIService
|
5
|
-
class Janky
|
6
|
-
attr_accessor :endpoint, :username, :password
|
7
|
-
|
8
|
-
def setup(settings)
|
9
|
-
@endpoint = settings['CI_SERVICE_ENDPOINT']
|
10
|
-
@username = settings['CI_SERVICE_USERNAME']
|
11
|
-
@password = settings['CI_SERVICE_PASSWORD']
|
12
|
-
end
|
13
|
-
|
6
|
+
class Janky < DeepThought::CIService::CIService
|
14
7
|
def is_branch_green?(app, branch, hash)
|
15
8
|
is_green = false
|
16
9
|
|
@@ -4,6 +4,7 @@ require 'deep_thought/git'
|
|
4
4
|
module DeepThought
|
5
5
|
module Deployer
|
6
6
|
class DeployerNotFoundError < StandardError; end
|
7
|
+
class DeployerSetupFailedError < StandardError; end
|
7
8
|
class DeploymentFailedError < StandardError; end
|
8
9
|
class DeploymentInProgressError < StandardError; end
|
9
10
|
|
@@ -84,8 +85,12 @@ module DeepThought
|
|
84
85
|
|
85
86
|
klass = adapters[deploy_type]
|
86
87
|
deployer = klass.new
|
87
|
-
|
88
|
-
|
88
|
+
|
89
|
+
if !deployer.setup?(deploy.project, project_config)
|
90
|
+
raise DeployerSetupFailedError, "Deployer setup failed - check the deployer and project settings."
|
91
|
+
end
|
92
|
+
|
93
|
+
deploy_status = deployer.execute?(deploy, project_config)
|
89
94
|
|
90
95
|
unlock_deployer
|
91
96
|
|
@@ -3,7 +3,7 @@ require 'deep_thought/deployer/deployer'
|
|
3
3
|
module DeepThought
|
4
4
|
module Deployer
|
5
5
|
class Shell < DeepThought::Deployer::Deployer
|
6
|
-
def execute(deploy, config)
|
6
|
+
def execute?(deploy, config)
|
7
7
|
environment = deploy.environment || "development"
|
8
8
|
|
9
9
|
root = config['root'] || "script/deploy"
|
data/lib/deep_thought/version.rb
CHANGED
@@ -12,7 +12,7 @@ class DeepThoughtApiTest < MiniTest::Unit::TestCase
|
|
12
12
|
|
13
13
|
deployer = mock('class')
|
14
14
|
deployer.stubs(:new).returns(deployer)
|
15
|
-
deployer.stubs(:setup)
|
15
|
+
deployer.stubs(:setup?).returns(true)
|
16
16
|
DeepThought::Deployer.register_adapter('mock', deployer)
|
17
17
|
|
18
18
|
@user = DeepThought::User.create(:email => 'test@test.com', :password => 'secret', :password_confirmation => 'secret', :api_key => '12345')
|
@@ -9,8 +9,8 @@ class DeepThoughtAppTest < MiniTest::Unit::TestCase
|
|
9
9
|
|
10
10
|
@deployer = mock('class')
|
11
11
|
@deployer.stubs(:new).returns(@deployer)
|
12
|
-
@deployer.stubs(:setup)
|
13
|
-
@deployer.stubs(:execute).returns(true)
|
12
|
+
@deployer.stubs(:setup?).returns(true)
|
13
|
+
@deployer.stubs(:execute?).returns(true)
|
14
14
|
DeepThought::Deployer.register_adapter('mock', @deployer)
|
15
15
|
|
16
16
|
@user_email = 'test@test.com'
|
@@ -22,10 +22,18 @@ class DeepThoughtCIServiceTest < MiniTest::Unit::TestCase
|
|
22
22
|
assert_raises(DeepThought::CIService::CIServiceNotFoundError) { DeepThought::CIService.setup({"CI_SERVICE" => "no-service"}) }
|
23
23
|
end
|
24
24
|
|
25
|
+
def test_ci_service_setup_failed
|
26
|
+
ci_service = mock('class')
|
27
|
+
ci_service.expects(:new).returns(ci_service)
|
28
|
+
ci_service.expects(:setup?).with({"CI_SERVICE" => "mock"}).returns(false)
|
29
|
+
DeepThought::CIService.register_adapter('mock', ci_service)
|
30
|
+
assert_raises(DeepThought::CIService::CIServiceSetupFailedError) { DeepThought::CIService.setup({"CI_SERVICE" => "mock"}) }
|
31
|
+
end
|
32
|
+
|
25
33
|
def test_ci_service_is_branch_green_success
|
26
34
|
ci_service = mock('class')
|
27
35
|
ci_service.expects(:new).returns(ci_service)
|
28
|
-
ci_service.expects(:setup).with({"CI_SERVICE" => "mock"})
|
36
|
+
ci_service.expects(:setup?).with({"CI_SERVICE" => "mock"}).returns(true)
|
29
37
|
ci_service.expects(:is_branch_green?).with('app', 'master', 'hash').returns(true)
|
30
38
|
DeepThought::CIService.register_adapter('mock', ci_service)
|
31
39
|
DeepThought::CIService.setup({"CI_SERVICE" => "mock"})
|
@@ -35,7 +43,7 @@ class DeepThoughtCIServiceTest < MiniTest::Unit::TestCase
|
|
35
43
|
def test_ci_service_is_branch_green_failed
|
36
44
|
ci_service = mock('class')
|
37
45
|
ci_service.expects(:new).returns(ci_service)
|
38
|
-
ci_service.expects(:setup).with({"CI_SERVICE" => "mock"})
|
46
|
+
ci_service.expects(:setup?).with({"CI_SERVICE" => "mock"}).returns(true)
|
39
47
|
ci_service.expects(:is_branch_green?).with('app', 'master', 'hash').returns(false)
|
40
48
|
DeepThought::CIService.register_adapter('mock', ci_service)
|
41
49
|
DeepThought::CIService.setup({"CI_SERVICE" => "mock"})
|
@@ -8,7 +8,7 @@ class DeepThoughtDeployerTest < MiniTest::Unit::TestCase
|
|
8
8
|
|
9
9
|
@deployer = mock('class')
|
10
10
|
@deployer.stubs(:new).returns(@deployer)
|
11
|
-
@deployer.stubs(:setup)
|
11
|
+
@deployer.stubs(:setup?).returns(true)
|
12
12
|
DeepThought::Deployer.register_adapter('mock', @deployer)
|
13
13
|
|
14
14
|
@project = DeepThought::Project.create(:name => '_test', :repo_url => './test/fixtures/project-test')
|
@@ -31,11 +31,17 @@ class DeepThoughtDeployerTest < MiniTest::Unit::TestCase
|
|
31
31
|
assert_raises(DeepThought::Deployer::DeployerNotFoundError) { @deploy.save }
|
32
32
|
end
|
33
33
|
|
34
|
+
def test_deployer_setup_failed
|
35
|
+
@deployer.stubs(:setup?).returns(false)
|
36
|
+
@deploy.branch = 'mock'
|
37
|
+
assert_raises(DeepThought::Deployer::DeployerSetupFailedError) { @deploy.save }
|
38
|
+
end
|
39
|
+
|
34
40
|
def test_deployer_execute_success
|
35
41
|
@deploy.branch = 'mock'
|
36
42
|
|
37
43
|
DeepThought::Notifier.stubs(:notify)
|
38
|
-
@deployer.expects(:execute).with(@deploy, {'deploy_type' => 'mock'}).returns(true)
|
44
|
+
@deployer.expects(:execute?).with(@deploy, {'deploy_type' => 'mock'}).returns(true)
|
39
45
|
|
40
46
|
assert !@deploy.started_at
|
41
47
|
assert !@deploy.finished_at
|
@@ -51,7 +57,7 @@ class DeepThoughtDeployerTest < MiniTest::Unit::TestCase
|
|
51
57
|
@deploy.branch = 'mock'
|
52
58
|
|
53
59
|
DeepThought::Notifier.stubs(:notify)
|
54
|
-
@deployer.expects(:execute).with(@deploy, {'deploy_type' => 'mock'}).returns(false)
|
60
|
+
@deployer.expects(:execute?).with(@deploy, {'deploy_type' => 'mock'}).returns(false)
|
55
61
|
|
56
62
|
assert !@deploy.started_at
|
57
63
|
assert !@deploy.finished_at
|
@@ -66,7 +72,7 @@ class DeepThoughtDeployerTest < MiniTest::Unit::TestCase
|
|
66
72
|
|
67
73
|
def test_deployer_lock
|
68
74
|
DeepThought::Deployer.lock_deployer
|
69
|
-
@deployer.stubs(:execute).with(@deploy).returns(true)
|
75
|
+
@deployer.stubs(:execute?).with(@deploy).returns(true)
|
70
76
|
assert_raises(DeepThought::Deployer::DeploymentInProgressError) { @deploy.save }
|
71
77
|
end
|
72
78
|
end
|
@@ -10,7 +10,7 @@ class DeepThoughtGitTest < MiniTest::Unit::TestCase
|
|
10
10
|
|
11
11
|
deployer = mock('class')
|
12
12
|
deployer.stubs(:new).returns(deployer)
|
13
|
-
deployer.stubs(:setup)
|
13
|
+
deployer.stubs(:setup?)
|
14
14
|
DeepThought::Deployer.register_adapter('mock', deployer)
|
15
15
|
|
16
16
|
@project = DeepThought::Project.new(:name => '_test', :repo_url => './test/fixtures/project-test')
|
@@ -12,7 +12,7 @@ class DeepThoughtJankyTest < MiniTest::Unit::TestCase
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def test_janky_setup_success
|
15
|
-
@janky.setup({"CI_SERVICE_ENDPOINT" => "endpoint", "CI_SERVICE_USERNAME" => "username", "CI_SERVICE_PASSWORD" => "password"})
|
15
|
+
@janky.setup?({"CI_SERVICE_ENDPOINT" => "endpoint", "CI_SERVICE_USERNAME" => "username", "CI_SERVICE_PASSWORD" => "password"})
|
16
16
|
|
17
17
|
assert @janky.endpoint == 'endpoint'
|
18
18
|
assert @janky.username == 'username'
|
@@ -8,7 +8,7 @@ class DeepThoughtNotifierTest < MiniTest::Unit::TestCase
|
|
8
8
|
|
9
9
|
@deployer = mock('class')
|
10
10
|
@deployer.expects(:new).returns(@deployer)
|
11
|
-
@deployer.expects(:setup)
|
11
|
+
@deployer.expects(:setup?).returns(true)
|
12
12
|
|
13
13
|
@project = DeepThought::Project.create(:name => '_test', :repo_url => './test/fixtures/project-test')
|
14
14
|
@user = DeepThought::User.create(:email => 'test@test.com', :password => 'secret', :password_confirmation => 'secret', :api_key => '12345', :notification_url => 'url')
|
@@ -21,14 +21,14 @@ class DeepThoughtNotifierTest < MiniTest::Unit::TestCase
|
|
21
21
|
|
22
22
|
def test_api_notifier_success
|
23
23
|
DeepThought::Notifier.expects(:notify).with(@user, 'SUCCESS: _test mock')
|
24
|
-
@deployer.expects(:execute).with(@deploy, {'deploy_type' => 'mock'}).returns(true)
|
24
|
+
@deployer.expects(:execute?).with(@deploy, {'deploy_type' => 'mock'}).returns(true)
|
25
25
|
DeepThought::Deployer.register_adapter('mock', @deployer)
|
26
26
|
assert @deploy.save
|
27
27
|
end
|
28
28
|
|
29
29
|
def test_api_notifier_failed
|
30
30
|
DeepThought::Notifier.expects(:notify).with(@user, 'FAILED: _test mock')
|
31
|
-
@deployer.expects(:execute).with(@deploy, {'deploy_type' => 'mock'}).returns(false)
|
31
|
+
@deployer.expects(:execute?).with(@deploy, {'deploy_type' => 'mock'}).returns(false)
|
32
32
|
DeepThought::Deployer.register_adapter('mock', @deployer)
|
33
33
|
assert_raises(DeepThought::Deployer::DeploymentFailedError) { @deploy.save }
|
34
34
|
end
|
@@ -10,7 +10,7 @@ class DeepThoughtProjectTest < MiniTest::Unit::TestCase
|
|
10
10
|
|
11
11
|
deployer = mock('class')
|
12
12
|
deployer.stubs(:new).returns(deployer)
|
13
|
-
deployer.stubs(:setup)
|
13
|
+
deployer.stubs(:setup?)
|
14
14
|
DeepThought::Deployer.register_adapter('mock', deployer)
|
15
15
|
|
16
16
|
@project = DeepThought::Project.create(:name => '_test', :repo_url => './test/fixtures/project-test')
|
@@ -8,7 +8,7 @@ class DeepThoughtShellTest < MiniTest::Unit::TestCase
|
|
8
8
|
|
9
9
|
deployer = mock('class')
|
10
10
|
deployer.stubs(:new).returns(deployer)
|
11
|
-
deployer.stubs(:setup)
|
11
|
+
deployer.stubs(:setup?).returns(true)
|
12
12
|
DeepThought::Deployer.register_adapter('mock', deployer)
|
13
13
|
|
14
14
|
@project = DeepThought::Project.create(:name => '_test', :repo_url => './test/fixtures/project-test')
|
@@ -25,14 +25,14 @@ class DeepThoughtShellTest < MiniTest::Unit::TestCase
|
|
25
25
|
|
26
26
|
def test_shell_execute_success
|
27
27
|
@project.setup
|
28
|
-
assert @deployer.execute(@deploy, {})
|
28
|
+
assert @deployer.execute?(@deploy, {})
|
29
29
|
assert @deploy.log
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_shell_execute_failed
|
33
33
|
@project.setup
|
34
34
|
@deploy.actions = ['fail_test'].to_yaml
|
35
|
-
assert !@deployer.execute(@deploy, {})
|
35
|
+
assert !@deployer.execute?(@deploy, {})
|
36
36
|
assert @deploy.log
|
37
37
|
end
|
38
38
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deep_thought
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Lollar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -332,6 +332,7 @@ files:
|
|
332
332
|
- lib/deep_thought/api.rb
|
333
333
|
- lib/deep_thought/app.rb
|
334
334
|
- lib/deep_thought/ci_service.rb
|
335
|
+
- lib/deep_thought/ci_service/ci_service.rb
|
335
336
|
- lib/deep_thought/ci_service/janky.rb
|
336
337
|
- lib/deep_thought/deployer.rb
|
337
338
|
- lib/deep_thought/deployer/deployer.rb
|
@@ -400,7 +401,7 @@ files:
|
|
400
401
|
- test/fixtures/project-test/refs/heads/.gitkeep
|
401
402
|
- test/fixtures/project-test/refs/tags/.gitkeep
|
402
403
|
- test/test_helper.rb
|
403
|
-
homepage:
|
404
|
+
homepage: https://github.com/redhotvengeance/deep_thought
|
404
405
|
licenses: []
|
405
406
|
metadata: {}
|
406
407
|
post_install_message:
|