From ee11e571b7547c4cb54607ec314d7287bfdf6980 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Tue, 22 Jan 2013 16:18:43 +0100 Subject: [PATCH 001/165] pass the api payload type for workers because we now do not return AR scopes any more --- lib/travis/api/app/endpoint/workers.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/travis/api/app/endpoint/workers.rb b/lib/travis/api/app/endpoint/workers.rb index bb84d038..bd648785 100644 --- a/lib/travis/api/app/endpoint/workers.rb +++ b/lib/travis/api/app/endpoint/workers.rb @@ -4,11 +4,11 @@ class Travis::Api::App class Endpoint class Workers < Endpoint get '/' do - respond_with service(:find_workers, params) + respond_with service(:find_workers, params), type: :workers end get '/:id' do - respond_with service(:find_worker, params) + respond_with service(:find_worker, params), type: :worker end end end From cc8b4b0ef4d3c34c1341ee09a4fa7fe97d04e3ab Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 23 Jan 2013 02:45:15 +0100 Subject: [PATCH 002/165] bump travis-core --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 7f2c8c6b..207b180a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/getsentry/raven-ruby.git - revision: a0f59d3974034b38891fb1d4a70ff45fa996e7c9 + revision: ac0e242733733ad07891031ddc5706e1247cb6f0 specs: sentry-raven (0.4.0) faraday (>= 0.7.6) @@ -66,7 +66,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: aecd4e464e4c18d0e77e1e44deac75e4f1054efe + revision: 259e48ffc68a67eff32848334025ef17ab58a3b3 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From 8c5529a50a145393ed50e4095039b5d51870d6e0 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 23 Jan 2013 21:05:36 +0100 Subject: [PATCH 003/165] Revert "go back to unicorn for now" Server is not the bottleneck and new relic does not work on unicorn. This reverts commit 4a88b2d8c66705e30bc406d667e98214f68e52a2. Conflicts: Gemfile.lock --- Gemfile | 2 +- Gemfile.lock | 12 ++++-------- config.ru | 10 +++++----- script/server | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index c0555e45..a66a06a7 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'sinatra-contrib', github: 'sinatra/sinatra-contrib', require: nil # TODO need to release the gem as soon i'm certain this change makes sense gem 'simple_states', github: 'svenfuchs/simple_states', branch: 'sf-set-state-early' -gem 'unicorn' +gem 'puma' gem "sentry-raven", github: 'getsentry/raven-ruby' gem 'yard-sinatra', github: 'rkh/yard-sinatra' gem 'rack-contrib', github: 'rack/rack-contrib' diff --git a/Gemfile.lock b/Gemfile.lock index 7f2c8c6b..6eca4641 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -154,7 +154,7 @@ GEM arel (3.0.2) atomic (1.0.1) avl_tree (1.1.3) - backports (2.7.1) + backports (2.7.0) builder (3.0.4) bunny (0.8.0) celluloid (0.12.4) @@ -188,7 +188,6 @@ GEM i18n (0.6.1) journey (1.0.4) json (1.7.6) - kgio (2.8.0) listen (0.7.2) mail (2.4.4) i18n (>= 0.4.0) @@ -221,6 +220,8 @@ GEM coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) + puma (1.6.3) + rack (~> 1.2) pusher (0.11.2) multi_json (~> 1.0) signature (~> 0.1.6) @@ -240,7 +241,6 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - raindrops (0.10.0) rake (0.9.2.2) rdoc (3.12) json (~> 1.4) @@ -283,10 +283,6 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.35) - unicorn (4.5.0) - kgio (~> 2.6) - rack - raindrops (~> 0.7) uuidtools (2.1.3) yajl-ruby (1.1.0) yard (0.8.3) @@ -305,6 +301,7 @@ DEPENDENCIES micro_migrations! mocha (~> 0.12) pry + puma rack-cache (~> 1.2) rack-contrib! rake (~> 0.9.2) @@ -318,5 +315,4 @@ DEPENDENCIES travis-core! travis-sidekiqs! travis-support! - unicorn yard-sinatra! diff --git a/config.ru b/config.ru index 7806e127..a570b9e2 100644 --- a/config.ru +++ b/config.ru @@ -7,10 +7,10 @@ $stdout.sync = true require 'travis/api/app' require 'core_ext/module/load_constants' -# models = Travis::Model.constants.map(&:to_s) -# only = [/^(ActiveRecord|ActiveModel|Travis|GH|#{models.join('|')})/] -# [Travis::Api, Travis, GH].each do |target| -# target.load_constants! :only => only, :skip => ['Travis::Memory', 'GH::ResponseWrapper'], :debug => false -# end +models = Travis::Model.constants.map(&:to_s) +only = [/^(ActiveRecord|ActiveModel|Travis|GH|#{models.join('|')})/] +[Travis::Api, Travis, GH].each do |target| + target.load_constants! :only => only, :skip => ['Travis::Memory', 'GH::ResponseWrapper'], :debug => false +end run Travis::Api::App.new diff --git a/script/server b/script/server index cf218d5f..a17c4245 100755 --- a/script/server +++ b/script/server @@ -3,6 +3,6 @@ cd "$(dirname "$0")/.." [ $PORT ] || PORT=3000 [ $RACK_ENV ] || RACK_ENV=development -cmd="ruby -I lib -S bundle exec ruby -I lib -S unicorn config.ru -c config/unicorn.rb -p $PORT -E $RACK_ENV" -[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -l 127.0.0.1:$PORT" +cmd="ruby -I lib -S bundle exec ruby -I lib -S puma config.ru -p $PORT -e $RACK_ENV --threads 0:16" +[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -b tcp://127.0.0.1:$PORT" exec $cmd From 2718bc7e98d16f807581c30dc6f3fc41804ce170 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 23 Jan 2013 22:04:37 +0100 Subject: [PATCH 004/165] bump travis-support --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 207b180a..c117f3d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/getsentry/raven-ruby.git - revision: ac0e242733733ad07891031ddc5706e1247cb6f0 + revision: 73ee575e641bfe9e6d919599bde277bb21529954 specs: sentry-raven (0.4.0) faraday (>= 0.7.6) @@ -66,7 +66,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 259e48ffc68a67eff32848334025ef17ab58a3b3 + revision: 4637ea48abe8fb0976d8e0bbf997ea2578a3ca62 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -96,7 +96,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-support.git - revision: cf916e10949db43ce6f2b6f86082b367f04acfcd + revision: ff712aca1083a588974f835a84c574e6976aeb29 specs: travis-support (0.0.1) @@ -201,7 +201,7 @@ GEM avl_tree (~> 1.1.2) hitimes (~> 1.1) mime-types (1.19) - mocha (0.13.1) + mocha (0.13.2) metaclass (~> 0.0.1) multi_json (1.5.0) multipart-post (1.1.5) From 37dd125a8cb55dcab064edffea9f40674d51a16e Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 23 Jan 2013 22:12:15 +0100 Subject: [PATCH 005/165] start notifications --- lib/travis/api/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index bedd863f..277520fe 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -120,7 +120,7 @@ module Travis::Api end if Travis.config.sentry Travis::LogSubscriber::ActiveRecordMetrics.attach - $metriks_reporter = Metriks::Reporter::Logger.new + Travis::Notification.setup end def self.load_endpoints From 441f2a30911f10f360de5a67c39d8277ab6dee28 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 24 Jan 2013 01:34:50 +0100 Subject: [PATCH 006/165] Bump travis-core --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c7d85634..e5665432 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,7 +66,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 4637ea48abe8fb0976d8e0bbf997ea2578a3ca62 + revision: 12f2f486aad3226451434307902317c0b1691571 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -154,7 +154,7 @@ GEM arel (3.0.2) atomic (1.0.1) avl_tree (1.1.3) - backports (2.7.0) + backports (2.7.1) builder (3.0.4) bunny (0.8.0) celluloid (0.12.4) From 8c6d3bb9df221ce1cf6e07feea9e80f488bb97cc Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 24 Jan 2013 01:39:37 +0100 Subject: [PATCH 007/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e5665432..3603db93 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,7 +66,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 12f2f486aad3226451434307902317c0b1691571 + revision: e5f10976b8a2fe319c598d18f2b8cc866e0c548c specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From 9ced671da5828f84a360e3acc81cdcec97c7300c Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 24 Jan 2013 02:03:09 +0100 Subject: [PATCH 008/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3603db93..5257e875 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,7 +66,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: e5f10976b8a2fe319c598d18f2b8cc866e0c548c + revision: 09485de1c87b0223f9acce0a23ae9f68cfe89b6a specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From 36c40da55d33e9236986fa94ad744f24ab507478 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 24 Jan 2013 14:37:05 +0100 Subject: [PATCH 009/165] Fix workers tests --- spec/integration/v1/workers_spec.rb | 7 ++++--- spec/integration/v2/workers_spec.rb | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/spec/integration/v1/workers_spec.rb b/spec/integration/v1/workers_spec.rb index 11bdf4ec..34edd9e3 100644 --- a/spec/integration/v1/workers_spec.rb +++ b/spec/integration/v1/workers_spec.rb @@ -4,8 +4,8 @@ describe 'Workers' do before(:each) do Time.stubs(:now).returns(Time.utc(2011, 11, 11, 11, 11, 11)) @workers = [ - Factory(:worker, :name => 'worker-1', :state => :working), - Factory(:worker, :name => 'worker-2', :state => :errored) + Worker.new('1', full_name: 'ruby1:ruby1.travis-ci.org'), + Worker.new('2', full_name: 'ruby2:ruby1.travis-ci.org') ] end @@ -14,8 +14,9 @@ describe 'Workers' do attr_reader :workers it 'GET /workers' do + Worker.stubs(all: @workers) response = get '/workers', {}, headers - response.should deliver_json_for(Worker.order(:host, :name), version: 'v1') + response.should deliver_json_for(@workers, version: 'v1', type: 'workers') end end diff --git a/spec/integration/v2/workers_spec.rb b/spec/integration/v2/workers_spec.rb index 17231394..35f03e36 100644 --- a/spec/integration/v2/workers_spec.rb +++ b/spec/integration/v2/workers_spec.rb @@ -4,8 +4,8 @@ describe 'Workers' do before(:each) do Time.stubs(:now).returns(Time.utc(2011, 11, 11, 11, 11, 11)) @workers = [ - Factory(:worker, :name => 'worker-1', :state => :working), - Factory(:worker, :name => 'worker-2', :state => :errored) + Worker.new('1', full_name: 'ruby1:ruby1.travis-ci.org'), + Worker.new('2', full_name: 'ruby2:ruby1.travis-ci.org') ] end @@ -14,8 +14,9 @@ describe 'Workers' do attr_reader :workers it 'GET /workers' do + Worker.stubs(all: @workers) response = get '/workers', {}, headers - response.should deliver_json_for(Worker.order(:host, :name), version: 'v2') + response.should deliver_json_for(@workers, version: 'v2', type: 'workers') end end From 7195d48e7bc40dca39ec72ad6cbd66318742625f Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Thu, 24 Jan 2013 22:15:55 +0100 Subject: [PATCH 010/165] downgrade sinatra --- Gemfile | 4 ++-- Gemfile.lock | 40 +++++++++++++++------------------------- 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/Gemfile b/Gemfile index a66a06a7..85cf5d16 100644 --- a/Gemfile +++ b/Gemfile @@ -6,8 +6,8 @@ gemspec gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-core', github: 'travis-ci/travis-core' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' -gem 'sinatra', github: 'sinatra/sinatra' -gem 'sinatra-contrib', github: 'sinatra/sinatra-contrib', require: nil +gem 'sinatra' #github: 'sinatra/sinatra' +gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil # TODO need to release the gem as soon i'm certain this change makes sense gem 'simple_states', github: 'svenfuchs/simple_states', branch: 'sf-set-state-early' diff --git a/Gemfile.lock b/Gemfile.lock index 5257e875..63849b5c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -34,27 +34,6 @@ GIT yard-sinatra (1.0.0) yard (~> 0.7) -GIT - remote: git://github.com/sinatra/sinatra-contrib.git - revision: 86c85007860bbaf596092547e7902ff5e0a07698 - specs: - sinatra-contrib (1.4.0) - backports (>= 2.0) - eventmachine - rack-protection - rack-test - sinatra (~> 1.4.0) - tilt (~> 1.3) - -GIT - remote: git://github.com/sinatra/sinatra.git - revision: 459369eb66224836f72e21bbece58c007f3422fa - specs: - sinatra (1.4.0) - rack (~> 1.4) - rack-protection (~> 1.3) - tilt (~> 1.3, >= 1.3.3) - GIT remote: git://github.com/svenfuchs/simple_states.git revision: b1d45144e6a758220d7b21f83b08dc92de0d3196 @@ -66,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 09485de1c87b0223f9acce0a23ae9f68cfe89b6a + revision: ba4e4a83b473393539728a3aeb8e3499ab1ef1bc specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -96,7 +75,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-support.git - revision: ff712aca1083a588974f835a84c574e6976aeb29 + revision: a288008629ae7eab18c529008880d364daca82ce specs: travis-support (0.0.1) @@ -266,6 +245,17 @@ GEM redis (~> 3) redis-namespace signature (0.1.6) + sinatra (1.3.3) + rack (~> 1.3, >= 1.3.6) + rack-protection (~> 1.2) + tilt (~> 1.3, >= 1.3.3) + sinatra-contrib (1.3.2) + backports (>= 2.0) + eventmachine + rack-protection + rack-test + sinatra (~> 1.3.0) + tilt (~> 1.3) slop (3.4.3) sprockets (2.2.2) hike (~> 1.2) @@ -309,8 +299,8 @@ DEPENDENCIES rspec (~> 2.11) sentry-raven! simple_states! - sinatra! - sinatra-contrib! + sinatra + sinatra-contrib travis-api! travis-core! travis-sidekiqs! From 01c585e189bf25782f5a770a9517ecd4fa5db6ac Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Fri, 25 Jan 2013 11:29:05 +0100 Subject: [PATCH 011/165] I have no idea --- lib/travis/api/app/base.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index 172e3342..4ab5af58 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -18,6 +18,12 @@ class Travis::Api::App "This feature has not yet been implemented. Sorry :(\n\nPull Requests welcome!" end + def call(env) + super + rescue Sinatra::NotFound + [404, {'Content-Type' => 'text/plain'}, ['Tell Konstantin to fix this!']] + end + configure do # We pull in certain protection middleware in App. # Being token based makes us invulnerable to common From 48cc0d366a0e310e21131ee7569e60c8ee44ab01 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Fri, 25 Jan 2013 11:40:41 +0100 Subject: [PATCH 012/165] disable newrelic --- lib/travis/api/app/base.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index 4ab5af58..65bf2382 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -1,6 +1,6 @@ require 'travis/api/app' require 'sinatra/base' -require 'new_relic/agent/instrumentation/rack' +#require 'new_relic/agent/instrumentation/rack' class Travis::Api::App # Superclass for any endpoint and middleware. @@ -9,7 +9,7 @@ class Travis::Api::App register Extensions::SmartConstants configure :production do - require 'newrelic_rpm' + #require 'newrelic_rpm' end error NotImplementedError do @@ -18,12 +18,6 @@ class Travis::Api::App "This feature has not yet been implemented. Sorry :(\n\nPull Requests welcome!" end - def call(env) - super - rescue Sinatra::NotFound - [404, {'Content-Type' => 'text/plain'}, ['Tell Konstantin to fix this!']] - end - configure do # We pull in certain protection middleware in App. # Being token based makes us invulnerable to common From bde974e1829a435beaa62c793c5ee13266c87cda Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Fri, 25 Jan 2013 22:11:53 +0100 Subject: [PATCH 013/165] Revert "disable newrelic" This reverts commit 48cc0d366a0e310e21131ee7569e60c8ee44ab01. --- lib/travis/api/app/base.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index 65bf2382..4ab5af58 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -1,6 +1,6 @@ require 'travis/api/app' require 'sinatra/base' -#require 'new_relic/agent/instrumentation/rack' +require 'new_relic/agent/instrumentation/rack' class Travis::Api::App # Superclass for any endpoint and middleware. @@ -9,7 +9,7 @@ class Travis::Api::App register Extensions::SmartConstants configure :production do - #require 'newrelic_rpm' + require 'newrelic_rpm' end error NotImplementedError do @@ -18,6 +18,12 @@ class Travis::Api::App "This feature has not yet been implemented. Sorry :(\n\nPull Requests welcome!" end + def call(env) + super + rescue Sinatra::NotFound + [404, {'Content-Type' => 'text/plain'}, ['Tell Konstantin to fix this!']] + end + configure do # We pull in certain protection middleware in App. # Being token based makes us invulnerable to common From 85e8f27047826528f84dfb3edb2adfef1e6b095b Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Fri, 25 Jan 2013 22:13:33 +0100 Subject: [PATCH 014/165] hotfix for strange bug --- lib/travis/api/app/base.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index 4ab5af58..90c73b42 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -18,6 +18,11 @@ class Travis::Api::App "This feature has not yet been implemented. Sorry :(\n\nPull Requests welcome!" end + # hotfix?? + def route_missing + @app ? forward : halt 404 + end + def call(env) super rescue Sinatra::NotFound From 939b35cbff36efdb78d639ab0ba40f585cc2fbbb Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Fri, 25 Jan 2013 22:30:47 +0100 Subject: [PATCH 015/165] fix syntrax --- lib/travis/api/app/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index 90c73b42..92031836 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -20,7 +20,7 @@ class Travis::Api::App # hotfix?? def route_missing - @app ? forward : halt 404 + @app ? forward : halt(404) end def call(env) From c6e3c29a579f3e268cbf25340ccc37e4ec10feff Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 25 Jan 2013 23:47:21 +0100 Subject: [PATCH 016/165] Load the data for integration tests upfront We can do it, because we use :transaction strategy with DatabaseCleaner, which starts transaction before each test and rollbacks after it. That way data before each test is consistent. The big advantage of such approach is that tests are fast now - we need to only load Scenario data once. One of the drawbacks, on the other hand, is that we need to always load this data, even if no integration tests need running. We can try to be smart about it and check if any integration tests are loaded. --- spec/integration/v1/branches_spec.rb | 2 -- spec/integration/v1/builds_spec.rb | 2 -- spec/integration/v1/hooks_spec.rb | 1 - spec/integration/v1/repositories_spec.rb | 2 -- spec/integration/v2/branches_spec.rb | 2 -- spec/integration/v2/builds_spec.rb | 2 -- spec/integration/v2/hooks_spec.rb | 1 - spec/integration/v2/repositories_spec.rb | 2 -- spec/integration/v2/users_spec.rb | 2 +- spec/spec_helper.rb | 3 ++- spec/unit/endpoint/accounts_spec.rb | 2 +- 11 files changed, 4 insertions(+), 17 deletions(-) diff --git a/spec/integration/v1/branches_spec.rb b/spec/integration/v1/branches_spec.rb index 07beef62..6e5c8735 100644 --- a/spec/integration/v1/branches_spec.rb +++ b/spec/integration/v1/branches_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe 'Branches' do - before { Scenario.default } - let(:repo) { Repository.by_slug('svenfuchs/minimal').first } let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } } diff --git a/spec/integration/v1/builds_spec.rb b/spec/integration/v1/builds_spec.rb index 3c1bca96..73d2fe85 100644 --- a/spec/integration/v1/builds_spec.rb +++ b/spec/integration/v1/builds_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe 'Builds' do - before { Scenario.default } - let(:repo) { Repository.by_slug('svenfuchs/minimal').first } let(:build) { repo.builds.first } let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } } diff --git a/spec/integration/v1/hooks_spec.rb b/spec/integration/v1/hooks_spec.rb index 35160330..ccf76a00 100644 --- a/spec/integration/v1/hooks_spec.rb +++ b/spec/integration/v1/hooks_spec.rb @@ -2,7 +2,6 @@ require 'spec_helper' describe 'Hooks' do before(:each) do - Scenario.default user.permissions.create repository: repo, admin: true end diff --git a/spec/integration/v1/repositories_spec.rb b/spec/integration/v1/repositories_spec.rb index 9d4da90b..aea3fd4c 100644 --- a/spec/integration/v1/repositories_spec.rb +++ b/spec/integration/v1/repositories_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe 'v1 repos' do - before(:each) { Scenario.default } - let(:repo) { Repository.by_slug('svenfuchs/minimal').first } let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } } diff --git a/spec/integration/v2/branches_spec.rb b/spec/integration/v2/branches_spec.rb index 6f52bbf7..3e54ecc8 100644 --- a/spec/integration/v2/branches_spec.rb +++ b/spec/integration/v2/branches_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe 'Branches' do - before { Scenario.default } - let(:repo) { Repository.by_slug('svenfuchs/minimal').first } let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } } diff --git a/spec/integration/v2/builds_spec.rb b/spec/integration/v2/builds_spec.rb index 1f948fb8..4366a558 100644 --- a/spec/integration/v2/builds_spec.rb +++ b/spec/integration/v2/builds_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe 'Builds' do - before { Scenario.default } - let(:repo) { Repository.by_slug('svenfuchs/minimal').first } let(:build) { repo.builds.first } let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } } diff --git a/spec/integration/v2/hooks_spec.rb b/spec/integration/v2/hooks_spec.rb index 37f1a931..c0a685de 100644 --- a/spec/integration/v2/hooks_spec.rb +++ b/spec/integration/v2/hooks_spec.rb @@ -3,7 +3,6 @@ require 'travis/testing/payloads' describe 'Hooks' do before(:each) do - Scenario.default user.permissions.create repository: repo, admin: true end diff --git a/spec/integration/v2/repositories_spec.rb b/spec/integration/v2/repositories_spec.rb index fba8035d..9de7ad63 100644 --- a/spec/integration/v2/repositories_spec.rb +++ b/spec/integration/v2/repositories_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe 'Repos' do - before(:each) { Scenario.default } - let(:repo) { Repository.by_slug('svenfuchs/minimal').first } let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } } diff --git a/spec/integration/v2/users_spec.rb b/spec/integration/v2/users_spec.rb index 945afa57..739ebc43 100644 --- a/spec/integration/v2/users_spec.rb +++ b/spec/integration/v2/users_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'Users' do - let(:user) { Factory(:user, locale: 'en') } + let(:user) { User.first } let(:token) { Travis::Api::App::AccessToken.create(user: user, app_id: -1) } let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json', 'HTTP_AUTHORIZATION' => "token #{token}" } } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index af4563da..33a828a1 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -41,7 +41,8 @@ RSpec.configure do |c| c.before :suite do DatabaseCleaner.strategy = :transaction - DatabaseCleaner.clean_with :transaction + DatabaseCleaner.clean_with :truncation + Scenario.default end c.before :each do diff --git a/spec/unit/endpoint/accounts_spec.rb b/spec/unit/endpoint/accounts_spec.rb index 2277ea8d..ecae3c03 100644 --- a/spec/unit/endpoint/accounts_spec.rb +++ b/spec/unit/endpoint/accounts_spec.rb @@ -18,7 +18,7 @@ describe Travis::Api::App::Endpoint::Accounts do 'login' => user.login, 'name' => user.name, 'type' => 'user', - 'repos_count' => nil + 'repos_count' => 1 }] end end From 46eefaf26dc0aa98f035218f14bb001d57cecf84 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 26 Jan 2013 00:02:15 +0100 Subject: [PATCH 017/165] Fix syntax error --- lib/travis/api/app/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index 90c73b42..92031836 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -20,7 +20,7 @@ class Travis::Api::App # hotfix?? def route_missing - @app ? forward : halt 404 + @app ? forward : halt(404) end def call(env) From f2d768080f0228eaeb4390b094ff7ca099101b1d Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 26 Jan 2013 01:12:42 +0100 Subject: [PATCH 018/165] Return last builds on each branch for /builds?branches=true This is a hack to fix travis-ci/travis-web#123 easier. A proper solution would be to refactor how /branches work. --- lib/travis/api/app/endpoint/builds.rb | 3 ++- spec/integration/v2/builds_spec.rb | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/endpoint/builds.rb b/lib/travis/api/app/endpoint/builds.rb index fe7b21c4..3ef22141 100644 --- a/lib/travis/api/app/endpoint/builds.rb +++ b/lib/travis/api/app/endpoint/builds.rb @@ -4,7 +4,8 @@ class Travis::Api::App class Endpoint class Builds < Endpoint get '/' do - respond_with service(:find_builds, params) + name = params[:branches] ? :find_branches : :find_builds + respond_with service(name, params) end get '/:id' do diff --git a/spec/integration/v2/builds_spec.rb b/spec/integration/v2/builds_spec.rb index 4366a558..51eb82fb 100644 --- a/spec/integration/v2/builds_spec.rb +++ b/spec/integration/v2/builds_spec.rb @@ -29,4 +29,9 @@ describe 'Builds' do response = get "/repos/svenfuchs/minimal/builds/#{build.id}", {}, headers response.should deliver_json_for(build, version: 'v2') end + + it 'GET /builds/1?repository_id=1&branches=true' do + response = get "/builds?repository_id=#{repo.id}&branches=true", {}, headers + response.should deliver_json_for(repo.last_finished_builds_by_branches, version: 'v2') + end end From d441336573ea8344e0213bf72a76945ece8b566b Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Thu, 24 Jan 2013 00:06:42 +0100 Subject: [PATCH 019/165] expose logs on /job/:id/log.txt --- Gemfile | 2 +- Gemfile.lock | 2 +- lib/travis/api/app.rb | 21 ++++++++++++--------- lib/travis/api/app/endpoint/jobs.rb | 4 ++++ spec/integration/v1/workers_spec.rb | 15 +++------------ spec/integration/v2/jobs_spec.rb | 8 +++++++- spec/integration/v2/workers_spec.rb | 15 +++------------ spec/support/matchers.rb | 20 ++++++++++++++++++++ 8 files changed, 51 insertions(+), 36 deletions(-) diff --git a/Gemfile b/Gemfile index 85cf5d16..add18133 100644 --- a/Gemfile +++ b/Gemfile @@ -3,8 +3,8 @@ ruby '1.9.3' rescue nil source :rubygems gemspec +gem 'travis-core', github: 'travis-ci/travis-core', branch: 'sf-archive-logs' gem 'travis-support', github: 'travis-ci/travis-support' -gem 'travis-core', github: 'travis-ci/travis-core' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' gem 'sinatra' #github: 'sinatra/sinatra' gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil diff --git a/Gemfile.lock b/Gemfile.lock index 63849b5c..b1b903d3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: ba4e4a83b473393539728a3aeb8e3499ab1ef1bc + revision: 4637ea48abe8fb0976d8e0bbf997ea2578a3ca62 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 277520fe..e57abdab 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -111,16 +111,19 @@ module Travis::Api Travis::Amqp.config = Travis.config.amqp Travis::Database.connect Travis::Features.start - Sidekiq.configure_client do |config| - config.redis = Travis.config.redis.merge(size: 1, namespace: Travis.config.sidekiq.namespace) + + unless Travis.env == 'test' + Sidekiq.configure_client do |config| + config.redis = Travis.config.redis.merge(size: 1, namespace: Travis.config.sidekiq.namespace) + end + + Raven.configure do |config| + config.dsn = Travis.config.sentry.dsn + end if Travis.config.sentry + + Travis::LogSubscriber::ActiveRecordMetrics.attach + Travis::Notification.setup end - - Raven.configure do |config| - config.dsn = Travis.config.sentry.dsn - end if Travis.config.sentry - - Travis::LogSubscriber::ActiveRecordMetrics.attach - Travis::Notification.setup end def self.load_endpoints diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index de02c291..963e2c59 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -10,6 +10,10 @@ class Travis::Api::App get '/:id' do respond_with service(:find_job, params) end + + get '/:job_id/log' do + respond_with service(:find_artifact, params) + end end end end diff --git a/spec/integration/v1/workers_spec.rb b/spec/integration/v1/workers_spec.rb index 34edd9e3..22bb8683 100644 --- a/spec/integration/v1/workers_spec.rb +++ b/spec/integration/v1/workers_spec.rb @@ -1,22 +1,13 @@ require 'spec_helper' describe 'Workers' do - before(:each) do - Time.stubs(:now).returns(Time.utc(2011, 11, 11, 11, 11, 11)) - @workers = [ - Worker.new('1', full_name: 'ruby1:ruby1.travis-ci.org'), - Worker.new('2', full_name: 'ruby2:ruby1.travis-ci.org') - ] - end - - let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } } - - attr_reader :workers + let!(:workers) { [Worker.create(full_name: 'one'), Worker.create(full_name: 'two')] } + let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } } it 'GET /workers' do Worker.stubs(all: @workers) response = get '/workers', {}, headers - response.should deliver_json_for(@workers, version: 'v1', type: 'workers') + response.should deliver_json_for(Worker.all, version: 'v1', type: 'workers') end end diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb index 4da7acae..58e370ef 100644 --- a/spec/integration/v2/jobs_spec.rb +++ b/spec/integration/v2/jobs_spec.rb @@ -13,8 +13,14 @@ describe 'Jobs' do response.should deliver_json_for(Job.queued('builds.common'), version: 'v2') end - it '/jobs/:job_id' do + it '/jobs/:id' do response = get "/jobs/#{job.id}", {}, headers response.should deliver_json_for(job, version: 'v2') end + + it '/jobs/:id' do + job.log.update_attributes!(content: 'the log') + response = get "/jobs/#{job.id}/log.txt", {}, headers + response.should deliver_as_txt('the log', version: 'v2') + end end diff --git a/spec/integration/v2/workers_spec.rb b/spec/integration/v2/workers_spec.rb index 35f03e36..047dff94 100644 --- a/spec/integration/v2/workers_spec.rb +++ b/spec/integration/v2/workers_spec.rb @@ -1,22 +1,13 @@ require 'spec_helper' describe 'Workers' do - before(:each) do - Time.stubs(:now).returns(Time.utc(2011, 11, 11, 11, 11, 11)) - @workers = [ - Worker.new('1', full_name: 'ruby1:ruby1.travis-ci.org'), - Worker.new('2', full_name: 'ruby2:ruby1.travis-ci.org') - ] - end - - let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } } - - attr_reader :workers + let!(:workers) { [Worker.create(full_name: 'one'), Worker.create(full_name: 'two')] } + let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } } it 'GET /workers' do Worker.stubs(all: @workers) response = get '/workers', {}, headers - response.should deliver_json_for(@workers, version: 'v2', type: 'workers') + response.should deliver_json_for(Worker.all, version: 'v2', type: 'workers') end end diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 53cc97aa..3152322a 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -24,6 +24,26 @@ RSpec::Matchers.define :deliver_json_for do |resource, options = {}| end end +RSpec::Matchers.define :deliver_as_txt do |expected, options = {}| + match do |response| + if response.status == 200 + failure_message_for_should do + "expected\n\n#{actual}\n\nto equal\n\n#{expected}" + end + response.body.to_s == expected + else + failure_message_for_should do + "expected the request to be successful (200) but was #{response.status}" + end + false + end + end + + def parse(body) + MultiJson.decode(body) + end +end + RSpec::Matchers.define :deliver_result_image_for do |name| match do |response| header = response.headers['content-disposition'] From 598a586ed422cf5698eafe2bca937c5521b45a84 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Thu, 24 Jan 2013 00:48:26 +0100 Subject: [PATCH 020/165] don't start metrics logger etc unless in production --- lib/travis/api/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index e57abdab..0bd99d02 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -112,7 +112,7 @@ module Travis::Api Travis::Database.connect Travis::Features.start - unless Travis.env == 'test' + if Travis.env == 'production' Sidekiq.configure_client do |config| config.redis = Travis.config.redis.merge(size: 1, namespace: Travis.config.sidekiq.namespace) end From 4ea95494de673befe8e4bb7c50616b7c5efdaf79 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Thu, 24 Jan 2013 23:56:48 +0100 Subject: [PATCH 021/165] allow put to /artifacts/:id --- Gemfile | 2 +- Gemfile.lock | 11 ++++++----- lib/travis/api/app/endpoint/artifacts.rb | 4 ++++ 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index add18133..83b45662 100644 --- a/Gemfile +++ b/Gemfile @@ -38,5 +38,5 @@ end group :development, :test do gem 'rake', '~> 0.9.2' - gem 'micro_migrations', git: 'http://gist.github.com/4269321.git' + gem 'micro_migrations', git: 'https://gist.github.com/4269321.git' end diff --git a/Gemfile.lock b/Gemfile.lock index b1b903d3..abc22ad6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,8 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 4637ea48abe8fb0976d8e0bbf997ea2578a3ca62 + revision: c5f4fb9c33d78cd984e041ba6b280191c8b5349c + branch: sf-archive-logs specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -59,7 +60,7 @@ GIT postmark-rails (~> 0.4.1) pusher (~> 0.11.0) railties (~> 3.2.11) - rake (~> 0.9.2.2) + rake redis (~> 3.0) rollout (~> 1.1.0) simple_states (~> 0.1.1) @@ -80,7 +81,7 @@ GIT travis-support (0.0.1) GIT - remote: http://gist.github.com/4269321.git + remote: https://gist.github.com/4269321.git revision: 8e2d21b924a69dd48191df6a18e51769f5a88614 specs: micro_migrations (0.0.1) @@ -185,7 +186,7 @@ GEM multipart-post (1.1.5) net-http-persistent (2.8) net-http-pipeline (1.0.1) - newrelic_rpm (3.5.5.38) + newrelic_rpm (3.5.6.46) pg (0.13.2) polyglot (0.3.3) postmark (0.9.18) @@ -220,7 +221,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - rake (0.9.2.2) + rake (0.9.6) rdoc (3.12) json (~> 1.4) redcarpet (2.2.2) diff --git a/lib/travis/api/app/endpoint/artifacts.rb b/lib/travis/api/app/endpoint/artifacts.rb index 43fb9040..94601d53 100644 --- a/lib/travis/api/app/endpoint/artifacts.rb +++ b/lib/travis/api/app/endpoint/artifacts.rb @@ -9,6 +9,10 @@ class Travis::Api::App get '/:id' do |id| respond_with service(:find_artifact, params) end + + put '/:id' do |id| + respond_with service(:update_artifact, params) + end end end end From b81644acba2e8542d64887e66b8a9fdddaaed9c1 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sat, 26 Jan 2013 20:41:18 +0100 Subject: [PATCH 022/165] comment out put to /artifacts/:id for now --- lib/travis/api/app/endpoint/artifacts.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/travis/api/app/endpoint/artifacts.rb b/lib/travis/api/app/endpoint/artifacts.rb index 94601d53..1db1bb99 100644 --- a/lib/travis/api/app/endpoint/artifacts.rb +++ b/lib/travis/api/app/endpoint/artifacts.rb @@ -10,9 +10,11 @@ class Travis::Api::App respond_with service(:find_artifact, params) end - put '/:id' do |id| - respond_with service(:update_artifact, params) - end + # TODO needs auth, required for live log archiving on log:aggregted in travis-tasks + # + # put '/:id' do |id| + # respond_with service(:update_artifact, params) + # end end end end From 7b4712c32cbe22bb669db639c14d954e2bb01ebc Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sat, 26 Jan 2013 20:54:58 +0100 Subject: [PATCH 023/165] fix after rebase --- Gemfile.lock | 10 +++++----- spec/integration/v1/workers_spec.rb | 1 - spec/integration/v2/workers_spec.rb | 1 - 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index abc22ad6..d447a621 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: c5f4fb9c33d78cd984e041ba6b280191c8b5349c + revision: 801d0dee5bd85811afa000f705f34e29ff2c65e9 branch: sf-archive-logs specs: travis-core (0.0.1) @@ -60,7 +60,7 @@ GIT postmark-rails (~> 0.4.1) pusher (~> 0.11.0) railties (~> 3.2.11) - rake + rake (~> 0.9.2.2) redis (~> 3.0) rollout (~> 1.1.0) simple_states (~> 0.1.1) @@ -76,7 +76,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-support.git - revision: a288008629ae7eab18c529008880d364daca82ce + revision: ff712aca1083a588974f835a84c574e6976aeb29 specs: travis-support (0.0.1) @@ -144,7 +144,7 @@ GEM coderay (1.0.8) connection_pool (0.9.3) daemons (1.1.9) - dalli (2.6.0) + dalli (2.6.2) data_migrations (0.0.1) activerecord rake @@ -221,7 +221,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - rake (0.9.6) + rake (0.9.2.2) rdoc (3.12) json (~> 1.4) redcarpet (2.2.2) diff --git a/spec/integration/v1/workers_spec.rb b/spec/integration/v1/workers_spec.rb index 22bb8683..1c897384 100644 --- a/spec/integration/v1/workers_spec.rb +++ b/spec/integration/v1/workers_spec.rb @@ -5,7 +5,6 @@ describe 'Workers' do let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.1+json' } } it 'GET /workers' do - Worker.stubs(all: @workers) response = get '/workers', {}, headers response.should deliver_json_for(Worker.all, version: 'v1', type: 'workers') end diff --git a/spec/integration/v2/workers_spec.rb b/spec/integration/v2/workers_spec.rb index 047dff94..120934a4 100644 --- a/spec/integration/v2/workers_spec.rb +++ b/spec/integration/v2/workers_spec.rb @@ -5,7 +5,6 @@ describe 'Workers' do let(:headers) { { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json' } } it 'GET /workers' do - Worker.stubs(all: @workers) response = get '/workers', {}, headers response.should deliver_json_for(Worker.all, version: 'v2', type: 'workers') end From 616b8df27cd9b82b313909def4008d960bb4f827 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 27 Jan 2013 21:42:00 +0100 Subject: [PATCH 024/165] Use travis-core from master --- Gemfile | 2 +- Gemfile.lock | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 83b45662..d75971de 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ ruby '1.9.3' rescue nil source :rubygems gemspec -gem 'travis-core', github: 'travis-ci/travis-core', branch: 'sf-archive-logs' +gem 'travis-core', github: 'travis-ci/travis-core' gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' gem 'sinatra' #github: 'sinatra/sinatra' diff --git a/Gemfile.lock b/Gemfile.lock index d447a621..daf0b41c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,8 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 801d0dee5bd85811afa000f705f34e29ff2c65e9 - branch: sf-archive-logs + revision: 987188a5f96f5d7e4f6a6e314ab402f3fbad0963 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -60,7 +59,7 @@ GIT postmark-rails (~> 0.4.1) pusher (~> 0.11.0) railties (~> 3.2.11) - rake (~> 0.9.2.2) + rake redis (~> 3.0) rollout (~> 1.1.0) simple_states (~> 0.1.1) @@ -221,7 +220,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - rake (0.9.2.2) + rake (0.9.6) rdoc (3.12) json (~> 1.4) redcarpet (2.2.2) From edc9749bcef8baa2f3ee9c5ae151d6417e8f6082 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 28 Jan 2013 00:54:32 +0100 Subject: [PATCH 025/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index daf0b41c..98ba2bd9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 987188a5f96f5d7e4f6a6e314ab402f3fbad0963 + revision: be085ccf0aa58fba8d383d6ed72d22e47dae5836 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From 31371686c95878ff06eb53728de011d5dc281c3c Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 28 Jan 2013 03:04:36 +0100 Subject: [PATCH 026/165] Redirect to archive logs --- Gemfile.lock | 2 +- lib/travis/api/app/endpoint/jobs.rb | 15 ++++++++++++++- spec/integration/v2/jobs_spec.rb | 26 ++++++++++++++++++++++---- 3 files changed, 37 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 98ba2bd9..b82358b1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: be085ccf0aa58fba8d383d6ed72d22e47dae5836 + revision: 2d766c54c2fea70dfc4d937c22413eee937f002b specs: travis-core (0.0.1) actionmailer (~> 3.2.11) diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index 963e2c59..288c6bb9 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -12,7 +12,20 @@ class Travis::Api::App end get '/:job_id/log' do - respond_with service(:find_artifact, params) + resource = service(:find_artifact, params).run + if !resource || resource.archived? + redirect archive_url("/jobs/#{params[:job_id]}/log.txt") + else + respond_with resource + end + end + + def archive_url(path) + "https://#{hostname('archive')}#{path}" + end + + def hostname(name) + "#{name}#{'-staging' if Travis.env == 'staging'}.#{Travis.config.host.split('.')[-2, 2].join('.')}" end end end diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb index 58e370ef..847e56f5 100644 --- a/spec/integration/v2/jobs_spec.rb +++ b/spec/integration/v2/jobs_spec.rb @@ -18,9 +18,27 @@ describe 'Jobs' do response.should deliver_json_for(job, version: 'v2') end - it '/jobs/:id' do - job.log.update_attributes!(content: 'the log') - response = get "/jobs/#{job.id}/log.txt", {}, headers - response.should deliver_as_txt('the log', version: 'v2') + context 'GET /jobs/:job_id/log.txt' do + it 'returns log for a job' do + job.log.update_attributes!(content: 'the log') + response = get "/jobs/#{job.id}/log.txt", {}, headers + response.should deliver_as_txt('the log', version: 'v2') + end + + context 'when log is archived' do + it 'redirects to archive' do + job.log.update_attributes!(content: 'the log', archived_at: Time.now, archive_verified: true) + response = get "/jobs/#{job.id}/log.txt", {}, headers + response.should redirect_to("https://archive.travis-ci.org/jobs/#{job.id}/log.txt") + end + end + + context 'when log is missing' do + it 'redirects to archive' do + job.log.destroy + response = get "/jobs/#{job.id}/log.txt", {}, headers + response.should redirect_to("https://archive.travis-ci.org/jobs/#{job.id}/log.txt") + end + end end end From a565522f41348ebde62590d211d7028f1ce6b474 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 28 Jan 2013 03:43:24 +0100 Subject: [PATCH 027/165] Redirect to full amazon url Amazon can't work properly with SSL and CNAME for subdomains. For now we can use full amazon url. --- lib/travis/api/app/endpoint/jobs.rb | 2 +- spec/integration/v2/jobs_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index 288c6bb9..b5a6d410 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -21,7 +21,7 @@ class Travis::Api::App end def archive_url(path) - "https://#{hostname('archive')}#{path}" + "https://s3.amazonaws.com/#{hostname('archive')}#{path}" end def hostname(name) diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb index 847e56f5..fa617d15 100644 --- a/spec/integration/v2/jobs_spec.rb +++ b/spec/integration/v2/jobs_spec.rb @@ -29,7 +29,7 @@ describe 'Jobs' do it 'redirects to archive' do job.log.update_attributes!(content: 'the log', archived_at: Time.now, archive_verified: true) response = get "/jobs/#{job.id}/log.txt", {}, headers - response.should redirect_to("https://archive.travis-ci.org/jobs/#{job.id}/log.txt") + response.should redirect_to("https://s3.amazonaws.com/archive.travis-ci.org/jobs/#{job.id}/log.txt") end end @@ -37,7 +37,7 @@ describe 'Jobs' do it 'redirects to archive' do job.log.destroy response = get "/jobs/#{job.id}/log.txt", {}, headers - response.should redirect_to("https://archive.travis-ci.org/jobs/#{job.id}/log.txt") + response.should redirect_to("https://s3.amazonaws.com/archive.travis-ci.org/jobs/#{job.id}/log.txt") end end end From 62b876d2e107d9987c8e7942248b09afa5a8c86e Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Mon, 28 Jan 2013 15:47:28 +0100 Subject: [PATCH 028/165] keep query string when redirecting in rewrite middleware --- lib/travis/api/app/middleware/rewrite.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/travis/api/app/middleware/rewrite.rb b/lib/travis/api/app/middleware/rewrite.rb index 3215602b..5fb12586 100644 --- a/lib/travis/api/app/middleware/rewrite.rb +++ b/lib/travis/api/app/middleware/rewrite.rb @@ -40,6 +40,7 @@ class Travis::Api::App end def force_redirect(path) + path += "?#{request.query_string}" unless request.query_string.empty? response.body = '' response['Content-Length'] = '0' response['Content-Type'] = '' From 489a33cbf68efb2365958e9ff1b2cf9c0d4c0968 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 28 Jan 2013 19:05:07 +0100 Subject: [PATCH 029/165] Try 307 redirect on /logs.txt --- lib/travis/api/app/endpoint/jobs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index b5a6d410..ed554324 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -14,7 +14,7 @@ class Travis::Api::App get '/:job_id/log' do resource = service(:find_artifact, params).run if !resource || resource.archived? - redirect archive_url("/jobs/#{params[:job_id]}/log.txt") + redirect archive_url("/jobs/#{params[:job_id]}/log.txt"), 307 else respond_with resource end From 260c46181d18f6e43d0a7a1e00a34211e21bc11c Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 29 Jan 2013 03:13:01 +0100 Subject: [PATCH 030/165] Add hack to allow handling redirect to logs on the client properly. This hack is temporary and should be removed when we find better solution. TL;DR: we can't handle redirects to S3 using CORS, so in case we want to get logs from S3 without additional requests to API, we need to return status that will not be automatically redirected (in this case 204 seems like the best answer). Longer rationale: Old logs are hosted on S3 now and in case log is not available in the database, we would like to redirect to the archived log. Although S3 support CORS, our use case breaks on some browsers: * when request is triggered to /jobs/:id/log and log is archived, api returns 302 redirect, Location header points to the log on S3 * browser transparently redirects to given url, but it sets Origin to null, for security reasons * "Origin: null" is ok, because we allow every origin by setting AllowedOrigin to "*" * S3 returns "Access-Control-Allow-Origin: null" header, which breaks some browsers (I confirmed it for webkit based browsers) In order to fix this, S3 would need to return * in Access-Control-Allow-Origin header or we would need to tell the browser to not follow redirect. Both solutions are not achiveable. Another option would be to return log information in job payload - we could send log_url field which should be either log url on amazon or null, but in such case we would need to query artifacts table in each job request. This is something that should be avoided as archived logs are not frequently requested - slowing down every request to get info for it would be a waste. --- lib/travis/api/app/endpoint/jobs.rb | 10 +++++++++- spec/integration/v2/jobs_spec.rb | 9 +++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index ed554324..3759316c 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -14,7 +14,15 @@ class Travis::Api::App get '/:job_id/log' do resource = service(:find_artifact, params).run if !resource || resource.archived? - redirect archive_url("/jobs/#{params[:job_id]}/log.txt"), 307 + archived_log_path = archive_url("/jobs/#{params[:job_id]}/log.txt") + + if params[:cors_hax] + status 204 + headers['Access-Control-Expose-Headers'] = 'Location' + headers['Location'] = archived_log_path + else + redirect archived_log_path, 307 + end else respond_with resource end diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb index fa617d15..6df25881 100644 --- a/spec/integration/v2/jobs_spec.rb +++ b/spec/integration/v2/jobs_spec.rb @@ -40,5 +40,14 @@ describe 'Jobs' do response.should redirect_to("https://s3.amazonaws.com/archive.travis-ci.org/jobs/#{job.id}/log.txt") end end + + context 'with cors_hax param' do + it 'renders No Content response with location of the archived log' do + job.log.destroy + response = get "/jobs/#{job.id}/log.txt?cors_hax=true", {}, headers + response.status.should == 204 + response.headers['Location'].should == "https://s3.amazonaws.com/archive.travis-ci.org/jobs/#{job.id}/log.txt" + end + end end end From b8dfb1cd007148f9747a4e1dc2e8a047b20ac3b6 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 30 Jan 2013 08:50:27 +0100 Subject: [PATCH 031/165] auth PUT to /artifacts/:id --- Gemfile | 1 + Gemfile.lock | 18 ++++++++++-------- lib/travis/api/app/endpoint/artifacts.rb | 12 +++++++----- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index d75971de..b0810ca4 100644 --- a/Gemfile +++ b/Gemfile @@ -34,6 +34,7 @@ group :development do gem 'foreman' gem 'rerun' # gem 'debugger' + gem 'rb-fsevent', '~> 0.9.1' end group :development, :test do diff --git a/Gemfile.lock b/Gemfile.lock index b82358b1..52630c30 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ GIT remote: git://github.com/getsentry/raven-ruby.git - revision: 73ee575e641bfe9e6d919599bde277bb21529954 + revision: ab0e8e5a14c416d38686de9a20f436e005efe735 specs: - sentry-raven (0.4.0) + sentry-raven (0.4.2) faraday (>= 0.7.6) hashie multi_json (~> 1.0) @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 2d766c54c2fea70dfc4d937c22413eee937f002b + revision: b8d0d63f433c8e63472b97b3c287b99d31027ecb specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -209,7 +209,7 @@ GEM rack (>= 0.4) rack-protection (1.3.2) rack - rack-ssl (1.3.2) + rack-ssl (1.3.3) rack rack-test (0.6.2) rack (>= 1.0) @@ -221,6 +221,7 @@ GEM rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) rake (0.9.6) + rb-fsevent (0.9.3) rdoc (3.12) json (~> 1.4) redcarpet (2.2.2) @@ -237,7 +238,7 @@ GEM rspec-core (2.12.2) rspec-expectations (2.12.1) diff-lcs (~> 1.1.3) - rspec-mocks (2.12.1) + rspec-mocks (2.12.2) sidekiq (2.5.4) celluloid (~> 0.12.0) connection_pool (~> 0.9.2) @@ -245,9 +246,9 @@ GEM redis (~> 3) redis-namespace signature (0.1.6) - sinatra (1.3.3) - rack (~> 1.3, >= 1.3.6) - rack-protection (~> 1.2) + sinatra (1.3.4) + rack (~> 1.4) + rack-protection (~> 1.3) tilt (~> 1.3, >= 1.3.3) sinatra-contrib (1.3.2) backports (>= 2.0) @@ -295,6 +296,7 @@ DEPENDENCIES rack-cache (~> 1.2) rack-contrib! rake (~> 0.9.2) + rb-fsevent (~> 0.9.1) rerun rspec (~> 2.11) sentry-raven! diff --git a/lib/travis/api/app/endpoint/artifacts.rb b/lib/travis/api/app/endpoint/artifacts.rb index 1db1bb99..1c718e81 100644 --- a/lib/travis/api/app/endpoint/artifacts.rb +++ b/lib/travis/api/app/endpoint/artifacts.rb @@ -10,11 +10,13 @@ class Travis::Api::App respond_with service(:find_artifact, params) end - # TODO needs auth, required for live log archiving on log:aggregted in travis-tasks - # - # put '/:id' do |id| - # respond_with service(:update_artifact, params) - # end + put '/:id' do |id| + # TODO @rkh ... rather lost in the auth/scopes code. + token = env['HTTP_TOKEN'] + halt 403, 'no token' unless token + halt 403, 'internal' unless token == Travis.config.tokens.internal + respond_with service(:update_artifact, params) + end end end end From de692185c6824b233d1f1f4d22ca692ef29c4795 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 30 Jan 2013 10:06:20 +0100 Subject: [PATCH 032/165] bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 52630c30..aeecbe29 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: b8d0d63f433c8e63472b97b3c287b99d31027ecb + revision: 26b751e65d7c821db25fa36dc2595a18bd7c7c1b specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From ac08027149fdf2bdae860e3acce3989d77704e3c Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Wed, 30 Jan 2013 11:24:51 +0100 Subject: [PATCH 033/165] bump travis-core --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index aeecbe29..089f1062 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/getsentry/raven-ruby.git - revision: ab0e8e5a14c416d38686de9a20f436e005efe735 + revision: 0bf46f9e957b179a5d0ce1295840eaff89d8146a specs: sentry-raven (0.4.2) faraday (>= 0.7.6) @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 26b751e65d7c821db25fa36dc2595a18bd7c7c1b + revision: c8a51b98b49ac69a527715d9a6f058572daf5fe8 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From 7b3c1b62154b9833f542f943dc9d5e9272f6260b Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 30 Jan 2013 12:57:28 +0100 Subject: [PATCH 034/165] update core, support and rack-ssl --- Gemfile.lock | 6 +++--- travis-api.gemspec | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 089f1062..c3ba7970 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: c8a51b98b49ac69a527715d9a6f058572daf5fe8 + revision: 7e5772be7a2837cf5631a2690c52b36dffae4d35 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -75,7 +75,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-support.git - revision: ff712aca1083a588974f835a84c574e6976aeb29 + revision: a288008629ae7eab18c529008880d364daca82ce specs: travis-support (0.0.1) @@ -94,7 +94,7 @@ PATH newrelic_rpm (~> 3.5.0) pg (~> 0.13.2) rack-contrib (~> 1.1) - rack-ssl (~> 1.3) + rack-ssl (~> 1.3, >= 1.3.3) redcarpet (~> 2.1) sinatra (~> 1.3) sinatra-contrib (~> 1.3) diff --git a/travis-api.gemspec b/travis-api.gemspec index 38449832..11927410 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -171,7 +171,7 @@ Gem::Specification.new do |s| s.add_dependency 'sinatra', '~> 1.3' s.add_dependency 'sinatra-contrib', '~> 1.3' s.add_dependency 'redcarpet', '~> 2.1' - s.add_dependency 'rack-ssl', '~> 1.3' + s.add_dependency 'rack-ssl', '~> 1.3', '>= 1.3.3' s.add_dependency 'rack-contrib', '~> 1.1' end From 06dda8f802f009c3b5bf6b64ad99a7da9c0f150f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 1 Feb 2013 02:44:53 +0100 Subject: [PATCH 035/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index c3ba7970..9d0a16df 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 7e5772be7a2837cf5631a2690c52b36dffae4d35 + revision: 6a64950402618a791eaa4b459239d2b6715e251b specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From 01bb1c55c2eaa0aec5ea0c4a55467d070ce919ac Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 3 Feb 2013 17:38:24 +0100 Subject: [PATCH 036/165] Use ps-db-encryption branch --- Gemfile | 2 +- Gemfile.lock | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index b0810ca4..c393b1d0 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ ruby '1.9.3' rescue nil source :rubygems gemspec -gem 'travis-core', github: 'travis-ci/travis-core' +gem 'travis-core', github: 'travis-ci/travis-core', branch: 'ps-db-encryption' gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' gem 'sinatra' #github: 'sinatra/sinatra' diff --git a/Gemfile.lock b/Gemfile.lock index 9d0a16df..3ad48b8a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,8 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 6a64950402618a791eaa4b459239d2b6715e251b + revision: 0dc3bcee4d3a54d057085355d731c3186c61c38d + branch: ps-db-encryption specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From 5695eabd953ef60010502de830b1d409655e7b72 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 3 Feb 2013 19:03:55 +0100 Subject: [PATCH 037/165] Update travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 3ad48b8a..c4aba7c9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 0dc3bcee4d3a54d057085355d731c3186c61c38d + revision: 2302df3b30b533d675dca8212648768058f69cd3 branch: ps-db-encryption specs: travis-core (0.0.1) From 2baa5c9ec3f3b6e0fc7cf72acbb653af0a56eee9 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 4 Feb 2013 13:49:12 +0100 Subject: [PATCH 038/165] Use travis-core from master --- Gemfile | 2 +- Gemfile.lock | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index c393b1d0..b0810ca4 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ ruby '1.9.3' rescue nil source :rubygems gemspec -gem 'travis-core', github: 'travis-ci/travis-core', branch: 'ps-db-encryption' +gem 'travis-core', github: 'travis-ci/travis-core' gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' gem 'sinatra' #github: 'sinatra/sinatra' diff --git a/Gemfile.lock b/Gemfile.lock index c4aba7c9..c01bedae 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,8 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 2302df3b30b533d675dca8212648768058f69cd3 - branch: ps-db-encryption + revision: 299ceefc5dff40a41271d1508a9931857354458f specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -134,7 +133,7 @@ GEM arel (3.0.2) atomic (1.0.1) avl_tree (1.1.3) - backports (2.7.1) + backports (2.8.2) builder (3.0.4) bunny (0.8.0) celluloid (0.12.4) @@ -179,7 +178,7 @@ GEM atomic (~> 1.0) avl_tree (~> 1.1.2) hitimes (~> 1.1) - mime-types (1.19) + mime-types (1.20.1) mocha (0.13.2) metaclass (~> 0.0.1) multi_json (1.5.0) @@ -202,7 +201,7 @@ GEM slop (~> 3.4) puma (1.6.3) rack (~> 1.2) - pusher (0.11.2) + pusher (0.11.3) multi_json (~> 1.0) signature (~> 0.1.6) rack (1.4.4) From 06e4d1918416d85a436e3e9f9fc77b6b44828ecb Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 5 Feb 2013 16:49:26 +0100 Subject: [PATCH 039/165] Bump travis-core --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c01bedae..2c96cd5b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 299ceefc5dff40a41271d1508a9931857354458f + revision: dee8d862b9ac450d799b488af87a51e8adfd6a81 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -154,7 +154,7 @@ GEM facter (1.6.17) factory_girl (2.4.2) activesupport - faraday (0.8.4) + faraday (0.8.5) multipart-post (~> 1.1) foreman (0.61.0) thor (>= 0.13.6) From 87088496460353a6668254a2048e2a57812e6558 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 5 Feb 2013 17:15:06 +0100 Subject: [PATCH 040/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2c96cd5b..e1d4958d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: dee8d862b9ac450d799b488af87a51e8adfd6a81 + revision: c17052b885a90a3433407c8832fd272ea2e2a6e0 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From 0eadcfedbdbfc3d000c6ac920eccbb24e32592cf Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 6 Feb 2013 14:20:03 +0100 Subject: [PATCH 041/165] Use redis for sidekiq from config also on staging --- lib/travis/api/app.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 0bd99d02..f6c332a2 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -112,11 +112,13 @@ module Travis::Api Travis::Database.connect Travis::Features.start - if Travis.env == 'production' + if Travis.env == 'production' || Travis.env == 'staging' Sidekiq.configure_client do |config| config.redis = Travis.config.redis.merge(size: 1, namespace: Travis.config.sidekiq.namespace) end + end + if Travis.env == 'production' Raven.configure do |config| config.dsn = Travis.config.sentry.dsn end if Travis.config.sentry From 273cd6c2e3ac3080b7659a30a0c2f398a35917d7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 7 Feb 2013 01:57:31 +0100 Subject: [PATCH 042/165] Bump travis-core --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e1d4958d..2e1ec3f3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: c17052b885a90a3433407c8832fd272ea2e2a6e0 + revision: bc4a97f3f23c5588943ceec5e6558ce5aacde3f9 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -222,7 +222,7 @@ GEM thor (>= 0.14.6, < 2.0) rake (0.9.6) rb-fsevent (0.9.3) - rdoc (3.12) + rdoc (3.12.1) json (~> 1.4) redcarpet (2.2.2) redis (3.0.2) From 903b9799f5bbb3e0a39a4a2db0e6bb5ce5e44bf5 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 7 Feb 2013 15:21:39 +0100 Subject: [PATCH 043/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2e1ec3f3..e7abe623 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: bc4a97f3f23c5588943ceec5e6558ce5aacde3f9 + revision: d0039167cecebdd99f976144cc5ff0f2c7c40a9b specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From 0aa2d6566c569db20195af11e419f8cf6d6703f3 Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Thu, 7 Feb 2013 22:35:35 +0100 Subject: [PATCH 044/165] bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index e7abe623..37d09bf7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: d0039167cecebdd99f976144cc5ff0f2c7c40a9b + revision: 4d4fc4f4d18624278ad552d037a574ce8fdd77b0 specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From bfdb5f02943a6d6d6c1cefbab6573fa9ce0f90c7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 8 Feb 2013 23:58:06 +0100 Subject: [PATCH 045/165] Bump travis-core --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e7abe623..50acdc22 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: d0039167cecebdd99f976144cc5ff0f2c7c40a9b + revision: 7d41b8c9951ae78fe8c5946ab55b5ce0f2713d8e specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -204,7 +204,7 @@ GEM pusher (0.11.3) multi_json (~> 1.0) signature (~> 0.1.6) - rack (1.4.4) + rack (1.4.5) rack-cache (1.2) rack (>= 0.4) rack-protection (1.3.2) From 7e005aad1baa7cc5de18f36346a2547f5013d32f Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sun, 10 Feb 2013 19:50:01 +0100 Subject: [PATCH 046/165] use travis-core/sf-log-models --- Gemfile | 2 +- Gemfile.lock | 17 +++++++++-------- lib/travis/api/app/endpoint/artifacts.rb | 12 +++--------- lib/travis/api/app/endpoint/jobs.rb | 2 +- lib/travis/api/app/endpoint/logs.rb | 21 +++++++++++++++++++++ lib/travis/api/app/responders/plain.rb | 4 ++-- 6 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 lib/travis/api/app/endpoint/logs.rb diff --git a/Gemfile b/Gemfile index b0810ca4..d28ce3bb 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ ruby '1.9.3' rescue nil source :rubygems gemspec -gem 'travis-core', github: 'travis-ci/travis-core' +gem 'travis-core', github: 'travis-ci/travis-core', branch: 'sf-log-models' gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' gem 'sinatra' #github: 'sinatra/sinatra' diff --git a/Gemfile.lock b/Gemfile.lock index 37d09bf7..57646ac4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ GIT remote: git://github.com/getsentry/raven-ruby.git - revision: 0bf46f9e957b179a5d0ce1295840eaff89d8146a + revision: f6a97f1544480645c4dfdb4d1e9e97ede1e737a9 specs: - sentry-raven (0.4.2) + sentry-raven (0.4.3) faraday (>= 0.7.6) hashie multi_json (~> 1.0) @@ -45,7 +45,8 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 4d4fc4f4d18624278ad552d037a574ce8fdd77b0 + revision: 258d823c367a13db76db87d2f42942ee7af8a041 + branch: sf-log-models specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -161,7 +162,7 @@ GEM hashie (1.2.0) hashr (0.0.22) hike (1.2.1) - hitimes (1.1.1) + hitimes (1.2.0) hubble (0.1.2) yajl-ruby (~> 1.1) i18n (0.6.1) @@ -178,7 +179,7 @@ GEM atomic (~> 1.0) avl_tree (~> 1.1.2) hitimes (~> 1.1) - mime-types (1.20.1) + mime-types (1.21) mocha (0.13.2) metaclass (~> 0.0.1) multi_json (1.5.0) @@ -204,7 +205,7 @@ GEM pusher (0.11.3) multi_json (~> 1.0) signature (~> 0.1.6) - rack (1.4.4) + rack (1.4.5) rack-cache (1.2) rack (>= 0.4) rack-protection (1.3.2) @@ -228,7 +229,7 @@ GEM redis (3.0.2) redis-namespace (1.2.1) redis (~> 3.0.0) - rerun (0.7.1) + rerun (0.8.0) listen rollout (1.1.0) rspec (2.12.0) @@ -276,7 +277,7 @@ GEM tzinfo (0.3.35) uuidtools (2.1.3) yajl-ruby (1.1.0) - yard (0.8.3) + yard (0.8.4.1) PLATFORMS ruby diff --git a/lib/travis/api/app/endpoint/artifacts.rb b/lib/travis/api/app/endpoint/artifacts.rb index 1c718e81..4f465f97 100644 --- a/lib/travis/api/app/endpoint/artifacts.rb +++ b/lib/travis/api/app/endpoint/artifacts.rb @@ -4,18 +4,12 @@ class Travis::Api::App class Endpoint # Artifacts are generated by builds. Currently we only expose logs as # artifacts + # + # DEPRECATED will be removed as soon as the client uses /logs/:id class Artifacts < Endpoint # Fetches an artifact by it's *id*. get '/:id' do |id| - respond_with service(:find_artifact, params) - end - - put '/:id' do |id| - # TODO @rkh ... rather lost in the auth/scopes code. - token = env['HTTP_TOKEN'] - halt 403, 'no token' unless token - halt 403, 'internal' unless token == Travis.config.tokens.internal - respond_with service(:update_artifact, params) + respond_with service(:find_log, params) end end end diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index 3759316c..966ef7cd 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -12,7 +12,7 @@ class Travis::Api::App end get '/:job_id/log' do - resource = service(:find_artifact, params).run + resource = service(:find_log, params).run if !resource || resource.archived? archived_log_path = archive_url("/jobs/#{params[:job_id]}/log.txt") diff --git a/lib/travis/api/app/endpoint/logs.rb b/lib/travis/api/app/endpoint/logs.rb new file mode 100644 index 00000000..83692be5 --- /dev/null +++ b/lib/travis/api/app/endpoint/logs.rb @@ -0,0 +1,21 @@ +require 'travis/api/app' + +class Travis::Api::App + class Endpoint + # Logs are generated by builds. + class Logs < Endpoint + # Fetches a log by it's *id*. + get '/:id' do |id| + respond_with service(:find_log, params) + end + + put '/:id' do |id| + # TODO @rkh ... rather lost in the auth/scopes code. + token = env['HTTP_TOKEN'] + halt 403, 'no token' unless token + halt 403, 'internal' unless token == Travis.config.tokens.internal + respond_with service(:update_log, params) + end + end + end +end diff --git a/lib/travis/api/app/responders/plain.rb b/lib/travis/api/app/responders/plain.rb index 89328c96..c1bc0dfa 100644 --- a/lib/travis/api/app/responders/plain.rb +++ b/lib/travis/api/app/responders/plain.rb @@ -1,12 +1,12 @@ module Travis::Api::App::Responders class Plain < Base def apply? - # make sure that we don't leak anything by processing only Artifact::Log + # make sure that we don't leak anything by processing only Log # instances here. I don't want to create entire new API builder just # for log's content for now. # # TODO: think how to handle other formats correctly - options[:format] == 'txt' && resource.is_a?(Artifact::Log) + options[:format] == 'txt' && resource.is_a?(Log) end def apply From be52ae9b1dfd0f46a3f8fe7f02a9698f0cde4f6a Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sun, 10 Feb 2013 22:43:02 +0100 Subject: [PATCH 047/165] use travis-core/master --- Gemfile | 2 +- Gemfile.lock | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index d28ce3bb..b0810ca4 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ ruby '1.9.3' rescue nil source :rubygems gemspec -gem 'travis-core', github: 'travis-ci/travis-core', branch: 'sf-log-models' +gem 'travis-core', github: 'travis-ci/travis-core' gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' gem 'sinatra' #github: 'sinatra/sinatra' diff --git a/Gemfile.lock b/Gemfile.lock index 57646ac4..0e42cf34 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -46,7 +46,6 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git revision: 258d823c367a13db76db87d2f42942ee7af8a041 - branch: sf-log-models specs: travis-core (0.0.1) actionmailer (~> 3.2.11) From d633b84eea3e7d5a7c7fef0efdcc0fef060913b8 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 11 Feb 2013 20:59:55 +0100 Subject: [PATCH 048/165] Bump travis-core --- Gemfile.lock | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0e42cf34..c5b09155 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,11 +45,11 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 258d823c367a13db76db87d2f42942ee7af8a041 + revision: 1a4970b11a2112b9216d2b8c63331b8de62049b1 specs: travis-core (0.0.1) - actionmailer (~> 3.2.11) - activerecord (~> 3.2.11) + actionmailer (~> 3.2.12) + activerecord (~> 3.2.12) coder (~> 0.3.0) data_migrations (~> 0.0.1) gh @@ -58,7 +58,7 @@ GIT multi_json postmark-rails (~> 0.4.1) pusher (~> 0.11.0) - railties (~> 3.2.11) + railties (~> 3.2.12) rake redis (~> 3.0) rollout (~> 1.1.0) @@ -105,28 +105,28 @@ PATH GEM remote: http://rubygems.org/ specs: - actionmailer (3.2.11) - actionpack (= 3.2.11) + actionmailer (3.2.12) + actionpack (= 3.2.12) mail (~> 2.4.4) - actionpack (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) + actionpack (3.2.12) + activemodel (= 3.2.12) + activesupport (= 3.2.12) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.4) - rack (~> 1.4.0) + rack (~> 1.4.5) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) - activemodel (3.2.11) - activesupport (= 3.2.11) + activemodel (3.2.12) + activesupport (= 3.2.12) builder (~> 3.0.0) - activerecord (3.2.11) - activemodel (= 3.2.11) - activesupport (= 3.2.11) + activerecord (3.2.12) + activemodel (= 3.2.12) + activesupport (= 3.2.12) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activesupport (3.2.11) + activesupport (3.2.12) i18n (~> 0.6) multi_json (~> 1.0) addressable (2.3.2) @@ -166,7 +166,7 @@ GEM yajl-ruby (~> 1.1) i18n (0.6.1) journey (1.0.4) - json (1.7.6) + json (1.7.7) listen (0.7.2) mail (2.4.4) i18n (>= 0.4.0) @@ -181,7 +181,7 @@ GEM mime-types (1.21) mocha (0.13.2) metaclass (~> 0.0.1) - multi_json (1.5.0) + multi_json (1.5.1) multipart-post (1.1.5) net-http-persistent (2.8) net-http-pipeline (1.0.1) @@ -213,9 +213,9 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) - railties (3.2.11) - actionpack (= 3.2.11) - activesupport (= 3.2.11) + railties (3.2.12) + actionpack (= 3.2.12) + activesupport (= 3.2.12) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) From 0a2d66be931e440d1c277c4c73a0418ebed0cbda Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Mon, 11 Feb 2013 23:05:54 -0800 Subject: [PATCH 049/165] remove hubble, and in the process also update sentry --- Gemfile.lock | 6 +----- travis-api.gemspec | 1 - 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c5b09155..d6a1d497 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/getsentry/raven-ruby.git - revision: f6a97f1544480645c4dfdb4d1e9e97ede1e737a9 + revision: e520389a56d099276c167d8b442967c7fa549ecd specs: sentry-raven (0.4.3) faraday (>= 0.7.6) @@ -90,7 +90,6 @@ PATH specs: travis-api (0.0.1) backports (~> 2.5) - hubble (~> 0.1) newrelic_rpm (~> 3.5.0) pg (~> 0.13.2) rack-contrib (~> 1.1) @@ -162,8 +161,6 @@ GEM hashr (0.0.22) hike (1.2.1) hitimes (1.2.0) - hubble (0.1.2) - yajl-ruby (~> 1.1) i18n (0.6.1) journey (1.0.4) json (1.7.7) @@ -275,7 +272,6 @@ GEM polyglot (>= 0.3.1) tzinfo (0.3.35) uuidtools (2.1.3) - yajl-ruby (1.1.0) yard (0.8.4.1) PLATFORMS diff --git a/travis-api.gemspec b/travis-api.gemspec index 11927410..f206e4d1 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -163,7 +163,6 @@ Gem::Specification.new do |s| s.add_dependency 'travis-support' s.add_dependency 'travis-core' - s.add_dependency 'hubble', '~> 0.1' s.add_dependency 'backports', '~> 2.5' s.add_dependency 'pg', '~> 0.13.2' s.add_dependency 'newrelic_rpm', '~> 3.5.0' From 51c6e7d3925800a3c5dfa6be9a13b17963cd1ee6 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Tue, 12 Feb 2013 00:08:37 -0800 Subject: [PATCH 050/165] Revert "remove hubble, and in the process also update sentry" revert for now as travis-core uses 'rescue' which uses travis-support which uses hubble several places where this could be fixed first, but step one is to get all apps using sentry This reverts commit 0a2d66be931e440d1c277c4c73a0418ebed0cbda. --- Gemfile.lock | 6 +++++- travis-api.gemspec | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index d6a1d497..c5b09155 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/getsentry/raven-ruby.git - revision: e520389a56d099276c167d8b442967c7fa549ecd + revision: f6a97f1544480645c4dfdb4d1e9e97ede1e737a9 specs: sentry-raven (0.4.3) faraday (>= 0.7.6) @@ -90,6 +90,7 @@ PATH specs: travis-api (0.0.1) backports (~> 2.5) + hubble (~> 0.1) newrelic_rpm (~> 3.5.0) pg (~> 0.13.2) rack-contrib (~> 1.1) @@ -161,6 +162,8 @@ GEM hashr (0.0.22) hike (1.2.1) hitimes (1.2.0) + hubble (0.1.2) + yajl-ruby (~> 1.1) i18n (0.6.1) journey (1.0.4) json (1.7.7) @@ -272,6 +275,7 @@ GEM polyglot (>= 0.3.1) tzinfo (0.3.35) uuidtools (2.1.3) + yajl-ruby (1.1.0) yard (0.8.4.1) PLATFORMS diff --git a/travis-api.gemspec b/travis-api.gemspec index f206e4d1..11927410 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -163,6 +163,7 @@ Gem::Specification.new do |s| s.add_dependency 'travis-support' s.add_dependency 'travis-core' + s.add_dependency 'hubble', '~> 0.1' s.add_dependency 'backports', '~> 2.5' s.add_dependency 'pg', '~> 0.13.2' s.add_dependency 'newrelic_rpm', '~> 3.5.0' From 9f1f1fecda10e415f3f7f8a3e1499dd7eacaec67 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 13 Feb 2013 12:02:06 +0100 Subject: [PATCH 051/165] Bump travis-core --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index c5b09155..bd9a2744 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 1a4970b11a2112b9216d2b8c63331b8de62049b1 + revision: 2f330bfef494a05361c5e957a100fd8f4be9d3e1 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -181,7 +181,7 @@ GEM mime-types (1.21) mocha (0.13.2) metaclass (~> 0.0.1) - multi_json (1.5.1) + multi_json (1.6.0) multipart-post (1.1.5) net-http-persistent (2.8) net-http-pipeline (1.0.1) From a148575fe6f344d069a2777c57535a0e2f84d08f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 13 Feb 2013 13:07:38 +0100 Subject: [PATCH 052/165] Add newrelic_rpm to Gemfile to hopefully fix bundler error when running tests --- Gemfile | 1 + Gemfile.lock | 1 + 2 files changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index b0810ca4..673e2fa2 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,7 @@ gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' gem 'sinatra' #github: 'sinatra/sinatra' gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil +gem 'newrelic_rpm', '~> 3.5.5' # TODO need to release the gem as soon i'm certain this change makes sense gem 'simple_states', github: 'svenfuchs/simple_states', branch: 'sf-set-state-early' diff --git a/Gemfile.lock b/Gemfile.lock index bd9a2744..6049c1c5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -291,6 +291,7 @@ DEPENDENCIES metriks (= 0.9.9.2) micro_migrations! mocha (~> 0.12) + newrelic_rpm (~> 3.5.5) pry puma rack-cache (~> 1.2) From afe7de8e724544f21f50a9abfad8dc292aa51a19 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 13 Feb 2013 13:20:06 +0100 Subject: [PATCH 053/165] Depend on newrelic_rpm in ~> 3.5.5.0 versions --- Gemfile | 1 - Gemfile.lock | 5 ++--- travis-api.gemspec | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 673e2fa2..b0810ca4 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,6 @@ gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' gem 'sinatra' #github: 'sinatra/sinatra' gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil -gem 'newrelic_rpm', '~> 3.5.5' # TODO need to release the gem as soon i'm certain this change makes sense gem 'simple_states', github: 'svenfuchs/simple_states', branch: 'sf-set-state-early' diff --git a/Gemfile.lock b/Gemfile.lock index 6049c1c5..08f1348d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,7 +91,7 @@ PATH travis-api (0.0.1) backports (~> 2.5) hubble (~> 0.1) - newrelic_rpm (~> 3.5.0) + newrelic_rpm (~> 3.5.5.0) pg (~> 0.13.2) rack-contrib (~> 1.1) rack-ssl (~> 1.3, >= 1.3.3) @@ -185,7 +185,7 @@ GEM multipart-post (1.1.5) net-http-persistent (2.8) net-http-pipeline (1.0.1) - newrelic_rpm (3.5.6.46) + newrelic_rpm (3.5.5.38) pg (0.13.2) polyglot (0.3.3) postmark (0.9.18) @@ -291,7 +291,6 @@ DEPENDENCIES metriks (= 0.9.9.2) micro_migrations! mocha (~> 0.12) - newrelic_rpm (~> 3.5.5) pry puma rack-cache (~> 1.2) diff --git a/travis-api.gemspec b/travis-api.gemspec index 11927410..a4b7755b 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -166,7 +166,7 @@ Gem::Specification.new do |s| s.add_dependency 'hubble', '~> 0.1' s.add_dependency 'backports', '~> 2.5' s.add_dependency 'pg', '~> 0.13.2' - s.add_dependency 'newrelic_rpm', '~> 3.5.0' + s.add_dependency 'newrelic_rpm', '~> 3.5.5.0' s.add_dependency 'thin', '~> 1.4' s.add_dependency 'sinatra', '~> 1.3' s.add_dependency 'sinatra-contrib', '~> 1.3' From 4f05de7214a68b3e8822c6236dd14321db7c09f8 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 13 Feb 2013 17:35:26 +0100 Subject: [PATCH 054/165] update core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 08f1348d..e9d89868 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 2f330bfef494a05361c5e957a100fd8f4be9d3e1 + revision: 0e923ed738b1c9384f4cb73e34eb7cbb32f0768f specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From 48cf45c5f628d2d2b8ced1629684e18bae73b50b Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 13 Feb 2013 17:55:11 +0100 Subject: [PATCH 055/165] disable new relic --- Gemfile.lock | 2 -- config.ru | 6 ++++-- lib/travis/api/app/base.rb | 8 ++++---- travis-api.gemspec | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e9d89868..af003d6b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -91,7 +91,6 @@ PATH travis-api (0.0.1) backports (~> 2.5) hubble (~> 0.1) - newrelic_rpm (~> 3.5.5.0) pg (~> 0.13.2) rack-contrib (~> 1.1) rack-ssl (~> 1.3, >= 1.3.3) @@ -185,7 +184,6 @@ GEM multipart-post (1.1.5) net-http-persistent (2.8) net-http-pipeline (1.0.1) - newrelic_rpm (3.5.5.38) pg (0.13.2) polyglot (0.3.3) postmark (0.9.18) diff --git a/config.ru b/config.ru index a570b9e2..8fb5947a 100644 --- a/config.ru +++ b/config.ru @@ -8,9 +8,11 @@ require 'travis/api/app' require 'core_ext/module/load_constants' models = Travis::Model.constants.map(&:to_s) -only = [/^(ActiveRecord|ActiveModel|Travis|GH|#{models.join('|')})/] +only = [/^(ActiveRecord|ActiveModel|Travis|GH|#{models.join('|')})/] +skip = ['Travis::Memory', 'GH::ResponseWrapper', 'Travis::NewRelic'] + [Travis::Api, Travis, GH].each do |target| - target.load_constants! :only => only, :skip => ['Travis::Memory', 'GH::ResponseWrapper'], :debug => false + target.load_constants! :only => only, :skip => skip, :debug => false end run Travis::Api::App.new diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index 92031836..a100398a 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -1,6 +1,6 @@ require 'travis/api/app' require 'sinatra/base' -require 'new_relic/agent/instrumentation/rack' +#require 'new_relic/agent/instrumentation/rack' class Travis::Api::App # Superclass for any endpoint and middleware. @@ -8,9 +8,9 @@ class Travis::Api::App class Base < Sinatra::Base register Extensions::SmartConstants - configure :production do - require 'newrelic_rpm' - end + # configure :production do + # require 'newrelic_rpm' + # end error NotImplementedError do content_type :txt diff --git a/travis-api.gemspec b/travis-api.gemspec index a4b7755b..6c2ffd10 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -166,7 +166,7 @@ Gem::Specification.new do |s| s.add_dependency 'hubble', '~> 0.1' s.add_dependency 'backports', '~> 2.5' s.add_dependency 'pg', '~> 0.13.2' - s.add_dependency 'newrelic_rpm', '~> 3.5.5.0' + #s.add_dependency 'newrelic_rpm', '~> 3.5.5.0' s.add_dependency 'thin', '~> 1.4' s.add_dependency 'sinatra', '~> 1.3' s.add_dependency 'sinatra-contrib', '~> 1.3' From 2e6865d55ff3ae6483471a95cf5ef14e14b4d403 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Thu, 14 Feb 2013 19:12:26 +0100 Subject: [PATCH 056/165] don't run metrics etc in heroku console --- lib/travis/api/app.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index f6c332a2..c88a3b5d 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -100,6 +100,10 @@ module Travis::Api private + def self.console? + defined? Travis::Console + end + def self.setup! setup_travis load_endpoints @@ -118,7 +122,7 @@ module Travis::Api end end - if Travis.env == 'production' + if Travis.env == 'production' and not console? Raven.configure do |config| config.dsn = Travis.config.sentry.dsn end if Travis.config.sentry From d902f44e9c26dab1b7d523f587b80281cca2d914 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 17 Feb 2013 14:01:04 +0100 Subject: [PATCH 057/165] Bump travis-support --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index af003d6b..28bd9c53 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -75,7 +75,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-support.git - revision: a288008629ae7eab18c529008880d364daca82ce + revision: 01d9ccd14f2cb99b2446cb6b49cb7abe93e38967 specs: travis-support (0.0.1) From 2b8d1f91615cf3f3d345c9c8089fbf3fbc7ae0f4 Mon Sep 17 00:00:00 2001 From: Steve Richert Date: Thu, 21 Feb 2013 20:56:16 -0500 Subject: [PATCH 058/165] Update the build status images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Badges… CONSOLIDATE! The Shields project is standardizing the design of code badges. Gemnasium and Code Climate are already on board. https://twitter.com/svenfuchs/status/300327379673436160 --- public/images/result/failing.png | Bin 1586 -> 1247 bytes public/images/result/passing.png | Bin 1791 -> 1416 bytes public/images/result/unknown.png | Bin 1678 -> 1131 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/public/images/result/failing.png b/public/images/result/failing.png index 46eda84ee223c2e811e6300c6acff48bffbb7756..ed9087edd499a8ea344dc1e5f214f2e6d096ca54 100644 GIT binary patch delta 1226 zcmV;*1U37z4BrVMiBL{Q4GJ0x0000DNk~Le0000+0000I2nGNE0Om2MWsxB#e*}R^ zL_t(|+U!_uOj}hLep;^U=m%C5Y|AtXM8>EjM%Dr*b_spd^)_4c-1G?BDF ze4D4|oadbTo^zg__wBt`;c~h3e*pRg*pLF-qx2%pY)F8EbGzLs6NTAMZXw--VOsQa zkx0ar%2n{;Fw)R$TsXxG3o0V%C=60A44&v)4hD`G#c;L?R)G`;>6Rtv2tw=6^6Uw=9wNjhaUz9Vb0dU z7v!auV|Sq@h&Wc7n=g*8rxEABBJZHx#}04mhoj>K9*c z#x`>i%IluT*x^^frV0yR+a4_!xsta(K!!#KZ9x(Fn)&oN=G>p*&eAgKliG#-&ye4L z97=3+I-L$pO--;`t(cjaL3MRCc%BzG%@92W(alD$WysIZM_pZ=f9S*G@em&uO2UbW z;^d2a$j_0A9k}3jVR7*foP42y+SffZ$g=K&H^9?LVdL2+B#0yBSb1ga5?yoZ<-IUE zo+Cc@sb?|ZJVgA&cW3Z@$NRW3>xr3PiloAfkB?(@brm@|IT#%sg-WH05r9FX(TJOs z3&X}UAM^9`qK|~ae@NoGBwI^|6O&hz6pK9S~+<>h7ak(ZYz`iPE^g5?+~f1-JZ%Qc~}p%G5I1&6KM zadXatkg#o@uG<*HO4gQhYA%E7N~Kctmnm>R^?XdeK5D3e|H@R{+)^aWF^rp?oke?l zJLMRb8=Ouj@qK-L#50?im=MQHPfRqYba!{7tE-FJ%m)+eb~)zno4yEcc&_5tkzpMC zc7(X!C&s{Ze`BG;LP#1)B)E)Yb=(q~)j3TT${Y9LF#*i34)o*FhewhoUxkoBBZ>Z% zR#sLJ3WaE+9LGVg*F&LD(5dnJ{TrEE;2BsxT3A@1kYVA+Os!T^o%xZEmD>J{n=$S4 z*O#y}SHB_V(w~$+$e-|w=Vq#)%249ksvkvqE%h7Ke_N?v&Sh=kupSEI;-VM3N=sn> z#ErMg9-^_?dH3PK>9aWfgeAE!cDp^LcUUiROPf9i6Ug%JF%()WMQ-5OQLKFBO8$5K zZ|+q#<&hw~`SUA~_KorSi1{uSmmhD! oZOxI&AQx2&Tp%r9RQ)Bu07}2kfu>(l{Qv*}07*qoM6N<$f`OM|e*gdg delta 1567 zcmV+)2H^SM39<|!iBL{Q4GJ0x0000DNk~Le0000|0000D2nGNE06O$Jxsf3!e+AS@ zL_t(|+SFHVOq*2{e%{g+S_cbIjXH_~16`CczyKXeJF zIXU;^eB689=iGa%sH*yOMMXuwf7NP5Y-}uIVq&mZDIp;N>1WPhMST22jhpXqtWe6! z%T?}7O-;e;^&$`mEZRgSCnw{j?@l1|A;vTi_?8wG!7ws93g&y0lUTiaHL9zt0Y!Nr zXJ%yyJt?EjE##xPq~wAAQ|$HyeMDn*9v5_WVNFm)Tt-I3TwYTXl3raCe<9Tq7FB;Y zo`Hn?e0)a7)p%e3oH^zn)|SF~=@O=>?IT;+pRczdQ$mgNp=z_)uy^-v(LQweFp`s! zkdu>xHVo9A|m!-10Ge_}LKP$sLzf+|9xoi;x>G=xb)x1Kg_+$e0B&YeGx%*;&K zD49GyGBSeK)~^?HTp2AbEqIYig^4g05u5F+tExmy*5^6)AxR{Y(Mh!8&>|o52A0^u870OO_ZA=%RjY-BxUP zV*}aRq4IR5oO4daIGy6W93H*} zdrHcjFFn64Wl#;G``R^F=;rUGz??|E{`aR(W6PUc1poBQf6oHRya*E|wWy$w&chTT zLolQXN-ifcTI?Q*le2OqC4Da;as*!|U*oTNol=Sg}3_E-dT5R93LnMsLl4I~3m-qGS z*9l?!;qiFH96PX3WkicTMjQK-kj4J~8W_OJ=d2nK9Bg^;q#2oF#nXFZsGu9 z3^C#p8I4AvCnZ1R`5nq{P^rUXlH?o{+n7uy_~?9N-%MdUMuIUU{q(G0A2ZW45wY2y zC?~R)Yn1QE!c&dN(9X_hfv(XB@4>WMFj z2a!dTc=XtEE+Q5qQXo(bmuH%W$VU-k=+>2>ovd;taaun`(_=)ZXov3=LgecwP6&

