solano_notify_and_deploy 0.0.4.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 55109ac523ad2d71ee42ca773c8aa7188098b50d
4
- data.tar.gz: af231f4180a7edda7921cff18cec9103646b1ca9
3
+ metadata.gz: c224b093021bb19ea89d945093dade7dbfa83ae0
4
+ data.tar.gz: ac6d6152f8e7c40945ca4ad1e05c4a3b08cf1562
5
5
  SHA512:
6
- metadata.gz: 7044aced1a32d40b18ad046f7bc2edcdd2b246fe34fae1e39a4399712c4b68c86c3e9a45fa818a3150268232c085943c07481827ec5ee4097689ade0a5a6217d
7
- data.tar.gz: e2e5c8fd56f958d5505fa5172958a66055984452ea4b3f54135355dd14917e6a56bc8f20fed05c02b7bc8171ad0eaf2479f38834cd7e041fe6d17ea5cf0ec239
6
+ metadata.gz: e3b7c1bfc16f987de5ce4829fd7e17b0359d1912ddc58019535d3f17a684fe1d95b0edaae7034621d20ae843eba4cf0f6056b85e2cddd37de250549b4686e5b2
7
+ data.tar.gz: 395ebc2597a638d5b67f4792ed50bfc732d10e04584d46716777a3802da01dbda7ef43b534997fc05ec5b32cb8e423ebfc71510fe95b8de507bfb90701f971c3
data/README.md CHANGED
@@ -7,9 +7,32 @@ Generator
7
7
  ========
8
8
 
9
9
  The gem includes a rails generator which will create a solano.yml file
10
- in the root of your rails app. It also configures a set of rake tasks (which live at lib/tasks/solano/deploy.rake).
10
+ in the root of your rails app. It also configures a set of rake tasks.
11
11
 
12
12
  Usage:
13
- rails g solano HIPCHAT_API_KEY HIPCHAT_ROOM_ID DEPLOY_HOOK_URL
13
+ ---
14
+ Run the generator to create the solano.yml and rake files. Customise them (eg. build start notifications are currently disabled by default in the solano.yaml). Commit them and trigger a build in Solano labs (use a github service hook to have this happen automatically on commit). Solano labs will pick up the solano.yaml and use the rake tasks in to trigger notifications to hipchat and deploy events.
14
15
 
15
- Run the generator and commit the solano.yml and rake tasks file. Solano labs will pick these up and the hooks configured in the solano.yml will trigger notifications and deploy events.
16
+ rails g solano HIPCHAT_API_KEY HIPCHAT_ROOM_ID DEPLOY_HOOK_URL
17
+
18
+
19
+ Rake Tasks
20
+ =========
21
+
22
+ The generator creates rake files at lib/tasks/solano.rake and lib/tasks/deploy.rake. It configures a number of rake tasks for use during the Solano Labs CI process. It also provides a manual deploy task.
23
+
24
+ solano:notify:build_start
25
+
26
+ provides a task to notify hipchat that ci run has started (used by Solano Labs CI process - configured in solano.yml).
27
+
28
+ solano:notify:build_complete
29
+
30
+ notify hipchat that ci run has completed and the status, success or failure (used by Solano Labs CI process - configured in solano.yml).
31
+
32
+ solano:notify_and_deploy
33
+
34
+ notify hipchat that ci run has completed (success or failure) and deploy on success (used by Solano Labs CI process - configured in solano.yml).
35
+
36
+ deploy:production
37
+
38
+ manually hit the web deploy hook url to deploy the app to production - you can run this rake task to deploy to production at any time.
@@ -9,7 +9,12 @@ class SolanoGenerator < Rails::Generators::Base
9
9
  template 'solano.yml.erb', 'solano.yml'
10
10
  end
11
11
 
12
- def create_deploy_task
13
- template 'deploy.rake.erb', 'lib/tasks/solano/deploy.rake'
12
+ def create_deploy_module
13
+ template 'notification_and_deployment.rb.erb', 'lib/notification_and_deployment.rb'
14
+ end
15
+
16
+ def copy_rake_tasks
17
+ copy_file 'solano.rake', 'lib/tasks/solano.rake'
18
+ copy_file 'deploy.rake', 'lib/tasks/deploy.rake'
14
19
  end
15
20
  end
