bugsnag-capistrano 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NDg1ZGZiMDhkYTNiOWZiYmZiMWZmOGRiZDU1NzNkMjc1YTIzNThkYg==
5
- data.tar.gz: !binary |-
6
- ZGFkNTMxYTEwYjBiYmUxNDhkMTc2Y2YyNGIwYWI0NWFmNzhmYWI2Zg==
2
+ SHA1:
3
+ metadata.gz: 79c3760c59cce6a32240955ba0ffb0604c789135
4
+ data.tar.gz: 69b90256827c6e24a07f7a1e9491337a0c5e9cee
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MDk4NWQzMDE3NTRlZWUyNzcxNTdmZWY2YThiZWU0MjYzODVhM2Y5NGQ4YmVk
10
- ZWIzNWU1YjY0ZGM0MTgwMTgwMTA2ZTBhMWNmZDc2YmU2ZmRjNzBlZDk5N2Fh
11
- M2RlODI4YzY2YmY5YWIyOTg1NjE3MTZiZjU4OTlmNzVkNGQ4MmY=
12
- data.tar.gz: !binary |-
13
- Y2Q1NmYxZTNlM2Q3MzFiZWQwYmFmNWNjMzE3YTM0NjczOTk0MDFiOGQ0ZTdm
14
- NTZiMjI2NjkwYzJhOTdiMTAyZTE1MTkwMWIxMWQxYzRjMDVhYmU2MzAwOWQ4
15
- NTI5YzVlOTc2ZmVlOGRhM2Y2NmI2YTRkYzhmZGQwM2QwNzFiZGE=
6
+ metadata.gz: f7c991ec8c557f2d2e6ce823b2b9b24ec21daf4bf532a568b389f4824f81f64144402c09e49d854807314409d9777430ca5540c86aab5fcdeeb44bf280b568c0
7
+ data.tar.gz: 35c9f306c9abae72d6a3eb2c89102163b8f801c98e3f7d040a92dce882bab119cf1efa826891600d816c793bfbb440c049a2c5031464c321cfdb8538b0d93045
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 1.1.0 (23-11-2017)
2
+
3
+ ### Enhancements
4
+
5
+ * Add Heroku deployment hooks task
6
+ | [#5](https://github.com/bugsnag/bugsnag-capistrano/pull/5)
7
+
1
8
  ## 1.0.1 (09-11-2017)
2
9
 
3
10
  ### Bug fixes
data/README.md CHANGED
@@ -6,11 +6,19 @@ application with [Capistrano](https://github.com/capistrano/capistrano),
6
6
  allowing to correlate deploys with new errors and increased error rates in
7
7
  Bugsnag.
8
8
 
9
+ It also includes a Rake task for manually sending deploy notifications or
10
+ for projects not using Capistrano.
11
+
9
12
  [Bugsnag](http://bugsnag.com) captures errors in real-time from your web,
10
13
  mobile and desktop applications, helping you to understand and resolve them
11
14
  as fast as possible. [Create a free account](http://bugsnag.com) to start
12
15
  capturing exceptions from your applications.
13
16
 
17
+ ## Getting started
18
+
19
+ * [Integrating with Capistrano](https://docs.bugsnag.com/api/deploy-tracking/capistrano/)
20
+ * [Integrating with Rake](https://docs.bugsnag.com/api/deploy-tracking/rake/)
21
+
14
22
  ## Contributing
15
23
 
16
24
  All contributors are welcome! For information on how to build, test,
@@ -20,6 +28,6 @@ and release `bugsnag-capistrano`, see our
20
28
 
21
29
  ## License
22
30
 
23
- The Bugsnag Cocoa library is free software released under the MIT License.
31
+ The Bugsnag Capistrano library is free software released under the MIT License.
24
32
  See [LICENSE.txt](https://github.com/bugsnag/bugsnag-capistrano/blob/master/LICENSE.txt)
25
33
  for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.1.0
@@ -1,5 +1,6 @@
1
1
  require "json"
2
2
  require "net/http"
3
+ require "logger"
3
4
 
4
5
  module Bugsnag
5
6
  module Capistrano
@@ -1,4 +1,4 @@
1
- require "bugsnag"
1
+ require "bugsnag-capistrano/deploy"
2
2
 
3
3
  namespace :bugsnag do
4
4
 
@@ -10,6 +10,7 @@ namespace :bugsnag do
10
10
  revision = ENV["BUGSNAG_REVISION"]
11
11
  repository = ENV["BUGSNAG_REPOSITORY"]
12
12
  branch = ENV["BUGSNAG_BRANCH"]
13
+ endpoint = ENV["BUGSNAG_ENDPOINT"]
13
14
 
14
15
  Rake::Task["load"].invoke unless api_key
15
16
 
@@ -19,10 +20,61 @@ namespace :bugsnag do
19
20
  :app_version => app_version,
20
21
  :revision => revision,
21
22
  :repository => repository,
22
- :branch => branch
23
+ :branch => branch,
24
+ :endpoint => endpoint,
23
25
  })
24
26
  end
25
27
 
28
+ namespace :heroku do
29
+ desc "Add a heroku deploy hook to notify Bugsnag of deploys"
30
+ task :add_deploy_hook => :load do
31
+ # Wrapper to run command safely even in bundler
32
+ run_command = lambda { |command|
33
+ defined?(Bundler.with_clean_env) ? Bundler.with_clean_env { `#{command}` } : `#{command}`
34
+ }
35
+
36
+ # Fetch heroku config settings
37
+ config_command = "heroku config --shell"
38
+ config_command += " --app #{ENV["HEROKU_APP"]}" if ENV["HEROKU_APP"]
39
+ heroku_env = run_command.call(config_command).split(/[\n\r]/).each_with_object({}) do |c, obj|
40
+ k,v = c.split("=")
41
+ obj[k] = (v.nil? || v.strip.empty?) ? nil : v
42
+ end
43
+
44
+ # Check for Bugsnag API key (required) using Bugsnag configuration only if available
45
+ begin
46
+ require 'bugsnag'
47
+ api_key = heroku_env["BUGSNAG_API_KEY"] || Bugsnag.configuration.api_key || ENV["BUGSNAG_API_KEY"]
48
+ rescue LoadError
49
+ api_key = heroku_env["BUGSNAG_API_KEY"] || ENV["BUGSNAG_API_KEY"]
50
+ end
51
+
52
+ unless api_key
53
+ puts "Error: No API key found, have you run 'heroku config:set BUGSNAG_API_KEY=your-api-key'?"
54
+ next
55
+ end
56
+
57
+ # Build the request, making use of deploy hook variables
58
+ # (https://devcenter.heroku.com/articles/deploy-hooks#customizing-messages)
59
+ params = {
60
+ :apiKey => api_key,
61
+ :branch => "master",
62
+ :revision => "{{head_long}}",
63
+ :releaseStage => heroku_env["RAILS_ENV"] || ENV["RAILS_ENV"] || "production"
64
+ }
65
+ repo = `git config --get remote.origin.url`.strip
66
+ params[:repository] = repo unless repo.empty?
67
+
68
+ # Add the hook
69
+ url = "https://notify.bugsnag.com/deploy?" + params.map {|k,v| "#{k}=#{v}"}.join("&")
70
+ command = "heroku addons:add deployhooks:http --url=\"#{url}\""
71
+ command += " --app #{ENV["HEROKU_APP"]}" if ENV["HEROKU_APP"]
72
+
73
+ puts "$ #{command}"
74
+ run_command.call(command)
75
+ end
76
+ end
77
+
26
78
  end
27
79
 
28
80
  task :load do
data/spec/rake_spec.rb ADDED
@@ -0,0 +1,64 @@
1
+ require 'webmock/rspec'
2
+ require 'rspec/expectations'
3
+ require 'rspec/mocks'
4
+
5
+ require 'webrick'
6
+
7
+ describe "bugsnag rake", :always do
8
+
9
+ server = nil
10
+ queue = Queue.new
11
+ fixture_path = '../examples/rake'
12
+ exec_string = 'bundle exec rake bugsnag:deploy'
13
+ example_path = File.join(File.dirname(__FILE__), fixture_path)
14
+
15
+ before do
16
+ server = WEBrick::HTTPServer.new :Port => 0, :Logger => WEBrick::Log.new(STDOUT), :AccessLog => []
17
+ server.mount_proc '/deploy' do |req, res|
18
+ queue.push req.body
19
+ res.status = 200
20
+ res.body = "OK\n"
21
+ end
22
+ Thread.new{ server.start }
23
+ end
24
+
25
+ after do
26
+ server.stop
27
+ queue.clear
28
+ end
29
+
30
+ let(:request) { JSON.parse(queue.pop) }
31
+
32
+ it "sends a deploy notification to the set endpoint" do
33
+ ENV['BUGSNAG_ENDPOINT'] = "http://localhost:" + server.config[:Port].to_s + "/deploy"
34
+ ENV['BUGSNAG_API_KEY'] = "YOUR_API_KEY"
35
+
36
+ Dir.chdir(example_path) do
37
+ system(exec_string)
38
+ end
39
+
40
+ payload = request()
41
+ expect(payload["apiKey"]).to eq('YOUR_API_KEY')
42
+ end
43
+
44
+ it "allows modifications of deployment characteristics" do
45
+ ENV['BUGSNAG_ENDPOINT'] = "http://localhost:" + server.config[:Port].to_s + "/deploy"
46
+ ENV['BUGSNAG_API_KEY'] = "this is a test key"
47
+ ENV['BUGSNAG_RELEASE_STAGE'] = "test"
48
+ ENV['BUGSNAG_REVISION'] = "test"
49
+ ENV['BUGSNAG_APP_VERSION'] = "1"
50
+ ENV['BUGSNAG_REPOSITORY'] = "test@repo.com:test/test_repo.git"
51
+
52
+ Dir.chdir(example_path) do
53
+ system(exec_string)
54
+ end
55
+
56
+ payload = request()
57
+ expect(payload["apiKey"]).to eq('this is a test key')
58
+ expect(payload["releaseStage"]).to eq('test')
59
+ expect(payload["repository"]).to eq("test@repo.com:test/test_repo.git")
60
+ expect(payload["appVersion"]).to eq("1")
61
+ expect(payload["revision"]).to eq("test")
62
+ end
63
+ end
64
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bugsnag-capistrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keegan Lowenstein
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2017-11-10 00:00:00.000000000 Z
14
+ date: 2017-11-23 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: Correlate Capistrano deploys with new errors and increased error rates
17
17
  in Bugsnag
@@ -23,8 +23,8 @@ extra_rdoc_files:
23
23
  - README.md
24
24
  - CHANGELOG.md
25
25
  files:
26
- - .gitignore
27
- - .travis.yml
26
+ - ".gitignore"
27
+ - ".travis.yml"
28
28
  - CHANGELOG.md
29
29
  - CONTRIBUTING.md
30
30
  - Gemfile
@@ -42,6 +42,7 @@ files:
42
42
  - lib/bugsnag-capistrano/tasks/bugsnag.cap
43
43
  - spec/capistrano_spec.rb
44
44
  - spec/deploy_spec.rb
45
+ - spec/rake_spec.rb
45
46
  homepage: http://github.com/bugsnag/bugsnag-capistrano
46
47
  licenses:
47
48
  - MIT
@@ -52,17 +53,17 @@ require_paths:
52
53
  - lib
53
54
  required_ruby_version: !ruby/object:Gem::Requirement
54
55
  requirements:
55
- - - ! '>='
56
+ - - ">="
56
57
  - !ruby/object:Gem::Version
57
58
  version: 1.9.2
58
59
  required_rubygems_version: !ruby/object:Gem::Requirement
59
60
  requirements:
60
- - - ! '>='
61
+ - - ">="
61
62
  - !ruby/object:Gem::Version
62
63
  version: '0'
63
64
  requirements: []
64
65
  rubyforge_project:
65
- rubygems_version: 2.6.12
66
+ rubygems_version: 2.6.13
66
67
  signing_key:
67
68
  specification_version: 4
68
69
  summary: Notify Bugsnag when deploying with Capistrano