+XhJ8GlBlu&7Aog~%k%-hhjb_~};A*ogH1!S~<9F0IWMj!iosxi8 R*c|`>002ovPDHLkV1hor0OSAw diff --git a/public/images/result/passing.png b/public/images/result/passing.png index 1d1bbe396fad82108a229a8c172a5ee4a0ea4a13..9926569875f48a0663cb6218a4394766e7851137 100644 GIT binary patch delta 1396 zcmV-)1&jLs4TuXNiBL{Q4GJ0x0000DNk~Le0000@0000I2nGNE03Oj(l93@Ne+4Q@ zL_t(|+SFKWOq)d<|2W*%w5KkdO&k0BHhSmgpumhM4f8G{a#ASjuED9O5YNZ!N8N*Yu%p=sq}V|H&`U z-T&@>clW!y|2@ycb#``20bC)-e?buJsZ;$3A?qd33A($xgC-cY=Tq84Ni?d{6@k;~ z%n9ZwcI*f>%Mmynj-Zaf5qhE_=%R(-PD27Zp`oDxeSLk* z?-qsf78Mntw6v7v&1N&k$H(E@pQmW4ad~(_T@9&7fyi(f?k}0p*005;&5A5l1uLUA zI%`0;sl>~7XWoeR0WD6Sf9PR6)P5MPME^t$zB=c`g=-wEua*}hQIhV}hW7VbRu6l+ z?b};=+?;B9_~S_@E*6VXR#t}0%uGy8O+l;G!fv5}3k6Q?LTMC6jfx^Np>*ZhUk)(g@G+sFAh#`bH%NM+`6yGxI>#ld7UK`0b@i9-<;6~znTD;lj&Ip*f(c#eM)%}L_L--($a$F=4O_s98}1EifOcniu9It2nU2R{61^K^}!lQ$g*dp zRiLBRiG`I(HbL6%otK7?9OH^lBW5EOm#ny0zPoT8*DJktntM%s`=ouPlEtF@)b1^q zaLK5}#73l&U@C~bEgq;$hsg!?b$Dh zAz{GdPx=pDuJpb2$qlUWe|e@p`aBrp-KU%L#*a-n`*siCX5beCi*q7z;8zZgymUH) z`F8!x%ir_qja6WA9!N^v-!afW7yj7IM@fN%N+bX0�ZbdBBbn^-T0000+ee>OO4=Pa<(>HC}yv|Dk_3~ti9*?$S)`u*MCZC>T`X>5|#LJe`JMe1uo`X zd}003z$iRE4|;}rpeD{L5)cF~;cKzv*6rJQzn_n5>*|o0kbt>!=i&!8Uc`W*@ulWw6y)c_ z(bUBCj4YSi7<*G0F!y_Ue=smG5aDy3)yi$DojH3JnVFeLVnEZnhuxx8D_8P8x>c7h zUBcqLydYfBvB|!I-8PCz`m{$rf{mjsy(zYoa#W>%4zt0`=f%zvxCZax!u#ifYdi0L z0f)zd3zqXR=}d49xlnxLBW_3bijMP%6IDyA(D+YdgwM*3EofkCe`Ifo&tZCP%+C~L zT*;Eoq7n(@$oy+G8t~=UUm-0mjemS=YbyjHz)vqQhSFFOg+H8?Y`$gNR;*pKmf5Bv z+%Exi^w*bP|28IBW+JuasGhvyQgW6?>kb`c-D z`Wd(nV4mbHiO&5^}J! zbth``Yawh8f1q~B;SgxDPw&irc(wi9K3$WJMi=ujTZJZfldPwbgxRTCDZ#4=siF`u zD>V%h*~iYGHxJzmaJRb;i7bVXUP5Am{54`!4_M~s@cCPBW`*rZ(tNoYm0P!9kKK;E z+(rDVQw-Xpl+n@A!I*iFS2wgr4h-x@#fshU_2Qeoe|x#Vzq-2c-n-cmv4Q~0AQOYl zlg%iaS;)X~!j@bPi_wAwzb%BLy9p*eOA&$#3mO+fU88}sw++@LEB3nf^Ev6+Qp;h| znnJ&%I!IDJzt?{c)(nZgg~^2q^CV&av=UAdS7M_gIxZrM<=JqZ@G@}Q)@{gQ6$7;^EmzRTt~<2~TLo^kIkEYZ&D^ff z?dETQyU&f)t5@U5k)OuIrZ|bU@S2lWJtYt*o)5mJMj9vC_PsOuf_}e zoIMaK{b*q9vrNuG(TqY|SaY76xSqPO@A5uee<(SRqNx&Kb$`@zKZ?&_FOTaw>tUT` zg|NyGr>9NQ4aj=z2T?6A$md6-ABAdU63Ty+=O}+t&h(A=Sj7;4My=tBTCJArDgA^A z6EHF|fWt7%<*QFwwK8ui^OCx_+HRodn98D>k0a?YkGaK zCm+f@m`B5y9KA=49<1@2fv1hwv6a0sf3bp07DLIL@J>hMi;^BA+ehonz}Q!4hCH4m zvv`sub-yzvuV766ECBC_7saPbcvTU6`WEHoiF8O}0|BhC;&p6PexArZ4$&-s+*3%b zdm{{UnNU!L(rOGi`5;)cMCpo%vL(R(2Cp#a#)#A9ygf|mf!)5gTkUGg+u4GTL|s8Y zUFqN>`1&;+OC@3_8w^AN=0?m)CDwery|MG?6&d!Ya@v_HLboGc{jUH60B6c(%9bRx Qg8%>k07*qoM6N<$g6~suPXGV_ diff --git a/public/images/result/unknown.png b/public/images/result/unknown.png index cb7abbda12ba406a470bca8a210781fcfea7c100..6f3e3e8712bb158284af0627bb64220fc61fadea 100644 GIT binary patch delta 1109 zcmV-b1giUv4eJOYiBL{Q4GJ0x0000DNk~Le0000~0000I2nGNE0L5zgu#q7re*_Il zL_t(|+U!_MD7;Y=KQl(&43THZt4KCPk!Imh7BZBbNXde&jbdRXtSl%Cik-KzM3It| zlE^D0B(H_{+nC>}d;8||jsO3jsrfg}sngthzH`n!_jk`Z_xnaSGBRQ$qA4qz$O)95 zo=z@83syE8CMPGI1}5nK{@zspe+7n928+dFa%L1CA0OmGWHNkyev%td$B`RQ2a_Iv zsu>qWYilcMJ+sH7qoe#=R#wKWeqK;eK=t+Y-{b)FH{8(B@M|BAWc1K)D8IhG(%ah` zX+5(?xw*L%5fMQzFE2b-+rlTFspXEy(ElmRHA^0wj*N_?p`ju2_xGp$fBk*x?Cj)c zeSLjoHk)}|TwF{^NlDb(+e=GJODq?F!EZ%H1yxs9^L%e_k9Kx;NWGpCjEsy7N=Zqf zv9U3p7ZnxJ`T04mudh>MVhVuxJWB2 zD-;wIM5U#rHgd#NRaHeje?2{HgLP(RW_V5LV*S|ISWSO_UGe}WARvHhYHBDaCx-(^ zknivB5-hODIsuZf1t%mVPyNT znwlyPBP=Y8GBY#z&;bB^-~gf9)zw8=Sy`-`mzO8yZEbBV*X#9ce*+(BX=!wMdC8Rq z{g{{-nwy)m>radA0=l)eMURh7vId!`)9J`yFi3f2WhE^yFH>-EFarb|q3hw{!G55NID{N)A08gE3~?d>l9Q8Z ze0-b|6BBuSadE-xf7tV<38>hFnvnrfQBgcbDc#=Q(%s!1ZvYEIZZer{`lYfzqCDXv zIyzeV5IRa$27`yu0OX%~=%*9Q&SVqu{kAhN-&jk=(V@EQ*(1O zU0+|@0It+U`PS9dQAc=7)VfMSe^no(@Q+R6A^`(zWUR=3 z^j2iQkfWEw7JcvP>Wa%BG2m?lz(5D%v$HelAJq^N62fC-D%ODvdxTzGTpVZS>FKGa zKTSXj3kxmIe9aK8z-7La{^ecM{iWpo^mGcK3(oxeE6&9LT`)X7J(->P2Qw}hSNenb bOMn3YK44;CU%{3*00000NkvXXu0mjfcFPK4 delta 1660 zcmV-?27~$Q2#yUQiBL{Q4GJ0x0000DNk~Le0001A0000D2nGNE0M81t36UWue+Do~ zL_t(|+SFKEPgGYF{?5z*GTd*4K?dbAv|bRX7@*cF@TO_3#>S*3CG`PR^e41^FsU`_ z1NzcpliC>jP#@}pmnI^Zh_>|_HGIy2lEWIzT6n3>bH)|oR5m#Xjtd$P0l*?aB1 z_F3y&-(F`FRaJ9pYHD6aMMYuRf3jtWh=_oqC|HUmK0Y3~xw%-iYSp4VUmy^G&*zi6 zY11Z)vU~S#m5n_)ISH@Vi;0N|kVBTF@l#S#@X6-Qu-R;j@_Yt^0Vb14T6rFL^$Ms$Ajt1@ure_NB2lJN1y zjSE^kpX&GfF+M(yv9U1%`WOt1alQH}EVzb`%~jiz@S!f}Z9KhoP6m{FS zZk0KX!sg~?d{j{(&wTUD)XnSbC^}gu%kv!Xp%)!xT&!7H$Vkt?oqKmf{hr<)d#$&{`|P_hrMK`}G`JZ{9>?WF&6ixs5~h2W5=;@8YG4B6s5WarE`~ zp|!OYc88t#F=CePfBgJBxcd9iaIyhobVqTLFqI&vZ2ge&IlMW{`C0FCYb2eGryH?$ z&06H;<>A%fAUNSDCg=Wk{yZY1BH^Puu)Vz<4<9{5&6hQZjfsUV--auHT!GW+#LgW% zkr1CC2}*oioV-^YwMmIdqQ~tX!iww_)AZOK&LBWE2bgAFf30?h10#go?(QBz3#MLc zR$p%eY5?~hJV3PBOdfwO#t)bO{lW$8`C^aMKmYzqB1R?U5p>{+vU1}0ENL~kD||DF z;pftQpY#;1TStyMLC7D#FK5r9gAk?51ys#Zp(qGCPVaNu*Vl)P%uE?b0!~1T z&&6iTM^|^ZfAmK@Be0O1myF35B^!A7^=lb>@$!W{^IjH9rnGVKaY#!`g@c^KVJmYa zYt;3q8XYUaxHcf{Lg3@Cux2AB+KiIoVmQbVE>}NNh>BP)IVCv=c6CMztS|XcoRA*Q2PDRqq5(> zc01OsEu5w+5SXgNuSW=t@zRem$H;o>O0+5bQw*W8p`js(Ohz}$b1@146fu^Y=Gh7P zdHIC)NQyw4sO;?QM9#{ULV=wfodj4b(b%BOX;}>?0-7Ga3j==bPGlV>&3k4U@{=lpeF__PZ7t6f89`8ifpSjG#&`b7-;?`(P4FUwd~FO z{pj&yqLyrVX5i@OV7>g!FPpiOJ}dxQ7zP5Nf(=Kb`%SwEwm=a-jP ze+a+oA2nTFT_VqWG1te$#=njU2JmjAQj%uz-WMZ6By1FpH z4?;Qm<+TJ$T3VV=jzz+Iv4LJgJZE?b2?;oK@L Date: Fri, 22 Feb 2013 08:42:31 -0500 Subject: [PATCH 059/165] Add pending and error status images --- public/images/result/error.png | Bin 0 -> 932 bytes public/images/result/pending.png | Bin 0 -> 1494 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 public/images/result/error.png create mode 100644 public/images/result/pending.png diff --git a/public/images/result/error.png b/public/images/result/error.png new file mode 100644 index 0000000000000000000000000000000000000000..5e8f4b4c51a1b873fc2d036191d78ae4b08e6384 GIT binary patch literal 932 zcmV;V16%xwP)}1Gt8Y%e`tXSB2tZb$%B$Dz73oG(UStuJ3k|ZNZDet%W&F53!+nvjZ z)s>%9r~5sR@A=;I`JVIr-Wl8Y__#wvX2R?d3#g=|L@cD0FnhJ>>1oRV0Nvc&SP261 zp3y>~kjKimczt~pi^-$Cy}ikQ4ubrF5GFf7Ff$ITj*brb$QF$!CMNi-tE(fM?Uj|4 z(%RbkP7e^QW}FG{ka>D~lIQ1V`N$TH%FD|oJw06>A0H{3=OQL-X8n(C2fS!TMurRz z4@*Kqf*c$iNKa1>ZT%TwbX&&v%bDArKP12 zev^}vUvCE_l9-q%O-)TwR#wIU)z#JV^75i52v)nR5>s=*xw*MgUth1sI6gk6{PoJ!uQ@3%FOPbU#}m>2#(uxNykv~5tSmi-@-eb;M*tWS@cDe?uC6ZG+S;NY09SsH z0hrxxr@Xzr&E3ZsAi7*Gwy@dnTa^G^Fc_4+zCNOeUheMhrhaN_ih9uQ?rub77%Ktg zIW#mR0|Nt;5d*+{RtbxXiv)gTWJHfKIy$PyR=#QtB`+*2NJ~qLw70iY9vd4YpxCUh z9KN>j;THPncDTL0)lt_pO&ksf`xVuIlH;iw)`M|=oS&bwEYU)sxVSiu5y$LnB%BvU zIz2trD-OGlN;)|?VL2lv=;Gpn&*bD}K5>&_o_ep;)KuEceo;ZFs;UZEc|EB%vGj`k z&bPqdXY(%yVa3Xy(mw!%74821-fQKbD!4JM{!`_j00RJ-YA-D+l?6Hg0000MD$a zqewA;GSS7Mvdo(J!>;5fn(StJVPeb{SacV=kvTIj#3d?bar1&~a5Do&&?~*rf!oNk zh!*^#B92NOR#c$11^V~xd*9lRQi^fOwBt?QoO7OY-uImIeD8U`^L>hzmKGg=c1g{M zgKS@S3-eGqC9M?N+S=kq9Lf8Mm**pS#8|(tiHLlwY8PYii!%>=>ClxH)8kh-Lr7NUwrLqc<)>2az8=h zq7RX~zV$!zOF3^Aqh7BUKA#V<`sR|dvNB|5W@2h;irdk)c5pw=Zmi-#dov zcWb$i#9?j5K-U+H>6dIpvc81z@xME9>*6-9FE2mC{z#qttKo)o<|d#tF8ezDT)tW;G^VwpTm0L_kVP3U=SgGkUC@ngLihilR>`fL<$FRy`SVF?VyHTdCR z3FF#~^;np*Rf?z}JQE_0e`#c;aiOub@QP_NE=VK=#gKoON94Jv9K3g({hj` z#|^B`XM?zZtpOTU>?@Tr94XOSR8)kltSqjVmX^Zlbi(Cwv60DSV%%&t&&Y3)`D}cA zoPA_xXUjgqV|pIfj2fndl#VdR@ittM1gsuc3IDN(J!?-!5pJl}s^g2~a| z8EcHxn2|@A-EK!iLj&hL%2oCC^^BiAdzNvMzP`R0kr)|yl;fJ3n$XzT$ZhgLguX2D zXoDX27}jmSgaj!P9CiyVzaB?Yf|EB?d#IPkxyJ|bTT8V(m+V6f`LJ9$hDGm~QU2Kz zh961MOw$HlkjIhtVl3MRrv11YKXNo}G6g+>7?>DUZE3Bc|M5wBhV6iE0pXQ*vhq~fx---ld-fYf9KtTw-t<3d{_ zKN$;^P$wub{4~I})NjzMc-Ah}G#VMBdbk}q_GOVLJs+%CDooFdP=ZgFHcuKU;da=^vOGa< zn-;5LZkX`MeyY>MSyd?DvEx4O-TnoK8lCd^3$0(x`3Wifo4ed=`8m^yj4D3w{&Hu7BMw8bW&tFpW w_^(Q*FflPv8PA`gBcs82NgVwQ{YQWS0P$Q18#qp1Jpcdz07*qoM6N<$f>PnxdH?_b literal 0 HcmV?d00001 From ecae377a0be2d85a9e498b8b77acd8cf47b10014 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Sun, 24 Feb 2013 13:04:50 +1100 Subject: [PATCH 060/165] a bundle update, mostly for core but lets see how this goes --- Gemfile.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 28bd9c53..98dc07c2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/getsentry/raven-ruby.git - revision: f6a97f1544480645c4dfdb4d1e9e97ede1e737a9 + revision: e520389a56d099276c167d8b442967c7fa549ecd specs: sentry-raven (0.4.3) faraday (>= 0.7.6) @@ -29,7 +29,7 @@ GIT GIT remote: git://github.com/rkh/yard-sinatra.git - revision: 3b1064eef407d2d288a5b96d258178a1e67b3b80 + revision: e61831bca0431b35eaa62fdd18acbc65f81322af specs: yard-sinatra (1.0.0) yard (~> 0.7) @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 0e923ed738b1c9384f4cb73e34eb7cbb32f0768f + revision: 7970030f4bd44977d808d46ea1edd03d701aa439 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -128,7 +128,7 @@ GEM activesupport (3.2.12) i18n (~> 0.6) multi_json (~> 1.0) - addressable (2.3.2) + addressable (2.3.3) arel (3.0.2) atomic (1.0.1) avl_tree (1.1.3) @@ -139,7 +139,7 @@ GEM facter (>= 1.6.12) timers (>= 1.0.0) coder (0.3.0) - coderay (1.0.8) + coderay (1.0.9) connection_pool (0.9.3) daemons (1.1.9) dalli (2.6.2) @@ -147,7 +147,7 @@ GEM activerecord rake database_cleaner (0.8.0) - diff-lcs (1.1.3) + diff-lcs (1.2.1) erubis (2.7.0) eventmachine (1.0.0) facter (1.6.17) @@ -157,7 +157,7 @@ GEM multipart-post (~> 1.1) foreman (0.61.0) thor (>= 0.13.6) - hashie (1.2.0) + hashie (2.0.0) hashr (0.0.22) hike (1.2.1) hitimes (1.2.0) @@ -180,20 +180,20 @@ GEM mime-types (1.21) mocha (0.13.2) metaclass (~> 0.0.1) - multi_json (1.6.0) + multi_json (1.6.1) multipart-post (1.1.5) net-http-persistent (2.8) net-http-pipeline (1.0.1) pg (0.13.2) polyglot (0.3.3) - postmark (0.9.18) + postmark (0.9.19) json rake postmark-rails (0.4.1) actionmailer postmark (>= 0.9.0) rake - pry (0.9.11.4) + pry (0.9.12) coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) @@ -229,14 +229,14 @@ GEM rerun (0.8.0) listen rollout (1.1.0) - rspec (2.12.0) - rspec-core (~> 2.12.0) - rspec-expectations (~> 2.12.0) - rspec-mocks (~> 2.12.0) - rspec-core (2.12.2) - rspec-expectations (2.12.1) - diff-lcs (~> 1.1.3) - rspec-mocks (2.12.2) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.0) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.0) sidekiq (2.5.4) celluloid (~> 0.12.0) connection_pool (~> 0.9.2) From 179c5cbc4ce23ff93f64ef7c2cbeb880ea77aa6e Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Sun, 24 Feb 2013 13:25:16 +1100 Subject: [PATCH 061/165] also test against jruby --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 67e6504c..27dc76a5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: ruby rvm: - 1.9.3 - rbx-19mode + - jruby-19mode before_script: - 'RAILS_ENV=test rake db:create db:schema:load --trace' notifications: @@ -9,3 +10,4 @@ notifications: matrix: allow_failures: - rvm: rbx-19mode + - rvm: jruby-19mode From c9e99cf2cff201022337f03dfee1ff0063dcedb2 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 15 Feb 2013 17:16:45 +0100 Subject: [PATCH 062/165] Allow more than one type in Accept header --- lib/travis/api/app/helpers/accept.rb | 52 ++++++++++++++++++++++++++++ spec/unit/helpers/accept_spec.rb | 29 ++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 spec/unit/helpers/accept_spec.rb diff --git a/lib/travis/api/app/helpers/accept.rb b/lib/travis/api/app/helpers/accept.rb index ed29d328..b1ffc82b 100644 --- a/lib/travis/api/app/helpers/accept.rb +++ b/lib/travis/api/app/helpers/accept.rb @@ -7,6 +7,58 @@ class Travis::Api::App DEFAULT_VERSION = 'v1' DEFAULT_FORMAT = 'json' + class Entry + SEPARATORS = Regexp.escape("()<>@,;:\/[]?={}\t ") + TOKEN = /[^#{SEPARATORS}]+/ + attr_reader :type, :subtype, :quality, :params + def initialize(accept_string) + @type, @subtype, @quality, @params = parse(accept_string) + end + + def <=>(other) + [1 - quality, full_type.count('*'), 1 - params.size] <=> + [1 - other.quality, other.full_type.count('*'), 1 - other.params.size] + end + + def full_type + "#{type}/#{subtype}" + end + + def mime_type + subtype = self.subtype =~ HEADER_FORMAT ? $2 : self.subtype + "#{type}/#{subtype}" + end + + def version + $1 if subtype =~ HEADER_FORMAT + end + + def to_s + str = "#{full_type}; q=#{quality}" + str << "; #{params.map { |k,v| "#{k}=#{v}" }.join('; ')}" if params.length > 0 + str + end + + private + def parse(str) + # this handles only subset of what Accept header can + # contain, only the simplest cases, no quoted strings etc. + type, subtype, params = str.scan(%r{(#{TOKEN})/(#{TOKEN})(.*)}).flatten + quality = 1 + if params + params = Hash[*params.split(';').map { |p| p.scan /(#{TOKEN})=(#{TOKEN})/ }.flatten] + quality = params.delete('q').to_f if params['q'] + end + + [type, subtype, quality, params] + end + end + + def accept_entries + entries = env['HTTP_ACCEPT'].to_s.delete(' ').to_s.split(',').map { |e| Entry.new(e) } + entries.empty? ? [Entry.new('*/*')] : entries.sort + end + def accept_version @accept_version ||= request.accept.join =~ HEADER_FORMAT && "v#{$1}" || DEFAULT_VERSION end diff --git a/spec/unit/helpers/accept_spec.rb b/spec/unit/helpers/accept_spec.rb new file mode 100644 index 00000000..11f845ec --- /dev/null +++ b/spec/unit/helpers/accept_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +module Travis::Api::App::Helpers + describe Accept do + class FakeApp < Struct.new(:env) + include Accept + end + + it 'returns accept entries sorted properly' do + accept = "text/html; q=0.2; level=1, application/vnd.travis-ci.2+json, text/*, text/html;level=2; q=0.5" + FakeApp.new('HTTP_ACCEPT' => accept).accept_entries.map(&:to_s).should == + ["application/vnd.travis-ci.2+json; q=1", "text/*; q=1", "text/html; q=0.5; level=2", "text/html; q=0.2; level=1"] + end + + it 'properly parses params, quality and version' do + accept = "application/vnd.travis-ci.2+json; q=0.2; level=1; foo=bar" + accept_entry = FakeApp.new('HTTP_ACCEPT' => accept).accept_entries.first + accept_entry.quality.should == 0.2 + accept_entry.params.should == { 'level' => '1', 'foo' => 'bar' } + accept_entry.mime_type.should == 'application/json' + accept_entry.version.should == '2' + end + + it 'returns */* for empty accept header' do + accept_entry = FakeApp.new({}).accept_entries.first + accept_entry.mime_type.should == '*/*' + end + end +end From 1d7be066cbe7f21bc53eff7f4aab970184c4241a Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 16 Feb 2013 04:30:30 +0100 Subject: [PATCH 063/165] Make it easy to check if Accept::Entry accepts given mime type --- lib/travis/api/app/helpers/accept.rb | 39 ++++++++++++++++++---------- spec/unit/helpers/accept_spec.rb | 27 ++++++++++++++++++- 2 files changed, 52 insertions(+), 14 deletions(-) diff --git a/lib/travis/api/app/helpers/accept.rb b/lib/travis/api/app/helpers/accept.rb index b1ffc82b..d5dd97c1 100644 --- a/lib/travis/api/app/helpers/accept.rb +++ b/lib/travis/api/app/helpers/accept.rb @@ -10,31 +10,29 @@ class Travis::Api::App class Entry SEPARATORS = Regexp.escape("()<>@,;:\/[]?={}\t ") TOKEN = /[^#{SEPARATORS}]+/ - attr_reader :type, :subtype, :quality, :params + attr_reader :type, :subtype, :quality, :version, :params def initialize(accept_string) - @type, @subtype, @quality, @params = parse(accept_string) + @type, @subtype, @quality, @version, @params = parse(accept_string) end def <=>(other) - [1 - quality, full_type.count('*'), 1 - params.size] <=> - [1 - other.quality, other.full_type.count('*'), 1 - other.params.size] - end - - def full_type - "#{type}/#{subtype}" + [1 - quality, mime_type.count('*'), 1 - params.size] <=> + [1 - other.quality, other.mime_type.count('*'), 1 - other.params.size] end def mime_type - subtype = self.subtype =~ HEADER_FORMAT ? $2 : self.subtype "#{type}/#{subtype}" end - def version - $1 if subtype =~ HEADER_FORMAT + def accepts?(mime_type) + return true if self.mime_type == '*/*' + + type, subtype = mime_type.scan(%r{(#{TOKEN})/(#{TOKEN})}).flatten + type == self.type && (self.subtype == '*' || subtype == self.subtype) end def to_s - str = "#{full_type}; q=#{quality}" + str = "#{mime_type}; q=#{quality}" str << "; #{params.map { |k,v| "#{k}=#{v}" }.join('; ')}" if params.length > 0 str end @@ -45,12 +43,19 @@ class Travis::Api::App # contain, only the simplest cases, no quoted strings etc. type, subtype, params = str.scan(%r{(#{TOKEN})/(#{TOKEN})(.*)}).flatten quality = 1 + + version = nil if params params = Hash[*params.split(';').map { |p| p.scan /(#{TOKEN})=(#{TOKEN})/ }.flatten] quality = params.delete('q').to_f if params['q'] end - [type, subtype, quality, params] + if subtype =~ HEADER_FORMAT + subtype = $2 + version = $1 + end + + [type, subtype, quality, version, params] end end @@ -59,6 +64,14 @@ class Travis::Api::App entries.empty? ? [Entry.new('*/*')] : entries.sort end + def acceptable_formats + if format = env['travis.format_from_path'] + [Entry.new(Rack::Mime.mime_type(".#{format}"))] + else + accept_entries + end + end + def accept_version @accept_version ||= request.accept.join =~ HEADER_FORMAT && "v#{$1}" || DEFAULT_VERSION end diff --git a/spec/unit/helpers/accept_spec.rb b/spec/unit/helpers/accept_spec.rb index 11f845ec..1ce845c6 100644 --- a/spec/unit/helpers/accept_spec.rb +++ b/spec/unit/helpers/accept_spec.rb @@ -9,7 +9,7 @@ module Travis::Api::App::Helpers it 'returns accept entries sorted properly' do accept = "text/html; q=0.2; level=1, application/vnd.travis-ci.2+json, text/*, text/html;level=2; q=0.5" FakeApp.new('HTTP_ACCEPT' => accept).accept_entries.map(&:to_s).should == - ["application/vnd.travis-ci.2+json; q=1", "text/*; q=1", "text/html; q=0.5; level=2", "text/html; q=0.2; level=1"] + ["application/json; q=1", "text/*; q=1", "text/html; q=0.5; level=2", "text/html; q=0.2; level=1"] end it 'properly parses params, quality and version' do @@ -25,5 +25,30 @@ module Travis::Api::App::Helpers accept_entry = FakeApp.new({}).accept_entries.first accept_entry.mime_type.should == '*/*' end + + describe Accept::Entry do + describe 'accepts?' do + it 'accepts everything with */* type' do + entry = Accept::Entry.new('*/*') + entry.accepts?('application/json').should be_true + entry.accepts?('foo/bar').should be_true + end + + it 'accepts every subtype with application/* type' do + entry = Accept::Entry.new('application/*') + + entry.accepts?('application/foo').should be_true + entry.accepts?('application/bar').should be_true + entry.accepts?('text/plain').should be_false + end + + it 'accepts when type and subtype match' do + entry = Accept::Entry.new('application/json') + + entry.accepts?('application/json').should be_true + entry.accepts?('application/xml').should be_false + end + end + end end end From 212eb6d9d3f29feacb67795060e2e63b69e02fba Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 16 Feb 2013 04:47:27 +0100 Subject: [PATCH 064/165] Allow passing more than one mime type in Accept --- lib/travis/api/app/helpers/respond_with.rb | 20 ++++++++++++---- lib/travis/api/app/middleware/rewrite.rb | 1 + lib/travis/api/app/responders/base.rb | 14 +++++++++++ lib/travis/api/app/responders/image.rb | 4 ++-- lib/travis/api/app/responders/json.rb | 2 +- lib/travis/api/app/responders/plain.rb | 6 ++++- lib/travis/api/app/responders/xml.rb | 4 ---- spec/integration/formats_handling_spec.rb | 27 ++++++++++++++++++++++ 8 files changed, 65 insertions(+), 13 deletions(-) create mode 100644 spec/integration/formats_handling_spec.rb diff --git a/lib/travis/api/app/helpers/respond_with.rb b/lib/travis/api/app/helpers/respond_with.rb index cfb1cc44..565f0172 100644 --- a/lib/travis/api/app/helpers/respond_with.rb +++ b/lib/travis/api/app/helpers/respond_with.rb @@ -6,8 +6,9 @@ class Travis::Api::App # convert (in addition to the return values supported by Sinatra, of # course). These values will be encoded in JSON. module RespondWith + include Accept + def respond_with(resource, options = {}) - options[:format] ||= env['travis.format'] result = respond(resource, options) result = result ? result.to_json : 404 halt result @@ -21,15 +22,24 @@ class Travis::Api::App private def respond(resource, options) - responders(resource, options).each do |const| - responder = const.new(self, resource, options) - resource = responder.apply if responder.apply? + resource = apply_service_responder(resource, options) + + acceptable_formats.find do |accept| + responders(resource, options).find do |const| + responder = const.new(self, resource, options.dup.merge(accept: accept)) + responder.apply if responder.apply? + end end + end + + def apply_service_responder(resource, options) + responder = Responders::Service.new(self, resource, options) + resource = responder.apply if responder.apply? resource end def responders(resource, options) - [:Service, :Json, :Image, :Xml, :Plain].map do |name| + [:Json, :Image, :Xml, :Plain].map do |name| Responders.const_get(name) end end diff --git a/lib/travis/api/app/middleware/rewrite.rb b/lib/travis/api/app/middleware/rewrite.rb index 5fb12586..8ac8b9f2 100644 --- a/lib/travis/api/app/middleware/rewrite.rb +++ b/lib/travis/api/app/middleware/rewrite.rb @@ -24,6 +24,7 @@ class Travis::Api::App def extract_format env['PATH_INFO'].sub!(FORMAT, '') + env['travis.format_from_path'] = $1 env['travis.format'] = $1 || accept_format end diff --git a/lib/travis/api/app/responders/base.rb b/lib/travis/api/app/responders/base.rb index 14f5df38..9c099cdd 100644 --- a/lib/travis/api/app/responders/base.rb +++ b/lib/travis/api/app/responders/base.rb @@ -31,5 +31,19 @@ module Travis::Api::App::Responders def headers endpoint.headers end + + def apply? + acceptable_format? + end + + def format + self.class.name.split('::').last.downcase + end + + def acceptable_format? + if accept = options[:accept] + accept.accepts?(Rack::Mime.mime_type(".#{format}")) + end + end end end diff --git a/lib/travis/api/app/responders/image.rb b/lib/travis/api/app/responders/image.rb index 2c4c4f69..c75a752f 100644 --- a/lib/travis/api/app/responders/image.rb +++ b/lib/travis/api/app/responders/image.rb @@ -1,7 +1,7 @@ module Travis::Api::App::Responders class Image < Base - def apply? - options[:format] == 'png' + def format + 'png' end def apply diff --git a/lib/travis/api/app/responders/json.rb b/lib/travis/api/app/responders/json.rb index 8ad49337..b4c2e2a6 100644 --- a/lib/travis/api/app/responders/json.rb +++ b/lib/travis/api/app/responders/json.rb @@ -4,7 +4,7 @@ class Travis::Api::App include Helpers::Accept def apply? - options[:format] == 'json' && !resource.is_a?(String) && !resource.nil? + super && !resource.is_a?(String) && !resource.nil? end def apply diff --git a/lib/travis/api/app/responders/plain.rb b/lib/travis/api/app/responders/plain.rb index c1bc0dfa..2320b1e2 100644 --- a/lib/travis/api/app/responders/plain.rb +++ b/lib/travis/api/app/responders/plain.rb @@ -1,12 +1,16 @@ module Travis::Api::App::Responders class Plain < Base + def format + 'txt' + end + def apply? # make sure that we don't leak anything by processing only Log # instances here. I don't want to create entire new API builder just # for log's content for now. # # TODO: think how to handle other formats correctly - options[:format] == 'txt' && resource.is_a?(Log) + super && resource.is_a?(Log) end def apply diff --git a/lib/travis/api/app/responders/xml.rb b/lib/travis/api/app/responders/xml.rb index b6a075a6..7a959a23 100644 --- a/lib/travis/api/app/responders/xml.rb +++ b/lib/travis/api/app/responders/xml.rb @@ -15,10 +15,6 @@ module Travis::Api::App::Responders started: 'Building' } - def apply? - options[:format] == 'xml' - end - def apply halt TEMPLATE % data end diff --git a/spec/integration/formats_handling_spec.rb b/spec/integration/formats_handling_spec.rb new file mode 100644 index 00000000..ede76766 --- /dev/null +++ b/spec/integration/formats_handling_spec.rb @@ -0,0 +1,27 @@ +require 'spec_helper' + +describe 'App' do + before do + FactoryGirl.create(:test, :number => '3.1', :queue => 'builds.common') + + add_endpoint '/foo' do + get '/' do + respond_with(Log.first) + end + + get '/hash' do + respond_with foo: 'bar' + end + end + end + + it 'gives priority to format given the url' do + response = get '/foo.txt', {}, 'HTTP_ACCEPT' => 'application/json' + response.content_type.should =~ /^text\/plain/ + end + + it 'responds with first available type' do + response = get '/foo', {}, 'HTTP_ACCEPT' => 'image/jpeg, application/json' + response.content_type.should =~ /^application\/json/ + end +end From 65b1e6b988a9e0dcfb0fdf3a3079e74c4219db25 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 16 Feb 2013 05:03:51 +0100 Subject: [PATCH 065/165] Respond with 406 if we can't return requested formats --- lib/travis/api/app/helpers/respond_with.rb | 4 +++- spec/integration/formats_handling_spec.rb | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/helpers/respond_with.rb b/lib/travis/api/app/helpers/respond_with.rb index 565f0172..a5b19204 100644 --- a/lib/travis/api/app/helpers/respond_with.rb +++ b/lib/travis/api/app/helpers/respond_with.rb @@ -24,12 +24,14 @@ class Travis::Api::App def respond(resource, options) resource = apply_service_responder(resource, options) - acceptable_formats.find do |accept| + response = acceptable_formats.find do |accept| responders(resource, options).find do |const| responder = const.new(self, resource, options.dup.merge(accept: accept)) responder.apply if responder.apply? end end + + response || (resource ? error(406) : error(404)) end def apply_service_responder(resource, options) diff --git a/spec/integration/formats_handling_spec.rb b/spec/integration/formats_handling_spec.rb index ede76766..efda70b5 100644 --- a/spec/integration/formats_handling_spec.rb +++ b/spec/integration/formats_handling_spec.rb @@ -24,4 +24,9 @@ describe 'App' do response = get '/foo', {}, 'HTTP_ACCEPT' => 'image/jpeg, application/json' response.content_type.should =~ /^application\/json/ end + + it 'responds with 406 if server can\'t use any mime type' do + response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'text/plain, image/jpeg' + response.status.should == 406 + end end From 0e6757080e38b759a1430163f63bfe311086f987 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 18 Feb 2013 16:24:56 +0100 Subject: [PATCH 066/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 98dc07c2..42c24470 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 7970030f4bd44977d808d46ea1edd03d701aa439 + revision: bea9d64f47ac3e15752f2c81d1e5b8c7227507be specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From 36783e6359157d76d1fac442bd62df6a178e950d Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 18 Feb 2013 16:58:06 +0100 Subject: [PATCH 067/165] Handle chunked=true param in Accept header --- lib/travis/api/app/responders/json.rb | 19 +++++++++++++++++-- spec/integration/v2/jobs_spec.rb | 25 +++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/lib/travis/api/app/responders/json.rb b/lib/travis/api/app/responders/json.rb index b4c2e2a6..ef8377b0 100644 --- a/lib/travis/api/app/responders/json.rb +++ b/lib/travis/api/app/responders/json.rb @@ -4,7 +4,7 @@ class Travis::Api::App include Helpers::Accept def apply? - super && !resource.is_a?(String) && !resource.nil? + super && !resource.is_a?(String) && !resource.nil? && accepts_log? end def apply @@ -13,13 +13,28 @@ class Travis::Api::App private + def accepts_log? + return true unless resource.is_a?(Log) + + chunked = accept_params[:chunked] + chunked ? !resource.aggregated_at : true + end + def result - builder ? builder.new(resource, request.params).data : resource + builder ? builder.new(resource, params).data : resource end def builder @builder ||= Travis::Api.builder(resource, { :version => accept_version }.merge(options)) end + + def accept_params + (options[:accept].params || {}).symbolize_keys + end + + def params + (request.params || {}).merge(accept_params) + end end end end diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb index 6df25881..4c7d202e 100644 --- a/spec/integration/v2/jobs_spec.rb +++ b/spec/integration/v2/jobs_spec.rb @@ -49,5 +49,30 @@ describe 'Jobs' do response.headers['Location'].should == "https://s3.amazonaws.com/archive.travis-ci.org/jobs/#{job.id}/log.txt" end end + + context 'with chunked log requested' do + it 'responds with 406 when log is already aggregated' do + job.log.update_attributes(aggregated_at: Time.now) + headers = { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json; chunked=true' } + response = get "/jobs/#{job.id}/log", {}, headers + response.status.should == 406 + end + + it 'responds with chunks instead of full log' do + job.log.parts << Log::Part.new(content: 'foo', number: 1, final: false) + job.log.parts << Log::Part.new(content: 'bar', number: 2, final: true) + + headers = { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json; chunked=true' } + response = get "/jobs/#{job.id}/log", {}, headers + response.should deliver_json_for(job.log, version: 'v2', params: { chunked: true}) + end + + it 'responds with full log if chunks are not available and full log is accepted' do + job.log.update_attributes(aggregated_at: Time.now) + headers = { 'HTTP_ACCEPT' => 'application/vnd.travis-ci.2+json; chunked=true, application/vnd.travis-ci.2+json' } + response = get "/jobs/#{job.id}/log", {}, headers + response.should deliver_json_for(job.log, version: 'v2') + end + end end end From 5f91706e64aa7ca1141eac1620274ce20c6de33f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 18 Feb 2013 17:14:34 +0100 Subject: [PATCH 068/165] Allow to pass version as Accept param --- lib/travis/api/app/helpers/accept.rb | 5 +++++ spec/unit/helpers/accept_spec.rb | 19 ++++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/helpers/accept.rb b/lib/travis/api/app/helpers/accept.rb index d5dd97c1..a57dfa8e 100644 --- a/lib/travis/api/app/helpers/accept.rb +++ b/lib/travis/api/app/helpers/accept.rb @@ -24,6 +24,11 @@ class Travis::Api::App "#{type}/#{subtype}" end + def version + version = @version || params['version'] + version ? "v#{version}" : nil + end + def accepts?(mime_type) return true if self.mime_type == '*/*' diff --git a/spec/unit/helpers/accept_spec.rb b/spec/unit/helpers/accept_spec.rb index 1ce845c6..cd41d0d3 100644 --- a/spec/unit/helpers/accept_spec.rb +++ b/spec/unit/helpers/accept_spec.rb @@ -18,7 +18,7 @@ module Travis::Api::App::Helpers accept_entry.quality.should == 0.2 accept_entry.params.should == { 'level' => '1', 'foo' => 'bar' } accept_entry.mime_type.should == 'application/json' - accept_entry.version.should == '2' + accept_entry.version.should == 'v2' end it 'returns */* for empty accept header' do @@ -27,6 +27,23 @@ module Travis::Api::App::Helpers end describe Accept::Entry do + describe 'version' do + it 'can be passed as a vendor extension' do + entry = Accept::Entry.new('application/vnd.travis-ci.2+json') + entry.version.should == 'v2' + end + + it 'can be passed as a param' do + entry = Accept::Entry.new('application/json; version=2') + entry.version.should == 'v2' + end + + it 'has a higher priority when in vendor extension' do + entry = Accept::Entry.new('application/vnd.travis-ci.1+json; version=2') + entry.version.should == 'v1' + end + end + describe 'accepts?' do it 'accepts everything with */* type' do entry = Accept::Entry.new('*/*') From 5345ef818ec2a150fc788d6204111974514b9db3 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 18 Feb 2013 17:58:45 +0100 Subject: [PATCH 069/165] Use version from each of the accept headers, not only first one --- lib/travis/api/app/responders/json.rb | 6 +++++- spec/integration/version_spec.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 spec/integration/version_spec.rb diff --git a/lib/travis/api/app/responders/json.rb b/lib/travis/api/app/responders/json.rb index ef8377b0..464be510 100644 --- a/lib/travis/api/app/responders/json.rb +++ b/lib/travis/api/app/responders/json.rb @@ -25,13 +25,17 @@ class Travis::Api::App end def builder - @builder ||= Travis::Api.builder(resource, { :version => accept_version }.merge(options)) + @builder ||= Travis::Api.builder(resource, { :version => version }.merge(options)) end def accept_params (options[:accept].params || {}).symbolize_keys end + def version + options[:accept].version || Travis::Api::App::Helpers::Accept::DEFAULT_VERSION + end + def params (request.params || {}).merge(accept_params) end diff --git a/spec/integration/version_spec.rb b/spec/integration/version_spec.rb new file mode 100644 index 00000000..818a0dbd --- /dev/null +++ b/spec/integration/version_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe 'App' do + before do + add_endpoint '/foo' do + get '/' do + respond_with foo: 'bar' + end + end + end + + it 'uses version from current accept header' do + Travis::Api.expects(:builder).with { |r, options| options[:version] == 'v1' } + + Travis::Api::App::Responders::Json.any_instance.stubs(:apply?). + returns(false).then.returns(true) + + response = get '/foo', {}, 'HTTP_ACCEPT' => 'application/json; version=2, application/json; version=1' + response.content_type.should == 'application/json;charset=utf-8' + end + + it 'uses v1 by default' do + Travis::Api.expects(:builder).with { |r, options| options[:version] == 'v1' } + get '/foo', {}, 'HTTP_ACCEPT' => 'application/json' + end +end From 2065b3ded08d3a6dea90c8449eace114e44b6042 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 25 Feb 2013 17:29:33 +0100 Subject: [PATCH 070/165] Bump travis-core --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 42c24470..b3b4dc04 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: bea9d64f47ac3e15752f2c81d1e5b8c7227507be + revision: fa5a513084a089db3d331b9ff546d6f8249b136c specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -153,7 +153,7 @@ GEM facter (1.6.17) factory_girl (2.4.2) activesupport - faraday (0.8.5) + faraday (0.8.6) multipart-post (~> 1.1) foreman (0.61.0) thor (>= 0.13.6) @@ -220,7 +220,7 @@ GEM thor (>= 0.14.6, < 2.0) rake (0.9.6) rb-fsevent (0.9.3) - rdoc (3.12.1) + rdoc (3.12.2) json (~> 1.4) redcarpet (2.2.2) redis (3.0.2) From 8599ca80a28ca93d0e99bfc7125a10cdea60a380 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 26 Feb 2013 21:04:05 +0100 Subject: [PATCH 071/165] Bump travis-core --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b3b4dc04..d22ac457 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: fa5a513084a089db3d331b9ff546d6f8249b136c + revision: 0b11bc7f2943bf7ec3c382ff34af286e3d1b8533 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -163,7 +163,7 @@ GEM hitimes (1.2.0) hubble (0.1.2) yajl-ruby (~> 1.1) - i18n (0.6.1) + i18n (0.6.2) journey (1.0.4) json (1.7.7) listen (0.7.2) @@ -181,7 +181,7 @@ GEM mocha (0.13.2) metaclass (~> 0.0.1) multi_json (1.6.1) - multipart-post (1.1.5) + multipart-post (1.2.0) net-http-persistent (2.8) net-http-pipeline (1.0.1) pg (0.13.2) From 7384011e546f6b5bf8f2f6ace5d0e65b0a85bee4 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 26 Feb 2013 21:06:16 +0100 Subject: [PATCH 072/165] Use rubygems via https --- Gemfile | 2 +- Gemfile.lock | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index b0810ca4..b9791555 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ ruby '1.9.3' rescue nil -source :rubygems +source 'https://rubygems.org' gemspec gem 'travis-core', github: 'travis-ci/travis-core' diff --git a/Gemfile.lock b/Gemfile.lock index d22ac457..416c2b1f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,7 +102,7 @@ PATH travis-support GEM - remote: http://rubygems.org/ + remote: https://rubygems.org/ specs: actionmailer (3.2.12) actionpack (= 3.2.12) From 5372e34b135ec8514af7e3e976a5523bc53fe18c Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Thu, 28 Feb 2013 07:44:41 -0800 Subject: [PATCH 073/165] Use brighter green color for passing badge This is the same color used for the best scores on Code Climate and Coveralls and is more pleasing to the eye than the current yellowy-green. --- public/images/result/passing.png | Bin 1416 -> 1449 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/public/images/result/passing.png b/public/images/result/passing.png index 9926569875f48a0663cb6218a4394766e7851137..e621970059052f8a5be210e52b64d19298afe37c 100644 GIT binary patch delta 1431 zcmV;I1!($+3#ki`B!3`dNK#Dz0D2|>0Dy!50Qvv`0D$NK0Cg|`0P0`>06Lfe02gqa zx=}m;000DMK}|sb0I`mI`%#ks0004VQb$4nuFf3k00006VoOIv0RI600RN!9r;`8x z010qNS#tmY4#WTe4#WYKD-Ig~00jU^L_t(|+U;0xOj}hH|9`#LS6Ygx1qP#_brYBQ zVT&Dc3$UmoEJ#2G3RwbnE?FR}Y{)hi!}dXuEe@F?B%5JzVVZ0L0s+Gx2NCfj+3ogB0A`-& z_h6N2a&Irz1%L5q<5{LUH>9+k$;rt%F9hr4TKRIX_$#a{VsMmmxm>vn!>pMPZuk0% z84u)g0?KqkTRSJ#(DpwhBkLB9+E=Tuug6ld<#hb%ddskC?fMS;L)nLO`^gXY1LjVA zd_44e{j$1pncKa3NHbPwvEjLZf4vXqFFhVKbs{1nB!8Wi?#r)YO$*%}@KEgeMViTE zLP|;sMn^|cRaJ%l{(iKyv>+oRLs}!B%g5rr(b3T;EG$HLcsM#bI=qp#D7co`G1S_s z@Nz^Rew+Oj=lb(;XX-~u#tXj@=O8Kuig4?m1*WJI$kLnfC>KiCB;54$zW796l#}rl z>pAR?JbwbGdlnb&o`z+t8C!#lD1Pc9B2)%6k9>^m$U;eHMM1M#tw>HzMtXWW%w{u+ zii&)u-okWqFX)M0Lqh{vTU(Ktnd!CO*U4Llt$4n1GctF)h7-?Jz}&l+^0%MYf@N4d zyEz_jy;y~V@@5~Y4S(-+TM)g zPkexDJ(uvs51%0`?f?+!?W5nIb#`_lC@2VBU0uk}&-V(5_^IMAXa<7;-QC@EAA+=k zf`VmhTI^@tG~$oE5!$!yRRk#1NZ)Qk-|s(D z{$a!0IMZ2#T^~l_NaKD1aSF<}IGd1Dn}3Kyb^C-=dPCaB7vED3{f>}WD{=6J*Rdz^B^n3Ou!e{B_kU>Y&U%+#P#t@)G-$(!e002ovPDHLkV1l3Lva|pI delta 1397 zcmV-*1&aEq3y2GlB!3xnMObuGZ)S9NVRB^vL1b@YWgtmyVP|DhWnpA_ami&o000Fl zNklOCuIBNgN zFVEfo?tXXoySx8A&%`x?5R`z2qEhw&C6e{D0b`!HOmn=9FCxlz!7?)A?Tuo;7&sr70nkKjRsX!RR~nJ7YqgidlnQFF!+|| z=H{Zjyxh;fvwwp}j(1;l{-=C2ruiwky}b>a&4xf_ds%jNHWCvPv9-0u^1f{;CoS{! z@5fGi;~WQd<|96ybYe+KNoZ|tMRasDEEWrDYin6qV`C$9Ivq>r=jTJEQlX)t0eyXa z%dCu+n=Xssd0IDL0t{0NPmIIa2f6|nb6j+#iq@QEL8<7 zqc%EgK)0#H%Xeqqi1q<3PM_#uJk)*|twjGs4Zb?(#D!}dtFM+9BT)rR)>T2>Ex zy6xLrdfc39didi>CoUF?QC3!l%*;$oO-(_o)xvJK^MX*gcaK{LcUuaDLV?13Hv=lKF1_YUCG%@h<{f>tGxdv~GNKI?@Qw@Tifs`T9mB21g7q4m5d< z%@ccyHaa?r_4Rec#l^v7GC?R5dWl036&1w`;eRU{txq}T=H_^ge-q6~;>F}W(pTIh zRL6m#F$1`586v`D$kLSK@&zXvs}>-Nl(EUzca-3{V|l3m$bxiD9#&SZ_^ho2Zx&ah z_WdD9Br-429OMxEblZT0G%LgEx)q#FhT$G-+?wyy0kR0QRPa|d{7MHBJSiZY(9oH+pcA9%lefy++rIN*>{D0K$ zEtqi0sKv&%HDFBRNHBK>x;@v{*2wj`!$c4W1dvLl;5d%$w$05=*DXT)6g2+L&(E`C zNRKo%kx0bSl*hNOryW229iKid&BMu~6*&K;maVAp0FbP5UGuXOfNdKHk8stM6aW1? zBt~tx@*+Z;_yjrLBfH$OazGXjOn(dms$+olPnVzis7>7l;tm6!lv(h_Wj${FW@P?` zvld(()Wb4oeE8dwPEI0`_}!=!G>%dD?#$TOSoVyJjO2YZ?aq7F-E*fAamczLMeW%y zi6LRY<4^hzUas`L^~nva@qc-yKKeWu$ zS0K@PgZXPH1V7k&1sfY1x?ui Date: Thu, 28 Feb 2013 14:43:26 -0800 Subject: [PATCH 074/165] Fix kerning/alignment/anti-aliasing of passing image --- public/images/result/passing.png | Bin 1449 -> 1461 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/public/images/result/passing.png b/public/images/result/passing.png index e621970059052f8a5be210e52b64d19298afe37c..2d1cc7585852b43772600a95647870ac3bca1e49 100644 GIT binary patch delta 1456 zcmV;h1yA~^3$+W77k?871^@s6)s28R00009a7bBm000XU000XU0RWnu7ytkO8FWQh zbW?9;ba!ELWdK2BZ(?O2No`?gWm08fWO;GPWjp`?1wu(gK~#9!>{we&TtyiE&hBBC z?(X3%Md&V?f}}StrA6BiOa+BN4Mqq)c#DGRLla_vG(@cr^ndoGz0kBi*u)fR8k0s+ zD6J;iRv@)Plwt|CKnWJ8WqpxBFkM--L*9V-u5xW>jt601vs7zr=LDswc6W|i;~-`m@JE>eOqFN!Wl zlW3&VIo|Ddr+-A!3%A>YC@U#E<+R9(hNvqPX%Th66NREFNVH&NWo4nEp#kCEJqXec z%kR(Fko?U@&2+4 z97{YQn12$1o_!<^Pi<2@zDT2-77j+E5vNa|Mq67O4u2m$jHIL_2731ODK0KXb#*ms z_w@9H*r=$eVEqZDrKR5G7(ADI8P5s%IFa=u+MgdqNA5k=)+t2x?k!_2;|P1!oDAU( zZ8*y~s(l>2CvKqLCif?s!D9@n6nwqun#>bkO{@&?%^zWxCw+_{2&k&6LT+v@#>dB* zKu)Jqj(;KoMWlc9_{I{_($bh{J{u;JiSeP!6EYk#(g*M|OGSr{1V*HVgJ85P>(;HX*=!6{D2j+LC@2WX zU;g>ZYPB*O$;rvG4S&Ix0U31q$uQ&~Iqq5ZT(Z6b)_DsG^ySb(kBm_&>%18!b2=cz=rK5b9nCizAqw$$$5@BK-F8gQ{|S?2jLp-O*MEr( zg7?bYGu{dF%-{H>Z24N&cy*6#-+g}tgqu^R5|OzohuLSo+WS#APyxHs5_TitN=iyR z;dam2*;ytMO~ms&^m;uwj)UE9$HKyb_mC&?1j>KY)6;Aj(vqg4(P&tk>;(7qFSgyk z%IzFg0p5G24m-}g29FC+YB>lQynod8z<$#O_oB2k)Ew(8WGXRp%LUi0*ZmlggLWMc zORqz=w_>#tu}>>t?r|VKF9r*f-XDxOwiashMtY@WH+gr>JI$YZ{jHiGW)4)7uuKGF&c3nO}uvVYPi zx1ClG7Vf&COIJQo9~PxK=kK`W=a>Wqv}=|B-D{Np^a_E4X1(%>-$!E%3WkS0bn{Z) zIwsY1|Noccq02Fj@|1KO*eOT004R>004l5008;`004mK004C` z008P>0026e000+ooVrmw00004XF*Lt006O$eEU(800001b5ch_0Itp)=>Px#24YJ` zL;(K){{a7>y{D4^000SaNLh0L01m_e01m_fl`9S#000F5NqQRTTfd z*H>DKsRah3pmh_M`C*G4aSO1hBP>Wj1`1gMb}m^Ut8Bma?rq-lK}%t}fFz#g=H7eGJ@=e3YksYVGbNk5;_XFlme0)6gdi}Dxa+%w`dPp-?XtCkBfPa6z59cpE9yE0#A|fQ6mF~;0 zVoeL(9q>@>`9+$^WI{?x3PwjqQB_ri{{DWnw6q{2BSTsvpUcPMzR}UqC@d^Qcz8HE zIy$_OwkWuk*fG@Fs_=3|9)6qs73cc%acAmBNyZDm5$7N(28wX&o&~0;6Ufq=@hBHc z*CgEZ^nbqiL|>GX@fGVi?2kMGr+XF`?w*EatQlK_j3|EUA|g}?3Y?8rh%XGKA? zTCGSii(PSrryGIb1&$LUPD6zT3cI@nVIRe-q*=nhpl+NaWgV^yoM9c zRKVQ3m-4rt*MenOJi9p_Z@pNBgX6Kt))%7Oa(@bKy`RH5KO>+?N!KpLm)je&k7G~s z7VI?aMrra#_}bo#<4=5mYdx3n#Sfn$EA9Xg>FuN6pmlb3A}A;bU0q$s&(HS?i1?}E zFK7mX0o~o*bRUAWf`Wo&Yg+5jRj7<}Xt!U*F-<95lc7I^Y(Y0%6$J&u2?%vj{yUw8 zIDZgl#>s@UXs}h|%HVr+kEQr>dyNB^p*8~F3y9sIj-awlnyu*kqn6rl8@h%!cfRlC zBTMRwuSSTZWgol}JrZm1@-DS|;*{o_rsB z?NtOQ)JWfMLf`K{Q~qJY+c?u%gk2v-;eSZuegSa`%C|V1kW-t8Lv{OvRC+_&#~0sI z4*s^og$uq2=dRE(lB{p+Hqu1<+e`~|#O4=iAt52CtE+>}WdB<>jHNsmVurdLu2|^*GvN`!PKE3r>A`7`&cG&39EOPpN^EpFz_=jen%u z^U4GrPuw3v^|$5Hp)JLi+oL?0c_KSwIfi#rE}`JbvuNr66w~*oynJMml9GJB<_MxR z8VzPe#V~_`xqllzs zaB#51Q>)bya)=HYi#^SMA>cZlPFhd)TYxklN2WF?Xp^r|MX|JrM8<@#i+@!v`ke9f zzW9VEm&Q&6+Jp4PNV_ZaoBk^ocI__ZnqT6H4@>&U^WTtvIjV(EhqC`K>?{3ih`GQCHRqyG y?4K5#&k|UVthNtx!|Nt!6CJ{5>E)0?N7G-xbA`sBL*GaM0000 Date: Sun, 3 Mar 2013 18:27:29 -0600 Subject: [PATCH 075/165] Fix link to travis-web Fix #55 --- lib/travis/api/app/endpoint/documentation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app/endpoint/documentation.rb b/lib/travis/api/app/endpoint/documentation.rb index f7feaaf6..18653990 100644 --- a/lib/travis/api/app/endpoint/documentation.rb +++ b/lib/travis/api/app/endpoint/documentation.rb @@ -190,7 +190,7 @@ __END__

  • - + Example Client From 04bb751b023fe3875135eeabdfb2e53ec438d0d2 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 11 Mar 2013 20:54:24 +0100 Subject: [PATCH 076/165] When serving image, return proper Last-Modified header --- lib/travis/api/app/responders/image.rb | 2 +- spec/integration/v2/repositories_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/responders/image.rb b/lib/travis/api/app/responders/image.rb index c75a752f..09b7a5a1 100644 --- a/lib/travis/api/app/responders/image.rb +++ b/lib/travis/api/app/responders/image.rb @@ -8,7 +8,7 @@ module Travis::Api::App::Responders headers['Pragma'] = "no-cache" headers['Expires'] = Time.now.utc.httpdate headers['Content-Disposition'] = %(inline; filename="#{File.basename(filename)}") - halt send_file(filename, type: :png) + halt send_file(filename, type: :png, last_modified: resource.last_build_finished_at) end private diff --git a/spec/integration/v2/repositories_spec.rb b/spec/integration/v2/repositories_spec.rb index 9de7ad63..0d7c6e9c 100644 --- a/spec/integration/v2/repositories_spec.rb +++ b/spec/integration/v2/repositories_spec.rb @@ -115,6 +115,7 @@ describe 'Repos' do Factory(:build, repository: repo, state: :passed, commit: on_bar) result = get('/repos/svenfuchs/minimal.png?branch=foo,bar', {}, headers) result.should deliver_result_image_for('passing') + result.headers['Last-Modified'].should == repo.last_build_finished_at.httpdate end it '"passing" when there is a running build but the previous one has passed' do From b6f3ef10aac610aea1ca75b47cec16fcfc9f1702 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 11 Mar 2013 20:57:45 +0100 Subject: [PATCH 077/165] Resource can be nil in Responders::Image --- lib/travis/api/app/responders/image.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/responders/image.rb b/lib/travis/api/app/responders/image.rb index 09b7a5a1..604094cf 100644 --- a/lib/travis/api/app/responders/image.rb +++ b/lib/travis/api/app/responders/image.rb @@ -8,7 +8,7 @@ module Travis::Api::App::Responders headers['Pragma'] = "no-cache" headers['Expires'] = Time.now.utc.httpdate headers['Content-Disposition'] = %(inline; filename="#{File.basename(filename)}") - halt send_file(filename, type: :png, last_modified: resource.last_build_finished_at) + halt send_file(filename, type: :png, last_modified: last_modified) end private @@ -24,5 +24,10 @@ module Travis::Api::App::Responders def root File.expand_path('.') # TODO wat. end + + def last_modified + resource ? resource.last_build_finished_at : nil + end + end end From 54a6926aaf1ebd44ce09089c727cc4f828a9dcee Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 11 Mar 2013 23:52:53 +0100 Subject: [PATCH 078/165] Properly handle non existent resources This commit changes travis-api to always return 404 response if resource is not available. Previously we were returning image/png with "unknown" status instead if user used "*/*" Accept header, which was confusing. --- lib/travis/api/app/responders/base.rb | 2 +- spec/integration/v1/repositories_spec.rb | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/travis/api/app/responders/base.rb b/lib/travis/api/app/responders/base.rb index 9c099cdd..8849f553 100644 --- a/lib/travis/api/app/responders/base.rb +++ b/lib/travis/api/app/responders/base.rb @@ -33,7 +33,7 @@ module Travis::Api::App::Responders end def apply? - acceptable_format? + resource && acceptable_format? end def format diff --git a/spec/integration/v1/repositories_spec.rb b/spec/integration/v1/repositories_spec.rb index aea3fd4c..b1b35fd1 100644 --- a/spec/integration/v1/repositories_spec.rb +++ b/spec/integration/v1/repositories_spec.rb @@ -40,10 +40,6 @@ describe 'v1 repos' do end describe 'GET /svenfuchs/minimal.png' do - it '"unknown" when the repository does not exist' do - get('/svenfuchs/does-not-exist.png').should deliver_result_image_for('unknown') - end - it '"unknown" when it only has one build that is not finished' do Build.delete_all Factory(:build, repository: repo, state: :created, result: nil) @@ -72,10 +68,6 @@ describe 'v1 repos' do let(:on_foo) { Factory(:commit, branch: 'foo') } let(:on_bar) { Factory(:commit, branch: 'bar') } - it '"unknown" when the repository does not exist' do - get('/svenfuchs/does-not-exist.png?branch=foo,bar').should deliver_result_image_for('unknown') - end - it '"unknown" when it only has unfinished builds on the relevant branches' do Build.delete_all Factory(:build, repository: repo, state: :started, commit: on_foo) From c0b9a468d688e3e5c2d8472bad9d8960a98fe716 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 11 Mar 2013 23:58:58 +0100 Subject: [PATCH 079/165] Forgot to delete one of the tests --- spec/integration/v2/repositories_spec.rb | 5 ----- 1 file changed, 5 deletions(-) diff --git a/spec/integration/v2/repositories_spec.rb b/spec/integration/v2/repositories_spec.rb index 0d7c6e9c..0db122ae 100644 --- a/spec/integration/v2/repositories_spec.rb +++ b/spec/integration/v2/repositories_spec.rb @@ -90,11 +90,6 @@ describe 'Repos' do let(:on_foo) { Factory(:commit, branch: 'foo') } let(:on_bar) { Factory(:commit, branch: 'bar') } - it '"unknown" when the repository does not exist' do - result = get('/repos/svenfuchs/does-not-exist.png?branch=foo,bar', {}, headers) - result.should deliver_result_image_for('unknown') - end - it '"unknown" when it only has unfinished builds on the relevant branches' do Build.delete_all Factory(:build, repository: repo, state: :started, commit: on_foo) From 705927ff74c330306ac274cedaa1222dc414cc1f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 12 Mar 2013 12:08:40 +0100 Subject: [PATCH 080/165] Don't error out if xml is requested with something else than repo --- lib/travis/api/app/responders/xml.rb | 4 ++++ spec/integration/v2/repositories_spec.rb | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/lib/travis/api/app/responders/xml.rb b/lib/travis/api/app/responders/xml.rb index 7a959a23..9fa43fcf 100644 --- a/lib/travis/api/app/responders/xml.rb +++ b/lib/travis/api/app/responders/xml.rb @@ -15,6 +15,10 @@ module Travis::Api::App::Responders started: 'Building' } + def apply? + super && resource.is_a?(Repository) + end + def apply halt TEMPLATE % data end diff --git a/spec/integration/v2/repositories_spec.rb b/spec/integration/v2/repositories_spec.rb index 0db122ae..0c2c928a 100644 --- a/spec/integration/v2/repositories_spec.rb +++ b/spec/integration/v2/repositories_spec.rb @@ -86,6 +86,11 @@ describe 'Repos' do response.should deliver_cc_xml_for(Repository.by_slug('svenfuchs/minimal').first) end + it 'does not respond with cc.xml for /repos list' do + response = get '/repos', {}, 'HTTP_ACCEPT' => 'application/xml; version=2' + response.status.should == 406 + end + describe 'GET /repos/svenfuchs/minimal.png?branch=foo,bar' do let(:on_foo) { Factory(:commit, branch: 'foo') } let(:on_bar) { Factory(:commit, branch: 'bar') } From ce470af1c3c67214c7304b20d4136aa115b3ee3f Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 16 Mar 2013 14:38:40 +0100 Subject: [PATCH 081/165] Bump travis-core --- Gemfile.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 416c2b1f..4d1326f1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,7 +17,7 @@ GIT GIT remote: git://github.com/rkh/gh.git - revision: 1dece05c588c63e714520aae686589de1b3bcbd5 + revision: 5e781e424e346838604563bd6408c4419f5480b0 specs: gh (0.9.1) addressable @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 0b11bc7f2943bf7ec3c382ff34af286e3d1b8533 + revision: 146ca839b286b67294c84e8ebf489c76d7add898 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -160,10 +160,10 @@ GEM hashie (2.0.0) hashr (0.0.22) hike (1.2.1) - hitimes (1.2.0) + hitimes (1.2.1) hubble (0.1.2) yajl-ruby (~> 1.1) - i18n (0.6.2) + i18n (0.6.4) journey (1.0.4) json (1.7.7) listen (0.7.2) @@ -223,7 +223,7 @@ GEM rdoc (3.12.2) json (~> 1.4) redcarpet (2.2.2) - redis (3.0.2) + redis (3.0.3) redis-namespace (1.2.1) redis (~> 3.0.0) rerun (0.8.0) @@ -266,12 +266,12 @@ GEM eventmachine (>= 0.12.6) rack (>= 1.0.0) thor (0.14.6) - tilt (1.3.3) + tilt (1.3.5) timers (1.1.0) treetop (1.4.12) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.35) + tzinfo (0.3.37) uuidtools (2.1.3) yajl-ruby (1.1.0) yard (0.8.4.1) From 70993319077375b8528bc8966520d89b9d646f57 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 16 Mar 2013 15:34:59 +0100 Subject: [PATCH 082/165] Read .deploy-sha file from the proper path --- lib/travis/api/app.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index c88a3b5d..b15013be 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -52,7 +52,11 @@ module Travis::Api end def self.deploy_sha - @deploy_sha ||= File.exist?('.deploy_sha') ? File.read('.deploy-sha')[0..7] : 'deploy-sha' + @deploy_sha ||= File.exist?(deploy_sha_path) ? File.read(deploy_sha_path)[0..7] : 'deploy-sha' + end + + def self.deploy_sha_path + File.expand_path('../../../../.deploy_sha', __FILE__) end attr_accessor :app @@ -70,8 +74,8 @@ module Travis::Api if Travis::Features.feature_active?(:use_rack_cache) && memcache_server use Rack::Cache, verbose: true, - metastore: "memcached://#{memcache_servers}/#{self.class.deploy_sha}", - entitystore: "memcached://#{memcache_servers}/#{self.class.deploy_sha}" + metastore: "memcached://#{memcache_servers}/#{Travis::Api::App.deploy_sha}", + entitystore: "memcached://#{memcache_servers}/#{Travis::Api::App.deploy_sha}" end use Rack::Deflater From 2efd1cb9a6e2409e79d3c26568dc5236ec601517 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 16 Mar 2013 16:42:52 +0100 Subject: [PATCH 083/165] It's .deploy-sha, not .deploy_sha :rage: --- lib/travis/api/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index b15013be..609c5f0a 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -56,7 +56,7 @@ module Travis::Api end def self.deploy_sha_path - File.expand_path('../../../../.deploy_sha', __FILE__) + File.expand_path('../../../../.deploy-sha', __FILE__) end attr_accessor :app From 591bca9093f75a70d4273d71525176ce278ad2ff Mon Sep 17 00:00:00 2001 From: Nick Schonning Date: Mon, 18 Mar 2013 23:07:55 -0300 Subject: [PATCH 084/165] First cut generic Contributing.md file for Travis For https://github.com/travis-ci/travis-ci/issues/940 --- CONTRIBUTING.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..0545a308 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing to Travis-CI +Issues for any Travis-CI repo should be submitted to https://github.com/travis-ci/travis-ci/issues + +## Security Issues +***Any security issues should be submitted directly to [security@travis-ci.org](mailto:security@travis-ci.org)*** + +## Reporting Issues +- Explain what you expected to happen vs the actual results +- Include a screenshot if it helps illustrate the issue. https://github.com/blog/1347-issue-attachments +- What steps are required to reproduce the issue +- An example build that shows the issue + +## Submitting a PR to Travis-API + +See testing and setup notes in the base [README](https://github.com/travis-ci/travis-api) From 0854912a4ebce18c7664d68e08c8ab42cdff0dfb Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 20 Mar 2013 18:04:50 +0100 Subject: [PATCH 085/165] update core and support --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4d1326f1..a96a56cd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 146ca839b286b67294c84e8ebf489c76d7add898 + revision: 5a161d52e8668abd4226b4fecab1271d4491a90c specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -75,7 +75,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-support.git - revision: 01d9ccd14f2cb99b2446cb6b49cb7abe93e38967 + revision: db10b27101763f39d46075ded19bcf4bb845b1ff specs: travis-support (0.0.1) From 268b02db50ffbdf5aa3843e3abc8116d69556abf Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 20 Mar 2013 19:53:29 +0100 Subject: [PATCH 086/165] regenerate gemspec --- travis-api.gemspec | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/travis-api.gemspec b/travis-api.gemspec index 6c2ffd10..5c78344b 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -13,8 +13,12 @@ Gem::Specification.new do |s| "Konstantin Haase", "Piotr Sarnacki", "Mathias Meyer", + "Josh Kalderimis", + "Henrik Hodne", + "Erik Michaels-Ober", "Brian Ford", - "Henrik Hodne" + "Steve Richert", + "Nick Schonning" ] s.email = [ @@ -23,11 +27,16 @@ Gem::Specification.new do |s| "drogus@gmail.com", "meyer@paperplanes.de", "svenfuchs@artweb-design.de", + "josh.kalderimis@gmail.com", + "me@henrikhodne.com", + "sferik@gmail.com", + "steve.richert@gmail.com", "bford@engineyard.com", - "me@henrikhodne.com" + "nschonni@gmail.com" ] s.files = [ + "CONTRIBUTING.md", "Procfile", "README.md", "Rakefile", @@ -84,6 +93,7 @@ Gem::Specification.new do |s| "lib/travis/api/app/endpoint/home.rb", "lib/travis/api/app/endpoint/hooks.rb", "lib/travis/api/app/endpoint/jobs.rb", + "lib/travis/api/app/endpoint/logs.rb", "lib/travis/api/app/endpoint/repos.rb", "lib/travis/api/app/endpoint/requests.rb", "lib/travis/api/app/endpoint/stats.rb", @@ -107,13 +117,17 @@ Gem::Specification.new do |s| "lib/travis/api/app/responders/base.rb", "lib/travis/api/app/responders/image.rb", "lib/travis/api/app/responders/json.rb", + "lib/travis/api/app/responders/plain.rb", "lib/travis/api/app/responders/service.rb", "lib/travis/api/app/responders/xml.rb", + "public/images/result/error.png", "public/images/result/failing.png", "public/images/result/passing.png", + "public/images/result/pending.png", "public/images/result/unknown.png", "script/console", "script/server", + "spec/integration/formats_handling_spec.rb", "spec/integration/routes.backup.rb", "spec/integration/v1/branches_spec.rb", "spec/integration/v1/builds_spec.rb", @@ -130,6 +144,7 @@ Gem::Specification.new do |s| "spec/integration/v2/users_spec.rb", "spec/integration/v2/workers_spec.rb", "spec/integration/v2_spec.backup.rb", + "spec/integration/version_spec.rb", "spec/spec_helper.rb", "spec/support/matchers.rb", "spec/unit/app_spec.rb", @@ -152,6 +167,7 @@ Gem::Specification.new do |s| "spec/unit/extensions/scoping_spec.rb", "spec/unit/extensions/smart_constants_spec.rb", "spec/unit/extensions/subclass_tracker_spec.rb", + "spec/unit/helpers/accept_spec.rb", "spec/unit/helpers/json_renderer_spec.rb", "spec/unit/middleware/logging_spec.rb", "spec/unit/middleware/scope_check_spec.rb", From 92be2a3fcdcb6c7003742bc446fa3516e6a74817 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 20 Mar 2013 19:53:38 +0100 Subject: [PATCH 087/165] fix test for new autosync --- spec/integration/v2/users_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/integration/v2/users_spec.rb b/spec/integration/v2/users_spec.rb index 739ebc43..1653227e 100644 --- a/spec/integration/v2/users_spec.rb +++ b/spec/integration/v2/users_spec.rb @@ -17,6 +17,7 @@ describe 'Users' do context 'POST /users/sync' do it 'syncs current_user repos' do + user.update_attribute :is_syncing, false response = post "/users/sync", {}, headers response.should be_successful end From 33463fe042ada7aadaeecf462111e675c8bc3a21 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Thu, 21 Mar 2013 16:33:57 +0100 Subject: [PATCH 088/165] update core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index a96a56cd..8530fdd0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 5a161d52e8668abd4226b4fecab1271d4491a90c + revision: ea09ee87dc019af902cc7cced289a3ff38d61407 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From 61142c7cf65f39ae44d8cd15bcffecaaa042c873 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sat, 8 Dec 2012 17:19:09 +0100 Subject: [PATCH 089/165] Return 404 unless we can find API builder for resource In order to protect us from rendering a resource simply converted to json, without processing it with API data class, this commit changes JSON responder behavior to render 404 if we can't find associated data class. The only exception to that rule is when resource is already a Hash, meaning that it was processed before - we sometimes return for example simple Hash responses like { result: true }. The Hash exception could allow to accidentally pass resource.as_json to responder, but in travis-ci/travis-support@124b8b6 I disabled default as_json method on AR::Base classes, so the risk of such mistake is lowered. --- lib/travis/api/app/responders/json.rb | 14 +++++-- spec/unit/responders/json_spec.rb | 54 +++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 spec/unit/responders/json_spec.rb diff --git a/lib/travis/api/app/responders/json.rb b/lib/travis/api/app/responders/json.rb index 464be510..13065d0e 100644 --- a/lib/travis/api/app/responders/json.rb +++ b/lib/travis/api/app/responders/json.rb @@ -8,7 +8,7 @@ class Travis::Api::App end def apply - halt result.to_json + halt result.to_json if result end private @@ -21,11 +21,15 @@ class Travis::Api::App end def result - builder ? builder.new(resource, params).data : resource + builder ? builder.new(resource, params).data : basic_type_resource end def builder - @builder ||= Travis::Api.builder(resource, { :version => version }.merge(options)) + if defined?(@builder) + @builder + else + @builder = Travis::Api.builder(resource, { :version => version }.merge(options)) + end end def accept_params @@ -39,6 +43,10 @@ class Travis::Api::App def params (request.params || {}).merge(accept_params) end + + def basic_type_resource + resource if resource.is_a?(Hash) + end end end end diff --git a/spec/unit/responders/json_spec.rb b/spec/unit/responders/json_spec.rb new file mode 100644 index 00000000..eb2ffa33 --- /dev/null +++ b/spec/unit/responders/json_spec.rb @@ -0,0 +1,54 @@ +require 'spec_helper' + +module Travis::Api::App::Responders + describe Json do + class MyJson < Json + end + + let(:request) { stub 'request', params: {} } + let(:endpoint) { stub 'endpoint', request: request } + let(:resource) { stub 'resource' } + let(:accept) { stub 'accept entry', version: '2', params: {} } + let(:options) { { :accept => accept} } + let(:json) { MyJson.new(endpoint, resource, options) } + + context 'with resource not associated with Api data class' do + it 'returns nil result' do + json.apply.should be_false + end + end + + context 'with resource being' do + context 'a Hash instance' do + let(:resource) { { foo: 'bar' } } + + it 'returns resource converted to_json' do + json.expects(:halt).with({ foo: 'bar' }.to_json) + json.apply + end + end + + context 'nil' do + let(:resource) { nil } + + it 'responds with 404' do + json.apply?.should be_false + json.apply.should be_false + end + end + end + + context 'with resource associated with Api data class' do + let(:builder) { stub 'builder', data: { foo: 'bar' } } + let(:builder_class) { stub 'builder class', new: builder } + before do + json.stubs :builder => builder_class + end + + it 'returns proper data converted to json' do + json.expects(:halt).with({ foo: 'bar' }.to_json) + json.apply + end + end + end +end From 69405329948532ef67d830bfdab5b590d46772fb Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Wed, 6 Feb 2013 23:25:12 -0800 Subject: [PATCH 090/165] Ensure proper content type for cc.xml --- spec/integration/v2/repositories_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/integration/v2/repositories_spec.rb b/spec/integration/v2/repositories_spec.rb index 0c2c928a..95ee74c6 100644 --- a/spec/integration/v2/repositories_spec.rb +++ b/spec/integration/v2/repositories_spec.rb @@ -74,6 +74,7 @@ describe 'Repos' do it 'GET /repos/1/cc.xml' do response = get "repos/#{repo.id}/cc.xml" response.should deliver_cc_xml_for(Repository.by_slug('svenfuchs/minimal').first) + response.content_type.should eq('application/xml;charset=utf-8') end it 'GET /repos/svenfuchs/minimal' do From c57e9cbcc69b58512b2ac027df66ca37f131330d Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Wed, 6 Feb 2013 23:25:42 -0800 Subject: [PATCH 091/165] valid URLs in cc.xml Project webUrl --- lib/travis/api/app/responders/xml.rb | 2 +- spec/spec_helper.rb | 1 + spec/support/matchers.rb | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/travis/api/app/responders/xml.rb b/lib/travis/api/app/responders/xml.rb index 9fa43fcf..8595a3cd 100644 --- a/lib/travis/api/app/responders/xml.rb +++ b/lib/travis/api/app/responders/xml.rb @@ -28,7 +28,7 @@ module Travis::Api::App::Responders def data { name: resource.slug, - url: [Travis.config.domain, resource.slug].join('/'), + url: File.join("http://", Travis.config.domain, resource.slug), activity: activity, label: last_build.try(:number), status: status, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 33a828a1..2384d178 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,6 +14,7 @@ require 'support/matchers' Travis.logger = Logger.new(StringIO.new) Travis::Api::App.setup +Travis.config.domain = "www.example.com" module TestHelpers include Sinatra::TestHelpers diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index 3152322a..fd46184e 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -62,7 +62,7 @@ RSpec::Matchers.define :deliver_cc_xml_for do |repo| "expected #{body} to be a valid cc.xml" end - body.include?('') && body.include?(%(name="#{repo.slug}")) + body.include?('') && body.include?(%(name="#{repo.slug}")) && body.include?("http://www.example.com/#{repo.slug}") end end From 2935050395521f05e9b1e46d6e8075ff8ea2f7b7 Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Wed, 6 Feb 2013 23:28:19 -0800 Subject: [PATCH 092/165] https is better --- lib/travis/api/app/responders/xml.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app/responders/xml.rb b/lib/travis/api/app/responders/xml.rb index 8595a3cd..8d306093 100644 --- a/lib/travis/api/app/responders/xml.rb +++ b/lib/travis/api/app/responders/xml.rb @@ -28,7 +28,7 @@ module Travis::Api::App::Responders def data { name: resource.slug, - url: File.join("http://", Travis.config.domain, resource.slug), + url: File.join("https://", Travis.config.domain, resource.slug), activity: activity, label: last_build.try(:number), status: status, From 637af8aa44d2392765b2dad6c226b0bf252c8b7e Mon Sep 17 00:00:00 2001 From: Andre Arko Date: Wed, 6 Feb 2013 23:36:31 -0800 Subject: [PATCH 093/165] oh and the spec cares too --- spec/support/matchers.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index fd46184e..798c9709 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -62,7 +62,7 @@ RSpec::Matchers.define :deliver_cc_xml_for do |repo| "expected #{body} to be a valid cc.xml" end - body.include?('') && body.include?(%(name="#{repo.slug}")) && body.include?("http://www.example.com/#{repo.slug}") + body.include?('') && body.include?(%(name="#{repo.slug}")) && body.include?("https://www.example.com/#{repo.slug}") end end From f3ceee9b28ead59da966502343342ad2f6bc2f51 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 25 Mar 2013 16:39:18 +0100 Subject: [PATCH 094/165] Always set content_type in responder --- lib/travis/api/app/responders/base.rb | 4 ++++ lib/travis/api/app/responders/image.rb | 4 ++++ lib/travis/api/app/responders/json.rb | 6 ++++++ lib/travis/api/app/responders/plain.rb | 7 ++++++- lib/travis/api/app/responders/xml.rb | 6 ++++++ spec/unit/responders/json_spec.rb | 2 +- 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/travis/api/app/responders/base.rb b/lib/travis/api/app/responders/base.rb index 8849f553..5f463d9c 100644 --- a/lib/travis/api/app/responders/base.rb +++ b/lib/travis/api/app/responders/base.rb @@ -32,6 +32,10 @@ module Travis::Api::App::Responders endpoint.headers end + def apply + endpoint.content_type content_type + end + def apply? resource && acceptable_format? end diff --git a/lib/travis/api/app/responders/image.rb b/lib/travis/api/app/responders/image.rb index 604094cf..d80d28e4 100644 --- a/lib/travis/api/app/responders/image.rb +++ b/lib/travis/api/app/responders/image.rb @@ -13,6 +13,10 @@ module Travis::Api::App::Responders private + def content_type + 'image/png' + end + def filename "#{root}/public/images/result/#{result}.png" end diff --git a/lib/travis/api/app/responders/json.rb b/lib/travis/api/app/responders/json.rb index 13065d0e..15388f6b 100644 --- a/lib/travis/api/app/responders/json.rb +++ b/lib/travis/api/app/responders/json.rb @@ -8,11 +8,17 @@ class Travis::Api::App end def apply + super + halt result.to_json if result end private + def content_type + 'application/json;charset=utf-8' + end + def accepts_log? return true unless resource.is_a?(Log) diff --git a/lib/travis/api/app/responders/plain.rb b/lib/travis/api/app/responders/plain.rb index 2320b1e2..9d045478 100644 --- a/lib/travis/api/app/responders/plain.rb +++ b/lib/travis/api/app/responders/plain.rb @@ -14,17 +14,22 @@ module Travis::Api::App::Responders end def apply + super + filename = resource.id disposition = params[:attachment] ? 'attachment' : 'inline' headers['Content-Disposition'] = %(#{disposition}; filename="#{filename}") - endpoint.content_type 'text/plain' halt(params[:deansi] ? clear_ansi(resource.content) : resource.content) end private + def content_type + 'text/plain' + end + def clear_ansi(content) content.gsub(/\r\r/, "\r") .gsub(/^.*\r(?!$)/, '') diff --git a/lib/travis/api/app/responders/xml.rb b/lib/travis/api/app/responders/xml.rb index 9fa43fcf..e2137f4a 100644 --- a/lib/travis/api/app/responders/xml.rb +++ b/lib/travis/api/app/responders/xml.rb @@ -20,11 +20,17 @@ module Travis::Api::App::Responders end def apply + super + halt TEMPLATE % data end private + def content_type + 'application/xml;charset=utf-8' + end + def data { name: resource.slug, diff --git a/spec/unit/responders/json_spec.rb b/spec/unit/responders/json_spec.rb index eb2ffa33..37146d58 100644 --- a/spec/unit/responders/json_spec.rb +++ b/spec/unit/responders/json_spec.rb @@ -6,7 +6,7 @@ module Travis::Api::App::Responders end let(:request) { stub 'request', params: {} } - let(:endpoint) { stub 'endpoint', request: request } + let(:endpoint) { stub 'endpoint', request: request, content_type: nil } let(:resource) { stub 'resource' } let(:accept) { stub 'accept entry', version: '2', params: {} } let(:options) { { :accept => accept} } From 887c835bd473f49b8da00c544314e0fbbc788fe7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 25 Mar 2013 16:53:20 +0100 Subject: [PATCH 095/165] Use client_domain instead of domain for url in CC.xml --- lib/travis/api/app/responders/xml.rb | 2 +- spec/spec_helper.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/travis/api/app/responders/xml.rb b/lib/travis/api/app/responders/xml.rb index 3d4fff71..b69911b1 100644 --- a/lib/travis/api/app/responders/xml.rb +++ b/lib/travis/api/app/responders/xml.rb @@ -34,7 +34,7 @@ module Travis::Api::App::Responders def data { name: resource.slug, - url: File.join("https://", Travis.config.domain, resource.slug), + url: File.join("https://", Travis.config.client_domain, resource.slug), activity: activity, label: last_build.try(:number), status: status, diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2384d178..44cd1061 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -14,7 +14,7 @@ require 'support/matchers' Travis.logger = Logger.new(StringIO.new) Travis::Api::App.setup -Travis.config.domain = "www.example.com" +Travis.config.client_domain = "www.example.com" module TestHelpers include Sinatra::TestHelpers From c1aaeeee32fc5b5b890ca0e3777c7cff24ea38e4 Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Mon, 3 Dec 2012 23:09:57 -0600 Subject: [PATCH 096/165] Add a way to add responses to documentation You can add a predefined JSON response by entering "json(:resource_name)" in the docstring. This will then be replaced with the resource with the same name, found in lib/travis/api/app/endpoint/documentation/resources.rb. --- lib/travis/api/app/endpoint/documentation.rb | 2 + .../app/endpoint/documentation/resources.rb | 95 +++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 lib/travis/api/app/endpoint/documentation/resources.rb diff --git a/lib/travis/api/app/endpoint/documentation.rb b/lib/travis/api/app/endpoint/documentation.rb index 18653990..569906da 100644 --- a/lib/travis/api/app/endpoint/documentation.rb +++ b/lib/travis/api/app/endpoint/documentation.rb @@ -1,4 +1,5 @@ require 'travis/api/app' +require 'travis/api/app/endpoint/documentation/resources' class Travis::Api::App class Endpoint @@ -44,6 +45,7 @@ class Travis::Api::App def with_code_highlighting(str) str. + gsub(/json\(:([^)]+)\)/) { "
    " + Resources::Helpers.json($1) + "
    " }. gsub('/, ''). gsub(/TODO:?/, 'TODO') diff --git a/lib/travis/api/app/endpoint/documentation/resources.rb b/lib/travis/api/app/endpoint/documentation/resources.rb new file mode 100644 index 00000000..7026a6fe --- /dev/null +++ b/lib/travis/api/app/endpoint/documentation/resources.rb @@ -0,0 +1,95 @@ +require 'json' + +class Travis::Api::App::Endpoint + module Resources + module Helpers + def self.json(key) + JSON.pretty_generate(Resources.const_get(key.to_s.upcase)) + end + end + + REPOSITORY_KEY = { + "public_key" => "-----BEGIN RSA PUBLIC KEY-----\nMIGJAoGBAOcx131amMqIzm5+FbZz+DhIgSDbFzjKKpzaN5UWVCrLSc57z64xxTV6\nkaOTZmjCWz6WpaPkFZY+czfL7lmuZ/Y6UNm0vupvdZ6t27SytFFGd1/RJlAe89tu\nGcIrC1vtEvQu2frMLvHqFylnGd5Gy64qkQT4KRhMsfZctX4z5VzTAgMBAAE=\n-----END RSA PUBLIC KEY-----\n", + } + + REPOSITORY = { + "id" => 59, + "slug" => "travis-ci/travis-ci", + "description" => "A distributed build system for the open source community.", + "public_key" => REPOSITORY_KEY["public_key"], + "last_build_id" => 3373911, + "last_build_number" => "2188", + "last_build_status" => 0, + "last_build_result" => 0, + "last_build_duration" => 221, + "last_build_language" => nil, + "last_build_started_at" => "2012-11-27T01:01:28Z", + "last_build_finished_at" => "2012-11-27T01:05:09Z", + } + + REPOSITORIES = [REPOSITORY] + + SHORT_BUILD = { + "id" => 3373911, + "repository_id" => 59, + "number" => "2188", + "state" => "finished", + "result" => 0, + "started_at" => "2012-11-27T01:01:28Z", + "finished_at" => "2012-11-27T01:05:09Z", + "duration" => 221, + "commit" => "a0e4dada7eb30b41817d9d3c5222b519502ef87a", + "branch" => "master", + "message" => "no need to set up services", + "event_type" => "push", + } + + BUILDS = [ + SHORT_BUILD, + ] + + CONFIG = { + "language" => "ruby", + "rvm" => [ + "1.9.3", + ], + "bundler_args" => "--without development", + "before_install" => [ + "gem install bundler --pre", + ], + "before_script" => [ + "cp config/database.example.yml config/database.yml" + ], + "script" => "RAILS_ENV=test bundle exec rake test:ci --trace", + "notifications" => { + "irc" => "irc.freenode.org#travis", + "campfire" => { + "secure" => "JJezWGD9KJY/LC2aznI3Zyohy31VTIhcTKX7RWR4C/C8YKbW9kZv3xV6Vn11\nSHxJTeZo6st2Bpv6tjlWZ+HCR09kyCNavIChedla3+oHOiuL0D4gSo+gkTNW\nUKYZz9mcQUd9RoQpTeyxvdvX+l7z62/7JwFA7txHOqxbTS8jrjc=" + } + }, + ".result" => "configured" + } + + BUILD = SHORT_BUILD.merge({ + "config" => CONFIG, + "committed_at" => "2012-11-27T01:01:06Z", + "author_name" => "Sven Fuchs", + "author_email" => "me@svenfuchs.com", + "committer_name" => "Sven Fuchs", + "committer_email" => "me@svenfuchs.com", + "compare_url" => "https://github.com/travis-ci/travis-ci/compare/18b6874865f2...a0e4dada7eb3", + "matrix" => [ + { + "id" => 3373912, + "repository_id" => 59, + "number" => "2188.1", + "config" => CONFIG, + "result" => 0, + "started_at" => "2012-11-27T01:01:28Z", + "finished_at" => "2012-11-27T01:05:09Z", + "allow_failure" => false + } + ] + }) + end +end From 6f5f7d0073431c3b52728bfea95735ce3e1a5378 Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Mon, 3 Dec 2012 23:11:01 -0600 Subject: [PATCH 097/165] Add responses to repository endpoints --- lib/travis/api/app/endpoint/repos.rb | 42 ++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/lib/travis/api/app/endpoint/repos.rb b/lib/travis/api/app/endpoint/repos.rb index 7e9eb3fe..40c430ce 100644 --- a/lib/travis/api/app/endpoint/repos.rb +++ b/lib/travis/api/app/endpoint/repos.rb @@ -8,10 +8,19 @@ class Travis::Api::App # You can filter the repositories by adding parameters to the request. For example, you can get all repositories # owned by johndoe by adding `owner_name=johndoe`, or all repositories that johndoe has access to by adding # `member=johndoe`. The parameter names correspond to the keys of the response hash. + # + # ### Response + # + # json(:repositories) get '/' do respond_with service(:find_repos, params) end + # Gets the repository with the given id. + # + # ### Response + # + # json(:repository) get '/:id' do respond_with service(:find_repo, params) end @@ -20,6 +29,15 @@ class Travis::Api::App respond_with service(:find_repo, params.merge(schema: 'cc')) end + # Get the public key for the repository with the given id. + # + # This can be used to encrypt secure variables in the build configuration. See + # [the encryption keys](http://about.travis-ci.org/docs/user/encryption-keys/) documentation page for more + # information. + # + # ### Response + # + # json(:repository_key) get '/:id/key' do respond_with service(:find_repo_key, params), version: :v2 end @@ -28,14 +46,29 @@ class Travis::Api::App respond_with service(:regenerate_repo_key, params), version: :v2 end + # Gets the repository with the given name. + # + # ### Response + # + # json(:repository) get '/:owner_name/:name' do respond_with service(:find_repo, params) end + # Gets the builds for the repository with the given name. + # + # ### Response + # + # json(:builds) get '/:owner_name/:name/builds' do respond_with service(:find_builds, params) end + # Get a build with the given id in the repository with the given name. + # + # ### Response + # + # json(:build) get '/:owner_name/:name/builds/:id' do respond_with service(:find_build, params) end @@ -44,6 +77,15 @@ class Travis::Api::App respond_with service(:find_repo, params.merge(schema: 'cc')) end + # Get the public key for a given repository. + # + # This can be used to encrypt secure variables in the build configuration. See + # [the encryption keys](http://about.travis-ci.org/docs/user/encryption-keys/) documentation page for more + # information. + # + # ### Response + # + # json(:repository_key) get '/:owner_name/:name/key' do respond_with service(:find_repo_key, params), version: :v2 end From 1d6587cabac5ad6ccb7cf0dc1efcc51a27bea479 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 27 Mar 2013 12:47:18 +0100 Subject: [PATCH 098/165] Bump travis-core --- Gemfile.lock | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8530fdd0..cb6c73d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: ea09ee87dc019af902cc7cced289a3ff38d61407 + revision: 16f58bb2b808c2a603ae9213ede8bd5fb765631f specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -104,12 +104,12 @@ PATH GEM remote: https://rubygems.org/ specs: - actionmailer (3.2.12) - actionpack (= 3.2.12) - mail (~> 2.4.4) - actionpack (3.2.12) - activemodel (= 3.2.12) - activesupport (= 3.2.12) + actionmailer (3.2.13) + actionpack (= 3.2.13) + mail (~> 2.5.3) + actionpack (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.4) @@ -117,16 +117,16 @@ GEM rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) - activemodel (3.2.12) - activesupport (= 3.2.12) + activemodel (3.2.13) + activesupport (= 3.2.13) builder (~> 3.0.0) - activerecord (3.2.12) - activemodel (= 3.2.12) - activesupport (= 3.2.12) + activerecord (3.2.13) + activemodel (= 3.2.13) + activesupport (= 3.2.13) arel (~> 3.0.2) tzinfo (~> 0.3.29) - activesupport (3.2.12) - i18n (~> 0.6) + activesupport (3.2.13) + i18n (= 0.6.1) multi_json (~> 1.0) addressable (2.3.3) arel (3.0.2) @@ -153,7 +153,7 @@ GEM facter (1.6.17) factory_girl (2.4.2) activesupport - faraday (0.8.6) + faraday (0.8.7) multipart-post (~> 1.1) foreman (0.61.0) thor (>= 0.13.6) @@ -163,11 +163,11 @@ GEM hitimes (1.2.1) hubble (0.1.2) yajl-ruby (~> 1.1) - i18n (0.6.4) + i18n (0.6.1) journey (1.0.4) json (1.7.7) listen (0.7.2) - mail (2.4.4) + mail (2.5.3) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) @@ -180,7 +180,7 @@ GEM mime-types (1.21) mocha (0.13.2) metaclass (~> 0.0.1) - multi_json (1.6.1) + multi_json (1.7.2) multipart-post (1.2.0) net-http-persistent (2.8) net-http-pipeline (1.0.1) @@ -211,9 +211,9 @@ GEM rack rack-test (0.6.2) rack (>= 1.0) - railties (3.2.12) - actionpack (= 3.2.12) - activesupport (= 3.2.12) + railties (3.2.13) + actionpack (= 3.2.13) + activesupport (= 3.2.13) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) @@ -266,7 +266,7 @@ GEM eventmachine (>= 0.12.6) rack (>= 1.0.0) thor (0.14.6) - tilt (1.3.5) + tilt (1.3.6) timers (1.1.0) treetop (1.4.12) polyglot From b4e59caebfc1eedbe9d798cdcb10352ef796f612 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 27 Mar 2013 12:32:35 +0100 Subject: [PATCH 099/165] Add task to migrate pull request data for builds --- Rakefile | 3 +++ lib/tasks/build_update_pull_request_data.rake | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 lib/tasks/build_update_pull_request_data.rake diff --git a/Rakefile b/Rakefile index 5c5bce13..1c36edac 100644 --- a/Rakefile +++ b/Rakefile @@ -33,3 +33,6 @@ task 'travis-api.gemspec' do end task default: 'travis-api.gemspec' + +tasks_path = File.expand_path('../lib/tasks/*.rake', __FILE__) +Dir.glob(tasks_path).each { |r| import r } diff --git a/lib/tasks/build_update_pull_request_data.rake b/lib/tasks/build_update_pull_request_data.rake new file mode 100644 index 00000000..b66b4d90 --- /dev/null +++ b/lib/tasks/build_update_pull_request_data.rake @@ -0,0 +1,21 @@ +namespace :build do + namespace :migrate do + task :pull_request_data do + require 'travis' + Travis::Database.connect + + Build.pull_requests.includes(:request).find_in_batches do |builds| + Build.transaction do + builds.each do |build| + attrs = { + :pull_request_number => build.request.pull_request_number, + :pull_request_title => build.request.pull_request_title + } + + Build.where(id: build.id).update_all(attrs) + end + end + end + end + end +end From 17de12655d767c678c0fc56143f6db1ce7126d96 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 27 Mar 2013 13:01:02 +0100 Subject: [PATCH 100/165] Don't require micro_migrations in Rakefile It breaks when I want to run any rake task --- Rakefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Rakefile b/Rakefile index 1c36edac..96f93a44 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,6 @@ require 'bundler/setup' ENV['SCHEMA'] = "#{Gem.loaded_specs['travis-core'].full_gem_path}/db/schema.rb" -require 'micro_migrations' require 'travis' begin From adbc0653e43acafd26fad060b2fd06956a6db542 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 27 Mar 2013 13:24:56 +0100 Subject: [PATCH 101/165] Revert "Don't require micro_migrations in Rakefile" Apparently it's needed to run tests This reverts commit 17de12655d767c678c0fc56143f6db1ce7126d96. --- Rakefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Rakefile b/Rakefile index 96f93a44..1c36edac 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,7 @@ require 'bundler/setup' ENV['SCHEMA'] = "#{Gem.loaded_specs['travis-core'].full_gem_path}/db/schema.rb" +require 'micro_migrations' require 'travis' begin From f28c47597efaaf49cfb06145beac866768acf0c6 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 27 Mar 2013 14:54:08 +0100 Subject: [PATCH 102/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index cb6c73d9..0355b926 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 16f58bb2b808c2a603ae9213ede8bd5fb765631f + revision: 21563250c911c803e03ae6930e2eb213bd88638a specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From 0ea7cc3ac424603427c2218eba7a570bb1c768be Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 27 Mar 2013 15:04:44 +0100 Subject: [PATCH 103/165] Update only builds that need to be updated in pull_request_data rake task --- lib/tasks/build_update_pull_request_data.rake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tasks/build_update_pull_request_data.rake b/lib/tasks/build_update_pull_request_data.rake index b66b4d90..ff59c7e6 100644 --- a/lib/tasks/build_update_pull_request_data.rake +++ b/lib/tasks/build_update_pull_request_data.rake @@ -4,7 +4,8 @@ namespace :build do require 'travis' Travis::Database.connect - Build.pull_requests.includes(:request).find_in_batches do |builds| + Build.pull_requests.where('pull_request_number IS NULL OR pull_request_title IS NULL'). + includes(:request).find_in_batches do |builds| Build.transaction do builds.each do |build| attrs = { From def6c92125dd8defe9e968f26d438d46d358242a Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 27 Mar 2013 15:13:19 +0100 Subject: [PATCH 104/165] Don't error out on micro migrations on production --- Rakefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index 1c36edac..29502405 100644 --- a/Rakefile +++ b/Rakefile @@ -1,7 +1,11 @@ require 'bundler/setup' ENV['SCHEMA'] = "#{Gem.loaded_specs['travis-core'].full_gem_path}/db/schema.rb" -require 'micro_migrations' +begin + require 'micro_migrations' +rescue LoadError + # we can't load micro migrations on production +end require 'travis' begin From cc70e158258d837372eb3c53f506162e81dc8e90 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 27 Mar 2013 15:48:44 +0100 Subject: [PATCH 105/165] Fetch all builds in PR rake task, but skip when it's already filled in --- lib/tasks/build_update_pull_request_data.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/build_update_pull_request_data.rake b/lib/tasks/build_update_pull_request_data.rake index ff59c7e6..0fbcd681 100644 --- a/lib/tasks/build_update_pull_request_data.rake +++ b/lib/tasks/build_update_pull_request_data.rake @@ -4,10 +4,10 @@ namespace :build do require 'travis' Travis::Database.connect - Build.pull_requests.where('pull_request_number IS NULL OR pull_request_title IS NULL'). - includes(:request).find_in_batches do |builds| + Build.pull_requests.includes(:request).order('id DESC').find_in_batches do |builds| Build.transaction do builds.each do |build| + next if build.pull_request_number && build.pull_request_title attrs = { :pull_request_number => build.request.pull_request_number, :pull_request_title => build.request.pull_request_title From d776f841c84de77bf6c3958a8c3d59bb8501e6d7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 29 Mar 2013 17:16:08 +0100 Subject: [PATCH 106/165] Bump travis-core --- Gemfile.lock | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0355b926..a005f603 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 21563250c911c803e03ae6930e2eb213bd88638a + revision: 336c5995144005b69cd00ef5b21b7256e3daa013 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -56,7 +56,6 @@ GIT hashr (~> 0.0.19) metriks (~> 0.9.7) multi_json - postmark-rails (~> 0.4.1) pusher (~> 0.11.0) railties (~> 3.2.12) rake @@ -130,7 +129,7 @@ GEM multi_json (~> 1.0) addressable (2.3.3) arel (3.0.2) - atomic (1.0.1) + atomic (1.0.2) avl_tree (1.1.3) backports (2.8.2) builder (3.0.4) @@ -186,13 +185,6 @@ GEM net-http-pipeline (1.0.1) pg (0.13.2) polyglot (0.3.3) - postmark (0.9.19) - json - rake - postmark-rails (0.4.1) - actionmailer - postmark (>= 0.9.0) - rake pry (0.9.12) coderay (~> 1.0.5) method_source (~> 0.8) From 3c75f9fa07f2f96816eeba87195d7645e44a765d Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 3 Apr 2013 13:39:10 +0200 Subject: [PATCH 107/165] Bump travis-core --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a005f603..02994584 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 336c5995144005b69cd00ef5b21b7256e3daa013 + revision: ba517fee12866b01860d1149040f63d429002a82 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -176,7 +176,7 @@ GEM atomic (~> 1.0) avl_tree (~> 1.1.2) hitimes (~> 1.1) - mime-types (1.21) + mime-types (1.22) mocha (0.13.2) metaclass (~> 0.0.1) multi_json (1.7.2) From be22ff6eda3dcb53b96c8d478c2a4570d2bfe189 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 11 Apr 2013 14:47:00 +0200 Subject: [PATCH 108/165] Ensure that we properly handle 404 formats --- spec/integration/v2/repositories_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spec/integration/v2/repositories_spec.rb b/spec/integration/v2/repositories_spec.rb index 95ee74c6..114bf474 100644 --- a/spec/integration/v2/repositories_spec.rb +++ b/spec/integration/v2/repositories_spec.rb @@ -92,6 +92,17 @@ describe 'Repos' do response.status.should == 406 end + it 'responds with 404 when repo can\'t be found and format is png' do + result = get('/repos/foo/bar.png', {}, 'HTTP_ACCEPT' => 'image/png; version=2') + result.status.should == 404 + end + + it 'responds with 404 when repo can\'t be found and format is other than png' do + result = get('/repos/foo/bar', {}, 'HTTP_ACCEPT' => 'application/json; version=2') + result.status.should == 404 + JSON.parse(result.body).should == { 'file' => 'not found' } + end + describe 'GET /repos/svenfuchs/minimal.png?branch=foo,bar' do let(:on_foo) { Factory(:commit, branch: 'foo') } let(:on_bar) { Factory(:commit, branch: 'bar') } From e0e3603d25e0b2627b53157dd03501bec0ea8f71 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 12 Apr 2013 03:32:32 +0200 Subject: [PATCH 109/165] Bump travis-core --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 02994584..db742902 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: ba517fee12866b01860d1149040f63d429002a82 + revision: c5ceac066aeea4a5b3d84e66a165b8c188f13c9f specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -129,7 +129,7 @@ GEM multi_json (~> 1.0) addressable (2.3.3) arel (3.0.2) - atomic (1.0.2) + atomic (1.1.7) avl_tree (1.1.3) backports (2.8.2) builder (3.0.4) @@ -158,7 +158,7 @@ GEM thor (>= 0.13.6) hashie (2.0.0) hashr (0.0.22) - hike (1.2.1) + hike (1.2.2) hitimes (1.2.1) hubble (0.1.2) yajl-ruby (~> 1.1) @@ -258,7 +258,7 @@ GEM eventmachine (>= 0.12.6) rack (>= 1.0.0) thor (0.14.6) - tilt (1.3.6) + tilt (1.3.7) timers (1.1.0) treetop (1.4.12) polyglot From e38b40e00a3c9fb016525cfc7d04ecec9ec76471 Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Mon, 15 Apr 2013 02:02:08 -0500 Subject: [PATCH 110/165] Update docs style to look more like the main docs site --- lib/travis/api/app/endpoint/artifacts.rb | 2 +- lib/travis/api/app/endpoint/documentation.rb | 208 +++--- .../app/endpoint/documentation/css/style.css | 594 ++++++++++++++++++ 3 files changed, 678 insertions(+), 126 deletions(-) create mode 100644 lib/travis/api/app/endpoint/documentation/css/style.css diff --git a/lib/travis/api/app/endpoint/artifacts.rb b/lib/travis/api/app/endpoint/artifacts.rb index 4f465f97..cd35a570 100644 --- a/lib/travis/api/app/endpoint/artifacts.rb +++ b/lib/travis/api/app/endpoint/artifacts.rb @@ -5,7 +5,7 @@ class Travis::Api::App # Artifacts are generated by builds. Currently we only expose logs as # artifacts # - # DEPRECATED will be removed as soon as the client uses /logs/:id + # **DEPRECATED** will be removed as soon as the client uses /logs/:id class Artifacts < Endpoint # Fetches an artifact by it's *id*. get '/:id' do |id| diff --git a/lib/travis/api/app/endpoint/documentation.rb b/lib/travis/api/app/endpoint/documentation.rb index 18653990..e46a504f 100644 --- a/lib/travis/api/app/endpoint/documentation.rb +++ b/lib/travis/api/app/endpoint/documentation.rb @@ -81,151 +81,113 @@ __END__ - + Travis API documentation - - - - - - - + + + + + + - - - Fork me on GitHub - - -
    -
    -
    -

    The Travis API

    -

    All the routes, just waiting for you to build something awesome.

    -
    + -
    + - - -
    - - <% general_docs.each do |doc| %> - <%= erb :entry, locals: doc %> - <% end %> - - <% endpoints.each do |endpoint| %> - <%= erb :entry, {}, - id: endpoint['name'], - title: endpoint['name'], - content: erb(:endpoint_content, {}, endpoint: endpoint) %> - <% end %> - -
    +
    +
    +
    + + @@ endpoint_content <% unless endpoint['doc'].to_s.empty? %> <%= docs_for endpoint %> -
    <% end %> <% endpoint['routes'].each do |route| %>
    -

    <%= route['verb'] %> <%= route['uri'] %>

    +

    <%= route['verb'] %> <%= route['uri'] %>

    <% if route['scope'] %>

    Required autorization scope: <%= route['scope'] %>
    @@ -237,11 +199,7 @@ __END__ @@ entry
    - +

    <%= title %> #

    <%= content %>
    diff --git a/lib/travis/api/app/endpoint/documentation/css/style.css b/lib/travis/api/app/endpoint/documentation/css/style.css new file mode 100644 index 00000000..ee4513a8 --- /dev/null +++ b/lib/travis/api/app/endpoint/documentation/css/style.css @@ -0,0 +1,594 @@ +/* ---( = begin global reset thanks to eric meyer elements )------------------------------- */ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, font, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td { + margin: 0; + padding: 0; + border: 0; + outline: 0; + font-weight: inherit; + font-style: inherit; + font-size: 100%; + font-family: inherit; + vertical-align: baseline; +} + +/* remember to define focus styles! */ +:focus { + outline: 0; +} + +body { + line-height: 1; + color: black; + background: white; +} + +ol, ul { + list-style: none; +} + +/* tables still need 'cellspacing="0"' in the markup */ +table { + border-collapse: separate; + border-spacing: 0; +} + +caption, th, td { + text-align: left; + font-weight: normal; +} + +blockquote:before, blockquote:after, q:before, q:after { + content: ""; +} + +blockquote, q { + quotes: "" ""; +} + +/* travis-ci styles */ + +body { + margin: 0 0 1em 0; + font-size: 14px; + line-height: 1.4286; + color: #555; + background: #fff; + font-family: "Helvetica Neue", Arial, Verdana, sans-serif; +} + +a { + color: #3366cc; + outline: none; + text-decoration: underline; +} + +a:visited { + color: #666; + +} + +a:hover { + color: #66cc33; + text-decoration: none; +} + +p, ul, blockquote, pre, td, th, label { + margin: 1.4286em 0; + font-size: 1em; + line-height: 1.4286; +} + +blockquote { + font-style: italic; + margin-left: 1em; +} + +blockquote small.author { + font-style: normal; + margin-top: 10px; + text-align: right; +} + +blockquote small.author:after { + content: ":"; +} + +p small.author { + margin: 0; +} + +ul, ol { + margin: 1.4286em 0; + text-align: left; +} + +li { + line-height: 1.4286; +} + +table { + border-collapse: collapse; + margin-bottom: 1.5em; +} + +strong { + font-family: Helvetica, Arial; + color: #8e7a2b; + font-weight: bold; +} + +em { + font-style: italic; +} +span.help { + font-style: italic; + background-color: #ffff99; + font-family: Georgia, Times, Serif; +} + +pre { + margin-top: 1em; + padding: 1em 1.5em; + line-height: 1.5em; + border: 1px solid #ddd; + background: #fafafa; + border-bottom-left-radius: 8px 8px; + border-bottom-right-radius: 8px 8px; + border-top-left-radius: 8px 8px; + border-top-right-radius: 8px 8px; + font-family: monospace; + font-size: 13px; + overflow-x: scroll; +} + +p > code, div > code, li > code { + background-color: #fafafa; + border: 1px solid #e0e0e0; + color: #333; + padding: 0px 0.2em; + font-family: monospace; + font-size: 13.3px; +} + +.wrapper { + width: 960px; + margin: 0 auto; + text-align: left; + overflow: hidden; + position: relative; +} + +div#navigation { + clear: both; + margin: 0 0 0 0; + padding: .8em 0 .6em 0; + overflow: hidden; + background: #efefef; + color: #888; + border-bottom: 1px solid #ccc; +} + +div#header { + clear: both; + margin: 1em auto 0 auto; + padding-top: 10px; + text-align: center; + overflow: hidden; +} + +div#navigation .wrapper { + width: 940px; +} + +div#navigation .wrapper a#logo { + color: #828282; + display:block; + float: left; + font-weight: bold; + font-size: 1.1em; + line-height: 1.2em; + margin: 0.15em 1em 0 0; + padding: 0 1em 0 0; + text-decoration: none; +} + +div#navigation .wrapper a#logo span { + color: #bbbaba; + font-size: .85em; +} + +div#navigation ul { + margin:0; + padding:0; +} + +div#navigation ul li { + margin: 0; + padding: 0; + float: left; + border-left: 1px solid #ccc; +} + +div#navigation ul li.right { + float: right; + border-left: none; + font-size: .83em; +} + +div#navigation ul li a, +div#navigation ul li a:visited { + color: #999; + display:block; + padding: 0em 1em 0 1em ; + text-decoration:none; +} + +div#navigation ul li a:hover, +div#navigation ul li a:visited { + text-decoration:underline; +} + +div#navigation ul li.selected a, +div#navigation ul li.selected a:visited { + text-decoration: none; + color: #6c3; +} + +div#navigation ul li.active a, +div#navigation ul li.selected a:visited { + text-decoration: none; + color: #444; +} + +div#content { + clear: both; + margin: 0 auto 3em auto; + padding: 0 0 0; + text-align:center; + overflow: hidden; +} + +div#content div.pad { + margin-left: 20px; + margin-right: 20px; +} + +div#main { + float:left; + width: 580px; + overflow: hidden; + padding-top: 2em; +} + +#main ul, +#main ul li { + list-style-type: disc; +} + +#main ol, +#main ol li { + list-style-type: decimal; +} + +#main li { + margin-left: 1.4286em; +} + +.clear { + clear: both; +} + +#main figure { + clear: both !important; + width: 578px; + border: 1px solid #efefef; + text-align: center; + margin: 0px; + border-radius: 4px; +} + +#main figure figcaption { + background-color: #efefef; + text-align: left; + font-size: 80%; + padding: 5px 10px; +} + +#main figure img { + max-width: 570px; + margin: 4px; +} + +#main figure.left { + margin-bottom: 1.4286em; + margin-right: 1.4286em; + float: left; +} + +#main figure.right { + margin-bottom: 1.4286em; + margin-left: 1.4286em; + float: right; +} + +#main figure.smallest { + width: 138px; +} + +#main figure.smallest img { + width: 130px; +} + + +#main figure.smaller { + width: 208px; +} + +#main figure.smaller img { + width: 200px; +} + +#main figure.small { + width: 258px; +} + +#main figure.small img { + max-width: 250px; +} + +div#sidebar { + float:right; + width: 325px; + overflow: hidden; + padding-top: 0; +} + +#sidebar ul { + margin:0 0 1.5em 0; + padding:0; +} + +#sidebar p { + margin: 0; + padding: 0; +} + +#sidebar p, +#sidebar ul li p, +#sidebar ul li a, +#sidebar ul li a:visited { + display:block; + text-decoration:none; + padding:4px 0 3px 20px; + border-top: 1px solid #efefef; +} + +#sidebar ul li a:hover, +#sidebar ul li a:visited:hover { + text-decoration:underline; +} + +#sidebar ul li.selected a, +#sidebar ul li.selected a:visited { + color: #6c3; + background: #efefef; + margin-left: 0; + padding-left: 20px; +} + +#sidebar ul li ul { + border-bottom: 0; + list-style-type: disc; + margin-bottom: 0.5em; +} + +#sidebar ul li ul li { + border-bottom: 0; + list-style-type: disc; + margin-left: 1.5em; +} + +#sidebar ul li ul li a, +#sidebar ul li ul li a:visited, +#sidebar ul li.selected ul li a, +#sidebar ul li.selected ul li a:visited { + display:block; + text-decoration:none; + padding:0; + border-top: 0; + font-weight: normal; + color: #195190; +} + +#sidebar ul li ul li.selected a, +#sidebar ul li ul li.selected a:visited { + color: #444; + font-weight: normal; +} + +div#footer { + clear: both; + margin: 0 auto; + padding-top: 10px; + text-align: center; + overflow: hidden; + background: #efefef; + border-top: 1px solid #ddd; + border-bottom: 1px solid #ddd +} + +div#footer .wrapper { + background: transparent; + width: 920px; +} + +div#footer div.box { + float: left; + width: 280px; + margin-right: 30px; + color: #888; +} + +div#footer div.last { + margin-right: 0; + margin-left: 15px; +} + +div#footer div.box ul li a, +div#footer div.box ul li a:visited { + color: #7d8997; +} + +h1, h2, h3, h4, h5, h6 { + margin: 0; + padding: 0; + font-weight: bold; + color: #40454F; +} + +h1 { + font-size: 3em; + line-height: 1em; + margin-bottom: 0.5em; + clear: both; +} + +h2 { + font-size: 1.6em; + margin-bottom: 1em; + line-height: 1em; + letter-spacing: -0.5px; + clear: both; +} + +.meta { + margin-top: -1.7em; + font-size: 80%; +} + +h3 { + font-size: 1.15em; + line-height: 1em; + margin-bottom: 0.5em; +} + +h4 { + font-size: 0.95em; + line-height: 1.25; + margin-bottom: 1.25em; + height: 1.25em; +} + +h1 img, h2 img, h3 img, h4 img, h5 img, h6 img { + margin: 0; +} + +h1 a, +h1 a:visited, +h2 a, +h2 a:visited, +h3 a, +h3 a:visited, +h4 a, +h4 a:visited, +h5 a, +h5 a:visited { + color: #464755; +} + +div#header h1 { + float: left; + width: 350px; + text-indent: -20000em; + background: transparent; + font-size:1px; + margin: 20px 0 0 20px; +} + +div#header h1 a, +div#header h1 a:visited, +div#header h1 a:hover, +div#header h1 a:visited:hover { + display: block; + width: 350px; + height: 75px; +} + +div#header h1.riddle { + float: none; + width: 100%; + text-indent: 0; + background: #fff; + color: #000; + font-size:4em; + margin: 20px 0 0 0; + padding:0; +} + +div#header h1.riddle a, +div#header h1.riddle a:visited, +div#header h1.riddle a:hover, +div#header h1.riddle a:visited:hover { + display: block; + width: 100%; + height: auto; + color: #000; + text-decoration: none; +} + +div#header p { + color: #777; + display: block; + font: italic 1.25em Georgia, Times, Serif; + line-height: 1.67em; + margin: 0.935em 0 1.87em 0; + padding: 0 0 1.25em 0; + border-bottom: 1px solid #ccc; +} + +div#sidebar h2 { + font-size: .9em; + letter-spacing: .5px; + text-transform:uppercase; + margin: 40px 20px 5px 20px; +} + +.highlight pre { + font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace; + padding: 0 1.5em; +} + +.highlight br { + display: none; +} + +.highlight { + background-color: #f8f8f8; + border: 1px solid silver; + font-family: 'Courier New', 'Terminal', monospace; + color: #100; + margin: 1.5em 0; +} + +div#content div.pad { + margin-left: 0; + margin-right: 0; +} + +div#navigation ul li.lang { + float: right; + border-left: none; + font-size: .83em; +} + +#dsq-global-toolbar ul li { + list-style-type: none; +} From 0f31ff4fb6aa235100f2b44012550e64c03c569d Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Mon, 15 Apr 2013 02:17:08 -0500 Subject: [PATCH 111/165] Add favicon --- public/favicon.ico | Bin 0 -> 231 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 public/favicon.ico diff --git a/public/favicon.ico b/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..cf16e253568938f39d02b8f9d82f630e4b28ff3f GIT binary patch literal 231 zcmZ?wbh9u|6krfwIKsei*-8e8uG=Yqkh3}*-Sjbqqgw%1w Date: Mon, 15 Apr 2013 14:11:58 -0500 Subject: [PATCH 112/165] Update example payloads --- .../app/endpoint/documentation/resources.rb | 188 +++++++++++------- 1 file changed, 117 insertions(+), 71 deletions(-) diff --git a/lib/travis/api/app/endpoint/documentation/resources.rb b/lib/travis/api/app/endpoint/documentation/resources.rb index 7026a6fe..aefc1392 100644 --- a/lib/travis/api/app/endpoint/documentation/resources.rb +++ b/lib/travis/api/app/endpoint/documentation/resources.rb @@ -9,87 +9,133 @@ class Travis::Api::App::Endpoint end REPOSITORY_KEY = { - "public_key" => "-----BEGIN RSA PUBLIC KEY-----\nMIGJAoGBAOcx131amMqIzm5+FbZz+DhIgSDbFzjKKpzaN5UWVCrLSc57z64xxTV6\nkaOTZmjCWz6WpaPkFZY+czfL7lmuZ/Y6UNm0vupvdZ6t27SytFFGd1/RJlAe89tu\nGcIrC1vtEvQu2frMLvHqFylnGd5Gy64qkQT4KRhMsfZctX4z5VzTAgMBAAE=\n-----END RSA PUBLIC KEY-----\n", + 'public_key' => '-----BEGIN RSA PUBLIC KEY-----\nMIGJAoGBAOcx131amMqIzm5+FbZz+DhIgSDbFzjKKpzaN5UWVCrLSc57z64xxTV6\nkaOTZmjCWz6WpaPkFZY+czfL7lmuZ/Y6UNm0vupvdZ6t27SytFFGd1/RJlAe89tu\nGcIrC1vtEvQu2frMLvHqFylnGd5Gy64qkQT4KRhMsfZctX4z5VzTAgMBAAE=\n-----END RSA PUBLIC KEY-----\n', } REPOSITORY = { - "id" => 59, - "slug" => "travis-ci/travis-ci", - "description" => "A distributed build system for the open source community.", - "public_key" => REPOSITORY_KEY["public_key"], - "last_build_id" => 3373911, - "last_build_number" => "2188", - "last_build_status" => 0, - "last_build_result" => 0, - "last_build_duration" => 221, - "last_build_language" => nil, - "last_build_started_at" => "2012-11-27T01:01:28Z", - "last_build_finished_at" => "2012-11-27T01:05:09Z", + 'repo' => { + 'id' => 119756, + 'slug' => 'travis-ci/travis-api', + 'description' => 'The public Travis API', + 'last_build_id' => 6347735, + 'last_build_number' => '468', + 'last_build_state' => 'started', + 'last_build_duration' => nil, + 'last_build_language' => nil, + 'last_build_started_at' => '2013-04-15T09:45:29Z', + 'last_build_finished_at' => nil, + } } - REPOSITORIES = [REPOSITORY] + REPOSITORIES = { 'repos' => [ REPOSITORY['repo'] ] } SHORT_BUILD = { - "id" => 3373911, - "repository_id" => 59, - "number" => "2188", - "state" => "finished", - "result" => 0, - "started_at" => "2012-11-27T01:01:28Z", - "finished_at" => "2012-11-27T01:05:09Z", - "duration" => 221, - "commit" => "a0e4dada7eb30b41817d9d3c5222b519502ef87a", - "branch" => "master", - "message" => "no need to set up services", - "event_type" => "push", - } - - BUILDS = [ - SHORT_BUILD, - ] - - CONFIG = { - "language" => "ruby", - "rvm" => [ - "1.9.3", - ], - "bundler_args" => "--without development", - "before_install" => [ - "gem install bundler --pre", - ], - "before_script" => [ - "cp config/database.example.yml config/database.yml" - ], - "script" => "RAILS_ENV=test bundle exec rake test:ci --trace", - "notifications" => { - "irc" => "irc.freenode.org#travis", - "campfire" => { - "secure" => "JJezWGD9KJY/LC2aznI3Zyohy31VTIhcTKX7RWR4C/C8YKbW9kZv3xV6Vn11\nSHxJTeZo6st2Bpv6tjlWZ+HCR09kyCNavIChedla3+oHOiuL0D4gSo+gkTNW\nUKYZz9mcQUd9RoQpTeyxvdvX+l7z62/7JwFA7txHOqxbTS8jrjc=" - } + 'id' => 6347735, + 'repository_id' => 119756, + 'commit_id' => 1873023, + 'number' => '468', + 'pull_request' => false, + 'pull_request_title' => nil, + 'pull_request_number' => nil, + 'config' => { + 'language' => 'ruby', + 'rvm' => [ + '1.9.3', + 'rbx-19mode', + 'jruby-19mode', + ], + 'before_script' => [ + 'RAILS_ENV=test rake db:create db:schema:load --trace', + ], + 'notifications' => { + 'irc' => 'irc.freenode.org#travis', + }, + 'matrix' => { + 'allow_failures' => [ + { + 'rvm' => 'rbx-19mode', + }, + { + 'rvm' => 'jruby-19mode', + }, + ], + }, + '.result' => 'configured', }, - ".result" => "configured" + 'state' => 'passed', + 'started_at' => '2013-04-15T09:45:29Z', + 'finished_at' => '2013-04-15T09:49:42Z', + 'duration' => 489, + 'job_ids' => [ + 6347736, + 6347737, + 6347738, + ], } - BUILD = SHORT_BUILD.merge({ - "config" => CONFIG, - "committed_at" => "2012-11-27T01:01:06Z", - "author_name" => "Sven Fuchs", - "author_email" => "me@svenfuchs.com", - "committer_name" => "Sven Fuchs", - "committer_email" => "me@svenfuchs.com", - "compare_url" => "https://github.com/travis-ci/travis-ci/compare/18b6874865f2...a0e4dada7eb3", - "matrix" => [ - { - "id" => 3373912, - "repository_id" => 59, - "number" => "2188.1", - "config" => CONFIG, - "result" => 0, - "started_at" => "2012-11-27T01:01:28Z", - "finished_at" => "2012-11-27T01:05:09Z", - "allow_failure" => false - } + COMMIT = { + 'id' => 1873023, + 'sha' => 'a18f211f6f921affd1ecd8c18691b40d9948aae5', + 'branch' => 'master', + 'message' => "Merge pull request #25 from henrikhodne/add-responses-to-documentation\n\nAdd responses to documentation", + 'committed_at' => '2013-04-15T09:44:31Z', + 'author_name' => 'Henrik Hodne', + 'author_email' => 'me@henrikhodne.com', + 'committer_name' => 'Henrik Hodne', + 'committer_email' => 'me@henrikhodne.com', + 'compare_url' => 'https://github.com/travis-ci/travis-api/compare/0f31ff4fb6aa...a18f211f6f92', + 'pull_request_number' => nil, + } + + BUILDS = { + 'builds' => [ + SHORT_BUILD + ], + 'commits' => [ + COMMIT ] - }) + } + + JOB = { + 'id' => 6347736, + 'repository_id' => 119756, + 'build_id' => 6347735, + 'commit_id' => 1873023, + 'log_id' => 1219815, + 'state' => 'passed', + 'number' => '468.1', + 'config' => { + 'language' => 'ruby', + 'rvm' => '1.9.3', + 'before_script' => [ + 'RAILS_ENV=test rake db:create db:schema:load --trace', + ], + 'notifications' => { + 'irc' => 'irc.freenode.org#travis', + }, + 'matrix' => { + 'allow_failures' => [ + { + 'rvm' => 'rbx-19mode', + }, + { + 'rvm' => 'jruby-19mode', + } + ] + }, + '.result' => 'configured' + }, + 'started_at' => '2013-04-15T09:45:29Z', + 'finished_at' => '2013-04-15T09:48:14Z', + 'queue' => 'builds.linux', + 'allow_failure' => false, + 'tags' => '', + } + + BUILD = { + 'build' => SHORT_BUILD, + 'commit' => COMMIT, + 'jobs' => [ JOB ] + } end end From 74612ed06789c5b000f44ba589aa07867a13a93a Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 16 Apr 2013 18:28:20 +0200 Subject: [PATCH 113/165] switch to unicorn --- Gemfile | 2 +- Gemfile.lock | 20 ++++++++++++-------- script/server | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index b9791555..a2121d50 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: # TODO need to release the gem as soon i'm certain this change makes sense gem 'simple_states', github: 'svenfuchs/simple_states', branch: 'sf-set-state-early' -gem 'puma' +gem 'unicorn' gem "sentry-raven", github: 'getsentry/raven-ruby' gem 'yard-sinatra', github: 'rkh/yard-sinatra' gem 'rack-contrib', github: 'rack/rack-contrib' diff --git a/Gemfile.lock b/Gemfile.lock index db742902..18225844 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,11 +17,11 @@ GIT GIT remote: git://github.com/rkh/gh.git - revision: 5e781e424e346838604563bd6408c4419f5480b0 + revision: e8d34e81640260441a2103f9d5395b2dbbe60258 specs: - gh (0.9.1) + gh (0.9.2) addressable - backports (~> 2.3) + backports faraday (~> 0.8) multi_json (~> 1.0) net-http-persistent (>= 2.7) @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: c5ceac066aeea4a5b3d84e66a165b8c188f13c9f + revision: 5fe14c24a41e249e53a365e0894c56ce74ed861c specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -127,7 +127,7 @@ GEM activesupport (3.2.13) i18n (= 0.6.1) multi_json (~> 1.0) - addressable (2.3.3) + addressable (2.3.4) arel (3.0.2) atomic (1.1.7) avl_tree (1.1.3) @@ -165,6 +165,7 @@ GEM i18n (0.6.1) journey (1.0.4) json (1.7.7) + kgio (2.8.0) listen (0.7.2) mail (2.5.3) i18n (>= 0.4.0) @@ -189,8 +190,6 @@ GEM coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) - puma (1.6.3) - rack (~> 1.2) pusher (0.11.3) multi_json (~> 1.0) signature (~> 0.1.6) @@ -210,6 +209,7 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) + raindrops (0.10.0) rake (0.9.6) rb-fsevent (0.9.3) rdoc (3.12.2) @@ -264,6 +264,10 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.37) + unicorn (4.6.2) + kgio (~> 2.6) + rack + raindrops (~> 0.7) uuidtools (2.1.3) yajl-ruby (1.1.0) yard (0.8.4.1) @@ -282,7 +286,6 @@ DEPENDENCIES micro_migrations! mocha (~> 0.12) pry - puma rack-cache (~> 1.2) rack-contrib! rake (~> 0.9.2) @@ -297,4 +300,5 @@ DEPENDENCIES travis-core! travis-sidekiqs! travis-support! + unicorn yard-sinatra! diff --git a/script/server b/script/server index a17c4245..29326751 100755 --- a/script/server +++ b/script/server @@ -3,6 +3,6 @@ cd "$(dirname "$0")/.." [ $PORT ] || PORT=3000 [ $RACK_ENV ] || RACK_ENV=development -cmd="ruby -I lib -S bundle exec ruby -I lib -S puma config.ru -p $PORT -e $RACK_ENV --threads 0:16" -[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -b tcp://127.0.0.1:$PORT" +cmd="ruby -I lib -S bundle exec ruby -I lib -S unicorn config.ru -p $PORT -E $RACK_ENV" +[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -l 127.0.0.1:$PORT" exec $cmd From 2a19cd5bfa0f1594c8d4e2e0fb8266c88e4448d7 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 16 Apr 2013 20:01:06 +0200 Subject: [PATCH 114/165] Revert "disable new relic" This reverts commit 48cf45c5f628d2d2b8ced1629684e18bae73b50b. --- Gemfile.lock | 2 ++ lib/travis/api/app/base.rb | 8 ++++---- travis-api.gemspec | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 18225844..b0e770b5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,6 +90,7 @@ PATH travis-api (0.0.1) backports (~> 2.5) hubble (~> 0.1) + newrelic_rpm (~> 3.5.5.0) pg (~> 0.13.2) rack-contrib (~> 1.1) rack-ssl (~> 1.3, >= 1.3.3) @@ -184,6 +185,7 @@ GEM multipart-post (1.2.0) net-http-persistent (2.8) net-http-pipeline (1.0.1) + newrelic_rpm (3.5.5.38) pg (0.13.2) polyglot (0.3.3) pry (0.9.12) diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index a100398a..92031836 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -1,6 +1,6 @@ require 'travis/api/app' require 'sinatra/base' -#require 'new_relic/agent/instrumentation/rack' +require 'new_relic/agent/instrumentation/rack' class Travis::Api::App # Superclass for any endpoint and middleware. @@ -8,9 +8,9 @@ class Travis::Api::App class Base < Sinatra::Base register Extensions::SmartConstants - # configure :production do - # require 'newrelic_rpm' - # end + configure :production do + require 'newrelic_rpm' + end error NotImplementedError do content_type :txt diff --git a/travis-api.gemspec b/travis-api.gemspec index 5c78344b..fe3516ca 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -182,7 +182,7 @@ Gem::Specification.new do |s| s.add_dependency 'hubble', '~> 0.1' s.add_dependency 'backports', '~> 2.5' s.add_dependency 'pg', '~> 0.13.2' - #s.add_dependency 'newrelic_rpm', '~> 3.5.5.0' + s.add_dependency 'newrelic_rpm', '~> 3.5.5.0' s.add_dependency 'thin', '~> 1.4' s.add_dependency 'sinatra', '~> 1.3' s.add_dependency 'sinatra-contrib', '~> 1.3' From a1de5fb6c5d4e397bb7d40efbc73391f8d54cbf6 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 16 Apr 2013 20:03:37 +0200 Subject: [PATCH 115/165] Update new relic --- Gemfile.lock | 6 +++--- travis-api.gemspec | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index b0e770b5..c48035d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,7 +90,7 @@ PATH travis-api (0.0.1) backports (~> 2.5) hubble (~> 0.1) - newrelic_rpm (~> 3.5.5.0) + newrelic_rpm (~> 3.6.0.83) pg (~> 0.13.2) rack-contrib (~> 1.1) rack-ssl (~> 1.3, >= 1.3.3) @@ -185,7 +185,7 @@ GEM multipart-post (1.2.0) net-http-persistent (2.8) net-http-pipeline (1.0.1) - newrelic_rpm (3.5.5.38) + newrelic_rpm (3.6.0.83) pg (0.13.2) polyglot (0.3.3) pry (0.9.12) @@ -255,7 +255,7 @@ GEM multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - thin (1.5.0) + thin (1.5.1) daemons (>= 1.0.9) eventmachine (>= 0.12.6) rack (>= 1.0.0) diff --git a/travis-api.gemspec b/travis-api.gemspec index fe3516ca..535c14b8 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -182,7 +182,7 @@ Gem::Specification.new do |s| s.add_dependency 'hubble', '~> 0.1' s.add_dependency 'backports', '~> 2.5' s.add_dependency 'pg', '~> 0.13.2' - s.add_dependency 'newrelic_rpm', '~> 3.5.5.0' + s.add_dependency 'newrelic_rpm', '~> 3.6.0.83' s.add_dependency 'thin', '~> 1.4' s.add_dependency 'sinatra', '~> 1.3' s.add_dependency 'sinatra-contrib', '~> 1.3' From 95b240e211f7aeb36a6ce270dd180e8a90c6a33d Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 16 Apr 2013 20:03:47 +0200 Subject: [PATCH 116/165] Revert "switch to unicorn" The switch was done in order to see if puma may be related to 503 issues, but since it didn't change a thing, we may bring it back This reverts commit 74612ed06789c5b000f44ba589aa07867a13a93a. --- Gemfile | 2 +- Gemfile.lock | 20 ++++++++------------ script/server | 4 ++-- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/Gemfile b/Gemfile index a2121d50..b9791555 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: # TODO need to release the gem as soon i'm certain this change makes sense gem 'simple_states', github: 'svenfuchs/simple_states', branch: 'sf-set-state-early' -gem 'unicorn' +gem 'puma' gem "sentry-raven", github: 'getsentry/raven-ruby' gem 'yard-sinatra', github: 'rkh/yard-sinatra' gem 'rack-contrib', github: 'rack/rack-contrib' diff --git a/Gemfile.lock b/Gemfile.lock index c48035d4..97eeaaf9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,11 +17,11 @@ GIT GIT remote: git://github.com/rkh/gh.git - revision: e8d34e81640260441a2103f9d5395b2dbbe60258 + revision: 5e781e424e346838604563bd6408c4419f5480b0 specs: - gh (0.9.2) + gh (0.9.1) addressable - backports + backports (~> 2.3) faraday (~> 0.8) multi_json (~> 1.0) net-http-persistent (>= 2.7) @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 5fe14c24a41e249e53a365e0894c56ce74ed861c + revision: c5ceac066aeea4a5b3d84e66a165b8c188f13c9f specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -128,7 +128,7 @@ GEM activesupport (3.2.13) i18n (= 0.6.1) multi_json (~> 1.0) - addressable (2.3.4) + addressable (2.3.3) arel (3.0.2) atomic (1.1.7) avl_tree (1.1.3) @@ -166,7 +166,6 @@ GEM i18n (0.6.1) journey (1.0.4) json (1.7.7) - kgio (2.8.0) listen (0.7.2) mail (2.5.3) i18n (>= 0.4.0) @@ -192,6 +191,8 @@ GEM coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) + puma (1.6.3) + rack (~> 1.2) pusher (0.11.3) multi_json (~> 1.0) signature (~> 0.1.6) @@ -211,7 +212,6 @@ GEM rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6, < 2.0) - raindrops (0.10.0) rake (0.9.6) rb-fsevent (0.9.3) rdoc (3.12.2) @@ -266,10 +266,6 @@ GEM polyglot polyglot (>= 0.3.1) tzinfo (0.3.37) - unicorn (4.6.2) - kgio (~> 2.6) - rack - raindrops (~> 0.7) uuidtools (2.1.3) yajl-ruby (1.1.0) yard (0.8.4.1) @@ -288,6 +284,7 @@ DEPENDENCIES micro_migrations! mocha (~> 0.12) pry + puma rack-cache (~> 1.2) rack-contrib! rake (~> 0.9.2) @@ -302,5 +299,4 @@ DEPENDENCIES travis-core! travis-sidekiqs! travis-support! - unicorn yard-sinatra! diff --git a/script/server b/script/server index 29326751..a17c4245 100755 --- a/script/server +++ b/script/server @@ -3,6 +3,6 @@ cd "$(dirname "$0")/.." [ $PORT ] || PORT=3000 [ $RACK_ENV ] || RACK_ENV=development -cmd="ruby -I lib -S bundle exec ruby -I lib -S unicorn config.ru -p $PORT -E $RACK_ENV" -[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -l 127.0.0.1:$PORT" +cmd="ruby -I lib -S bundle exec ruby -I lib -S puma config.ru -p $PORT -e $RACK_ENV --threads 0:16" +[[ $RACK_ENV == "development" ]] && exec rerun "$cmd -b tcp://127.0.0.1:$PORT" exec $cmd From f4cb2caed0a4121ef2eaad4fae2d7e81fd48ee46 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 16 Apr 2013 20:24:18 +0200 Subject: [PATCH 117/165] Try to always require newrelic_rpm --- lib/travis/api/app/base.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index 92031836..3bf0caa4 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -1,6 +1,7 @@ require 'travis/api/app' require 'sinatra/base' require 'new_relic/agent/instrumentation/rack' +require 'newrelic_rpm' class Travis::Api::App # Superclass for any endpoint and middleware. @@ -8,10 +9,6 @@ class Travis::Api::App class Base < Sinatra::Base register Extensions::SmartConstants - configure :production do - require 'newrelic_rpm' - end - error NotImplementedError do content_type :txt status 501 From f6af5172f2be66ebef6b8bcf988013858d472edf Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 16 Apr 2013 20:27:35 +0200 Subject: [PATCH 118/165] Try requiring newrelic_rpm before requiring the app --- config.ru | 1 + 1 file changed, 1 insertion(+) diff --git a/config.ru b/config.ru index 8fb5947a..593f757b 100644 --- a/config.ru +++ b/config.ru @@ -4,6 +4,7 @@ ENV['RAILS_ENV'] = ENV['RACK_ENV'] $stdout.sync = true +require 'newrelic_rpm' require 'travis/api/app' require 'core_ext/module/load_constants' From 426859a7a11099226af5acb2e2d6318c34186d85 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 16 Apr 2013 20:37:04 +0200 Subject: [PATCH 119/165] Don't require newrelic in base.rb --- lib/travis/api/app/base.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index 3bf0caa4..e4edfefc 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -1,7 +1,5 @@ require 'travis/api/app' require 'sinatra/base' -require 'new_relic/agent/instrumentation/rack' -require 'newrelic_rpm' class Travis::Api::App # Superclass for any endpoint and middleware. From a830d17554855228f2e7afb716d2de496c3f21ca Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 17 Apr 2013 23:04:39 +0200 Subject: [PATCH 120/165] Fix newrelic I updated newrelic to beta version, which fixed problems with starting the dispatcher in some of the environments. --- Gemfile.lock | 4 ++-- config.ru | 1 - lib/travis/api/app/base.rb | 4 ++++ travis-api.gemspec | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 97eeaaf9..8b409a92 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,7 +90,7 @@ PATH travis-api (0.0.1) backports (~> 2.5) hubble (~> 0.1) - newrelic_rpm (~> 3.6.0.83) + newrelic_rpm (~> 3.6.1.85.beta) pg (~> 0.13.2) rack-contrib (~> 1.1) rack-ssl (~> 1.3, >= 1.3.3) @@ -184,7 +184,7 @@ GEM multipart-post (1.2.0) net-http-persistent (2.8) net-http-pipeline (1.0.1) - newrelic_rpm (3.6.0.83) + newrelic_rpm (3.6.1.85.beta) pg (0.13.2) polyglot (0.3.3) pry (0.9.12) diff --git a/config.ru b/config.ru index 593f757b..8fb5947a 100644 --- a/config.ru +++ b/config.ru @@ -4,7 +4,6 @@ ENV['RAILS_ENV'] = ENV['RACK_ENV'] $stdout.sync = true -require 'newrelic_rpm' require 'travis/api/app' require 'core_ext/module/load_constants' diff --git a/lib/travis/api/app/base.rb b/lib/travis/api/app/base.rb index e4edfefc..f975fbb1 100644 --- a/lib/travis/api/app/base.rb +++ b/lib/travis/api/app/base.rb @@ -7,6 +7,10 @@ class Travis::Api::App class Base < Sinatra::Base register Extensions::SmartConstants + configure :production do + require 'newrelic_rpm' + end + error NotImplementedError do content_type :txt status 501 diff --git a/travis-api.gemspec b/travis-api.gemspec index 535c14b8..7256bc1d 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -182,7 +182,7 @@ Gem::Specification.new do |s| s.add_dependency 'hubble', '~> 0.1' s.add_dependency 'backports', '~> 2.5' s.add_dependency 'pg', '~> 0.13.2' - s.add_dependency 'newrelic_rpm', '~> 3.6.0.83' + s.add_dependency 'newrelic_rpm', '~> 3.6.1.85.beta' s.add_dependency 'thin', '~> 1.4' s.add_dependency 'sinatra', '~> 1.3' s.add_dependency 'sinatra-contrib', '~> 1.3' From 8b72b0a1b4cd2406c0c41c2519107ea48f0f80a4 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Mon, 22 Apr 2013 16:56:35 +0200 Subject: [PATCH 121/165] bundle update gh --- Gemfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8b409a92..6ecf748c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,11 +17,11 @@ GIT GIT remote: git://github.com/rkh/gh.git - revision: 5e781e424e346838604563bd6408c4419f5480b0 + revision: 0dfeb8fd07c41aaf89a8c630a4db9bc93a13c582 specs: - gh (0.9.1) + gh (0.10.3) addressable - backports (~> 2.3) + backports faraday (~> 0.8) multi_json (~> 1.0) net-http-persistent (>= 2.7) @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: c5ceac066aeea4a5b3d84e66a165b8c188f13c9f + revision: 359e77d688524591f2ee4f07c1cfbe89a271c0c5 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -128,7 +128,7 @@ GEM activesupport (3.2.13) i18n (= 0.6.1) multi_json (~> 1.0) - addressable (2.3.3) + addressable (2.3.4) arel (3.0.2) atomic (1.1.7) avl_tree (1.1.3) From 6b2a1a0da8a65419908492d8fcfe8ed577f8b2bc Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 24 Apr 2013 16:47:52 +0200 Subject: [PATCH 122/165] do not use client credentials for /auth/github --- lib/travis/api/app/endpoint/authorization.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app/endpoint/authorization.rb b/lib/travis/api/app/endpoint/authorization.rb index eb5a1e57..f433cfc1 100644 --- a/lib/travis/api/app/endpoint/authorization.rb +++ b/lib/travis/api/app/endpoint/authorization.rb @@ -218,7 +218,7 @@ class Travis::Api::App end def user_for_github_token(token, drop_token = false) - data = GH.with(token: token.to_s) { GH['user'] } + data = GH.with(token: token.to_s, client_id: nil) { GH['user'] } scopes = parse_scopes data.headers['x-oauth-scopes'] halt 403, 'insufficient access: %p' unless acceptable? scopes From 0d2188b5b2be90baa40f8291ae6c662daa92828b Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 24 Apr 2013 16:59:26 +0200 Subject: [PATCH 123/165] fix specs --- spec/unit/endpoint/authorization_spec.rb | 8 ++++---- travis-api.gemspec | 13 ++++++++++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/spec/unit/endpoint/authorization_spec.rb b/spec/unit/endpoint/authorization_spec.rb index 2f84ad19..7f1727f9 100644 --- a/spec/unit/endpoint/authorization_spec.rb +++ b/spec/unit/endpoint/authorization_spec.rb @@ -26,10 +26,10 @@ describe Travis::Api::App::Endpoint::Authorization do describe 'POST /auth/github' do before do data = { 'id' => user.github_id, 'name' => user.name, 'login' => user.login, 'gravatar_id' => user.gravatar_id } - GH.stubs(:with).with(token: 'private repos').returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'repo'}, :to_hash => data) - GH.stubs(:with).with(token: 'public repos').returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'public_repo'}, :to_hash => data) - GH.stubs(:with).with(token: 'no repos').returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'user'}, :to_hash => data) - GH.stubs(:with).with(token: 'invalid token').raises(Faraday::Error::ClientError, 'CLIENT ERROR!') + GH.stubs(:with).with(token: 'private repos', client_id: nil).returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'repo'}, :to_hash => data) + GH.stubs(:with).with(token: 'public repos', client_id: nil).returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'public_repo'}, :to_hash => data) + GH.stubs(:with).with(token: 'no repos', client_id: nil).returns stub(:[] => user.login, :headers => {'x-oauth-scopes' => 'user'}, :to_hash => data) + GH.stubs(:with).with(token: 'invalid token', client_id: nil).raises(Faraday::Error::ClientError, 'CLIENT ERROR!') end def get_token(github_token) diff --git a/travis-api.gemspec b/travis-api.gemspec index 7256bc1d..9d883c1f 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -12,12 +12,13 @@ Gem::Specification.new do |s| "Sven Fuchs", "Konstantin Haase", "Piotr Sarnacki", + "Henrik Hodne", "Mathias Meyer", "Josh Kalderimis", - "Henrik Hodne", + "Andre Arko", "Erik Michaels-Ober", - "Brian Ford", "Steve Richert", + "Brian Ford", "Nick Schonning" ] @@ -26,9 +27,10 @@ Gem::Specification.new do |s| "konstantin.mailinglists@googlemail.com", "drogus@gmail.com", "meyer@paperplanes.de", + "me@henrikhodne.com", "svenfuchs@artweb-design.de", "josh.kalderimis@gmail.com", - "me@henrikhodne.com", + "andre@arko.net", "sferik@gmail.com", "steve.richert@gmail.com", "bford@engineyard.com", @@ -46,6 +48,7 @@ Gem::Specification.new do |s| "config/unicorn.rb", "docs/00_overview.md", "docs/01_cross_origin.md", + "lib/tasks/build_update_pull_request_data.rake", "lib/travis/api/app.rb", "lib/travis/api/app/access_token.rb", "lib/travis/api/app/base.rb", @@ -63,6 +66,7 @@ Gem::Specification.new do |s| "lib/travis/api/app/endpoint/documentation/css/bootstrap.css", "lib/travis/api/app/endpoint/documentation/css/bootstrap.min.css", "lib/travis/api/app/endpoint/documentation/css/prettify.css", + "lib/travis/api/app/endpoint/documentation/css/style.css", "lib/travis/api/app/endpoint/documentation/img/glyphicons-halflings-white.png", "lib/travis/api/app/endpoint/documentation/img/glyphicons-halflings.png", "lib/travis/api/app/endpoint/documentation/img/grid-18px-masked.png", @@ -88,6 +92,7 @@ Gem::Specification.new do |s| "lib/travis/api/app/endpoint/documentation/js/lang-xq.js", "lib/travis/api/app/endpoint/documentation/js/lang-yaml.js", "lib/travis/api/app/endpoint/documentation/js/prettify.js", + "lib/travis/api/app/endpoint/documentation/resources.rb", "lib/travis/api/app/endpoint/endpoints.rb", "lib/travis/api/app/endpoint/events.rb", "lib/travis/api/app/endpoint/home.rb", @@ -120,6 +125,7 @@ Gem::Specification.new do |s| "lib/travis/api/app/responders/plain.rb", "lib/travis/api/app/responders/service.rb", "lib/travis/api/app/responders/xml.rb", + "public/favicon.ico", "public/images/result/error.png", "public/images/result/failing.png", "public/images/result/passing.png", @@ -172,6 +178,7 @@ Gem::Specification.new do |s| "spec/unit/middleware/logging_spec.rb", "spec/unit/middleware/scope_check_spec.rb", "spec/unit/middleware_spec.rb", + "spec/unit/responders/json_spec.rb", "spec/unit/responders/service_spec.rb", "travis-api.gemspec" ] From f9a1dc9bf342f1199613be3457e095cf028a0b07 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Tue, 30 Apr 2013 17:58:50 +0200 Subject: [PATCH 124/165] update core and gh --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 6ecf748c..9ea8a22b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,9 +17,9 @@ GIT GIT remote: git://github.com/rkh/gh.git - revision: 0dfeb8fd07c41aaf89a8c630a4db9bc93a13c582 + revision: c14f7619d24ff3aa156dae1ec3e6bd1f2734cd61 specs: - gh (0.10.3) + gh (0.11.0) addressable backports faraday (~> 0.8) @@ -45,7 +45,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 359e77d688524591f2ee4f07c1cfbe89a271c0c5 + revision: 75986691f25bd5533fa812dbe81638c7d1da3651 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From fa6ea0692ddc07a900f965b52f1d3600fdb381a9 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 16:38:20 +0200 Subject: [PATCH 125/165] use a follower for one of the repos endpoint --- Gemfile | 2 ++ Gemfile.lock | 9 +++++++++ lib/travis/api/app.rb | 6 ++++++ lib/travis/api/app/endpoint/repos.rb | 4 +++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index b9791555..ef1c408a 100644 --- a/Gemfile +++ b/Gemfile @@ -23,6 +23,8 @@ gem 'dalli' gem 'pry' gem 'metriks', '0.9.9.2' +gem 'ar-octopus', github: 'tchandy/octopus', require: 'octopus' + group :test do gem 'rspec', '~> 2.11' gem 'factory_girl', '~> 2.4.0' diff --git a/Gemfile.lock b/Gemfile.lock index 9ea8a22b..230d1cff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -43,6 +43,14 @@ GIT activesupport hashr (~> 0.0.10) +GIT + remote: git://github.com/tchandy/octopus.git + revision: 8df2768bf37e75e6cc30816eeb9440748a2a3ae9 + specs: + ar-octopus (0.5.0beta) + activerecord (>= 2.3.0) + activesupport (>= 2.3.0) + GIT remote: git://github.com/travis-ci/travis-core.git revision: 75986691f25bd5533fa812dbe81638c7d1da3651 @@ -274,6 +282,7 @@ PLATFORMS ruby DEPENDENCIES + ar-octopus! bunny dalli database_cleaner (~> 0.8.0) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 609c5f0a..cd07ea96 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -118,6 +118,12 @@ module Travis::Api def self.setup_travis Travis::Amqp.config = Travis.config.amqp Travis::Database.connect + + Octopus.setup do |config| + config.shards = { :follower => Travis.config.database_follower } + config.environments = [:production] + end + Travis::Features.start if Travis.env == 'production' || Travis.env == 'staging' diff --git a/lib/travis/api/app/endpoint/repos.rb b/lib/travis/api/app/endpoint/repos.rb index 40c430ce..6e36e104 100644 --- a/lib/travis/api/app/endpoint/repos.rb +++ b/lib/travis/api/app/endpoint/repos.rb @@ -52,7 +52,9 @@ class Travis::Api::App # # json(:repository) get '/:owner_name/:name' do - respond_with service(:find_repo, params) + Octopus.using(:follower) do + respond_with service(:find_repo, params) + end end # Gets the builds for the repository with the given name. From afddbb76ba635186c7c094c917b7e59e9c66680f Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 16:45:34 +0200 Subject: [PATCH 126/165] require octopus --- lib/travis/api/app.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index cd07ea96..3038b542 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -5,6 +5,7 @@ require 'rack/protection' require 'rack/contrib' require 'rack/cache' require 'active_record' +require 'octopus' require 'redis' require 'gh' require 'raven' From ab2714621f04ac399b555ddaf3e92b998e8fe99e Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 17:08:31 +0200 Subject: [PATCH 127/165] i wonder what i am doing wrong with octopus --- Gemfile | 4 +-- Gemfile.lock | 74 ++++++++++++++++++++++++------------------- lib/travis/api/app.rb | 2 +- 3 files changed, 45 insertions(+), 35 deletions(-) diff --git a/Gemfile b/Gemfile index ef1c408a..5d1c830b 100644 --- a/Gemfile +++ b/Gemfile @@ -21,9 +21,9 @@ gem 'gh', github: 'rkh/gh' gem 'bunny' gem 'dalli' gem 'pry' -gem 'metriks', '0.9.9.2' +gem 'metriks', '0.9.9.2' -gem 'ar-octopus', github: 'tchandy/octopus', require: 'octopus' +gem 'ar-octopus', github: 'tchandy/octopus', require: 'octopus' group :test do gem 'rspec', '~> 2.11' diff --git a/Gemfile.lock b/Gemfile.lock index 230d1cff..4cb1d2a7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,10 +1,10 @@ GIT remote: git://github.com/getsentry/raven-ruby.git - revision: e520389a56d099276c167d8b442967c7fa549ecd + revision: 267b33417a3ed43f552911cf353561a641ba9fb2 specs: - sentry-raven (0.4.3) + sentry-raven (0.4.6) faraday (>= 0.7.6) - hashie + hashie (>= 1.1.0) multi_json (~> 1.0) uuidtools @@ -17,9 +17,9 @@ GIT GIT remote: git://github.com/rkh/gh.git - revision: c14f7619d24ff3aa156dae1ec3e6bd1f2734cd61 + revision: ff93c759591a66c9d5250cada5234d2adde95dd3 specs: - gh (0.11.0) + gh (0.11.1) addressable backports faraday (~> 0.8) @@ -53,7 +53,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 75986691f25bd5533fa812dbe81638c7d1da3651 + revision: d3f5fd82fe81f5bfa97d810f90838a1dbeda6e17 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -82,7 +82,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-support.git - revision: db10b27101763f39d46075ded19bcf4bb845b1ff + revision: 1f705a2ce4bcc42c642b337f117073abedef971b specs: travis-support (0.0.1) @@ -138,7 +138,7 @@ GEM multi_json (~> 1.0) addressable (2.3.4) arel (3.0.2) - atomic (1.1.7) + atomic (1.1.8) avl_tree (1.1.3) backports (2.8.2) builder (3.0.4) @@ -155,17 +155,20 @@ GEM activerecord rake database_cleaner (0.8.0) - diff-lcs (1.2.1) + diff-lcs (1.2.4) + dotenv (0.7.0) erubis (2.7.0) - eventmachine (1.0.0) - facter (1.6.17) + eventmachine (1.0.3) + facter (1.7.0) factory_girl (2.4.2) activesupport faraday (0.8.7) multipart-post (~> 1.1) - foreman (0.61.0) + ffi (1.8.1) + foreman (0.63.0) + dotenv (>= 0.7) thor (>= 0.13.6) - hashie (2.0.0) + hashie (2.0.4) hashr (0.0.22) hike (1.2.2) hitimes (1.2.1) @@ -174,7 +177,10 @@ GEM i18n (0.6.1) journey (1.0.4) json (1.7.7) - listen (0.7.2) + listen (1.0.3) + rb-fsevent (>= 0.9.3) + rb-inotify (>= 0.9) + rb-kqueue (>= 0.2) mail (2.5.3) i18n (>= 0.4.0) mime-types (~> 1.16) @@ -185,29 +191,29 @@ GEM atomic (~> 1.0) avl_tree (~> 1.1.2) hitimes (~> 1.1) - mime-types (1.22) - mocha (0.13.2) + mime-types (1.23) + mocha (0.13.3) metaclass (~> 0.0.1) multi_json (1.7.2) multipart-post (1.2.0) net-http-persistent (2.8) net-http-pipeline (1.0.1) - newrelic_rpm (3.6.1.85.beta) + newrelic_rpm (3.6.1.88) pg (0.13.2) polyglot (0.3.3) - pry (0.9.12) + pry (0.9.12.1) coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) - puma (1.6.3) - rack (~> 1.2) + puma (2.0.1) + rack (>= 1.1, < 2.0) pusher (0.11.3) multi_json (~> 1.0) signature (~> 0.1.6) rack (1.4.5) rack-cache (1.2) rack (>= 0.4) - rack-protection (1.3.2) + rack-protection (1.5.0) rack rack-ssl (1.3.3) rack @@ -222,31 +228,35 @@ GEM thor (>= 0.14.6, < 2.0) rake (0.9.6) rb-fsevent (0.9.3) + rb-inotify (0.9.0) + ffi (>= 0.5.0) + rb-kqueue (0.2.0) + ffi (>= 0.5.0) rdoc (3.12.2) json (~> 1.4) redcarpet (2.2.2) - redis (3.0.3) + redis (3.0.4) redis-namespace (1.2.1) redis (~> 3.0.0) - rerun (0.8.0) - listen + rerun (0.8.1) + listen (>= 1.0.3) rollout (1.1.0) rspec (2.13.0) rspec-core (~> 2.13.0) rspec-expectations (~> 2.13.0) rspec-mocks (~> 2.13.0) - rspec-core (2.13.0) + rspec-core (2.13.1) rspec-expectations (2.13.0) diff-lcs (>= 1.1.3, < 2.0) - rspec-mocks (2.13.0) + rspec-mocks (2.13.1) sidekiq (2.5.4) celluloid (~> 0.12.0) connection_pool (~> 0.9.2) multi_json (~> 1) redis (~> 3) redis-namespace - signature (0.1.6) - sinatra (1.3.4) + signature (0.1.7) + sinatra (1.3.6) rack (~> 1.4) rack-protection (~> 1.3) tilt (~> 1.3, >= 1.3.3) @@ -257,7 +267,7 @@ GEM rack-test sinatra (~> 1.3.0) tilt (~> 1.3) - slop (3.4.3) + slop (3.4.4) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) @@ -268,15 +278,15 @@ GEM eventmachine (>= 0.12.6) rack (>= 1.0.0) thor (0.14.6) - tilt (1.3.7) + tilt (1.4.0) timers (1.1.0) treetop (1.4.12) polyglot polyglot (>= 0.3.1) tzinfo (0.3.37) - uuidtools (2.1.3) + uuidtools (2.1.4) yajl-ruby (1.1.0) - yard (0.8.4.1) + yard (0.8.6.1) PLATFORMS ruby diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 3038b542..04cdcaa8 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -120,7 +120,7 @@ module Travis::Api Travis::Amqp.config = Travis.config.amqp Travis::Database.connect - Octopus.setup do |config| + ::Octopus.setup do |config| config.shards = { :follower => Travis.config.database_follower } config.environments = [:production] end From de6cb2c163f8cae508ff14961fd86f0b0d1e9135 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 17:21:56 +0200 Subject: [PATCH 128/165] change the require order --- lib/travis/api/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 04cdcaa8..47a358e8 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -4,8 +4,8 @@ require 'rack' require 'rack/protection' require 'rack/contrib' require 'rack/cache' -require 'active_record' require 'octopus' +require 'active_record' require 'redis' require 'gh' require 'raven' From f4132786a6c58f13ffda9fd0bcd35beb5da7102f Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 18:05:32 +0200 Subject: [PATCH 129/165] i don't think this is the best solution --- lib/travis/api/app.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 47a358e8..a057e91b 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -120,9 +120,11 @@ module Travis::Api Travis::Amqp.config = Travis.config.amqp Travis::Database.connect - ::Octopus.setup do |config| - config.shards = { :follower => Travis.config.database_follower } - config.environments = [:production] + if Travis.env == 'production' + ::Octopus.setup do |config| + config.shards = { :follower => Travis.config.database_follower } + config.environments = [:production] + end end Travis::Features.start From d72f6ca02d5d6740a30a744d36b133bce47af0c4 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 18:23:41 +0200 Subject: [PATCH 130/165] octopus is on in production by default only --- lib/travis/api/app.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index a057e91b..09bd5d02 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -120,11 +120,9 @@ module Travis::Api Travis::Amqp.config = Travis.config.amqp Travis::Database.connect - if Travis.env == 'production' - ::Octopus.setup do |config| - config.shards = { :follower => Travis.config.database_follower } - config.environments = [:production] - end + # only used in Production by default + ::Octopus.setup do |config| + config.shards = { :follower => Travis.config.database_follower } end Travis::Features.start From 69b8dff382dc99f0726c89869fa00adf319b0c40 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 18:44:27 +0200 Subject: [PATCH 131/165] only add the shards info if in prod mode --- lib/travis/api/app.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 09bd5d02..ed2f4686 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -120,9 +120,10 @@ module Travis::Api Travis::Amqp.config = Travis.config.amqp Travis::Database.connect - # only used in Production by default - ::Octopus.setup do |config| - config.shards = { :follower => Travis.config.database_follower } + if Travis.env == 'production' + ::Octopus.setup do |config| + config.shards = { :follower => Travis.config.database_follower } + end end Travis::Features.start From 1a8b60cc98328a372b87bfd861b032052c67bbaa Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 18:50:59 +0200 Subject: [PATCH 132/165] turn on octopus in staging --- lib/travis/api/app.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index ed2f4686..7104013f 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -120,9 +120,10 @@ module Travis::Api Travis::Amqp.config = Travis.config.amqp Travis::Database.connect - if Travis.env == 'production' + if Travis.env == 'production' || Travis.env == 'staging' ::Octopus.setup do |config| config.shards = { :follower => Travis.config.database_follower } + config.environments = ['production', 'staging'] end end From 6feed546847a4cd434a914a22b9c21046d8a0df9 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 19:16:52 +0200 Subject: [PATCH 133/165] hit my head against a wall --- lib/travis/api/app.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 7104013f..6ac37eed 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -121,10 +121,13 @@ module Travis::Api Travis::Database.connect if Travis.env == 'production' || Travis.env == 'staging' + puts "is octopus working? #{::Octopus.enabled?}" + ActiveRecord::Base.custom_octopus_connection = false ::Octopus.setup do |config| config.shards = { :follower => Travis.config.database_follower } config.environments = ['production', 'staging'] end + end Travis::Features.start From cd9e0896315357986ee45454e85378a36b2f6642 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 2 May 2013 19:48:23 +0200 Subject: [PATCH 134/165] Enable octopus --- lib/travis/api/app.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 7104013f..ee7a00a0 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -121,6 +121,15 @@ module Travis::Api Travis::Database.connect if Travis.env == 'production' || Travis.env == 'staging' + # Octopus checks for Rails.env, just hardcode enabled? + Octopus.instance_eval do + def enabled? + true + end + end + + ActiveRecord::Base.custom_octopus_connection = false + ::Octopus.setup do |config| config.shards = { :follower => Travis.config.database_follower } config.environments = ['production', 'staging'] From 22bce30b59a06e49be171d559d9b21e906a440a7 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 20:24:04 +0200 Subject: [PATCH 135/165] bump newrelic --- Gemfile.lock | 2 +- travis-api.gemspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4cb1d2a7..dd8a9117 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,7 +98,7 @@ PATH travis-api (0.0.1) backports (~> 2.5) hubble (~> 0.1) - newrelic_rpm (~> 3.6.1.85.beta) + newrelic_rpm (~> 3.6.1.88) pg (~> 0.13.2) rack-contrib (~> 1.1) rack-ssl (~> 1.3, >= 1.3.3) diff --git a/travis-api.gemspec b/travis-api.gemspec index 9d883c1f..4fdfb215 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -189,7 +189,7 @@ Gem::Specification.new do |s| s.add_dependency 'hubble', '~> 0.1' s.add_dependency 'backports', '~> 2.5' s.add_dependency 'pg', '~> 0.13.2' - s.add_dependency 'newrelic_rpm', '~> 3.6.1.85.beta' + s.add_dependency 'newrelic_rpm', '~> 3.6.1.88' s.add_dependency 'thin', '~> 1.4' s.add_dependency 'sinatra', '~> 1.3' s.add_dependency 'sinatra-contrib', '~> 1.3' From 546d7b4ad4ed0bd7887cb8fcb9e1317253c15c6e Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 3 May 2013 00:14:29 +0200 Subject: [PATCH 136/165] Set puma's version to 1.6.3 Newest version has problems with logs and newrelic --- Gemfile | 2 +- Gemfile.lock | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 5d1c830b..94fd20a7 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,7 @@ gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: # TODO need to release the gem as soon i'm certain this change makes sense gem 'simple_states', github: 'svenfuchs/simple_states', branch: 'sf-set-state-early' -gem 'puma' +gem 'puma', '1.6.3' gem "sentry-raven", github: 'getsentry/raven-ruby' gem 'yard-sinatra', github: 'rkh/yard-sinatra' gem 'rack-contrib', github: 'rack/rack-contrib' diff --git a/Gemfile.lock b/Gemfile.lock index dd8a9117..c1f9a7c7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -205,8 +205,8 @@ GEM coderay (~> 1.0.5) method_source (~> 0.8) slop (~> 3.4) - puma (2.0.1) - rack (>= 1.1, < 2.0) + puma (1.6.3) + rack (~> 1.2) pusher (0.11.3) multi_json (~> 1.0) signature (~> 0.1.6) @@ -303,7 +303,7 @@ DEPENDENCIES micro_migrations! mocha (~> 0.12) pry - puma + puma (= 1.6.3) rack-cache (~> 1.2) rack-contrib! rake (~> 0.9.2) From a0a92b23faf242f44f88ee1c201e9ea24f3cc509 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 17:21:56 +0200 Subject: [PATCH 137/165] change the require order --- lib/travis/api/app.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 3038b542..adda06b3 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -4,8 +4,8 @@ require 'rack' require 'rack/protection' require 'rack/contrib' require 'rack/cache' -require 'active_record' require 'octopus' +require 'active_record' require 'redis' require 'gh' require 'raven' From 76e55c0125e1192c93ae7f96e027da9872022abd Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 18:05:32 +0200 Subject: [PATCH 138/165] i don't think this is the best solution --- lib/travis/api/app.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index adda06b3..a057e91b 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -120,9 +120,11 @@ module Travis::Api Travis::Amqp.config = Travis.config.amqp Travis::Database.connect - Octopus.setup do |config| - config.shards = { :follower => Travis.config.database_follower } - config.environments = [:production] + if Travis.env == 'production' + ::Octopus.setup do |config| + config.shards = { :follower => Travis.config.database_follower } + config.environments = [:production] + end end Travis::Features.start From e6f1e22ae8b1dd9eb05495fe93cf238a062a4813 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 18:23:41 +0200 Subject: [PATCH 139/165] octopus is on in production by default only --- lib/travis/api/app.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index a057e91b..09bd5d02 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -120,11 +120,9 @@ module Travis::Api Travis::Amqp.config = Travis.config.amqp Travis::Database.connect - if Travis.env == 'production' - ::Octopus.setup do |config| - config.shards = { :follower => Travis.config.database_follower } - config.environments = [:production] - end + # only used in Production by default + ::Octopus.setup do |config| + config.shards = { :follower => Travis.config.database_follower } end Travis::Features.start From 135008f1eabf664cc03b5156b171a5d2990fb5d1 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 18:44:27 +0200 Subject: [PATCH 140/165] only add the shards info if in prod mode --- lib/travis/api/app.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 09bd5d02..ed2f4686 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -120,9 +120,10 @@ module Travis::Api Travis::Amqp.config = Travis.config.amqp Travis::Database.connect - # only used in Production by default - ::Octopus.setup do |config| - config.shards = { :follower => Travis.config.database_follower } + if Travis.env == 'production' + ::Octopus.setup do |config| + config.shards = { :follower => Travis.config.database_follower } + end end Travis::Features.start From 4ea1079d39d60cff4ff2de23efc6e58b924e0689 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 18:50:59 +0200 Subject: [PATCH 141/165] turn on octopus in staging --- lib/travis/api/app.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index ed2f4686..7104013f 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -120,9 +120,10 @@ module Travis::Api Travis::Amqp.config = Travis.config.amqp Travis::Database.connect - if Travis.env == 'production' + if Travis.env == 'production' || Travis.env == 'staging' ::Octopus.setup do |config| config.shards = { :follower => Travis.config.database_follower } + config.environments = ['production', 'staging'] end end From 10c8d4b95f62bcafa8fefe89ef905a83f141b9e3 Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Thu, 2 May 2013 19:16:52 +0200 Subject: [PATCH 142/165] hit my head against a wall --- lib/travis/api/app.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 7104013f..6ac37eed 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -121,10 +121,13 @@ module Travis::Api Travis::Database.connect if Travis.env == 'production' || Travis.env == 'staging' + puts "is octopus working? #{::Octopus.enabled?}" + ActiveRecord::Base.custom_octopus_connection = false ::Octopus.setup do |config| config.shards = { :follower => Travis.config.database_follower } config.environments = ['production', 'staging'] end + end Travis::Features.start From f6d781c248b92ce5ee122f821254e9f111219209 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 2 May 2013 19:48:23 +0200 Subject: [PATCH 143/165] Enable octopus --- lib/travis/api/app.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 6ac37eed..6cf214f2 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -121,8 +121,15 @@ module Travis::Api Travis::Database.connect if Travis.env == 'production' || Travis.env == 'staging' - puts "is octopus working? #{::Octopus.enabled?}" + # Octopus checks for Rails.env, just hardcode enabled? + Octopus.instance_eval do + def enabled? + true + end + end + ActiveRecord::Base.custom_octopus_connection = false + ::Octopus.setup do |config| config.shards = { :follower => Travis.config.database_follower } config.environments = ['production', 'staging'] From f468370a026c69e13a5ed331f7a1dfdbdfbe6091 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 3 May 2013 01:06:54 +0200 Subject: [PATCH 144/165] Try newer version of newrelic --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9ea8a22b..2cd96046 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -184,7 +184,7 @@ GEM multipart-post (1.2.0) net-http-persistent (2.8) net-http-pipeline (1.0.1) - newrelic_rpm (3.6.1.85.beta) + newrelic_rpm (3.6.1.88) pg (0.13.2) polyglot (0.3.3) pry (0.9.12) From a6a370b334fd04a9ca14c9d4798f623f8d5eae67 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 3 May 2013 01:40:34 +0200 Subject: [PATCH 145/165] Update sinatra --- Gemfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 2cd96046..a3f3cb55 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -199,7 +199,7 @@ GEM rack (1.4.5) rack-cache (1.2) rack (>= 0.4) - rack-protection (1.3.2) + rack-protection (1.5.0) rack rack-ssl (1.3.3) rack @@ -238,7 +238,7 @@ GEM redis (~> 3) redis-namespace signature (0.1.6) - sinatra (1.3.4) + sinatra (1.3.6) rack (~> 1.4) rack-protection (~> 1.3) tilt (~> 1.3, >= 1.3.3) @@ -260,7 +260,7 @@ GEM eventmachine (>= 0.12.6) rack (>= 1.0.0) thor (0.14.6) - tilt (1.3.7) + tilt (1.4.0) timers (1.1.0) treetop (1.4.12) polyglot From 79564b9eac8090c229d2519c2ebd6113f08af7c2 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 3 May 2013 02:44:31 +0200 Subject: [PATCH 146/165] Use octopus from travis-ci's fork --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index ef1c408a..c9bbcc42 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ gem 'dalli' gem 'pry' gem 'metriks', '0.9.9.2' -gem 'ar-octopus', github: 'tchandy/octopus', require: 'octopus' +gem 'ar-octopus', github: 'travis-ci/octopus', require: 'octopus' group :test do gem 'rspec', '~> 2.11' diff --git a/Gemfile.lock b/Gemfile.lock index 926a02a9..79bfffa6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,8 +44,8 @@ GIT hashr (~> 0.0.10) GIT - remote: git://github.com/tchandy/octopus.git - revision: 8df2768bf37e75e6cc30816eeb9440748a2a3ae9 + remote: git://github.com/travis-ci/octopus.git + revision: 2d4cca475479516f47c3144971205f50c335ad35 specs: ar-octopus (0.5.0beta) activerecord (>= 2.3.0) From 23f3edc60cc25c458833f437581e823b9a37a44b Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 3 May 2013 09:21:48 +0200 Subject: [PATCH 147/165] move the db follower usage to a helper --- lib/travis/api/app/endpoint.rb | 2 +- lib/travis/api/app/endpoint/repos.rb | 2 +- lib/travis/api/app/helpers/db_follower.rb | 13 +++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 lib/travis/api/app/helpers/db_follower.rb diff --git a/lib/travis/api/app/endpoint.rb b/lib/travis/api/app/endpoint.rb index 2716ff13..11c82afc 100644 --- a/lib/travis/api/app/endpoint.rb +++ b/lib/travis/api/app/endpoint.rb @@ -10,7 +10,7 @@ class Travis::Api::App set(:prefix) { "/" << name[/[^:]+$/].underscore } set disable_root_endpoint: false register :scoping - helpers :current_user, :flash + helpers :current_user, :flash, :db_follower # TODO hmmm? before { flash.clear } diff --git a/lib/travis/api/app/endpoint/repos.rb b/lib/travis/api/app/endpoint/repos.rb index 6e36e104..e1db9bb5 100644 --- a/lib/travis/api/app/endpoint/repos.rb +++ b/lib/travis/api/app/endpoint/repos.rb @@ -52,7 +52,7 @@ class Travis::Api::App # # json(:repository) get '/:owner_name/:name' do - Octopus.using(:follower) do + prefer_follower do respond_with service(:find_repo, params) end end diff --git a/lib/travis/api/app/helpers/db_follower.rb b/lib/travis/api/app/helpers/db_follower.rb new file mode 100644 index 00000000..4658aca2 --- /dev/null +++ b/lib/travis/api/app/helpers/db_follower.rb @@ -0,0 +1,13 @@ +require 'travis/api/app' + +class Travis::Api::App + module Helpers + module DbFollower + def prefer_follower + Octopus.using(:follower) do + yield + end + end + end + end +end From 407a08f64413bdae43fe95f173e207093f54949c Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 3 May 2013 09:42:07 +0200 Subject: [PATCH 148/165] only use the db follower if use_database_follower is set in the config --- lib/travis/api/app.rb | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 34525662..5d887cc3 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -118,21 +118,8 @@ module Travis::Api def self.setup_travis Travis::Amqp.config = Travis.config.amqp - Travis::Database.connect - if Travis.env == 'production' || Travis.env == 'staging' - # Octopus checks for Rails.env, just hardcode enabled? - Octopus.instance_eval do - def enabled? - true - end - end - ActiveRecord::Base.custom_octopus_connection = false - ::Octopus.setup do |config| - config.shards = { :follower => Travis.config.database_follower } - config.environments = ['production', 'staging'] - end - end + setup_database_connections Travis::Features.start @@ -152,6 +139,26 @@ module Travis::Api end end + def self.setup_database_connections + Travis::Database.connect + + return unless Travis.config.use_database_follower? + + if Travis.env == 'production' || Travis.env == 'staging' + # Octopus checks for Rails.env, just hardcode enabled? + Octopus.instance_eval do + def enabled? + true + end + end + ActiveRecord::Base.custom_octopus_connection = false + ::Octopus.setup do |config| + config.shards = { :follower => Travis.config.database_follower } + config.environments = ['production', 'staging'] + end + end + end + def self.load_endpoints Backports.require_relative_dir 'app/middleware' Backports.require_relative_dir 'app/endpoint' From cd7cce54b5f814aafc39fea6c38e27f7ab47754e Mon Sep 17 00:00:00 2001 From: Josh Kalderimis Date: Fri, 3 May 2013 10:31:53 +0200 Subject: [PATCH 149/165] add some output when the db follower is setup --- lib/travis/api/app.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index 93073d44..d07ffa4f 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -145,6 +145,8 @@ module Travis::Api return unless Travis.config.use_database_follower? if Travis.env == 'production' || Travis.env == 'staging' + puts "Setting up the DB follower as a read slave" + # Octopus checks for Rails.env, just hardcode enabled? Octopus.instance_eval do def enabled? From c5b73b1ecc3ab466cbf2b8b215ed2d1577bcb5d1 Mon Sep 17 00:00:00 2001 From: James Dennes Date: Fri, 3 May 2013 12:16:12 +0200 Subject: [PATCH 150/165] s/autorization/authorization/ --- lib/travis/api/app/endpoint/documentation.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/travis/api/app/endpoint/documentation.rb b/lib/travis/api/app/endpoint/documentation.rb index 13d5cd4f..7d054b1c 100644 --- a/lib/travis/api/app/endpoint/documentation.rb +++ b/lib/travis/api/app/endpoint/documentation.rb @@ -192,7 +192,7 @@ __END__

    <%= route['verb'] %> <%= route['uri'] %>

    <% if route['scope'] %>

    -

    Required autorization scope: <%= route['scope'] %>
    +
    Required authorization scope: <%= route['scope'] %>

    <% end %> <%= docs_for route %> From 935288e8e9210c8d1a2958b1082e778e55f5e700 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 5 May 2013 00:17:44 +0200 Subject: [PATCH 151/165] Don't load octopus if there is no need --- Gemfile | 2 +- lib/travis/api/app.rb | 2 +- lib/travis/api/app/helpers/db_follower.rb | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 9db2f914..ace4c1c0 100644 --- a/Gemfile +++ b/Gemfile @@ -23,7 +23,7 @@ gem 'dalli' gem 'pry' gem 'metriks', '0.9.9.2' -gem 'ar-octopus', github: 'travis-ci/octopus', require: 'octopus' +gem 'ar-octopus', github: 'travis-ci/octopus', require: nil group :test do gem 'rspec', '~> 2.11' diff --git a/lib/travis/api/app.rb b/lib/travis/api/app.rb index d07ffa4f..68ed7981 100644 --- a/lib/travis/api/app.rb +++ b/lib/travis/api/app.rb @@ -4,7 +4,6 @@ require 'rack' require 'rack/protection' require 'rack/contrib' require 'rack/cache' -require 'octopus' require 'active_record' require 'redis' require 'gh' @@ -143,6 +142,7 @@ module Travis::Api Travis::Database.connect return unless Travis.config.use_database_follower? + require 'octopus' if Travis.env == 'production' || Travis.env == 'staging' puts "Setting up the DB follower as a read slave" diff --git a/lib/travis/api/app/helpers/db_follower.rb b/lib/travis/api/app/helpers/db_follower.rb index 4658aca2..1bd654e4 100644 --- a/lib/travis/api/app/helpers/db_follower.rb +++ b/lib/travis/api/app/helpers/db_follower.rb @@ -4,7 +4,11 @@ class Travis::Api::App module Helpers module DbFollower def prefer_follower - Octopus.using(:follower) do + if Travis.config.use_database_follower? + Octopus.using(:follower) do + yield + end + else yield end end From a22ae8a74573d6d7888d1a113c016210bf489e72 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 5 May 2013 01:50:06 +0200 Subject: [PATCH 152/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 0916dfe0..60c92623 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: d3f5fd82fe81f5bfa97d810f90838a1dbeda6e17 + revision: 7853a96ad203ee34828e8ab4df59d2052a608b20 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From 201e7a3176864ca43680ec65b4078bae27cd39fd Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 5 May 2013 02:14:48 +0200 Subject: [PATCH 153/165] Add rake task for updating branch value on builds --- lib/tasks/build_update_branch.rake | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/tasks/build_update_branch.rake diff --git a/lib/tasks/build_update_branch.rake b/lib/tasks/build_update_branch.rake new file mode 100644 index 00000000..daf76764 --- /dev/null +++ b/lib/tasks/build_update_branch.rake @@ -0,0 +1,21 @@ +namespace :build do + namespace :migrate do + task :branch do + require 'travis' + Travis::Database.connect + + branches = Hash.new { |h, k| h[k] = [] } + + Build.pushes.includes(:commit).find_in_batches do |builds| + builds.each do |build| + #next if build.branch + branches[build.commit.branch] << build.id + end + end + + branches.each do |branch, ids| + Build.where(id: ids).update_all(branch: branch) + end + end + end +end From 2c23c413ef5cf5ec4208a46acc29ff3a6cb45027 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 5 May 2013 02:46:00 +0200 Subject: [PATCH 154/165] Save branches in lower groups --- lib/tasks/build_update_branch.rake | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/tasks/build_update_branch.rake b/lib/tasks/build_update_branch.rake index daf76764..55a4575b 100644 --- a/lib/tasks/build_update_branch.rake +++ b/lib/tasks/build_update_branch.rake @@ -4,18 +4,20 @@ namespace :build do require 'travis' Travis::Database.connect - branches = Hash.new { |h, k| h[k] = [] } - Build.pushes.includes(:commit).find_in_batches do |builds| + Build.select(['id', 'commit_id']).pushes.includes(:commit).find_in_batches do |builds| + branches = Hash.new { |h, k| h[k] = [] } + builds.each do |build| #next if build.branch branches[build.commit.branch] << build.id end - end - branches.each do |branch, ids| - Build.where(id: ids).update_all(branch: branch) - end + branches.each do |branch, ids| + Build.where(id: ids).update_all(branch: branch) + end + end; nil + end end end From 0b0fca44931168907954c88a2e828ebab65dcc0d Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 5 May 2013 03:40:28 +0200 Subject: [PATCH 155/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 60c92623..80000883 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 7853a96ad203ee34828e8ab4df59d2052a608b20 + revision: 054f38bddf936daa100cf6b4e480290a0da84713 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From 98d656fdaf0c9b9f89939aa16509e923e5113df6 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 5 May 2013 03:47:43 +0200 Subject: [PATCH 156/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 80000883..02c11eed 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 054f38bddf936daa100cf6b4e480290a0da84713 + revision: 8433c1248f8c9e247162e8d569a0851cebb7e99c specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From 90929010134212975bcde66e1349d23535f3fd27 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Sun, 5 May 2013 04:22:53 +0200 Subject: [PATCH 157/165] Bump travis-core --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 02c11eed..ba2bb900 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 8433c1248f8c9e247162e8d569a0851cebb7e99c + revision: 744200da37cab44407e592b41b719aca04e52090 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) From b26349176f3e84ab8fa1f95a0fd8a7e971a81afd Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 6 May 2013 17:03:23 +0200 Subject: [PATCH 158/165] Bump travis-core --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index ba2bb900..44deceac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 744200da37cab44407e592b41b719aca04e52090 + revision: 2a17f5f4b52b503a56e08effccb880f6a95d7163 specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -194,7 +194,7 @@ GEM mime-types (1.23) mocha (0.13.3) metaclass (~> 0.0.1) - multi_json (1.7.2) + multi_json (1.7.3) multipart-post (1.2.0) net-http-persistent (2.8) net-http-pipeline (1.0.1) From 01356df26ff12dc41a99fac524f006f380579021 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 22 Apr 2013 17:10:51 +0200 Subject: [PATCH 159/165] Implement expiring access tokens --- lib/travis/api/app/access_token.rb | 15 ++++++++++++-- spec/unit/access_token_spec.rb | 32 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 spec/unit/access_token_spec.rb diff --git a/lib/travis/api/app/access_token.rb b/lib/travis/api/app/access_token.rb index a8e324b9..b3e62e5f 100644 --- a/lib/travis/api/app/access_token.rb +++ b/lib/travis/api/app/access_token.rb @@ -4,7 +4,7 @@ require 'securerandom' class Travis::Api::App class AccessToken DEFAULT_SCOPES = [:public, :private] - attr_reader :token, :scopes, :user_id, :app_id + attr_reader :token, :scopes, :user_id, :app_id, :expires_in def self.create(options = {}) new(options).tap(&:save) @@ -25,6 +25,12 @@ class Travis::Api::App raise ArgumentError, 'must supply either user_id or user' unless options.key?(:user) ^ options.key?(:user_id) raise ArgumentError, 'must supply app_id' unless options.key?(:app_id) + begin + @expires_in = Integer(options[:expires_in]) if options[:expires_in] + rescue ArgumentError + raise ArgumentError, 'expires_in must be of integer type' + end + @app_id = Integer(options[:app_id]) @scopes = Array(options[:scopes] || options[:scope] || DEFAULT_SCOPES).map(&:to_sym) @user = options[:user] @@ -37,6 +43,11 @@ class Travis::Api::App redis.del(key) redis.rpush(key, [user_id, app_id, *scopes].map(&:to_s)) redis.set(reuse_key, token) + + if expires_in + redis.expire(reuse_key, expires_in) + redis.expire(key, expires_in) + end end def user @@ -68,7 +79,7 @@ class Travis::Api::App private def reuse_token - redis.get(reuse_key) + redis.get(reuse_key) unless expires_in end def reuse_key diff --git a/spec/unit/access_token_spec.rb b/spec/unit/access_token_spec.rb new file mode 100644 index 00000000..846b0d9d --- /dev/null +++ b/spec/unit/access_token_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe Travis::Api::App::AccessToken do + it 'errors out on wrong type of :expires_in argument' do + expect { + described_class.new(app_id: 1, user_id: 2, expires_in: 'foo') + }.to raise_error(ArgumentError, 'expires_in must be of integer type') + end + + it 'allows to skip expires_in' do + expect { + described_class.new(app_id: 1, user_id: 2, expires_in: nil) + }.to_not raise_error(ArgumentError) + end + + it 'does not reuse token if expires_in is set' do + token = described_class.new(app_id: 1, user_id: 2).tap(&:save) + new_token = described_class.new(app_id: 1, user_id: 2, expires_in: 10) + + token.token.should_not == new_token.token + end + + it 'expires the token after given period of time' do + token = described_class.new(app_id: 1, user_id: 2, expires_in: 1).tap(&:save) + + described_class.find_by_token(token.token).should_not be_nil + + sleep 1.5 + + described_class.find_by_token(token.token).should be_nil + end +end From 1340fdb316f5a49183c076dfd988d98bdfce3060 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 24 Apr 2013 03:03:48 +0200 Subject: [PATCH 160/165] Allow to pass additional responders to respond_with --- lib/travis/api/app/helpers/respond_with.rb | 16 +++++++++--- lib/travis/api/app/responders/image.rb | 2 +- lib/travis/api/app/responders/json.rb | 2 +- lib/travis/api/app/responders/plain.rb | 2 +- lib/travis/api/app/responders/xml.rb | 2 +- spec/integration/responders_spec.rb | 30 ++++++++++++++++++++++ spec/unit/responders/json_spec.rb | 6 ++--- 7 files changed, 48 insertions(+), 12 deletions(-) create mode 100644 spec/integration/responders_spec.rb diff --git a/lib/travis/api/app/helpers/respond_with.rb b/lib/travis/api/app/helpers/respond_with.rb index a5b19204..19f4c4fd 100644 --- a/lib/travis/api/app/helpers/respond_with.rb +++ b/lib/travis/api/app/helpers/respond_with.rb @@ -10,8 +10,8 @@ class Travis::Api::App def respond_with(resource, options = {}) result = respond(resource, options) - result = result ? result.to_json : 404 - halt result + result = result.to_json if result && response.content_type =~ /application\/json/ + halt result || 404 end def body(value = nil, options = {}, &block) @@ -24,10 +24,18 @@ class Travis::Api::App def respond(resource, options) resource = apply_service_responder(resource, options) - response = acceptable_formats.find do |accept| + response = nil + acceptable_formats.find do |accept| responders(resource, options).find do |const| responder = const.new(self, resource, options.dup.merge(accept: accept)) - responder.apply if responder.apply? + response = responder.apply if responder.apply? + end + end + + if responders = options[:responders] + responders.each do |klass| + responder = klass.new(self, response, options) + response = responder.apply if responder.apply? end end diff --git a/lib/travis/api/app/responders/image.rb b/lib/travis/api/app/responders/image.rb index d80d28e4..c6c6a17d 100644 --- a/lib/travis/api/app/responders/image.rb +++ b/lib/travis/api/app/responders/image.rb @@ -8,7 +8,7 @@ module Travis::Api::App::Responders headers['Pragma'] = "no-cache" headers['Expires'] = Time.now.utc.httpdate headers['Content-Disposition'] = %(inline; filename="#{File.basename(filename)}") - halt send_file(filename, type: :png, last_modified: last_modified) + send_file(filename, type: :png, last_modified: last_modified) end private diff --git a/lib/travis/api/app/responders/json.rb b/lib/travis/api/app/responders/json.rb index 15388f6b..012b2be8 100644 --- a/lib/travis/api/app/responders/json.rb +++ b/lib/travis/api/app/responders/json.rb @@ -10,7 +10,7 @@ class Travis::Api::App def apply super - halt result.to_json if result + result end private diff --git a/lib/travis/api/app/responders/plain.rb b/lib/travis/api/app/responders/plain.rb index 9d045478..63d3d223 100644 --- a/lib/travis/api/app/responders/plain.rb +++ b/lib/travis/api/app/responders/plain.rb @@ -21,7 +21,7 @@ module Travis::Api::App::Responders headers['Content-Disposition'] = %(#{disposition}; filename="#{filename}") - halt(params[:deansi] ? clear_ansi(resource.content) : resource.content) + params[:deansi] ? clear_ansi(resource.content) : resource.content end private diff --git a/lib/travis/api/app/responders/xml.rb b/lib/travis/api/app/responders/xml.rb index b69911b1..836d5f20 100644 --- a/lib/travis/api/app/responders/xml.rb +++ b/lib/travis/api/app/responders/xml.rb @@ -22,7 +22,7 @@ module Travis::Api::App::Responders def apply super - halt TEMPLATE % data + TEMPLATE % data end private diff --git a/spec/integration/responders_spec.rb b/spec/integration/responders_spec.rb new file mode 100644 index 00000000..8624b486 --- /dev/null +++ b/spec/integration/responders_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +describe 'App' do + before do + FactoryGirl.create(:test, :number => '3.1', :queue => 'builds.common') + + responder = Class.new(Travis::Api::App::Responders::Base) do + def apply? + true + end + + def apply + resource[:extra] = 'moar!' + + resource + end + end + + add_endpoint '/foo' do + get '/hash' do + respond_with({ foo: 'bar' }, responders: [responder]) + end + end + end + + it '' do + response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json' + JSON.parse(response.body).should == { 'foo' => 'bar', 'extra' => 'moar!' } + end +end diff --git a/spec/unit/responders/json_spec.rb b/spec/unit/responders/json_spec.rb index 37146d58..5b43bbc1 100644 --- a/spec/unit/responders/json_spec.rb +++ b/spec/unit/responders/json_spec.rb @@ -23,8 +23,7 @@ module Travis::Api::App::Responders let(:resource) { { foo: 'bar' } } it 'returns resource converted to_json' do - json.expects(:halt).with({ foo: 'bar' }.to_json) - json.apply + json.apply.should == { foo: 'bar' } end end @@ -46,8 +45,7 @@ module Travis::Api::App::Responders end it 'returns proper data converted to json' do - json.expects(:halt).with({ foo: 'bar' }.to_json) - json.apply + json.apply.should == { foo: 'bar' } end end end From ee64af14d52cbbc5d558d1822912ad1ba3629ad2 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Tue, 7 May 2013 23:54:56 +0200 Subject: [PATCH 161/165] Allow to specify more than one scope for an endpoint --- lib/travis/api/app/extensions/scoping.rb | 35 +++++++++++++++--------- spec/integration/responders_spec.rb | 2 +- spec/integration/scopes_spec.rb | 32 ++++++++++++++++++++++ 3 files changed, 55 insertions(+), 14 deletions(-) create mode 100644 spec/integration/scopes_spec.rb diff --git a/lib/travis/api/app/extensions/scoping.rb b/lib/travis/api/app/extensions/scoping.rb index 626bdbb2..2e1624d3 100644 --- a/lib/travis/api/app/extensions/scoping.rb +++ b/lib/travis/api/app/extensions/scoping.rb @@ -18,23 +18,32 @@ class Travis::Api::App app.helpers(Helpers) end - def scope(name) + def scope(*names) condition do - name = settings.default_scope if name == :default + names = [settings.default_scope] if names == [:default] scopes = env['travis.access_token'].try(:scopes) || settings.anonymous_scopes - headers['X-OAuth-Scopes'] = scopes.map(&:to_s).join(',') - headers['X-Accepted-OAuth-Scopes'] = name.to_s - if scopes.include? name - env['travis.scope'] = name - headers['Vary'] = 'Accept' - headers['Vary'] << ', Authorization' unless public? - true - elsif env['travis.access_token'] - pass { halt 403, "insufficient access" } - else - pass { halt 401, "no access token supplied" } + result = names.any? do |name| + if scopes.include? name + headers['X-OAuth-Scopes'] = scopes.map(&:to_s).join(',') + headers['X-Accepted-OAuth-Scopes'] = name.to_s + + env['travis.scope'] = name + headers['Vary'] = 'Accept' + headers['Vary'] << ', Authorization' unless public? + true + end end + + if !result + if env['travis.access_token'] + pass { halt 403, "insufficient access" } + else + pass { halt 401, "no access token supplied" } + end + end + + result end end diff --git a/spec/integration/responders_spec.rb b/spec/integration/responders_spec.rb index 8624b486..2dc2cb78 100644 --- a/spec/integration/responders_spec.rb +++ b/spec/integration/responders_spec.rb @@ -23,7 +23,7 @@ describe 'App' do end end - it '' do + it 'runs responder when rendering the response with respond_with' do response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json' JSON.parse(response.body).should == { 'foo' => 'bar', 'extra' => 'moar!' } end diff --git a/spec/integration/scopes_spec.rb b/spec/integration/scopes_spec.rb new file mode 100644 index 00000000..d5b13576 --- /dev/null +++ b/spec/integration/scopes_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe 'App' do + before do + FactoryGirl.create(:test, :number => '3.1', :queue => 'builds.common') + + add_endpoint '/foo' do + get '/hash', scope: [:foo, :bar] do + respond_with foo: 'bar' + end + end + end + + it 'checks if token has one of the required scopes' do + token = Travis::Api::App::AccessToken.new(app_id: 1, user_id: 2, scopes: [:foo]).tap(&:save) + + response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}" + response.should be_successful + response.headers['X-Accepted-OAuth-Scopes'].should == 'foo' + + token = Travis::Api::App::AccessToken.new(app_id: 1, user_id: 2, scopes: [:bar]).tap(&:save) + + response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}" + response.should be_successful + response.headers['X-Accepted-OAuth-Scopes'].should == 'bar' + + token = Travis::Api::App::AccessToken.new(app_id: 1, user_id: 2, scopes: [:baz]).tap(&:save) + + response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}" + response.status.should == 403 + end +end From 56d61ed4612998981241ad342dc0b605181c5305 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 8 May 2013 00:48:58 +0200 Subject: [PATCH 162/165] Allow to pass extra params for tokens --- lib/travis/api/app/access_token.rb | 18 +++++++++++++++--- spec/unit/access_token_spec.rb | 17 +++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/lib/travis/api/app/access_token.rb b/lib/travis/api/app/access_token.rb index b3e62e5f..99a70ad5 100644 --- a/lib/travis/api/app/access_token.rb +++ b/lib/travis/api/app/access_token.rb @@ -4,7 +4,7 @@ require 'securerandom' class Travis::Api::App class AccessToken DEFAULT_SCOPES = [:public, :private] - attr_reader :token, :scopes, :user_id, :app_id, :expires_in + attr_reader :token, :scopes, :user_id, :app_id, :expires_in, :extra def self.create(options = {}) new(options).tap(&:save) @@ -18,7 +18,8 @@ class Travis::Api::App def self.find_by_token(token) return token if token.is_a? self user_id, app_id, *scopes = redis.lrange(key(token), 0, -1) - new(token: token, scopes: scopes, user_id: user_id, app_id: app_id) if user_id + extra = decode_json(scopes.pop) if scopes.last && scopes.last =~ /^json:/ + new(token: token, scopes: scopes, user_id: user_id, app_id: app_id, extra: extra) if user_id end def initialize(options = {}) @@ -36,12 +37,15 @@ class Travis::Api::App @user = options[:user] @user_id = Integer(options[:user_id] || @user.id) @token = options[:token] || reuse_token || SecureRandom.urlsafe_base64(16) + @extra = options[:extra] end def save key = key(token) redis.del(key) - redis.rpush(key, [user_id, app_id, *scopes].map(&:to_s)) + data = [user_id, app_id, *scopes] + data << encode_json(extra) if extra + redis.rpush(key, data.map(&:to_s)) redis.set(reuse_key, token) if expires_in @@ -71,6 +75,14 @@ class Travis::Api::App def key(token) "t:#{token}" end + + def encode_json(hash) + 'json:' + Base64.encode64(hash.to_json) + end + + def decode_json(json) + JSON.parse(Base64.decode64(json.gsub(/^json:/, ''))) + end end include Helpers diff --git a/spec/unit/access_token_spec.rb b/spec/unit/access_token_spec.rb index 846b0d9d..cfdca57f 100644 --- a/spec/unit/access_token_spec.rb +++ b/spec/unit/access_token_spec.rb @@ -29,4 +29,21 @@ describe Travis::Api::App::AccessToken do described_class.find_by_token(token.token).should be_nil end + + it 'allows to save extra information' do + attrs = { + app_id: 1, + user_id: 3, + expires_in: 1, + extra: { + required_params: { job_id: '1' } + } + } + + token = described_class.new(attrs).tap(&:save) + token.extra.should == attrs[:extra] + + token = described_class.find_by_token(token.token) + token.extra.should == { 'required_params' => { 'job_id' => '1' } } + end end From 3b299cfec7a16a71c6788aed730b28f8f1e34c28 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 8 May 2013 01:14:20 +0200 Subject: [PATCH 163/165] Allow to pass required_params to token required_params will be matched with actual params to check if the token may be used for authorization. For example if { job_id: 44 } is passed as a required param, the token will be rejected for GET /jobs/33 --- lib/travis/api/app/extensions/scoping.rb | 12 +++++++++++- spec/integration/scopes_spec.rb | 17 +++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/travis/api/app/extensions/scoping.rb b/lib/travis/api/app/extensions/scoping.rb index 2e1624d3..d932a053 100644 --- a/lib/travis/api/app/extensions/scoping.rb +++ b/lib/travis/api/app/extensions/scoping.rb @@ -11,6 +11,16 @@ class Travis::Api::App def public? scope == :public end + + def required_params_match? + return true unless token = env['travis.access_token'] + + if token.extra && (required_params = token.extra['required_params']) + required_params.all? { |name, value| params[name] == value } + else + true + end + end end def self.registered(app) @@ -24,7 +34,7 @@ class Travis::Api::App scopes = env['travis.access_token'].try(:scopes) || settings.anonymous_scopes result = names.any? do |name| - if scopes.include? name + if scopes.include?(name) && required_params_match? headers['X-OAuth-Scopes'] = scopes.map(&:to_s).join(',') headers['X-Accepted-OAuth-Scopes'] = name.to_s diff --git a/spec/integration/scopes_spec.rb b/spec/integration/scopes_spec.rb index d5b13576..6230ee54 100644 --- a/spec/integration/scopes_spec.rb +++ b/spec/integration/scopes_spec.rb @@ -8,6 +8,10 @@ describe 'App' do get '/hash', scope: [:foo, :bar] do respond_with foo: 'bar' end + + get '/:job_id/log' do + respond_with job_id: params[:job_id] + end end end @@ -29,4 +33,17 @@ describe 'App' do response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}" response.status.should == 403 end + + it 'checks if required_params match the from the request' do + extra = { + required_params: { job_id: '10' } + } + token = Travis::Api::App::AccessToken.new(app_id: 1, user_id: 2, extra: extra).tap(&:save) + + response = get '/foo/10/log', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}" + response.should be_successful + + response = get '/foo/11/log', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}" + response.status.should == 403 + end end From cdabec540d017711e05571089d1870aa4e7b6257 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 8 May 2013 13:21:22 +0200 Subject: [PATCH 164/165] Fix scopes and access token specs --- spec/integration/scopes_spec.rb | 10 +++++----- spec/unit/access_token_spec.rb | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/spec/integration/scopes_spec.rb b/spec/integration/scopes_spec.rb index 6230ee54..f06fd4db 100644 --- a/spec/integration/scopes_spec.rb +++ b/spec/integration/scopes_spec.rb @@ -5,7 +5,7 @@ describe 'App' do FactoryGirl.create(:test, :number => '3.1', :queue => 'builds.common') add_endpoint '/foo' do - get '/hash', scope: [:foo, :bar] do + get '/:id/bar', scope: [:foo, :bar] do respond_with foo: 'bar' end @@ -18,20 +18,20 @@ describe 'App' do it 'checks if token has one of the required scopes' do token = Travis::Api::App::AccessToken.new(app_id: 1, user_id: 2, scopes: [:foo]).tap(&:save) - response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}" + response = get '/foo/1/bar', {}, 'HTTP_ACCEPT' => 'application/json; version=2', 'HTTP_AUTHORIZATION' => "token #{token.token}" response.should be_successful response.headers['X-Accepted-OAuth-Scopes'].should == 'foo' token = Travis::Api::App::AccessToken.new(app_id: 1, user_id: 2, scopes: [:bar]).tap(&:save) - response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}" + response = get '/foo/1/bar', {}, 'HTTP_ACCEPT' => 'application/json; version=2', 'HTTP_AUTHORIZATION' => "token #{token.token}" response.should be_successful response.headers['X-Accepted-OAuth-Scopes'].should == 'bar' token = Travis::Api::App::AccessToken.new(app_id: 1, user_id: 2, scopes: [:baz]).tap(&:save) - response = get '/foo/hash', {}, 'HTTP_ACCEPT' => 'application/json', 'HTTP_AUTHORIZATION' => "token #{token.token}" - response.status.should == 403 + response = get '/foo/1/bar', {}, 'HTTP_ACCEPT' => 'application/json; version=2', 'HTTP_AUTHORIZATION' => "token #{token.token}" + response.status.should == 404 end it 'checks if required_params match the from the request' do diff --git a/spec/unit/access_token_spec.rb b/spec/unit/access_token_spec.rb index cfdca57f..3cb8794b 100644 --- a/spec/unit/access_token_spec.rb +++ b/spec/unit/access_token_spec.rb @@ -25,7 +25,7 @@ describe Travis::Api::App::AccessToken do described_class.find_by_token(token.token).should_not be_nil - sleep 1.5 + sleep 2 described_class.find_by_token(token.token).should be_nil end From d276cd5b326a1b5f470d703676a5b3410b68db08 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Wed, 8 May 2013 13:21:46 +0200 Subject: [PATCH 165/165] Return Oauth headers even if none scope was matched If an endpoint specifies more than one scope and none of the scopes from access token matches, return oauth headers for the first of the scopes --- lib/travis/api/app/extensions/scoping.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/travis/api/app/extensions/scoping.rb b/lib/travis/api/app/extensions/scoping.rb index d932a053..5945804e 100644 --- a/lib/travis/api/app/extensions/scoping.rb +++ b/lib/travis/api/app/extensions/scoping.rb @@ -46,6 +46,9 @@ class Travis::Api::App end if !result + headers['X-OAuth-Scopes'] = scopes.map(&:to_s).join(',') + headers['X-Accepted-OAuth-Scopes'] = names.first.to_s + if env['travis.access_token'] pass { halt 403, "insufficient access" } else