Skip to content

Improve some things and stuff and bits #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Nov 27, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +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 'sentry-raven'
gem 'rollout', github: 'jamesgolick/rollout', :ref => 'v1.1.0'
gem 'metriks'
gem 'metriks-librato_metrics'
gem 'jemalloc'

gem 'gh', github: 'travis-ci/gh'
gem 'gh'
gem 'aws-sdk'
gem 'actionmailer', '~> 3.2.18'
gem 'roadie'
gem 'roadie-rails', '~> 1.0'
gem 'multi_json'
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
Expand Down
36 changes: 8 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -87,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)
Expand Down Expand Up @@ -127,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)
Expand Down Expand Up @@ -202,19 +184,17 @@ DEPENDENCIES
actionmailer (~> 3.2.18)
aws-sdk
foreman
gh!
gh
guard
guard-rspec
jemalloc
metriks
metriks-librato_metrics
mocha (~> 0.10.0)
multi_json
pusher (~> 0.14.5)
redis-namespace
roadie
roadie-rails (~> 1.0)
rollout!
rspec (~> 2.14.0)
sentry-raven
sidekiq (~> 4.0.0)
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -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 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
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand All @@ -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).



1 change: 0 additions & 1 deletion lib/travis/addons.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 1 addition & 3 deletions lib/travis/addons/README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion lib/travis/addons/email/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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})")
Expand Down
15 changes: 8 additions & 7 deletions lib/travis/addons/github_status/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,20 @@ 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")
nil
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
Expand Down Expand Up @@ -95,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
Expand Down
8 changes: 0 additions & 8 deletions lib/travis/addons/pusher.rb

This file was deleted.

100 changes: 0 additions & 100 deletions lib/travis/addons/pusher/task.rb

This file was deleted.

13 changes: 0 additions & 13 deletions lib/travis/tasks/config.rb
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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] }

Expand Down
7 changes: 5 additions & 2 deletions lib/travis/tasks/middleware/logging.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'active_support/core_ext/string/inflections'

module Travis
module Tasks
module Middleware
Expand All @@ -7,9 +9,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
data['notifier'] = notifier.to_s.underscore.split('/')[2]
if payload['build']
data['build'] = payload['build']['id']
elsif message['build_id']
Expand Down
12 changes: 11 additions & 1 deletion spec/addons/github_status/task_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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))
Expand Down
Loading