From da4835bba475aa491c2465bd9ef70b1a63529552 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Wed, 25 Nov 2015 15:06:59 +0100 Subject: [PATCH 01/11] update gh gem to the gem version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit also remove new_relic, hasn’t been used in years. --- Gemfile | 21 ++++++++++----------- Gemfile.lock | 41 +++++++++++++---------------------------- 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/Gemfile b/Gemfile index 12a33db7..4cd666a8 100644 --- a/Gemfile +++ b/Gemfile @@ -3,27 +3,26 @@ source 'https://rubygems.org' ruby '2.1.6' gem 'travis-support', github: 'travis-ci/travis-support' -gem 'travis-config', '~> 1.0.0' +gem 'travis-config', '~> 1.0.0' gem 'sidekiq', '~> 4.0.0' gem 'redis-namespace' -gem 'gh', github: 'travis-ci/gh' +gem 'gh' gem 'sentry-raven' -gem 'rollout', github: 'jamesgolick/rollout', :ref => 'v1.1.0' -gem 'newrelic_rpm', '~> 3.3.2' +gem 'metriks' +gem 'metriks-librato_metrics' +gem 'jemalloc' + gem 'aws-sdk' gem 'actionmailer', '~> 3.2.18' gem 'roadie' -gem 'metriks' -gem 'metriks-librato_metrics' gem 'multi_json' -gem 'pusher', '~> 0.14.5' -gem 'jemalloc' +gem 'pusher', '~> 0.14.5' group :test do - gem 'rspec', '~> 2.14.0' - gem 'mocha', '~> 0.10.0' - gem 'webmock', '~> 1.8.0' + gem 'rspec', '~> 2.14.0' + gem 'mocha', '~> 0.10.0' + gem 'webmock', '~> 1.8.0' gem 'guard' gem 'guard-rspec' end diff --git a/Gemfile.lock b/Gemfile.lock index f9b2806f..755a52c6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,22 +1,3 @@ -GIT - remote: git://github.com/jamesgolick/rollout.git - revision: 3e7312cc018061b1ac6a8aeb9f11bbd0331da889 - ref: v1.1.0 - specs: - rollout (1.1.0) - -GIT - remote: git://github.com/travis-ci/gh.git - revision: 27e30fd01f6d5144d8d7d0c88db7875b95ed8939 - specs: - gh (0.14.0) - addressable - backports - faraday (~> 0.8) - multi_json (~> 1.0) - net-http-persistent (>= 2.7) - net-http-pipeline - GIT remote: git://github.com/travis-ci/travis-support.git revision: 2cd02d2a06fdd1e2fc2f129148c168b56f7c190f @@ -49,12 +30,12 @@ GEM atomic (1.1.99) avl_tree (1.2.1) atomic (~> 1.1) - aws-sdk (2.2.1) - aws-sdk-resources (= 2.2.1) - aws-sdk-core (2.2.1) + aws-sdk (2.2.3) + aws-sdk-resources (= 2.2.3) + aws-sdk-core (2.2.3) jmespath (~> 1.0) - aws-sdk-resources (2.2.1) - aws-sdk-core (= 2.2.1) + aws-sdk-resources (2.2.3) + aws-sdk-core (= 2.2.3) backports (3.6.7) builder (3.0.4) coderay (1.1.0) @@ -72,6 +53,13 @@ GEM foreman (0.78.0) thor (~> 0.19.1) formatador (0.2.5) + gh (0.14.0) + addressable + backports + faraday (~> 0.8) + multi_json (~> 1.0) + net-http-persistent (>= 2.7) + net-http-pipeline guard (2.13.0) formatador (>= 0.2.4) listen (>= 2.7, <= 4.0) @@ -117,7 +105,6 @@ GEM nenv (0.2.0) net-http-persistent (2.9.4) net-http-pipeline (1.0.1) - newrelic_rpm (3.3.5) nokogiri (1.6.6.4) mini_portile (~> 0.6.0) notiffany (0.0.8) @@ -188,7 +175,7 @@ DEPENDENCIES actionmailer (~> 3.2.18) aws-sdk foreman - gh! + gh guard guard-rspec jemalloc @@ -196,11 +183,9 @@ DEPENDENCIES metriks-librato_metrics mocha (~> 0.10.0) multi_json - newrelic_rpm (~> 3.3.2) pusher (~> 0.14.5) redis-namespace roadie - rollout! rspec (~> 2.14.0) sentry-raven sidekiq (~> 4.0.0) From 93a2f4bc605fb26a8b13df64083cbe8bfe509a0c Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Wed, 25 Nov 2015 15:10:56 +0100 Subject: [PATCH 02/11] improve with how we deal with errors from GitHub if we get a 401 error (token auth error), log a line and move on. if we get a 403 error (rate limit exceeded), only raise an error if in production. if we get a 404 error (repo not found), log a line and move on as this is most likely an auth error. --- lib/travis/addons/github_status/task.rb | 13 +++++++------ spec/addons/github_status/task_spec.rb | 12 +++++++++++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/travis/addons/github_status/task.rb b/lib/travis/addons/github_status/task.rb index ce641cc2..15f7aacf 100644 --- a/lib/travis/addons/github_status/task.rb +++ b/lib/travis/addons/github_status/task.rb @@ -49,6 +49,12 @@ def process_with_token(token) GH.post(url, :state => state, :description => description, :target_url => target_url, :context => context) end rescue GH::Error(:response_status => 401) + error("type=github_status build=#{build[:id]} repo=#{repository[:slug]} state=#{state} commit=#{sha} response_status=401 reason=incorrect_auth") + nil + rescue GH::Error(:response_status => 403) + raise if Travis.config.env == 'production' + rescue GH::Error(:response_status => 404) + error("type=github_status build=#{build[:id]} repo=#{repository[:slug]} state=#{state} commit=#{sha} response_status=404 reason=repo_not_found_or_incorrect_auth") nil rescue GH::Error(:response_status => 422) error("type=github_status build=#{build[:id]} repo=#{repository[:slug]} state=#{state} commit=#{sha} response_status=422 reason=maximum_number_of_statuses") @@ -56,12 +62,7 @@ def process_with_token(token) rescue GH::Error => e message = "type=github_status build=#{build[:id]} repo=#{repository[:slug]} error=not_updated commit=#{sha} url=#{GH.api_host + url} message=#{e.message}" error(message) - response_status = e.info[:response_status] - case response_status - when 401, 422, 404 - else - raise message - end + raise message end def target_url diff --git a/spec/addons/github_status/task_spec.rb b/spec/addons/github_status/task_spec.rb index 81a805fb..ef17bff6 100644 --- a/spec/addons/github_status/task_spec.rb +++ b/spec/addons/github_status/task_spec.rb @@ -63,7 +63,7 @@ def run subject.new(payload, token: '12345').run end - it 'does not raise if a 422 error was raised by GH' do + it 'does not raise if a 422 error was returned by GH' do error = { response_status: 422 } GH.stubs(:post).raises(GH::Error.new('failed', nil, error)) expect { @@ -73,6 +73,16 @@ def run io.string.should include('reason=maximum_number_of_statuses') end + it 'does not raise if a 404 error was returned by GH' do + error = { response_status: 404 } + GH.stubs(:post).raises(GH::Error.new('failed', nil, error)) + expect { + run + }.not_to raise_error + io.string.should include('response_status=404') + io.string.should include('reason=repo_not_found_or_incorrect_auth') + end + describe 'logging' do it 'warns about a failed request' do GH.stubs(:post).raises(GH::Error.new(nil)) From 0e3a8930db7669d44216954f92bcba9089d7eb44 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Wed, 25 Nov 2015 15:13:00 +0100 Subject: [PATCH 03/11] remove pusher notifier from tasks we have travis-live for that now --- Procfile | 2 +- README.md | 5 +- lib/travis/addons.rb | 1 - lib/travis/addons/README.markdown | 4 +- lib/travis/addons/pusher.rb | 8 -- lib/travis/addons/pusher/task.rb | 100 ------------------ lib/travis/tasks/config.rb | 13 --- spec/addons/pusher/task_spec.rb | 163 ------------------------------ 8 files changed, 3 insertions(+), 293 deletions(-) delete mode 100644 lib/travis/addons/pusher.rb delete mode 100644 lib/travis/addons/pusher/task.rb delete mode 100644 spec/addons/pusher/task_spec.rb diff --git a/Procfile b/Procfile index b1f6b532..80a56765 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -tasks: bundle exec je sidekiq -c 25 -r ./lib/travis/tasks.rb -q campfire -q email -q flowdock -q github_commit_status -q github_status -q hipchat -q irc -q pusher -q sqwiggle -q webhook -q slack -q pushover +tasks: bundle exec je sidekiq -c 25 -r ./lib/travis/tasks.rb -q campfire -q email -q flowdock -q github_commit_status -q github_status -q hipchat -q irc -q sqwiggle -q webhook -q slack -q pushover diff --git a/README.md b/README.md index 7721d514..3b255dc9 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Travis Task is a [Sidekiq](http://sidekiq.org/) based background processor whose These notifications are all queued up by state changes which are processed by [Travis Hub](https://github.com/travis-ci/travis-hub) and [Travis Gatekeeper](https://github.com/travis-ci/travis-gatekeeper). -And, to make Travis Tasks even more special, there is no database connection required! Travis Tasks is all about talking to 3rd party services, if it be [Pusher](http://pusher.com), [Mandrill](https://mandrillapp.com), [Campfire](http://campfirenow.com/), [Slack](http://slack.com/), or [Pushover](https://pushover.net/). +And, to make Travis Tasks even more special, there is no database connection required! Travis Tasks is all about talking to 3rd party services, if it be, [Mandrill](https://mandrillapp.com), [Campfire](http://campfirenow.com/), [Slack](http://slack.com/), or [Pushover](https://pushover.net/). You can find the full list of addon services Travis natively talks to within [Travis Core](https://github.com/travis-ci/travis-core/tree/master/lib/travis/addons). @@ -20,6 +20,3 @@ Please file any issues on the [central Travis CI issue tracker](https://github.c See LICENSE file. Copyright (c) 2011 [Travis CI development team](https://github.com/travis-ci). - - - diff --git a/lib/travis/addons.rb b/lib/travis/addons.rb index 2760e38b..2cfe5116 100644 --- a/lib/travis/addons.rb +++ b/lib/travis/addons.rb @@ -6,7 +6,6 @@ module Addons require 'travis/addons/github_status' require 'travis/addons/hipchat' require 'travis/addons/irc' - require 'travis/addons/pusher' require 'travis/addons/sqwiggle' require 'travis/addons/util' require 'travis/addons/webhook' diff --git a/lib/travis/addons/README.markdown b/lib/travis/addons/README.markdown index 936031d5..b58d3b18 100644 --- a/lib/travis/addons/README.markdown +++ b/lib/travis/addons/README.markdown @@ -8,10 +8,8 @@ The Addons are event handlers that accepts events such as "build finished" and f - GitHub Commit Statuses - Hipchat - IRC -- Pusher: Used to update our Web UI automatically. - Sqwiggle -- States cache: Caches the state of each branch in Memcached for status images. - Webhook - Pushover -To add a new notification service, an event handler and a task is needed. The event handler is run by [`travis-hub`](https://github.com/travis-ci/travis-hub) and has access to the database. This should check whether the event should be forwarded at all, and pull out any necessary configuration values. It should then asynchronously run the corresponding Task. The Task is run by [`travis-tasks`](https://github.com/travis-ci/travis-tasks) via Sidekiq and should do the actual API calls needed. The event handler should finish very quickly, while the task is allowed to take longer. +To add a new notification service, an event handler and a task is needed. The event handler is run by [`travis-hub`](https://github.com/travis-ci/travis-hub) and has access to the database. This should check whether the event should be forwarded at all, and pull out any necessary configuration values. It should then asynchronously run the corresponding Task. The Task is run by [`travis-tasks`](https://github.com/travis-ci/travis-tasks) via Sidekiq and should do the actual API calls needed. The event handler should finish very quickly, while the task is allowed to take longer. diff --git a/lib/travis/addons/pusher.rb b/lib/travis/addons/pusher.rb deleted file mode 100644 index 68b586cf..00000000 --- a/lib/travis/addons/pusher.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Travis - module Addons - module Pusher - require 'travis/addons/pusher/task' - end - end -end - diff --git a/lib/travis/addons/pusher/task.rb b/lib/travis/addons/pusher/task.rb deleted file mode 100644 index 5ba996cd..00000000 --- a/lib/travis/addons/pusher/task.rb +++ /dev/null @@ -1,100 +0,0 @@ -require 'travis/support/instrumentation' -require 'travis/support/chunkifier' - -module Travis - module Addons - module Pusher - - # Notifies registered clients about various state changes through Pusher. - class Task < Travis::Task - - def self.chunk_size - 9 * 1024 + 100 - end - - def event - params[:event] - end - - def client_event - @client_event ||= (event =~ /job:.*/ ? event.gsub(/(test|configure):/, '') : event) - end - - def channels - channels = private_channels? ? ["repo-#{repo_id}"] : ['common'] - channels.map { |channel| [channel_prefix, channels].compact.join('-') } - end - - private - - def process - channels.each { |channel| trigger(channel, payload) } - end - - def trigger(channel, payload) - parts(payload).each do |part| - begin - Travis.pusher[channel].trigger(client_event, part) - rescue ::Pusher::Error => e - Travis.logger.error("[addons:pusher] Could not send event due to Pusher::Error: #{e.message}, event=#{client_event}, payload: #{part.inspect}") - raise - end - end - end - - def job_id - payload[:id] - end - - def repo_id - # TODO api v1 is inconsistent here - payload.key?(:repository) ? payload[:repository][:id] : payload[:repository_id] - end - - def channel_prefix - 'private' if private_channels? - end - - def private_channels? - force_private_channels? || repository_private? - end - - def force_private_channels? - Travis.config.pusher.secure? - end - - def repository_private? - payload.key?(:repository) ? payload[:repository][:private] : payload[:repository_private] - end - - def parts(payload) - if client_event == 'job:log' && payload[:_log].present? - # split payload into 9kB chunks, the limit is 10 for entire request - # body, 1kB should be enough for headers - log = payload[:_log] - chunkifier = Chunkifier.new(log, chunk_size, :json => true) - - if chunkifier.length > 1 - # This should never happen when we update travis-worker to split log parts - # bigger than 9kB. - Travis.logger.warn("[addons:pusher] The log part from worker was bigger than 9kB (#{log.to_json.length}B), payload: #{payload.inspect}") - end - - chunkifier.each_with_index.map do |part, i| - new_payload = payload.dup.merge(:_log => part) - new_payload[:number] = "#{new_payload[:number]}.#{i}" unless i == 0 - new_payload[:final] = new_payload[:final] && chunkifier.length - 1 == i - new_payload - end - else - [payload] - end - end - - def chunk_size - self.class.chunk_size - end - end - end - end -end diff --git a/lib/travis/tasks/config.rb b/lib/travis/tasks/config.rb index 434d644e..a7c96024 100644 --- a/lib/travis/tasks/config.rb +++ b/lib/travis/tasks/config.rb @@ -1,22 +1,10 @@ require 'travis/config' -require 'pusher' module Travis def self.config @config ||= Tasks::Config.load end - def self.pusher - @pusher ||= ::Pusher.tap do |pusher| - pusher.scheme = config.pusher.scheme if config.pusher.scheme.present? - pusher.host = config.pusher.host if config.pusher.host.present? - pusher.port = config.pusher.port if config.pusher.port.present? - pusher.app_id = config.pusher.app_id - pusher.key = config.pusher.key - pusher.secret = config.pusher.secret - end - end - module Tasks class Config < Travis::Config HOSTS = { @@ -33,7 +21,6 @@ class Config < Travis::Config sidekiq: { namespace: "sidekiq", pool_size: 3 }, smtp: { }, ssl: { }, - pusher: { }, email: { }, assets: { host: HOSTS[Travis.env.to_sym] } diff --git a/spec/addons/pusher/task_spec.rb b/spec/addons/pusher/task_spec.rb deleted file mode 100644 index 5f68a004..00000000 --- a/spec/addons/pusher/task_spec.rb +++ /dev/null @@ -1,163 +0,0 @@ -# encoding: utf-8 -require 'spec_helper' - -module Support - module Mocks - module Pusher - class Channel - attr_accessor :messages - - def initialize - @messages = [] - end - - def trigger(*args) - messages << args - end - alias :trigger_async :trigger - - def reset! - @messages = [] - end - alias :clear! :reset! - end - end - end -end - -describe Travis::Addons::Pusher::Task do - include Travis::Testing::Stubs - - let(:subject) { Travis::Addons::Pusher::Task } - let(:channel) { Support::Mocks::Pusher::Channel.new } - let(:task_payload) {Marshal.load(Marshal.dump(TASK_PAYLOAD))} - - before do - Travis.config.notifications = [:pusher] - Travis.pusher.stubs(:[]).returns(channel) - end - - def run(event, object, options = {}) - type = event.sub('test:', '').sub(':', '/') - payload = options[:params] ? task_payload.merge(options[:params]) : task_payload - subject.new(payload, event: event).run - end - - it 'logs Pusher errors and reraises' do - channel.expects(:trigger).raises(Pusher::Error.new('message')) - payload = task_payload.deep_symbolize_keys - Travis.logger.expects(:error).with("[addons:pusher] Could not send event due to Pusher::Error: message, event=job:started, payload: #{payload.inspect}") - - expect { - run('job:test:started', test) - }.to raise_error(Pusher::Error) - end - - describe 'run' do - it 'job:test:finished' do - run('job:test:finished', test) - channel.should have_message('job:finished', test) - end - - it 'build:finished' do - run('build:finished', build) - channel.should have_message('build:finished', build) - end - end - - describe 'channels' do - describe 'for a private repo' do - describe 'build event' do - let(:data) { { 'build' => { 'id' => 1, 'repository_id' => 1, }, 'repository' => { 'id' => 1 } } } - - before :each do - data['repository']['private'] = true - end - - it 'includes "private-repo-1" for the event "build:finished"' do - task = subject.new(data, :event => 'build:finished') - task.channels.should include("private-repo-#{repository.id}") - end - end - - describe 'job event' do - let(:data) { { 'id' => 1, 'build_id' => 1, 'repository_id' => 1 } } - - before :each do - data['repository_private'] = true - end - - it 'includes "private-repo-1" for the event "job:finished"' do - task = subject.new(data, :event => 'job:test:finished') - task.channels.should include("private-repo-#{repository.id}") - end - end - end - - describe 'for a public repo' do - describe 'with config.pusher.secure being false' do - before do - Travis.config.pusher.secure = false - end - - describe 'build event' do - let(:data) { { 'build' => { 'id' => 1, 'repository_id' => 1, }, 'repository' => { 'id' => 1 } } } - - before :each do - data['repository']['private'] = false - end - - it 'includes "repo-1" for the event "build:finished"' do - task = subject.new(data, :event => 'build:finished') - task.channels.should include('common') - end - end - - describe 'job event' do - let(:data) { { 'id' => 1, 'build_id' => 1, 'repository_id' => 1 } } - - before :each do - data['repository_private'] = false - end - - it 'includes "repo-1" for the event "job:finished"' do - task = subject.new(data, :event => 'job:test:finished') - task.channels.should include('common') - end - end - end - - describe 'with config.pusher.secure being true' do - before do - Travis.config.pusher.secure = true - end - - describe 'build event' do - let(:data) { { 'build' => { 'id' => 1, 'repository_id' => 1, }, 'repository' => { 'id' => 1 } } } - - before :each do - data['repository']['private'] = false - end - - it 'includes "private-repo-1" for the event "build:finished"' do - task = subject.new(data, :event => 'build:finished') - task.channels.should include("private-repo-#{repository.id}") - end - end - - describe 'build event' do - let(:data) { { 'id' => 1, 'build_id' => 1, 'repository_id' => 1 } } - - before :each do - data['repository_private'] = false - end - - it 'includes "private-repo-1" for the event "job:finished"' do - task = subject.new(data, :event => 'job:test:finished') - task.channels.should include("private-repo-#{repository.id}") - end - end - end - end - end -end From 646fa3e9a42044605ad6e5f8dd2b6c0458394573 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Wed, 25 Nov 2015 15:16:01 +0100 Subject: [PATCH 04/11] she-hulk-preview is old, switching to the stable v3 --- lib/travis/addons/github_status/task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/addons/github_status/task.rb b/lib/travis/addons/github_status/task.rb index 15f7aacf..51cc7404 100644 --- a/lib/travis/addons/github_status/task.rb +++ b/lib/travis/addons/github_status/task.rb @@ -96,7 +96,7 @@ def http_options(token) def headers { - "Accept" => "application/vnd.github.she-hulk-preview+json" + "Accept" => "application/vnd.github.v3+json" } end end From 1dbbb19668e83e80f79df4a18fecd10f6f087ded Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Wed, 25 Nov 2015 15:35:35 +0100 Subject: [PATCH 05/11] remove the pusher gem as it is no longer used --- Gemfile | 1 - Gemfile.lock | 7 ------- 2 files changed, 8 deletions(-) diff --git a/Gemfile b/Gemfile index 4cd666a8..6ac37dad 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,6 @@ gem 'aws-sdk' gem 'actionmailer', '~> 3.2.18' gem 'roadie' gem 'multi_json' -gem 'pusher', '~> 0.14.5' group :test do gem 'rspec', '~> 2.14.0' diff --git a/Gemfile.lock b/Gemfile.lock index 755a52c6..ef3edaa2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,7 +75,6 @@ GEM hashr (2.0.0) hike (1.2.3) hitimes (1.2.3) - httpclient (2.7.0.1) i18n (0.7.0) jemalloc (1.0.1) jmespath (1.1.3) @@ -115,11 +114,6 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - pusher (0.14.6) - httpclient (~> 2.5) - multi_json (~> 1.0) - pusher-signature (~> 0.1.8) - pusher-signature (0.1.8) rack (1.4.7) rack-cache (1.5.1) rack (>= 0.4) @@ -183,7 +177,6 @@ DEPENDENCIES metriks-librato_metrics mocha (~> 0.10.0) multi_json - pusher (~> 0.14.5) redis-namespace roadie rspec (~> 2.14.0) From b10b8e726ec6b059eaab04ad65611bcf06eaf34a Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 27 Nov 2015 14:22:30 +0100 Subject: [PATCH 06/11] take care of the notifications queue as well --- Procfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Procfile b/Procfile index 80a56765..0c5e0d13 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -tasks: bundle exec je sidekiq -c 25 -r ./lib/travis/tasks.rb -q campfire -q email -q flowdock -q github_commit_status -q github_status -q hipchat -q irc -q sqwiggle -q webhook -q slack -q pushover +tasks: bundle exec je sidekiq -c 25 -r ./lib/travis/tasks.rb -q notifications -q campfire -q email -q flowdock -q github_commit_status -q github_status -q hipchat -q irc -q sqwiggle -q webhook -q slack -q pushover From c0f80ccb6f7abced46ea2f95d7d5262877f40c68 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 27 Nov 2015 14:44:06 +0100 Subject: [PATCH 07/11] add the type to the email log line --- lib/travis/addons/email/task.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/addons/email/task.rb b/lib/travis/addons/email/task.rb index 4dc0d075..6b0aa4ca 100644 --- a/lib/travis/addons/email/task.rb +++ b/lib/travis/addons/email/task.rb @@ -23,7 +23,7 @@ def type def process if recipients.any? Mailer::Build.finished_email(payload, recipients, broadcasts).deliver - info "status=sent msg='email sent' #{recipients.map { |r| 'email=' + obfuscate_email_address(r) }.join(' ')}" + info "type=email status=sent msg='email sent' #{recipients.map { |r| 'email=' + obfuscate_email_address(r) }.join(' ')}" end rescue Net::SMTPServerBusy => e error("Could not send email to: #{recipients} (error: #{e.message})") From e329b5f1e6dd24202dc6f7ddb294d865a255555c Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 27 Nov 2015 14:44:19 +0100 Subject: [PATCH 08/11] log the queue and notifier --- lib/travis/tasks/middleware/logging.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/travis/tasks/middleware/logging.rb b/lib/travis/tasks/middleware/logging.rb index c850d9d8..d7d1862c 100644 --- a/lib/travis/tasks/middleware/logging.rb +++ b/lib/travis/tasks/middleware/logging.rb @@ -7,9 +7,10 @@ def call(worker, message, queue, &block) yield end ensure - uuid, _, _, payload, params = *message['args'] + uuid, notifier, _, payload, params = *message['args'] data = Hash.new.tap do |data| - data['type'] = queue + data['queue'] = queue + date['notifier'] = notifier.to_s.split('::')[2] if payload['build'] data['build'] = payload['build']['id'] elsif message['build_id'] From 00abfae144b6688d5d9e765581e92af390ea4459 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 27 Nov 2015 14:54:15 +0100 Subject: [PATCH 09/11] some debugging time --- lib/travis/tasks/middleware/logging.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/travis/tasks/middleware/logging.rb b/lib/travis/tasks/middleware/logging.rb index d7d1862c..ebd577bc 100644 --- a/lib/travis/tasks/middleware/logging.rb +++ b/lib/travis/tasks/middleware/logging.rb @@ -10,7 +10,8 @@ def call(worker, message, queue, &block) uuid, notifier, _, payload, params = *message['args'] data = Hash.new.tap do |data| data['queue'] = queue - date['notifier'] = notifier.to_s.split('::')[2] + puts notifier + date['notifier'] = notifier.to_s.downcase.split('::')[2] if payload['build'] data['build'] = payload['build']['id'] elsif message['build_id'] From 64f78fd03c49daba706a50c315e4be9f2d6e7fa2 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 27 Nov 2015 14:55:09 +0100 Subject: [PATCH 10/11] data not date, oops --- lib/travis/tasks/middleware/logging.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/travis/tasks/middleware/logging.rb b/lib/travis/tasks/middleware/logging.rb index ebd577bc..e6c93691 100644 --- a/lib/travis/tasks/middleware/logging.rb +++ b/lib/travis/tasks/middleware/logging.rb @@ -10,8 +10,7 @@ def call(worker, message, queue, &block) uuid, notifier, _, payload, params = *message['args'] data = Hash.new.tap do |data| data['queue'] = queue - puts notifier - date['notifier'] = notifier.to_s.downcase.split('::')[2] + data['notifier'] = notifier.to_s.downcase.split('::')[2] if payload['build'] data['build'] = payload['build']['id'] elsif message['build_id'] From 06c4c22aeabfddb6c5457c16a35a210b15fe7e98 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 27 Nov 2015 15:12:40 +0100 Subject: [PATCH 11/11] tweak the notifier log line just a little --- lib/travis/tasks/middleware/logging.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/travis/tasks/middleware/logging.rb b/lib/travis/tasks/middleware/logging.rb index e6c93691..8616823e 100644 --- a/lib/travis/tasks/middleware/logging.rb +++ b/lib/travis/tasks/middleware/logging.rb @@ -1,3 +1,5 @@ +require 'active_support/core_ext/string/inflections' + module Travis module Tasks module Middleware @@ -10,7 +12,7 @@ def call(worker, message, queue, &block) uuid, notifier, _, payload, params = *message['args'] data = Hash.new.tap do |data| data['queue'] = queue - data['notifier'] = notifier.to_s.downcase.split('::')[2] + data['notifier'] = notifier.to_s.underscore.split('/')[2] if payload['build'] data['build'] = payload['build']['id'] elsif message['build_id']