@@ -0,0 +1,12 @@
1
+ require 'notification_and_deployment'
2
+
3
+ namespace :deploy do
4
+ include NotificationAndDeployment
5
+
6
+ desc 'run the deploy (notify hipchat on failure)'
7
+ task :production do
8
+ notify "Requesting deployment", "green"
9
+ deploy
10
+ end
11
+
12
+ end
@@ -0,0 +1,40 @@
1
+ module NotificationAndDeployment
2
+ def tddium?
3
+ ENV['TDDIUM'].present?
4
+ end
5
+
6
+ def passed?
7
+ ENV['TDDIUM_BUILD_STATUS'] == 'passed'
8
+ end
9
+
10
+ def build_passed?
11
+ tddium? && passed?
12
+ end
13
+
14
+ def deploy
15
+ succeeded = false
16
+ message = ""
17
+
18
+ begin
19
+ succeeded = system('curl -X POST -d "" <%= deploy_hook_url %>')
20
+ rescue Exception => e
21
+ succeeded = false
22
+ message = e.message
23
+ end
24
+
25
+ unless succeeded
26
+ notify "Deploy failed: #{message}", 'red'
27
+ raise "deployment failed"
28
+ end
29
+ end
30
+
31
+ def notify_build_status
32
+ notify "CI succeeded", "green" and return if build_passed?
33
+ notify "CI failed", "yellow"
34
+ end
35
+
36
+ def notify(message, colour)
37
+ client = HipChat::Client.new('<%= hipchat_api_key %>')
38
+ client['<%= hipchat_room_id %>'].send('Solano CI', message, :color => colour)
39
+ end
40
+ end
@@ -0,0 +1,27 @@
1
+ require 'notification_and_deployment'
2
+
3
+ namespace :solano do
4
+ include NotificationAndDeployment
5
+
6
+ namespace :notify do
7
+ desc 'build start - notify hipchat'
8
+ task :build_start do
9
+ notify 'CI starting', 'green'
10
+ end
11
+
12
+ desc 'build complete - notify hipchat'
13
+ task :build_complete do
14
+ notify_build_status
15
+ end
16
+ end
17
+
18
+ desc 'build complete - notify hipchat and deploy on successful build'
19
+ task :notify_and_deploy do
20
+ notify_build_status
21
+ unless build_passed?
22
+ notify "To deploy manually try rake solano:deploy", "yellow"
23
+ next
24
+ end
25
+ deploy
26
+ end
27
+ end
@@ -1,3 +1,3 @@
1
1
  module SolanoNotifyAndDeploy
2
- VERSION = '0.0.4.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solano_notify_and_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nic Pillinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-18 00:00:00.000000000 Z
11
+ date: 2014-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.6'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: hipchat
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Notify on solano labs build failure or success and optionally deploy
@@ -45,13 +45,15 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - ".gitignore"
48
+ - .gitignore
49
49
  - Gemfile
50
50
  - LICENSE
51
51
  - README.md
52
52
  - lib/generators/solano/USAGE
53
53
  - lib/generators/solano/solano_generator.rb
54
- - lib/generators/solano/templates/deploy.rake.erb
54
+ - lib/generators/solano/templates/deploy.rake
55
+ - lib/generators/solano/templates/notification_and_deployment.rb.erb
56
+ - lib/generators/solano/templates/solano.rake
55
57
  - lib/generators/solano/templates/solano.yml.erb
56
58
  - lib/solano_notify_and_deploy.rb
57
59
  - lib/solano_notify_and_deploy/railtie.rb
@@ -67,17 +69,17 @@ require_paths:
67
69
  - lib
68
70
  required_ruby_version: !ruby/object:Gem::Requirement
69
71
  requirements:
70
- - - ">="
72
+ - - '>='
71
73
  - !ruby/object:Gem::Version
72
74
  version: '0'
73
75
  required_rubygems_version: !ruby/object:Gem::Requirement
74
76
  requirements:
75
- - - ">="
77
+ - - '>='
76
78
  - !ruby/object:Gem::Version
77
79
  version: '0'
78
80
  requirements: []
79
81
  rubyforge_project:
80
- rubygems_version: 2.2.2
82
+ rubygems_version: 2.4.2
81
83
  signing_key:
82
84
  specification_version: 4
83
85
  summary: Notify on solano labs build failure or success and optionally deploy
@@ -1,70 +0,0 @@
1
- namespace :solano do
2
-
3
- namespace :notify do
4
-
5
- desc 'build start - notify hipchat'
6
- task :build_start do
7
- notify 'CI starting', 'green'
8
- end
9
-
10
- desc 'build complete - notify hipchat'
11
- task :build_complete do
12
- notify_build_status
13
- end
14
-
15
- end
16
-
17
- desc 'build complete - notify hipchat and deploy on successful build'
18
- task :notify_and_deploy do
19
- notify_build_status "- will not deploy, to deploy manually try rake solano:deploy"
20
- next unless build_passed?
21
- deploy
22
- end
23
-
24
- desc 'run the deploy (notify hipchat on failure)'
25
- task :deploy do
26
- deploy
27
- end
28
-
29
- private
30
-
31
- def tddium?
32
- ENV['TDDIUM'].present?
33
- end
34
-
35
- def passed?
36
- ENV['TDDIUM_BUILD_STATUS'] == 'passed'
37
- end
38
-
39
- def build_passed?
40
- tddium? && passed?
41
- end
42
-
43
- def deploy
44
- succeeded = false
45
- message = ""
46
-
47
- begin
48
- succeeded = system('curl -X POST -d "" <%= deploy_hook_url %>')
49
- rescue Exception => e
50
- succeeded = false
51
- message = e.message
52
- end
53
-
54
- unless succeeded
55
- notify "Deploy failed: #{message}", 'red'
56
- raise "deployment failed"
57
- end
58
- end
59
-
60
- def notify_build_status(failed_message = '')
61
- notify "CI succeeded", "green" and return if build_passed?
62
- notify "CI failed #{failed_message}", "yellow"
63
- end
64
-
65
- def notify(message, colour)
66
- client = HipChat::Client.new('<%= hipchat_api_key %>')
67
- client['<%= hipchat_room_id %>'].send('Solano CI', message, :color => colour)
68
- end
69
-
70
- end