solano_notify_and_deploy 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44c13d61e6e37e7c6720b1466a06ff9c3c6f6caa
4
- data.tar.gz: 5e20fee0c986b0119fde609e8322f7f8e0fc0390
3
+ metadata.gz: 452aa1dafc665615f73ba814b540e9af40df70fc
4
+ data.tar.gz: 10da2903fa341cdc736ddeda1a7c8e7936b9f1a0
5
5
  SHA512:
6
- metadata.gz: accf24fe796211518ef0bb46799e820e9f7985489f0829002785f0658d2e05e919307a8960bf8540a0c21eed816e7061bb806202132657096318a28830c46560
7
- data.tar.gz: 65be527cd7547e4560daa8bf67cf4542bd8196253635912f51934dcdf6b750ea113872769f320f7833f9d61ef1a904e6d283a7356070d1b6c6d3da74b86da269
6
+ metadata.gz: eb1d0de5a558fc6ec3e72b0656892df19e881e06305ad7ad0b91950975812f9d170e2ec3124102f0e3d084088edddd8619b7acb0da4fa5021ed139eec8aef2ae
7
+ data.tar.gz: 4a81d61cda879f1bdebeba0b5419b8736becbbe31add43a5b054931244c3324b375f0869d749a0d8e80ff81ac30fafdd76800779fbc8e6c732934b1f320c3812
@@ -9,4 +9,7 @@ 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'
14
+ end
12
15
  end
@@ -0,0 +1,60 @@
1
+ namespace :solano do
2
+ desc 'notify hipchat on build events'
3
+ task :notify do
4
+ notify_build_status
5
+ end
6
+
7
+ desc 'notify hipchat on build events, deploy on successful build'
8
+ task :notify_and_deploy do
9
+ notify_build_status "- will not deploy, to deploy manually try rake solano:deploy"
10
+ next unless build_passed?
11
+ deploy
12
+ end
13
+
14
+ desc 'run the deploy (notify on failure)'
15
+ task :deploy do
16
+ deploy
17
+ end
18
+
19
+ private
20
+
21
+ def tddium?
22
+ ENV['TDDIUM'].present?
23
+ end
24
+
25
+ def passed?
26
+ ENV['TDDIUM_BUILD_STATUS'] == 'passed'
27
+ end
28
+
29
+ def build_passed?
30
+ tddium? && passed?
31
+ end
32
+
33
+ def deploy
34
+ succeeded = false
35
+ message = ""
36
+
37
+ begin
38
+ succeeded = system('curl -X POST -d "" <%= deploy_hook_url %>')
39
+ rescue Exception => e
40
+ succeeded = false
41
+ message = e.message
42
+ end
43
+
44
+ unless succeeded
45
+ notify "Deploy failed: #{message}", 'red'
46
+ raise "deployment failed"
47
+ end
48
+ end
49
+
50
+ def notify_build_status(failed_message = '')
51
+ notify hipchat_api_key, hipchat_room_id, "Build succeeded", "green" and return if build_passed?
52
+ notify hipchat_api_key, hipchat_room_id, "Build failed #{failed_message}", "yellow"
53
+ end
54
+
55
+ def notify(message, colour)
56
+ client = HipChat::Client.new('<%= hipchat_api_key %>')
57
+ client['<%= hipchat_room_id %>'].send('Solano CI', message, :color => colour)
58
+ end
59
+
60
+ end
@@ -1,5 +1,8 @@
1
1
  ---
2
2
  :hooks:
3
- <%- if deploy_hook_url.nil? %> :post_build: bundle exec rake solano:notify[<%= hipchat_api_key %>, <%= hipchat_room_id %>]
4
- <%- else %> :post_build: bundle exec rake solano:notify_and_deploy[<%= hipchat_api_key %>, <%= hipchat_room_id %>, <%= deploy_hook_url %>]
3
+ :worker_setup: RAILS_ENV=test bundle exec rake db:test:prepare
4
+ <%- if deploy_hook_url.nil? %>
5
+ :post_build: bundle exec rake solano:notify
6
+ <%- else %>
7
+ :post_build: bundle exec rake solano:notify_and_deploy
5
8
  <%- end %>
@@ -5,10 +5,6 @@ module SolanoNotifyAndDeploy
5
5
  class Railtie < Rails::Railtie
6
6
  railtie_name :solano_notify_and_deploy
7
7
 
8
- rake_tasks do
9
- load File.join(File.dirname(__FILE__), "tasks/solano.rake")
10
- end
11
-
12
8
  generators do
13
9
  require "generators/solano/solano_generator"
14
10
  end
@@ -1,3 +1,3 @@
1
1
  module SolanoNotifyAndDeploy
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solano_notify_and_deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nic Pillinger
@@ -51,10 +51,10 @@ files:
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
55
  - lib/generators/solano/templates/solano.yml.erb
55
56
  - lib/solano_notify_and_deploy.rb
56
57
  - lib/solano_notify_and_deploy/railtie.rb
57
- - lib/solano_notify_and_deploy/tasks/solano.rake
58
58
  - lib/solano_notify_and_deploy/version.rb
59
59
  - solano_notify_and_deploy.gemspec
60
60
  homepage: http://lsf.io
@@ -1,57 +0,0 @@
1
- namespace :solano do
2
-
3
- desc 'notify hipchat on build events'
4
- task :notify, :hipchat_api_key, :hipchat_room_id do |t, args|
5
- notify_build_status args[:hipchat_api_key], args[:hipchat_room_id]
6
- end
7
-
8
- desc 'notify hipchat on build events, deploy on successful build'
9
- task :notify_and_deploy, :hipchat_api_key, :hipchat_room_id, :deploy_hook_url do |t, args|
10
- notify_build_status args[:hipchat_api_key], args[:hipchat_room_id]
11
- next unless build_passed?
12
-
13
- succeeded = false
14
- message = ""
15
-
16
- begin
17
- succeeded = deploy
18
- rescue Exception => e
19
- succeeded = false
20
- message = e.message
21
- end
22
-
23
- unless succeeded
24
- notify args[:hipchat_api_key], args[:hipchat_room_id], "Deploy failed: #{message}", 'red'
25
- raise "deployment failed"
26
- end
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(url)
44
- system "curl -X POST -d \"\" #{url}"
45
- end
46
-
47
- def notify_build_status(hipchat_api_key, hipchat_room_id)
48
- notify hipchat_api_key, hipchat_room_id, "Build succeeded", "green" and return if build_passed?
49
- notify hipchat_api_key, hipchat_room_id, "Build failed", "red"
50
- end
51
-
52
- def notify(hipchat_api_key, hipchat_room_id, message, colour)
53
- client = HipChat::Client.new(hipchat_api_key)
54
- client[hipchat_room_id].send('Solano', message, :color => colour)
55
- end
56
-
57
- end