diff --git a/.buildpacks b/.buildpacks index a2147aa5..36201cad 100644 --- a/.buildpacks +++ b/.buildpacks @@ -1,3 +1,3 @@ https://github.com/heroku/heroku-buildpack-ruby.git https://github.com/drogus/last-commit-sha-buildpack.git -https://dl.signalsciences.net/heroku/sigsci-buildpack-nginx.tgz +https://github.com/ryandotsmith/nginx-buildpack.git diff --git a/Gemfile b/Gemfile index 22c6d8be..bee58fa5 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,6 @@ gemspec gem 's3', github: 'travis-ci/s3' -gem 'travis-core', path: 'vendor/travis-core' gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-amqp', github: 'travis-ci/travis-amqp' gem 'travis-config', '~> 0.1.0' @@ -11,7 +10,6 @@ gem 'travis-settings', github: 'travis-ci/travis-settings' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs' gem 'travis-yaml', github: 'travis-ci/travis-yaml' -gem 'travis-settings', github: 'travis-ci/travis-settings' gem 'mustermann', github: 'rkh/mustermann' gem 'sinatra' gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil diff --git a/Gemfile.lock b/Gemfile.lock index 9d771a3a..82e45d07 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -101,29 +101,6 @@ PATH useragent virtus (~> 1.0.0) -PATH - remote: vendor/travis-core - specs: - travis-core (0.0.1) - activerecord (~> 3.2.19) - coder (~> 0.4.0) - data_migrations (~> 0.0.1) - gh - google-api-client (~> 0.9.4) - hashr - metriks (~> 0.9.7) - multi_json - pusher (~> 0.14.0) - railties (~> 3.2.19) - rake - redis (~> 3.0) - rollout (~> 1.1.0) - s3 (~> 0.3) - simple_states (~> 1.0.0) - thor - travis-config (~> 0.1.0) - virtus (~> 1.0.0) - GEM remote: https://rubygems.org/ specs: @@ -172,9 +149,6 @@ GEM customerio (1.0.0) multi_json (~> 1.0) dalli (2.7.6) - data_migrations (0.0.1) - activerecord - rake database_cleaner (0.8.0) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) @@ -412,7 +386,6 @@ DEPENDENCIES travis-amqp! travis-api! travis-config (~> 0.1.0) - travis-core! travis-migrations! travis-settings! travis-sidekiqs! diff --git a/README.md b/README.md index fa2c8741..73ee8aae 100644 --- a/README.md +++ b/README.md @@ -77,5 +77,4 @@ If you have problems with Nginx because the websocket is already in use, try res ### API documentation -We use source code comments to add documentation. If the server is running, you -can browse an HTML documentation at [`/docs`](http://localhost:5000/docs). +v3 documentation can be found at https://developer.travis-ci.org which is a repository that can be found at https://github.com/travis-pro/developer diff --git a/Rakefile b/Rakefile index dde12314..6e2e2574 100644 --- a/Rakefile +++ b/Rakefile @@ -18,7 +18,7 @@ end # t.pattern = 'spec_core/**{,/*/**}/*_spec.rb' # end # -# task :default => [:spec, :spec_core] +# task :default => [:spec] # rescue LoadError => e # puts e.inspect # end @@ -27,18 +27,8 @@ end namespace :spec do desc 'Run all specs' task :all do - sh 'bundle exec rspec -r spec_helper spec spec_core' - end - - desc 'Run api specs' - task :api do sh 'bundle exec rspec -r spec_helper spec' end - - desc 'Run core specs' - task :core do - sh 'bundle exec rspec -r spec_helper spec_core' - end end task :default => :'spec:all' diff --git a/config/nginx.conf.erb b/config/nginx.conf.erb index 941a76af..0d752e1b 100644 --- a/config/nginx.conf.erb +++ b/config/nginx.conf.erb @@ -13,10 +13,6 @@ http { gzip_comp_level 2; gzip_min_length 512; - <% unless ENV['SIGSCI_ENABLED'].nil? || ENV['SIGSCI_ENABLED'].empty? %> - include "../sigsci-module-nginx/sigsci.conf"; - <% end %> - server_tokens off; log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id'; diff --git a/heroku-buildpack-sigsci.tgz b/heroku-buildpack-sigsci.tgz new file mode 100644 index 00000000..1b0b6c83 Binary files /dev/null and b/heroku-buildpack-sigsci.tgz differ diff --git a/lib/travis.rb b/lib/travis.rb index cf1fc094..76babe23 100644 --- a/lib/travis.rb +++ b/lib/travis.rb @@ -1,7 +1,6 @@ require 'pusher' require 'travis/support' require 'travis/support/database' -require 'travis/version' require 'travis/redis_pool' require 'travis/errors' @@ -19,7 +18,6 @@ module Travis require 'travis/model' require 'travis/task' require 'travis/event' - require 'travis/addons' require 'travis/api/serialize' require 'travis/config/defaults' require 'travis/features' @@ -43,7 +41,6 @@ module Travis Travis.logger.info('Setting up Travis::Core') Github.setup - Addons.register Services.register Github::Services.register end diff --git a/lib/travis/api/app/endpoint/builds.rb b/lib/travis/api/app/endpoint/builds.rb index 923c712a..b23b8258 100644 --- a/lib/travis/api/app/endpoint/builds.rb +++ b/lib/travis/api/app/endpoint/builds.rb @@ -23,11 +23,6 @@ class Travis::Api::App Metriks.meter("api.request.cancel_build").mark service = Travis::Enqueue::Services::CancelModel.new(current_user, { build_id: params[:id] }) - repository_owner = service.target.repository.owner - - if !Travis::Features.enabled_for_all?(:enqueue_to_hub) && !Travis::Features.owner_active?(:enqueue_to_hub, repository_owner) - service = self.service(:cancel_build, params.merge(source: 'api')) - end if !service.authorized? json = { error: { @@ -48,11 +43,8 @@ class Travis::Api::App respond_with json else payload = { id: params[:id], user_id: current_user.id, source: 'api' } - if service.respond_to?(:push) - service.push("build:cancel", payload) - else - Travis::Sidekiq::BuildCancellation.perform_async(payload) - end + + service.push("build:cancel", payload) Metriks.meter("api.request.cancel_build.success").mark status 204 @@ -62,24 +54,15 @@ class Travis::Api::App post '/:id/restart' do Metriks.meter("api.request.restart_build").mark service = Travis::Enqueue::Services::RestartModel.new(current_user, build_id: params[:id]) - repository_owner = service.target.repository.owner - - if !Travis::Features.enabled_for_all?(:enqueue_to_hub) && !Travis::Features.owner_active?(:enqueue_to_hub, repository_owner) - service = self.service(:reset_model, build_id: params[:id]) - end result = if !service.accept? status 400 false - elsif service.respond_to?(:push) + else payload = { id: params[:id], user_id: current_user.id } service.push("build:restart", payload) status 202 true - else - Travis::Sidekiq::BuildRestart.perform_async(id: params[:id], user_id: current_user.id) - status 202 - true end respond_with(result: result, flash: service.messages) diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index aafef56c..4a217625 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -30,10 +30,6 @@ class Travis::Api::App Metriks.meter("api.request.cancel_job").mark service = Travis::Enqueue::Services::CancelModel.new(current_user, { job_id: params[:id] }) - repository_owner = service.target.repository.owner - if !Travis::Features.enabled_for_all?(:enqueue_to_hub) && !Travis::Features.owner_active?(:enqueue_to_hub, repository_owner) - service = self.service(:cancel_job, params.merge(source: 'api')) - end if !service.authorized? json = { error: { @@ -54,11 +50,7 @@ class Travis::Api::App respond_with json else payload = { id: params[:id], user_id: current_user.id, source: 'api' } - if service.respond_to?(:push) - service.push("job:cancel", payload) - else - Travis::Sidekiq::JobCancellation.perform_async(payload) - end + service.push("job:cancel", payload) Metriks.meter("api.request.cancel_job.success").mark status 204 @@ -69,23 +61,15 @@ class Travis::Api::App Metriks.meter("api.request.restart_job").mark service = Travis::Enqueue::Services::RestartModel.new(current_user, { job_id: params[:id] }) - repository_owner = service.target.repository.owner - if !Travis::Features.enabled_for_all?(:enqueue_to_hub) && !Travis::Features.owner_active?(:enqueue_to_hub, repository_owner) - service = self.service(:reset_model, job_id: params[:id]) - end result = if !service.accept? status 400 false - elsif service.respond_to?(:push) + else payload = {id: params[:id], user_id: current_user.id} service.push("job:restart", payload) status 202 true - else - Travis::Sidekiq::JobRestart.perform_async(id: params[:id], user_id: current_user.id) - status 202 - result = true end respond_with(result: result, flash: service.messages) diff --git a/lib/travis/api/app/endpoint/requests.rb b/lib/travis/api/app/endpoint/requests.rb index 3c9c96f2..d8c05a5d 100644 --- a/lib/travis/api/app/endpoint/requests.rb +++ b/lib/travis/api/app/endpoint/requests.rb @@ -30,19 +30,10 @@ class Travis::Api::App # I think we need to properly deprecate this by publishing a blog post. Metriks.meter("api.request.restart").mark - service = Travis::Enqueue::Services::RestartModel.new(current_user, params) - repository_owner = service.target.repository.owner - - if !Travis::Features.enabled_for_all?(:enqueue_to_hub) && !Travis::Features.owner_active?(:enqueue_to_hub, repository_owner) - respond_with service(:reset_model, params) - elsif service.respond_to?(:push) - params[:user_id] = repository_owner.id - type ||= params[:build_id] ? 'build' : 'job' - params[:id] = params[:build_id] || params[:job_id] - - service.push("#{type}:restart", params) - respond_with(result: true, flash: service.messages) - end + service = Travis::Enqueue::Services::RestartModel.new(current_user, { build_id: params[:build_id] }) + payload = {id: params[:build_id], user_id: current_user.id} + service.push("job:restart", payload) + status 202 end end end diff --git a/lib/travis/api/v3/queries/build.rb b/lib/travis/api/v3/queries/build.rb index 8133d54c..ed8e6685 100644 --- a/lib/travis/api/v3/queries/build.rb +++ b/lib/travis/api/v3/queries/build.rb @@ -12,26 +12,19 @@ module Travis::API::V3 def cancel(user) raise BuildNotCancelable if %w(passed failed canceled errored).include? find.state + payload = { id: id, user_id: user.id, source: 'api' } - if Travis::Features.enabled_for_all?(:enqueue_to_hub) || Travis::Features.owner_active?(:enqueue_to_hub, find.repository.owner) - service = Travis::Enqueue::Services::CancelModel.new(user, { build_id: id }) - service.push("build:cancel", payload) - else - perform_async(:build_cancellation, payload) - end + service = Travis::Enqueue::Services::CancelModel.new(user, { build_id: id }) + service.push("build:cancel", payload) payload end def restart(user) raise BuildAlreadyRunning if %w(received queued started).include? find.state - if Travis::Features.enabled_for_all?(:enqueue_to_hub) || Travis::Features.owner_active?(:enqueue_to_hub, find.repository.owner) - service = Travis::Enqueue::Services::RestartModel.new(user, { build_id: id }) - payload = { id: id, user_id: user.id } - service.push("build:restart", payload) - else - payload = { id: id, user_id: user.id, source: 'api' } - perform_async(:build_restart, payload) - end + + service = Travis::Enqueue::Services::RestartModel.new(user, { build_id: id }) + payload = { id: id, user_id: user.id } + service.push("build:restart", payload) payload end end diff --git a/lib/travis/api/v3/queries/job.rb b/lib/travis/api/v3/queries/job.rb index 755ab069..3d2f6485 100644 --- a/lib/travis/api/v3/queries/job.rb +++ b/lib/travis/api/v3/queries/job.rb @@ -12,28 +12,19 @@ module Travis::API::V3 def cancel(user) raise JobNotCancelable if %w(passed failed canceled errored).include? find.state + payload = { id: id, user_id: user.id, source: 'api' } - #look for repo.owner instead and look if the user belongs to the repo, instead of using user for the feature flag - if Travis::Features.enabled_for_all?(:enqueue_to_hub) || Travis::Features.owner_active?(:enqueue_to_hub, find.repository.owner) - service = Travis::Enqueue::Services::CancelModel.new(user, { job_id: id }) - service.push("job:cancel", payload) - else - perform_async(:job_cancellation, payload) - end + service = Travis::Enqueue::Services::CancelModel.new(user, { job_id: id }) + service.push("job:cancel", payload) payload end def restart(user) raise JobAlreadyRunning if %w(received queued started).include? find.state - if Travis::Features.enabled_for_all?(:enqueue_to_hub) || Travis::Features.owner_active?(:enqueue_to_hub, find.repository.owner) - service = Travis::Enqueue::Services::RestartModel.new(user, { job_id: id }) - payload = { id: id, user_id: user.id } - service.push("job:restart", payload) - else - payload = { id: id, user_id: user.id, source: 'api' } - perform_async(:job_restart, payload) - end + service = Travis::Enqueue::Services::RestartModel.new(user, { job_id: id }) + payload = { id: id, user_id: user.id } + service.push("job:restart", payload) payload end end diff --git a/vendor/travis-core/lib/travis/errors.rb b/lib/travis/errors.rb similarity index 100% rename from vendor/travis-core/lib/travis/errors.rb rename to lib/travis/errors.rb diff --git a/vendor/travis-core/lib/travis/event.rb b/lib/travis/event.rb similarity index 74% rename from vendor/travis-core/lib/travis/event.rb rename to lib/travis/event.rb index e9fc239e..9c25fa2b 100644 --- a/vendor/travis-core/lib/travis/event.rb +++ b/lib/travis/event.rb @@ -8,11 +8,6 @@ module Travis # # Handler registrations are defined in Travis.config so they can be added or # removed easily for different environments. - # - # Note that Travis::Event#notify accepts an internal event name like - # 'create' (coming from the simple_states implementation in the models) and - # turns it into a namespaced client event name like 'job:test:created'). - # Notification handlers register for and deal with these client event names. module Event require 'travis/event/config' require 'travis/event/handler' @@ -42,10 +37,6 @@ module Travis end end - def notify(event, *args) - Travis.logger.info("DEPRECATED: Event.notify used: event=#{event}, args=#{args}") - Travis::Event.dispatch(client_event(event, self), self, *args) - end protected diff --git a/vendor/travis-core/lib/travis/event/config.rb b/lib/travis/event/config.rb similarity index 100% rename from vendor/travis-core/lib/travis/event/config.rb rename to lib/travis/event/config.rb diff --git a/vendor/travis-core/lib/travis/event/handler.rb b/lib/travis/event/handler.rb similarity index 100% rename from vendor/travis-core/lib/travis/event/handler.rb rename to lib/travis/event/handler.rb diff --git a/vendor/travis-core/lib/travis/event/handler/metrics.rb b/lib/travis/event/handler/metrics.rb similarity index 100% rename from vendor/travis-core/lib/travis/event/handler/metrics.rb rename to lib/travis/event/handler/metrics.rb diff --git a/vendor/travis-core/lib/travis/event/handler/trail.rb b/lib/travis/event/handler/trail.rb similarity index 100% rename from vendor/travis-core/lib/travis/event/handler/trail.rb rename to lib/travis/event/handler/trail.rb diff --git a/vendor/travis-core/lib/travis/event/subscription.rb b/lib/travis/event/subscription.rb similarity index 100% rename from vendor/travis-core/lib/travis/event/subscription.rb rename to lib/travis/event/subscription.rb diff --git a/vendor/travis-core/lib/travis/features.rb b/lib/travis/features.rb similarity index 100% rename from vendor/travis-core/lib/travis/features.rb rename to lib/travis/features.rb diff --git a/vendor/travis-core/lib/travis/github.rb b/lib/travis/github.rb similarity index 91% rename from vendor/travis-core/lib/travis/github.rb rename to lib/travis/github.rb index 3afc1d72..6ff48dab 100644 --- a/vendor/travis-core/lib/travis/github.rb +++ b/lib/travis/github.rb @@ -11,7 +11,7 @@ module Travis GH.set( client_id: Travis.config.oauth2.client_id, client_secret: Travis.config.oauth2.client_secret, - user_agent: "Travis-CI/#{Travis::VERSION} GH/#{GH::VERSION}", + user_agent: "GH/#{GH::VERSION}", origin: Travis.config.host, api_url: Travis.config.github.api_url, ssl: Travis.config.ssl.to_h.merge(Travis.config.github.ssl || {}).to_h.compact diff --git a/vendor/travis-core/lib/travis/github/education.rb b/lib/travis/github/education.rb similarity index 100% rename from vendor/travis-core/lib/travis/github/education.rb rename to lib/travis/github/education.rb diff --git a/vendor/travis-core/lib/travis/github/oauth.rb b/lib/travis/github/oauth.rb similarity index 100% rename from vendor/travis-core/lib/travis/github/oauth.rb rename to lib/travis/github/oauth.rb diff --git a/vendor/travis-core/lib/travis/github/services.rb b/lib/travis/github/services.rb similarity index 100% rename from vendor/travis-core/lib/travis/github/services.rb rename to lib/travis/github/services.rb diff --git a/vendor/travis-core/lib/travis/github/services/set_hook.rb b/lib/travis/github/services/set_hook.rb similarity index 100% rename from vendor/travis-core/lib/travis/github/services/set_hook.rb rename to lib/travis/github/services/set_hook.rb diff --git a/vendor/travis-core/lib/travis/model.rb b/lib/travis/model.rb similarity index 100% rename from vendor/travis-core/lib/travis/model.rb rename to lib/travis/model.rb diff --git a/vendor/travis-core/lib/travis/model/account.rb b/lib/travis/model/account.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/account.rb rename to lib/travis/model/account.rb diff --git a/vendor/travis-core/lib/travis/model/annotation.rb b/lib/travis/model/annotation.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/annotation.rb rename to lib/travis/model/annotation.rb diff --git a/vendor/travis-core/lib/travis/model/annotation_provider.rb b/lib/travis/model/annotation_provider.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/annotation_provider.rb rename to lib/travis/model/annotation_provider.rb diff --git a/vendor/travis-core/lib/travis/model/branch.rb b/lib/travis/model/branch.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/branch.rb rename to lib/travis/model/branch.rb diff --git a/vendor/travis-core/lib/travis/model/broadcast.rb b/lib/travis/model/broadcast.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/broadcast.rb rename to lib/travis/model/broadcast.rb diff --git a/vendor/travis-core/lib/travis/model/build.rb b/lib/travis/model/build.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build.rb rename to lib/travis/model/build.rb diff --git a/vendor/travis-core/lib/travis/model/build/config.rb b/lib/travis/model/build/config.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/config.rb rename to lib/travis/model/build/config.rb diff --git a/vendor/travis-core/lib/travis/model/build/config/dist.rb b/lib/travis/model/build/config/dist.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/config/dist.rb rename to lib/travis/model/build/config/dist.rb diff --git a/vendor/travis-core/lib/travis/model/build/config/env.rb b/lib/travis/model/build/config/env.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/config/env.rb rename to lib/travis/model/build/config/env.rb diff --git a/vendor/travis-core/lib/travis/model/build/config/features.rb b/lib/travis/model/build/config/features.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/config/features.rb rename to lib/travis/model/build/config/features.rb diff --git a/vendor/travis-core/lib/travis/model/build/config/group.rb b/lib/travis/model/build/config/group.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/config/group.rb rename to lib/travis/model/build/config/group.rb diff --git a/vendor/travis-core/lib/travis/model/build/config/language.rb b/lib/travis/model/build/config/language.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/config/language.rb rename to lib/travis/model/build/config/language.rb diff --git a/vendor/travis-core/lib/travis/model/build/config/matrix.rb b/lib/travis/model/build/config/matrix.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/config/matrix.rb rename to lib/travis/model/build/config/matrix.rb diff --git a/vendor/travis-core/lib/travis/model/build/config/obfuscate.rb b/lib/travis/model/build/config/obfuscate.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/config/obfuscate.rb rename to lib/travis/model/build/config/obfuscate.rb diff --git a/vendor/travis-core/lib/travis/model/build/config/os.rb b/lib/travis/model/build/config/os.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/config/os.rb rename to lib/travis/model/build/config/os.rb diff --git a/vendor/travis-core/lib/travis/model/build/config/yaml.rb b/lib/travis/model/build/config/yaml.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/config/yaml.rb rename to lib/travis/model/build/config/yaml.rb diff --git a/vendor/travis-core/lib/travis/model/build/denormalize.rb b/lib/travis/model/build/denormalize.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/denormalize.rb rename to lib/travis/model/build/denormalize.rb diff --git a/vendor/travis-core/lib/travis/model/build/matrix.rb b/lib/travis/model/build/matrix.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/matrix.rb rename to lib/travis/model/build/matrix.rb diff --git a/vendor/travis-core/lib/travis/model/build/metrics.rb b/lib/travis/model/build/metrics.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/metrics.rb rename to lib/travis/model/build/metrics.rb diff --git a/vendor/travis-core/lib/travis/model/build/result_message.rb b/lib/travis/model/build/result_message.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/result_message.rb rename to lib/travis/model/build/result_message.rb diff --git a/vendor/travis-core/lib/travis/model/build/states.rb b/lib/travis/model/build/states.rb similarity index 96% rename from vendor/travis-core/lib/travis/model/build/states.rb rename to lib/travis/model/build/states.rb index 25b1193f..ae665acd 100644 --- a/vendor/travis-core/lib/travis/model/build/states.rb +++ b/lib/travis/model/build/states.rb @@ -28,21 +28,21 @@ class Build event :finish, to: :finished, if: :should_finish? event :reset, to: :created event :cancel, to: :canceled, if: :cancelable? - event :all, after: [:denormalize, :notify] + event :all, after: [:denormalize] end def should_finish? matrix_finished? && !finished? end - +#TODO remove? def receive(data = {}) self.received_at = data[:received_at] end - +#TODO remove? def start(data = {}) self.started_at = data[:started_at] end - +#TODO remove? def finish(data = {}) self.state = matrix_state self.duration = matrix_duration @@ -50,7 +50,7 @@ class Build save! end - +#TODO remove? def cancel(options = {}) matrix.each do |job| job.cancel! diff --git a/vendor/travis-core/lib/travis/model/build/update_branch.rb b/lib/travis/model/build/update_branch.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/build/update_branch.rb rename to lib/travis/model/build/update_branch.rb diff --git a/vendor/travis-core/lib/travis/model/commit.rb b/lib/travis/model/commit.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/commit.rb rename to lib/travis/model/commit.rb diff --git a/vendor/travis-core/lib/travis/model/email.rb b/lib/travis/model/email.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/email.rb rename to lib/travis/model/email.rb diff --git a/vendor/travis-core/lib/travis/model/encrypted_column.rb b/lib/travis/model/encrypted_column.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/encrypted_column.rb rename to lib/travis/model/encrypted_column.rb diff --git a/vendor/travis-core/lib/travis/model/env_helpers.rb b/lib/travis/model/env_helpers.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/env_helpers.rb rename to lib/travis/model/env_helpers.rb diff --git a/vendor/travis-core/lib/travis/model/job.rb b/lib/travis/model/job.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/job.rb rename to lib/travis/model/job.rb diff --git a/vendor/travis-core/lib/travis/model/job/cleanup.rb b/lib/travis/model/job/cleanup.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/job/cleanup.rb rename to lib/travis/model/job/cleanup.rb diff --git a/vendor/travis-core/lib/travis/model/job/queue.rb b/lib/travis/model/job/queue.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/job/queue.rb rename to lib/travis/model/job/queue.rb diff --git a/vendor/travis-core/lib/travis/model/job/test.rb b/lib/travis/model/job/test.rb similarity index 91% rename from vendor/travis-core/lib/travis/model/job/test.rb rename to lib/travis/model/job/test.rb index 6977b598..97fd8642 100644 --- a/vendor/travis-core/lib/travis/model/job/test.rb +++ b/lib/travis/model/job/test.rb @@ -21,11 +21,10 @@ class Job event :finish, to: :finished event :reset, to: :created, unless: :created? event :cancel, to: :canceled, if: :cancelable? - event :all, after: [:propagate, :notify] + event :all, after: [:propagate] def enqueue # TODO rename to queue and make it an event, simple_states should support that now update_attributes!(state: :queued, queued_at: Time.now.utc) - notify(:queue) end def receive(data = {}) @@ -95,13 +94,6 @@ class Job state == nil end - def notify(event, *args) - Metriks.timer("job.notify.#{event}").time do - event = :create if event == :reset - super - end - end - delegate :id, :content, :to => :log, :prefix => true, :allow_nil => true end end diff --git a/vendor/travis-core/lib/travis/model/log.rb b/lib/travis/model/log.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/log.rb rename to lib/travis/model/log.rb diff --git a/vendor/travis-core/lib/travis/model/log/part.rb b/lib/travis/model/log/part.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/log/part.rb rename to lib/travis/model/log/part.rb diff --git a/vendor/travis-core/lib/travis/model/logs_model.rb b/lib/travis/model/logs_model.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/logs_model.rb rename to lib/travis/model/logs_model.rb diff --git a/vendor/travis-core/lib/travis/model/membership.rb b/lib/travis/model/membership.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/membership.rb rename to lib/travis/model/membership.rb diff --git a/vendor/travis-core/lib/travis/model/organization.rb b/lib/travis/model/organization.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/organization.rb rename to lib/travis/model/organization.rb diff --git a/vendor/travis-core/lib/travis/model/permission.rb b/lib/travis/model/permission.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/permission.rb rename to lib/travis/model/permission.rb diff --git a/vendor/travis-core/lib/travis/model/repository.rb b/lib/travis/model/repository.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/repository.rb rename to lib/travis/model/repository.rb diff --git a/vendor/travis-core/lib/travis/model/repository/settings.rb b/lib/travis/model/repository/settings.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/repository/settings.rb rename to lib/travis/model/repository/settings.rb diff --git a/vendor/travis-core/lib/travis/model/repository/status_image.rb b/lib/travis/model/repository/status_image.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/repository/status_image.rb rename to lib/travis/model/repository/status_image.rb diff --git a/vendor/travis-core/lib/travis/model/request.rb b/lib/travis/model/request.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/request.rb rename to lib/travis/model/request.rb diff --git a/vendor/travis-core/lib/travis/model/request/pull_request.rb b/lib/travis/model/request/pull_request.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/request/pull_request.rb rename to lib/travis/model/request/pull_request.rb diff --git a/vendor/travis-core/lib/travis/model/ssl_key.rb b/lib/travis/model/ssl_key.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/ssl_key.rb rename to lib/travis/model/ssl_key.rb diff --git a/vendor/travis-core/lib/travis/model/token.rb b/lib/travis/model/token.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/token.rb rename to lib/travis/model/token.rb diff --git a/vendor/travis-core/lib/travis/model/url.rb b/lib/travis/model/url.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/url.rb rename to lib/travis/model/url.rb diff --git a/vendor/travis-core/lib/travis/model/user.rb b/lib/travis/model/user.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/user.rb rename to lib/travis/model/user.rb diff --git a/vendor/travis-core/lib/travis/model/user/oauth.rb b/lib/travis/model/user/oauth.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/user/oauth.rb rename to lib/travis/model/user/oauth.rb diff --git a/vendor/travis-core/lib/travis/model/user/renaming.rb b/lib/travis/model/user/renaming.rb similarity index 100% rename from vendor/travis-core/lib/travis/model/user/renaming.rb rename to lib/travis/model/user/renaming.rb diff --git a/vendor/travis-core/lib/travis/notification.rb b/lib/travis/notification.rb similarity index 100% rename from vendor/travis-core/lib/travis/notification.rb rename to lib/travis/notification.rb diff --git a/vendor/travis-core/lib/travis/notification/instrument.rb b/lib/travis/notification/instrument.rb similarity index 100% rename from vendor/travis-core/lib/travis/notification/instrument.rb rename to lib/travis/notification/instrument.rb diff --git a/vendor/travis-core/lib/travis/notification/instrument/event_handler.rb b/lib/travis/notification/instrument/event_handler.rb similarity index 100% rename from vendor/travis-core/lib/travis/notification/instrument/event_handler.rb rename to lib/travis/notification/instrument/event_handler.rb diff --git a/vendor/travis-core/lib/travis/notification/instrument/task.rb b/lib/travis/notification/instrument/task.rb similarity index 100% rename from vendor/travis-core/lib/travis/notification/instrument/task.rb rename to lib/travis/notification/instrument/task.rb diff --git a/vendor/travis-core/lib/travis/notification/publisher.rb b/lib/travis/notification/publisher.rb similarity index 100% rename from vendor/travis-core/lib/travis/notification/publisher.rb rename to lib/travis/notification/publisher.rb diff --git a/vendor/travis-core/lib/travis/notification/publisher/log.rb b/lib/travis/notification/publisher/log.rb similarity index 100% rename from vendor/travis-core/lib/travis/notification/publisher/log.rb rename to lib/travis/notification/publisher/log.rb diff --git a/vendor/travis-core/lib/travis/notification/publisher/memory.rb b/lib/travis/notification/publisher/memory.rb similarity index 100% rename from vendor/travis-core/lib/travis/notification/publisher/memory.rb rename to lib/travis/notification/publisher/memory.rb diff --git a/vendor/travis-core/lib/travis/notification/publisher/redis.rb b/lib/travis/notification/publisher/redis.rb similarity index 100% rename from vendor/travis-core/lib/travis/notification/publisher/redis.rb rename to lib/travis/notification/publisher/redis.rb diff --git a/vendor/travis-core/lib/travis/redis_pool.rb b/lib/travis/redis_pool.rb similarity index 100% rename from vendor/travis-core/lib/travis/redis_pool.rb rename to lib/travis/redis_pool.rb diff --git a/vendor/travis-core/lib/travis/secure_config.rb b/lib/travis/secure_config.rb similarity index 100% rename from vendor/travis-core/lib/travis/secure_config.rb rename to lib/travis/secure_config.rb diff --git a/vendor/travis-core/lib/travis/services.rb b/lib/travis/services.rb similarity index 94% rename from vendor/travis-core/lib/travis/services.rb rename to lib/travis/services.rb index 6d37cdbf..f9971993 100644 --- a/vendor/travis-core/lib/travis/services.rb +++ b/lib/travis/services.rb @@ -37,8 +37,6 @@ module Travis end require 'travis/services/base' -require 'travis/services/cancel_job' -require 'travis/services/cancel_build' require 'travis/services/delete_caches' require 'travis/services/find_admin' require 'travis/services/find_annotations' @@ -63,7 +61,6 @@ require 'travis/services/find_user_permissions' require 'travis/services/next_build_number' require 'travis/services/regenerate_repo_key' require 'travis/services/remove_log' -require 'travis/services/reset_model' require 'travis/services/sync_user' require 'travis/services/update_annotation' require 'travis/services/update_hook' diff --git a/vendor/travis-core/lib/travis/services/base.rb b/lib/travis/services/base.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/base.rb rename to lib/travis/services/base.rb diff --git a/vendor/travis-core/lib/travis/services/delete_caches.rb b/lib/travis/services/delete_caches.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/delete_caches.rb rename to lib/travis/services/delete_caches.rb diff --git a/vendor/travis-core/lib/travis/services/find_admin.rb b/lib/travis/services/find_admin.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_admin.rb rename to lib/travis/services/find_admin.rb diff --git a/vendor/travis-core/lib/travis/services/find_annotations.rb b/lib/travis/services/find_annotations.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_annotations.rb rename to lib/travis/services/find_annotations.rb diff --git a/vendor/travis-core/lib/travis/services/find_branch.rb b/lib/travis/services/find_branch.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_branch.rb rename to lib/travis/services/find_branch.rb diff --git a/vendor/travis-core/lib/travis/services/find_branches.rb b/lib/travis/services/find_branches.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_branches.rb rename to lib/travis/services/find_branches.rb diff --git a/vendor/travis-core/lib/travis/services/find_build.rb b/lib/travis/services/find_build.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_build.rb rename to lib/travis/services/find_build.rb diff --git a/vendor/travis-core/lib/travis/services/find_builds.rb b/lib/travis/services/find_builds.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_builds.rb rename to lib/travis/services/find_builds.rb diff --git a/vendor/travis-core/lib/travis/services/find_caches.rb b/lib/travis/services/find_caches.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_caches.rb rename to lib/travis/services/find_caches.rb diff --git a/vendor/travis-core/lib/travis/services/find_hooks.rb b/lib/travis/services/find_hooks.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_hooks.rb rename to lib/travis/services/find_hooks.rb diff --git a/vendor/travis-core/lib/travis/services/find_job.rb b/lib/travis/services/find_job.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_job.rb rename to lib/travis/services/find_job.rb diff --git a/vendor/travis-core/lib/travis/services/find_jobs.rb b/lib/travis/services/find_jobs.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_jobs.rb rename to lib/travis/services/find_jobs.rb diff --git a/vendor/travis-core/lib/travis/services/find_log.rb b/lib/travis/services/find_log.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_log.rb rename to lib/travis/services/find_log.rb diff --git a/vendor/travis-core/lib/travis/services/find_repo.rb b/lib/travis/services/find_repo.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_repo.rb rename to lib/travis/services/find_repo.rb diff --git a/vendor/travis-core/lib/travis/services/find_repo_key.rb b/lib/travis/services/find_repo_key.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_repo_key.rb rename to lib/travis/services/find_repo_key.rb diff --git a/vendor/travis-core/lib/travis/services/find_repo_settings.rb b/lib/travis/services/find_repo_settings.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_repo_settings.rb rename to lib/travis/services/find_repo_settings.rb diff --git a/vendor/travis-core/lib/travis/services/find_repos.rb b/lib/travis/services/find_repos.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_repos.rb rename to lib/travis/services/find_repos.rb diff --git a/vendor/travis-core/lib/travis/services/find_request.rb b/lib/travis/services/find_request.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_request.rb rename to lib/travis/services/find_request.rb diff --git a/vendor/travis-core/lib/travis/services/find_requests.rb b/lib/travis/services/find_requests.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_requests.rb rename to lib/travis/services/find_requests.rb diff --git a/vendor/travis-core/lib/travis/services/find_user_accounts.rb b/lib/travis/services/find_user_accounts.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_user_accounts.rb rename to lib/travis/services/find_user_accounts.rb diff --git a/vendor/travis-core/lib/travis/services/find_user_broadcasts.rb b/lib/travis/services/find_user_broadcasts.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_user_broadcasts.rb rename to lib/travis/services/find_user_broadcasts.rb diff --git a/vendor/travis-core/lib/travis/services/find_user_permissions.rb b/lib/travis/services/find_user_permissions.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/find_user_permissions.rb rename to lib/travis/services/find_user_permissions.rb diff --git a/vendor/travis-core/lib/travis/services/helpers.rb b/lib/travis/services/helpers.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/helpers.rb rename to lib/travis/services/helpers.rb diff --git a/vendor/travis-core/lib/travis/services/next_build_number.rb b/lib/travis/services/next_build_number.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/next_build_number.rb rename to lib/travis/services/next_build_number.rb diff --git a/vendor/travis-core/lib/travis/services/regenerate_repo_key.rb b/lib/travis/services/regenerate_repo_key.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/regenerate_repo_key.rb rename to lib/travis/services/regenerate_repo_key.rb diff --git a/vendor/travis-core/lib/travis/services/registry.rb b/lib/travis/services/registry.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/registry.rb rename to lib/travis/services/registry.rb diff --git a/vendor/travis-core/lib/travis/services/remove_log.rb b/lib/travis/services/remove_log.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/remove_log.rb rename to lib/travis/services/remove_log.rb diff --git a/vendor/travis-core/lib/travis/services/sync_user.rb b/lib/travis/services/sync_user.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/sync_user.rb rename to lib/travis/services/sync_user.rb diff --git a/vendor/travis-core/lib/travis/services/update_annotation.rb b/lib/travis/services/update_annotation.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/update_annotation.rb rename to lib/travis/services/update_annotation.rb diff --git a/vendor/travis-core/lib/travis/services/update_hook.rb b/lib/travis/services/update_hook.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/update_hook.rb rename to lib/travis/services/update_hook.rb diff --git a/vendor/travis-core/lib/travis/services/update_job.rb b/lib/travis/services/update_job.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/update_job.rb rename to lib/travis/services/update_job.rb diff --git a/vendor/travis-core/lib/travis/services/update_log.rb b/lib/travis/services/update_log.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/update_log.rb rename to lib/travis/services/update_log.rb diff --git a/vendor/travis-core/lib/travis/services/update_user.rb b/lib/travis/services/update_user.rb similarity index 100% rename from vendor/travis-core/lib/travis/services/update_user.rb rename to lib/travis/services/update_user.rb diff --git a/vendor/travis-core/lib/travis/states_cache.rb b/lib/travis/states_cache.rb similarity index 100% rename from vendor/travis-core/lib/travis/states_cache.rb rename to lib/travis/states_cache.rb diff --git a/vendor/travis-core/lib/travis/task.rb b/lib/travis/task.rb similarity index 100% rename from vendor/travis-core/lib/travis/task.rb rename to lib/travis/task.rb diff --git a/vendor/travis-core/lib/travis/testing.rb b/lib/travis/testing.rb similarity index 100% rename from vendor/travis-core/lib/travis/testing.rb rename to lib/travis/testing.rb diff --git a/vendor/travis-core/lib/travis/testing/factories.rb b/lib/travis/testing/factories.rb similarity index 100% rename from vendor/travis-core/lib/travis/testing/factories.rb rename to lib/travis/testing/factories.rb diff --git a/vendor/travis-core/lib/travis/testing/matchers.rb b/lib/travis/testing/matchers.rb similarity index 100% rename from vendor/travis-core/lib/travis/testing/matchers.rb rename to lib/travis/testing/matchers.rb diff --git a/vendor/travis-core/lib/travis/testing/payloads.rb b/lib/travis/testing/payloads.rb similarity index 100% rename from vendor/travis-core/lib/travis/testing/payloads.rb rename to lib/travis/testing/payloads.rb diff --git a/vendor/travis-core/lib/travis/testing/scenario.rb b/lib/travis/testing/scenario.rb similarity index 100% rename from vendor/travis-core/lib/travis/testing/scenario.rb rename to lib/travis/testing/scenario.rb diff --git a/vendor/travis-core/lib/travis/testing/stubs.rb b/lib/travis/testing/stubs.rb similarity index 100% rename from vendor/travis-core/lib/travis/testing/stubs.rb rename to lib/travis/testing/stubs.rb diff --git a/vendor/travis-core/lib/travis/testing/stubs/stub.rb b/lib/travis/testing/stubs/stub.rb similarity index 100% rename from vendor/travis-core/lib/travis/testing/stubs/stub.rb rename to lib/travis/testing/stubs/stub.rb diff --git a/sigsci-buildpack-nginx.tgz b/sigsci-buildpack-nginx.tgz new file mode 100644 index 00000000..47dcb4b6 Binary files /dev/null and b/sigsci-buildpack-nginx.tgz differ diff --git a/spec/integration/v2/builds_spec.rb b/spec/integration/v2/builds_spec.rb index 5670c46a..de6eab2d 100644 --- a/spec/integration/v2/builds_spec.rb +++ b/spec/integration/v2/builds_spec.rb @@ -97,20 +97,6 @@ describe 'Builds', set_app: true do build.update_attribute(:state, 'created') end - context 'from the Core' do - before { Travis::Sidekiq::BuildCancellation.stubs(:perform_async) } - - it 'cancels the build' do - Travis::Sidekiq::BuildCancellation.expects(:perform_async).with( id: build.id.to_s, user_id: user.id, source: 'api') - post "/builds/#{build.id}/cancel", {}, headers - end - - it 'responds with 204' do - response = post "/builds/#{build.id}/cancel", {}, headers - response.status.should == 204 - end - end - context 'and enqueues cancel event for the Hub' do before { Travis::Features.activate_owner(:enqueue_to_hub, repo.owner) } @@ -173,23 +159,6 @@ describe 'Builds', set_app: true do body.should == {"result"=>true, "flash"=>[{"notice"=>"The build was successfully restarted."}]} end end - - describe 'Restart from the Core' do - before { Travis::Sidekiq::BuildRestart.stubs(:perform_async) } - - it 'restarts the build' do - Travis::Sidekiq::BuildRestart.expects(:perform_async).with(id: build.id.to_s, user_id: user.id) - response = post "/builds/#{build.id}/restart", {}, headers - response.status.should == 202 - end - - it 'sends the correct response body' do - Travis::Sidekiq::BuildRestart.expects(:perform_async).with(id: build.id.to_s, user_id: user.id) - response = post "/builds/#{build.id}/restart", {}, headers - body = JSON.parse(response.body) - body.should == {"result"=>true, "flash"=>[{"notice"=>"The build was successfully restarted."}]} - end - end end end end diff --git a/spec/integration/v2/jobs_spec.rb b/spec/integration/v2/jobs_spec.rb index f618088e..1f5eecd6 100644 --- a/spec/integration/v2/jobs_spec.rb +++ b/spec/integration/v2/jobs_spec.rb @@ -262,16 +262,6 @@ describe 'Jobs', set_app: true do job.update_attribute(:state, 'created') end - it 'cancels the job' do - Travis::Sidekiq::JobCancellation.expects(:perform_async).with( id: job.id.to_s, user_id: user.id, source: 'api') - post "/jobs/#{job.id}/cancel", {}, headers - end - - it 'responds with 204' do - response = post "/jobs/#{job.id}/cancel", {}, headers - response.status.should == 204 - end - context 'and enqueues cancel event for the Hub' do before { Travis::Features.activate_owner(:enqueue_to_hub, job.repository.owner) } @@ -319,22 +309,6 @@ describe 'Jobs', set_app: true do context 'when job passed' do before { job.update_attribute(:state, 'passed') } - context 'Restart from travis-core' do - before { Travis::Sidekiq::JobCancellation.stubs(:perform_async) } - - it 'restarts the job' do - Travis::Sidekiq::JobRestart.expects(:perform_async).with(id: job.id.to_s, user_id: user.id) - response = post "/jobs/#{job.id}/restart", {}, headers - response.status.should == 202 - end - it 'sends the correct response body' do - Travis::Sidekiq::JobRestart.expects(:perform_async).with(id: job.id.to_s, user_id: user.id) - response = post "/jobs/#{job.id}/restart", {}, headers - body = JSON.parse(response.body) - body.should == {"result"=>true, "flash"=>[{"notice"=>"The job was successfully restarted."}]} - end - end - context 'Enqueues restart event for the Hub' do before { Travis::Features.activate_owner(:enqueue_to_hub, job.repository.owner) } diff --git a/spec/integration/v2/requests_spec.rb b/spec/integration/v2/requests_spec.rb index a51e45e6..de40b043 100644 --- a/spec/integration/v2/requests_spec.rb +++ b/spec/integration/v2/requests_spec.rb @@ -28,23 +28,9 @@ describe 'Requests', set_app: true do end describe 'POST /requests' do - it 'triggers a build request using Core code' do + it 'triggers a build request using Hub' do response = post "/requests", { build_id: build.id }, headers - response.status.should be(200) - end - - describe 'enqueues for Hub' do - it 'triggers a build request' do - payload = { build_id: build.id, user_id: repo.owner.id } - response = post "/requests", payload, headers - response.status.should be(200) - end - - it 'triggers a job request' do - payload = { job_id: build.matrix.first.id, user_id: repo.owner.id } - response = post "/requests", payload, headers - response.status.should be(200) - end + response.status.should be(202) end end end diff --git a/spec_core/github/oauth_spec.rb b/spec/lib/github/oauth_spec.rb similarity index 100% rename from spec_core/github/oauth_spec.rb rename to spec/lib/github/oauth_spec.rb diff --git a/spec_core/model/annotation_provider_spec.rb b/spec/lib/model/annotation_provider_spec.rb similarity index 100% rename from spec_core/model/annotation_provider_spec.rb rename to spec/lib/model/annotation_provider_spec.rb diff --git a/spec_core/model/annotation_spec.rb b/spec/lib/model/annotation_spec.rb similarity index 100% rename from spec_core/model/annotation_spec.rb rename to spec/lib/model/annotation_spec.rb diff --git a/spec_core/model/broadcast_spec.rb b/spec/lib/model/broadcast_spec.rb similarity index 100% rename from spec_core/model/broadcast_spec.rb rename to spec/lib/model/broadcast_spec.rb diff --git a/spec_core/model/build/config/dist_spec.rb b/spec/lib/model/build/config/dist_spec.rb similarity index 100% rename from spec_core/model/build/config/dist_spec.rb rename to spec/lib/model/build/config/dist_spec.rb diff --git a/spec_core/model/build/config/group_spec.rb b/spec/lib/model/build/config/group_spec.rb similarity index 100% rename from spec_core/model/build/config/group_spec.rb rename to spec/lib/model/build/config/group_spec.rb diff --git a/spec_core/model/build/config/matrix_spec.rb b/spec/lib/model/build/config/matrix_spec.rb similarity index 100% rename from spec_core/model/build/config/matrix_spec.rb rename to spec/lib/model/build/config/matrix_spec.rb diff --git a/spec_core/model/build/config/obfuscate_spec.rb b/spec/lib/model/build/config/obfuscate_spec.rb similarity index 100% rename from spec_core/model/build/config/obfuscate_spec.rb rename to spec/lib/model/build/config/obfuscate_spec.rb diff --git a/spec_core/model/build/config_spec.rb b/spec/lib/model/build/config_spec.rb similarity index 100% rename from spec_core/model/build/config_spec.rb rename to spec/lib/model/build/config_spec.rb diff --git a/spec_core/model/build/denormalize_spec.rb b/spec/lib/model/build/denormalize_spec.rb similarity index 100% rename from spec_core/model/build/denormalize_spec.rb rename to spec/lib/model/build/denormalize_spec.rb diff --git a/spec_core/model/build/matrix_spec.rb b/spec/lib/model/build/matrix_spec.rb similarity index 100% rename from spec_core/model/build/matrix_spec.rb rename to spec/lib/model/build/matrix_spec.rb diff --git a/spec_core/model/build/metrics_spec.rb b/spec/lib/model/build/metrics_spec.rb similarity index 100% rename from spec_core/model/build/metrics_spec.rb rename to spec/lib/model/build/metrics_spec.rb diff --git a/spec_core/model/build/result_message_spec.rb b/spec/lib/model/build/result_message_spec.rb similarity index 100% rename from spec_core/model/build/result_message_spec.rb rename to spec/lib/model/build/result_message_spec.rb diff --git a/spec_core/model/build/states_spec.rb b/spec/lib/model/build/states_spec.rb similarity index 76% rename from spec_core/model/build/states_spec.rb rename to spec/lib/model/build/states_spec.rb index e394d913..cc17e674 100644 --- a/spec_core/model/build/states_spec.rb +++ b/spec/lib/model/build/states_spec.rb @@ -57,44 +57,24 @@ describe Build::States do build.receive(data) build.state.should == :received end - - it 'notifies observers' do - Travis::Event.expects(:dispatch).with('build:received', build, data) - build.receive(data) - end end describe 'when the build is already received' do before :each do build.state = :received end - - it 'does not notify observers' do - Travis::Event.expects(:dispatch).never - build.receive(data) - end end describe 'when the build has failed' do before :each do build.state = :failed end - - it 'does not notify observers' do - Travis::Event.expects(:dispatch).never - build.receive(data) - end end describe 'when the build has errored' do before :each do build.state = :errored end - - it 'does not notify observers' do - Travis::Event.expects(:dispatch).never - build.receive(data) - end end end @@ -111,11 +91,6 @@ describe Build::States do build.expects(:denormalize) build.start(data) end - - it 'notifies observers' do - Travis::Event.expects(:dispatch).with('build:started', build, data) - build.start(data) - end end describe 'when the build is already started' do @@ -127,11 +102,6 @@ describe Build::States do build.expects(:denormalize).never build.start(data) end - - it 'does not notify observers' do - Travis::Event.expects(:dispatch).never - build.start(data) - end end describe 'when the build has failed' do @@ -143,11 +113,6 @@ describe Build::States do build.expects(:denormalize).never build.start(data) end - - it 'does not notify observers' do - Travis::Event.expects(:dispatch).never - build.start(data) - end end describe 'when the build has errored' do @@ -159,11 +124,6 @@ describe Build::States do build.expects(:denormalize).never build.start(data) end - - it 'does not notify observers' do - Travis::Event.expects(:dispatch).never - build.start(data) - end end end @@ -184,11 +144,6 @@ describe Build::States do build.expects(:denormalize).never build.finish(data) end - - it 'does not notify observers' do - Travis::Event.expects(:dispatch).never - build.finish(data) - end end end @@ -217,11 +172,6 @@ describe Build::States do build.expects(:denormalize).with(:finish, data) build.finish(data) end - - it 'notifies observers' do - Travis::Event.expects(:dispatch).with('build:finished', build, data) - build.finish(data) - end end describe 'when the build has already finished' do @@ -233,11 +183,6 @@ describe Build::States do build.expects(:denormalize).never build.finish(data) end - - it 'does not notify observers' do - Travis::Event.expects(:dispatch).never - build.finish(data) - end end end end diff --git a/spec_core/model/build/update_branch_spec.rb b/spec/lib/model/build/update_branch_spec.rb similarity index 100% rename from spec_core/model/build/update_branch_spec.rb rename to spec/lib/model/build/update_branch_spec.rb diff --git a/spec_core/model/build_spec.rb b/spec/lib/model/build_spec.rb similarity index 98% rename from spec_core/model/build_spec.rb rename to spec/lib/model/build_spec.rb index c9002034..78edaad8 100644 --- a/spec_core/model/build_spec.rb +++ b/spec/lib/model/build_spec.rb @@ -325,11 +325,6 @@ describe Build do build.matrix.each { |job| job.expects(:reset).never } build.reset end - - it 'notifies obsevers' do - Travis::Event.expects(:dispatch).with('build:created', build) - build.reset - end end end end diff --git a/spec_core/model/commit_spec.rb b/spec/lib/model/commit_spec.rb similarity index 100% rename from spec_core/model/commit_spec.rb rename to spec/lib/model/commit_spec.rb diff --git a/spec_core/model/encrypted_column_spec.rb b/spec/lib/model/encrypted_column_spec.rb similarity index 100% rename from spec_core/model/encrypted_column_spec.rb rename to spec/lib/model/encrypted_column_spec.rb diff --git a/spec_core/model/job/cleanup_spec.rb b/spec/lib/model/job/cleanup_spec.rb similarity index 100% rename from spec_core/model/job/cleanup_spec.rb rename to spec/lib/model/job/cleanup_spec.rb diff --git a/spec_core/model/job/queue_spec.rb b/spec/lib/model/job/queue_spec.rb similarity index 100% rename from spec_core/model/job/queue_spec.rb rename to spec/lib/model/job/queue_spec.rb diff --git a/spec_core/model/job/test_spec.rb b/spec/lib/model/job/test_spec.rb similarity index 88% rename from spec_core/model/job/test_spec.rb rename to spec/lib/model/job/test_spec.rb index bd3135f4..345ad20b 100644 --- a/spec_core/model/job/test_spec.rb +++ b/spec/lib/model/job/test_spec.rb @@ -82,11 +82,6 @@ describe Job::Test do job.receive(data) end - it 'notifies observers' do - Travis::Event.expects(:dispatch).with('job:test:received', job, data) - job.receive(data) - end - it 'propagates the event to the source' do job.source.expects(:receive) job.receive(data) @@ -109,11 +104,6 @@ describe Job::Test do job.state.should == :started end - it 'notifies observers' do - Travis::Event.expects(:dispatch).with('job:test:started', job, data) - job.start(data) - end - it 'propagates the event to the source' do job.source.expects(:start) job.start(data) @@ -128,11 +118,6 @@ describe Job::Test do job.state.should == 'passed' end - it 'notifies observers' do - Travis::Event.expects(:dispatch).with('job:test:finished', job, data) - job.finish(data) - end - it 'propagates the event to the source' do job.source.expects(:finish).with(data) job.finish(data) @@ -176,11 +161,6 @@ describe Job::Test do job.reset! job.reload.annotations.should be_empty end - - it 'triggers a :created event' do - job.expects(:notify).with(:reset) - job.reset - end end end end diff --git a/spec_core/model/job_spec.rb b/spec/lib/model/job_spec.rb similarity index 100% rename from spec_core/model/job_spec.rb rename to spec/lib/model/job_spec.rb diff --git a/spec_core/model/organization_spec.rb b/spec/lib/model/organization_spec.rb similarity index 100% rename from spec_core/model/organization_spec.rb rename to spec/lib/model/organization_spec.rb diff --git a/spec_core/model/permission_spec.rb b/spec/lib/model/permission_spec.rb similarity index 100% rename from spec_core/model/permission_spec.rb rename to spec/lib/model/permission_spec.rb diff --git a/spec_core/model/repository/settings/ssh_key_spec.rb b/spec/lib/model/repository/settings/ssh_key_spec.rb similarity index 100% rename from spec_core/model/repository/settings/ssh_key_spec.rb rename to spec/lib/model/repository/settings/ssh_key_spec.rb diff --git a/spec_core/model/repository/settings_spec.rb b/spec/lib/model/repository/settings_spec.rb similarity index 100% rename from spec_core/model/repository/settings_spec.rb rename to spec/lib/model/repository/settings_spec.rb diff --git a/spec_core/model/repository/status_image_spec.rb b/spec/lib/model/repository/status_image_spec.rb similarity index 100% rename from spec_core/model/repository/status_image_spec.rb rename to spec/lib/model/repository/status_image_spec.rb diff --git a/spec_core/model/repository_spec.rb b/spec/lib/model/repository_spec.rb similarity index 100% rename from spec_core/model/repository_spec.rb rename to spec/lib/model/repository_spec.rb diff --git a/spec_core/model/request_spec.rb b/spec/lib/model/request_spec.rb similarity index 100% rename from spec_core/model/request_spec.rb rename to spec/lib/model/request_spec.rb diff --git a/spec_core/model/ssl_key_spec.rb b/spec/lib/model/ssl_key_spec.rb similarity index 100% rename from spec_core/model/ssl_key_spec.rb rename to spec/lib/model/ssl_key_spec.rb diff --git a/spec_core/model/token_spec.rb b/spec/lib/model/token_spec.rb similarity index 100% rename from spec_core/model/token_spec.rb rename to spec/lib/model/token_spec.rb diff --git a/spec_core/model/url_spec.rb b/spec/lib/model/url_spec.rb similarity index 100% rename from spec_core/model/url_spec.rb rename to spec/lib/model/url_spec.rb diff --git a/spec_core/model/user/oauth_spec.rb b/spec/lib/model/user/oauth_spec.rb similarity index 100% rename from spec_core/model/user/oauth_spec.rb rename to spec/lib/model/user/oauth_spec.rb diff --git a/spec_core/model/user_spec.rb b/spec/lib/model/user_spec.rb similarity index 100% rename from spec_core/model/user_spec.rb rename to spec/lib/model/user_spec.rb diff --git a/spec_core/services/find_admin_spec.rb b/spec/lib/services/find_admin_spec.rb similarity index 100% rename from spec_core/services/find_admin_spec.rb rename to spec/lib/services/find_admin_spec.rb diff --git a/spec_core/services/find_annotation_spec.rb b/spec/lib/services/find_annotation_spec.rb similarity index 100% rename from spec_core/services/find_annotation_spec.rb rename to spec/lib/services/find_annotation_spec.rb diff --git a/spec_core/services/find_branch_spec.rb b/spec/lib/services/find_branch_spec.rb similarity index 100% rename from spec_core/services/find_branch_spec.rb rename to spec/lib/services/find_branch_spec.rb diff --git a/spec_core/services/find_branches_spec.rb b/spec/lib/services/find_branches_spec.rb similarity index 100% rename from spec_core/services/find_branches_spec.rb rename to spec/lib/services/find_branches_spec.rb diff --git a/spec_core/services/find_build_spec.rb b/spec/lib/services/find_build_spec.rb similarity index 100% rename from spec_core/services/find_build_spec.rb rename to spec/lib/services/find_build_spec.rb diff --git a/spec_core/services/find_builds_spec.rb b/spec/lib/services/find_builds_spec.rb similarity index 100% rename from spec_core/services/find_builds_spec.rb rename to spec/lib/services/find_builds_spec.rb diff --git a/spec_core/services/find_caches_spec.rb b/spec/lib/services/find_caches_spec.rb similarity index 100% rename from spec_core/services/find_caches_spec.rb rename to spec/lib/services/find_caches_spec.rb diff --git a/spec_core/services/find_hooks_spec.rb b/spec/lib/services/find_hooks_spec.rb similarity index 100% rename from spec_core/services/find_hooks_spec.rb rename to spec/lib/services/find_hooks_spec.rb diff --git a/spec_core/services/find_job_spec.rb b/spec/lib/services/find_job_spec.rb similarity index 100% rename from spec_core/services/find_job_spec.rb rename to spec/lib/services/find_job_spec.rb diff --git a/spec_core/services/find_jobs_spec.rb b/spec/lib/services/find_jobs_spec.rb similarity index 100% rename from spec_core/services/find_jobs_spec.rb rename to spec/lib/services/find_jobs_spec.rb diff --git a/spec_core/services/find_log_spec.rb b/spec/lib/services/find_log_spec.rb similarity index 100% rename from spec_core/services/find_log_spec.rb rename to spec/lib/services/find_log_spec.rb diff --git a/spec_core/services/find_repo_key_spec.rb b/spec/lib/services/find_repo_key_spec.rb similarity index 100% rename from spec_core/services/find_repo_key_spec.rb rename to spec/lib/services/find_repo_key_spec.rb diff --git a/spec_core/services/find_repo_settings_spec.rb b/spec/lib/services/find_repo_settings_spec.rb similarity index 100% rename from spec_core/services/find_repo_settings_spec.rb rename to spec/lib/services/find_repo_settings_spec.rb diff --git a/spec_core/services/find_repo_spec.rb b/spec/lib/services/find_repo_spec.rb similarity index 100% rename from spec_core/services/find_repo_spec.rb rename to spec/lib/services/find_repo_spec.rb diff --git a/spec_core/services/find_repos_spec.rb b/spec/lib/services/find_repos_spec.rb similarity index 100% rename from spec_core/services/find_repos_spec.rb rename to spec/lib/services/find_repos_spec.rb diff --git a/spec_core/services/find_request_spec.rb b/spec/lib/services/find_request_spec.rb similarity index 100% rename from spec_core/services/find_request_spec.rb rename to spec/lib/services/find_request_spec.rb diff --git a/spec_core/services/find_requests_spec.rb b/spec/lib/services/find_requests_spec.rb similarity index 100% rename from spec_core/services/find_requests_spec.rb rename to spec/lib/services/find_requests_spec.rb diff --git a/spec_core/services/find_user_accounts_spec.rb b/spec/lib/services/find_user_accounts_spec.rb similarity index 100% rename from spec_core/services/find_user_accounts_spec.rb rename to spec/lib/services/find_user_accounts_spec.rb diff --git a/spec_core/services/next_build_number_spec.rb b/spec/lib/services/next_build_number_spec.rb similarity index 100% rename from spec_core/services/next_build_number_spec.rb rename to spec/lib/services/next_build_number_spec.rb diff --git a/spec_core/services/regenerate_repo_key_spec.rb b/spec/lib/services/regenerate_repo_key_spec.rb similarity index 100% rename from spec_core/services/regenerate_repo_key_spec.rb rename to spec/lib/services/regenerate_repo_key_spec.rb diff --git a/spec_core/services/remove_log_spec.rb b/spec/lib/services/remove_log_spec.rb similarity index 100% rename from spec_core/services/remove_log_spec.rb rename to spec/lib/services/remove_log_spec.rb diff --git a/spec_core/services/sync_user_spec.rb b/spec/lib/services/sync_user_spec.rb similarity index 100% rename from spec_core/services/sync_user_spec.rb rename to spec/lib/services/sync_user_spec.rb diff --git a/spec_core/services/update_annotation_spec.rb b/spec/lib/services/update_annotation_spec.rb similarity index 100% rename from spec_core/services/update_annotation_spec.rb rename to spec/lib/services/update_annotation_spec.rb diff --git a/spec_core/services/update_hook_spec.rb b/spec/lib/services/update_hook_spec.rb similarity index 100% rename from spec_core/services/update_hook_spec.rb rename to spec/lib/services/update_hook_spec.rb diff --git a/spec_core/services/update_job_spec.rb b/spec/lib/services/update_job_spec.rb similarity index 100% rename from spec_core/services/update_job_spec.rb rename to spec/lib/services/update_job_spec.rb diff --git a/spec_core/services/update_log_spec.rb b/spec/lib/services/update_log_spec.rb similarity index 100% rename from spec_core/services/update_log_spec.rb rename to spec/lib/services/update_log_spec.rb diff --git a/spec_core/services/update_user_spec.rb b/spec/lib/services/update_user_spec.rb similarity index 100% rename from spec_core/services/update_user_spec.rb rename to spec/lib/services/update_user_spec.rb diff --git a/spec_core/services_spec.rb b/spec/lib/services_spec.rb similarity index 100% rename from spec_core/services_spec.rb rename to spec/lib/services_spec.rb diff --git a/spec/v3/services/build/cancel_spec.rb b/spec/v3/services/build/cancel_spec.rb index b6304547..c39b677d 100644 --- a/spec/v3/services/build/cancel_spec.rb +++ b/spec/v3/services/build/cancel_spec.rb @@ -1,8 +1,7 @@ describe Travis::API::V3::Services::Build::Cancel, set_app: true do let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first } let(:build) { repo.builds.first } - let(:sidekiq_payload) { JSON.load(Sidekiq::Client.last['args'].last.to_json) } - let(:sidekiq_params) { Sidekiq::Client.last['args'].last.deep_symbolize_keys } + let(:payload) { { 'id'=> "#{build.id}", 'user_id' => 1, 'source' => 'api' } } before do Travis::Features.stubs(:owner_active?).returns(true) @@ -131,101 +130,6 @@ describe Travis::API::V3::Services::Build::Cancel, set_app: true do end end - describe "existing repository, push access, cancelable" do - let(:params) {{}} - let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) } - let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}" }} - before { Travis::API::V3::Models::Permission.create(repository: repo, user: repo.owner, push: true) } - - describe "started state" do - before { build.update_attribute(:state, "started") } - before { post("/v3/build/#{build.id}/cancel", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "build", - "@href", - "@representation", - "minimal", - "cancel", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{build.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'build_cancellations' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::BuildCancellation' } - end - - describe "queued state" do - before { build.update_attribute(:state, "queued") } - before { post("/v3/build/#{build.id}/cancel", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "build", - "@href", - "@representation", - "minimal", - "cancel", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{build.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'build_cancellations' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::BuildCancellation' } - end - - describe "received state" do - before { build.update_attribute(:state, "received") } - before { post("/v3/build/#{build.id}/cancel", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "build", - "@href", - "@representation", - "minimal", - "cancel", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{build.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'build_cancellations' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::BuildCancellation' } - end - - describe "setting id has no effect" do - let(:params) {{ id: 42 }} - before { post("/v3/build/#{build.id}/cancel", params, headers) } - example { expect(sidekiq_payload).to be == { - "id" => "#{build.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - end - end - describe "existing repository, push & pull access, cancelable, enqueues message for Hub" do let(:params) {{}} let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) } @@ -251,7 +155,7 @@ describe Travis::API::V3::Services::Build::Cancel, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{build.id}", "user_id"=> repo.owner_id, "source" => "api"} @@ -277,7 +181,7 @@ describe Travis::API::V3::Services::Build::Cancel, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{build.id}", "user_id"=> repo.owner_id, "source" => "api"} @@ -303,7 +207,7 @@ describe Travis::API::V3::Services::Build::Cancel, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{build.id}", "user_id"=> repo.owner_id, "source" => "api"} @@ -316,7 +220,7 @@ describe Travis::API::V3::Services::Build::Cancel, set_app: true do describe "setting id has no effect" do let(:params) {{ id: 42 }} before { post("/v3/build/#{build.id}/cancel", params, headers) } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{build.id}", "user_id"=> repo.owner_id, "source" => "api"} @@ -353,7 +257,7 @@ describe Travis::API::V3::Services::Build::Cancel, set_app: true do # describe 'setting user' do # let(:params) {{ user: { id: repo.owner.id } }} # example { expect(last_response.status).to be == 202 } - # example { expect(sidekiq_payload).to be == { + # example { expect(payload).to be == { # # repository: { id: repo.id, owner_name: 'svenfuchs', name: 'minimal' }, # # user: { id: repo.owner.id }, # # message: nil, diff --git a/spec/v3/services/build/restart_spec.rb b/spec/v3/services/build/restart_spec.rb index 78d6d5b6..e38b17c1 100644 --- a/spec/v3/services/build/restart_spec.rb +++ b/spec/v3/services/build/restart_spec.rb @@ -1,8 +1,7 @@ describe Travis::API::V3::Services::Build::Restart, set_app: true do let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first } let(:build) { repo.builds.first } - let(:sidekiq_payload) { JSON.load(Sidekiq::Client.last['args'].last.to_json) } - let(:sidekiq_params) { Sidekiq::Client.last['args'].last.deep_symbolize_keys } + let(:payload) { { 'id'=> "#{build.id}", 'user_id' => 1 } } before do Travis::Features.stubs(:owner_active?).returns(true) @@ -119,131 +118,6 @@ describe Travis::API::V3::Services::Build::Restart, set_app: true do end end - describe "existing repository, push access, build not already running" do - let(:params) {{}} - let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) } - let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}" }} - before { Travis::API::V3::Models::Permission.create(repository: repo, user: repo.owner, push: true) } - - describe "errored state" do - before { build.update_attribute(:state, "errored") } - before { post("/v3/build/#{build.id}/restart", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "build", - "@href", - "@representation", - "minimal", - "restart", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{build.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'build_restarts' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::BuildRestart' } - end - - describe "passed state" do - before { build.update_attribute(:state, "passed") } - before { post("/v3/build/#{build.id}/restart", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "build", - "@href", - "@representation", - "minimal", - "restart", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{build.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'build_restarts' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::BuildRestart' } - end - - describe "failed state" do - before { build.update_attribute(:state, "failed") } - before { post("/v3/build/#{build.id}/restart", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "build", - "@href", - "@representation", - "minimal", - "restart", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{build.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'build_restarts' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::BuildRestart' } - end - - describe "canceled state" do - before { build.update_attribute(:state, "canceled") } - before { post("/v3/build/#{build.id}/restart", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "build", - "@href", - "@representation", - "minimal", - "restart", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{build.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'build_restarts' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::BuildRestart' } - end - - describe "setting id has no effect" do - before { post("/v3/build/#{build.id}/restart", params, headers) } - let(:params) {{ id: 42 }} - example { expect(sidekiq_payload).to be == { - "id" => "#{build.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - end - end - describe "existing repository, push access, build not already running, enqueues message for Hub" do let(:params) {{}} let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) } @@ -272,7 +146,7 @@ describe Travis::API::V3::Services::Build::Restart, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{build.id}", "user_id"=> repo.owner_id} } @@ -298,7 +172,7 @@ describe Travis::API::V3::Services::Build::Restart, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{build.id}", "user_id"=> repo.owner_id} } @@ -324,7 +198,7 @@ describe Travis::API::V3::Services::Build::Restart, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{build.id}", "user_id"=> repo.owner_id} } @@ -350,7 +224,7 @@ describe Travis::API::V3::Services::Build::Restart, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{build.id}", "user_id"=> repo.owner_id} } @@ -364,7 +238,7 @@ describe Travis::API::V3::Services::Build::Restart, set_app: true do before { post("/v3/build/#{build.id}/restart", params, headers) } let(:params) {{ id: 42 }} - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{build.id}", "user_id"=> repo.owner_id} } @@ -397,7 +271,7 @@ describe Travis::API::V3::Services::Build::Restart, set_app: true do # describe 'setting user' do # let(:params) {{ user: { id: repo.owner.id } }} # example { expect(last_response.status).to be == 202 } - # example { expect(sidekiq_payload).to be == { + # example { expect(payload).to be == { # # repository: { id: repo.id, owner_name: 'svenfuchs', name: 'minimal' }, # # user: { id: repo.owner.id }, # # message: nil, diff --git a/spec/v3/services/job/cancel_spec.rb b/spec/v3/services/job/cancel_spec.rb index f55a9a7d..a519d09b 100644 --- a/spec/v3/services/job/cancel_spec.rb +++ b/spec/v3/services/job/cancel_spec.rb @@ -2,8 +2,7 @@ describe Travis::API::V3::Services::Job::Cancel, set_app: true do let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first } let(:build) { repo.builds.first } let(:job) { build.jobs.first} - let(:sidekiq_payload) { JSON.load(Sidekiq::Client.last['args'].last.to_json) } - let(:sidekiq_params) { Sidekiq::Client.last['args'].last.deep_symbolize_keys } + let(:payload) { { 'id'=> "#{job.id}", 'user_id' => 1, 'source' => 'api' } } before do Travis::Features.stubs(:owner_active?).returns(true) @@ -77,103 +76,6 @@ describe Travis::API::V3::Services::Job::Cancel, set_app: true do }} end - describe "existing repository, push access, job cancelable" do - let(:params) {{}} - let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) } - let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}" }} - before { Travis::API::V3::Models::Permission.create(repository: repo, user: repo.owner, push: true) } - - describe "started state" do - before { job.update_attribute(:state, "started") } - before { post("/v3/job/#{job.id}/cancel", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "job", - "@href", - "@representation", - "minimal", - "cancel", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{job.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'job_cancellations' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::JobCancellation' } - end - describe "queued state" do - before { job.update_attribute(:state, "queued") } - before { post("/v3/job/#{job.id}/cancel", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "job", - "@href", - "@representation", - "minimal", - "cancel", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{job.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'job_cancellations' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::JobCancellation' } - end - - describe "received state" do - before { job.update_attribute(:state, "received") } - before { post("/v3/job/#{job.id}/cancel", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "job", - "@href", - "@representation", - "minimal", - "cancel", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{job.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'job_cancellations' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::JobCancellation' } - end - - describe "setting id has no effect" do - before { post("/v3/job/#{job.id}/cancel", params, headers) } - let(:params) {{ id: 42 }} - example { expect(sidekiq_payload).to be == { - "id" => "#{job.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - end - end - describe "existing repository, push access, job cancelable, enqueues message for Hub" do let(:params) {{}} let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) } @@ -200,7 +102,7 @@ describe Travis::API::V3::Services::Job::Cancel, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{job.id}", "user_id"=> repo.owner_id, "source" => "api"} @@ -226,7 +128,7 @@ describe Travis::API::V3::Services::Job::Cancel, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{job.id}", "user_id"=> repo.owner_id, "source" => "api"} @@ -253,7 +155,7 @@ describe Travis::API::V3::Services::Job::Cancel, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{job.id}", "user_id"=> repo.owner_id, "source" => "api"} @@ -266,7 +168,7 @@ describe Travis::API::V3::Services::Job::Cancel, set_app: true do describe "setting id has no effect" do before { post("/v3/job/#{job.id}/cancel", params, headers) } let(:params) {{ id: 42 }} - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{job.id}", "user_id"=> repo.owner_id, "source" => "api"} @@ -355,7 +257,7 @@ describe Travis::API::V3::Services::Job::Cancel, set_app: true do # describe 'setting user' do # let(:params) {{ user: { id: repo.owner.id } }} # example { expect(last_response.status).to be == 202 } - # example { expect(sidekiq_payload).to be == { + # example { expect(payload).to be == { # # repository: { id: repo.id, owner_name: 'svenfuchs', name: 'minimal' }, # # user: { id: repo.owner.id }, # # message: nil, diff --git a/spec/v3/services/job/restart_spec.rb b/spec/v3/services/job/restart_spec.rb index 3ea85898..3a677ce8 100644 --- a/spec/v3/services/job/restart_spec.rb +++ b/spec/v3/services/job/restart_spec.rb @@ -2,8 +2,7 @@ describe Travis::API::V3::Services::Job::Restart, set_app: true do let(:repo) { Travis::API::V3::Models::Repository.where(owner_name: 'svenfuchs', name: 'minimal').first } let(:build) { repo.builds.first } let(:job) { build.jobs.first } - let(:sidekiq_payload) { JSON.load(Sidekiq::Client.last['args'].last.to_json) } - let(:sidekiq_params) { Sidekiq::Client.last['args'].last.deep_symbolize_keys } + let(:payload) { { 'id'=> "#{job.id}", 'user_id' => 1 } } before do Travis::Features.stubs(:owner_active?).returns(true) @@ -77,128 +76,6 @@ describe Travis::API::V3::Services::Job::Restart, set_app: true do }} end - describe "existing repository, push access, job not already running" do - let(:params) {{}} - let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) } - let(:headers) {{ 'HTTP_AUTHORIZATION' => "token #{token}" }} - before { Travis::API::V3::Models::Permission.create(repository: repo, user: repo.owner, push: true) } - - describe "canceled state" do - before { job.update_attribute(:state, "canceled") } - before { post("/v3/job/#{job.id}/restart", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "job", - "@href", - "@representation", - "minimal", - "restart", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{job.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'job_restarts' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::JobRestart' } - end - describe "errored state" do - before { job.update_attribute(:state, "errored") } - before { post("/v3/job/#{job.id}/restart", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "job", - "@href", - "@representation", - "minimal", - "restart", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{job.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'job_restarts' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::JobRestart' } - end - describe "failed state" do - before { job.update_attribute(:state, "failed") } - before { post("/v3/job/#{job.id}/restart", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "job", - "@href", - "@representation", - "minimal", - "restart", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{job.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'job_restarts' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::JobRestart' } - end - describe "passed state" do - before { job.update_attribute(:state, "passed") } - before { post("/v3/job/#{job.id}/restart", params, headers) } - - example { expect(last_response.status).to be == 202 } - example { expect(JSON.load(body).to_s).to include( - "@type", - "pending", - "job", - "@href", - "@representation", - "minimal", - "restart", - "id", - "state_change") - } - - example { expect(sidekiq_payload).to be == { - "id" => "#{job.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - - example { expect(Sidekiq::Client.last['queue']).to be == 'job_restarts' } - example { expect(Sidekiq::Client.last['class']).to be == 'Travis::Sidekiq::JobRestart' } - end - - describe "setting id has no effect" do - before { post("/v3/job/#{job.id}/restart", params, headers) } - let(:params) {{ id: 42 }} - example { expect(sidekiq_payload).to be == { - "id" => "#{job.id}", - "user_id"=> repo.owner_id, - "source" => "api"} - } - end - end - describe "existing repository, push access, job not already running, enqueues message for Hub" do let(:params) {{}} let(:token) { Travis::Api::App::AccessToken.create(user: repo.owner, app_id: 1) } @@ -225,7 +102,7 @@ describe Travis::API::V3::Services::Job::Restart, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{job.id}", "user_id"=> repo.owner_id} } @@ -250,7 +127,7 @@ describe Travis::API::V3::Services::Job::Restart, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{job.id}", "user_id"=> repo.owner_id} } @@ -275,7 +152,7 @@ describe Travis::API::V3::Services::Job::Restart, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{job.id}", "user_id"=> repo.owner_id} } @@ -300,7 +177,7 @@ describe Travis::API::V3::Services::Job::Restart, set_app: true do "state_change") } - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{job.id}", "user_id"=> repo.owner_id} } @@ -316,7 +193,7 @@ describe Travis::API::V3::Services::Job::Restart, set_app: true do end let(:params) {{ id: 42 }} - example { expect(sidekiq_payload).to be == { + example { expect(payload).to be == { "id" => "#{job.id}", "user_id"=> repo.owner_id} } @@ -392,7 +269,7 @@ describe Travis::API::V3::Services::Job::Restart, set_app: true do # describe 'setting user' do # let(:params) {{ user: { id: repo.owner.id } }} # example { expect(last_response.status).to be == 202 } - # example { expect(sidekiq_payload).to be == { + # example { expect(payload).to be == { # # repository: { id: repo.id, owner_name: 'svenfuchs', name: 'minimal' }, # # user: { id: repo.owner.id }, # # message: nil, diff --git a/spec_core/services/cancel_build_spec.rb b/spec_core/services/cancel_build_spec.rb deleted file mode 100644 index 78cb940b..00000000 --- a/spec_core/services/cancel_build_spec.rb +++ /dev/null @@ -1,50 +0,0 @@ -describe Travis::Services::CancelBuild do - let(:repo) { Factory(:repository) } - let!(:job) { Factory(:test, repository: repo, state: :created) } - let!(:passed_job) { Factory(:test, repository: repo, state: :passed) } - let(:build) { Factory(:build, repository: repo) } - let(:params) { { id: build.id, source: 'tests' } } - let(:user) { Factory(:user) } - let(:service) { described_class.new(user, params) } - - before do - build.matrix.destroy_all - build.matrix << passed_job - build.matrix << job - end - - describe 'run' do - it 'should cancel the build if it\'s cancelable' do - job.stubs(:cancelable?).returns(true) - service.stubs(:authorized?).returns(true) - - publisher = mock('publisher') - service.stubs(:publisher).returns(publisher) - publisher.expects(:publish).with(type: 'cancel_job', job_id: job.id, source: 'tests') - publisher.expects(:publish).with(type: 'cancel_job', job_id: passed_job.id, source: 'tests') - - expect { - expect { - service.run - }.to change { build.reload.state } - }.to change { job.reload.state } - - job.state.should == 'canceled' - build.state.should == 'canceled' - end - - it 'should not cancel the job if it\'s not cancelable' do - job.stubs(:cancelable?).returns(false) - - expect { - service.run - }.to_not change { build.reload.state } - end - - it 'should not be able to cancel job if user does not have any permissions' do - user.permissions.destroy_all - - service.can_cancel?.should be false - end - end -end diff --git a/spec_core/services/cancel_job_spec.rb b/spec_core/services/cancel_job_spec.rb deleted file mode 100644 index 75a7eb31..00000000 --- a/spec_core/services/cancel_job_spec.rb +++ /dev/null @@ -1,40 +0,0 @@ -describe Travis::Services::CancelJob do - let(:repo) { Factory(:repository) } - let!(:job) { Factory(:test, repository: repo, state: :created) } - let(:params) { { id: job.id, source: 'tests' } } - let(:user) { Factory(:user) } - let(:service) { described_class.new(user, params) } - - describe 'run' do - it 'should cancel the job if it\'s cancelable' do - job.stubs(:cancelable?).returns(true) - service.stubs(:authorized?).returns(true) - - publisher = mock('publisher') - service.stubs(:publisher).returns(publisher) - publisher.expects(:publish).with(type: 'cancel_job', job_id: job.id, source: 'tests') - - expect { - service.run - }.to change { job.reload.state } - - job.state.should == 'canceled' - end - - it 'should not cancel the job if it\'s not cancelable' do - job.state.should == :created - job.stubs(:cancelable?).returns(false) - - expect { - service.run - }.to_not change { job.state } - end - - it 'should not be able to cancel job if user does not have pull permission' do - user.permissions.destroy_all - - service.can_cancel?.should be false - end - end -end - diff --git a/spec_core/services/reset_model_spec.rb b/spec_core/services/reset_model_spec.rb deleted file mode 100644 index 02cb33ce..00000000 --- a/spec_core/services/reset_model_spec.rb +++ /dev/null @@ -1,92 +0,0 @@ -describe Travis::Services::ResetModel do - let(:user) { User.first || Factory(:user) } - - before :each do - Travis.config.roles = {} - end - - describe 'given a job_id' do - let(:service) { described_class.new(user, job_id: job.id, token: 'token') } - let(:job) { Factory(:test, state: :passed) } - - before :each do - service.stubs(:service).with(:find_job, id: job.id).returns(stub(run: job)) - end - - it 'resets the job' do - user.permissions.create!(repository_id: job.repository_id, pull: true) - job.expects(:reset!) - service.run - end - - it 'has message: all cool' do - user.permissions.create!(repository_id: job.repository_id, pull: true) - service.run - service.messages.should == [{ notice: 'The job was successfully restarted.' }] - end - - it 'has message: missing permissions and can not be enqueued' do - job.stubs(:resetable?).returns(false) - service.run - service.messages.should == [ - { error: 'You do not seem to have sufficient permissions.' }, - { error: 'This job currently can not be restarted.' } - ] - end - end - - describe 'given a build_id' do - let(:service) { described_class.new(user, build_id: build.id, token: 'token') } - let(:build) { Factory(:build, state: 'passed') } - - before :each do - service.stubs(:service).with(:find_build, id: build.id).returns(stub(run: build)) - end - - it 'resets the build (given no roles configuration and the user has permissions)' do - user.permissions.create!(repository_id: build.repository_id, pull: true) - build.expects(:reset!) - service.run - end - - it 'resets the build (given roles configuration and the user has permissions)' do - Travis.config.roles.reset_model = 'push' - user.permissions.create!(repository_id: build.repository_id, push: true) - build.expects(:reset!) - service.run - end - - it 'does not reset the build (given no roles configuration and the user does not have permissions)' do - build.expects(:reset!).never - service.run - end - - it 'does not reset the build (given roles configuration and the user does not have permissions)' do - Travis.config.roles.reset_model = 'push' - build.expects(:reset!).never - service.run - end - - describe 'Instrument' do - let(:publisher) { Travis::Notification::Publisher::Memory.new } - let(:event) { publisher.events.last } - - before :each do - Travis::Notification.publishers.replace([publisher]) - end - - it 'publishes a event' do - service.run - event.should publish_instrumentation_event( - event: 'travis.services.reset_model.run:completed', - message: "Travis::Services::ResetModel#run:completed build_id=#{build.id} not accepted", - data: { - type: :build, - id: build.id, - accept?: false - } - ) - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons.rb b/vendor/travis-core/lib/travis/addons.rb deleted file mode 100644 index 240c66cc..00000000 --- a/vendor/travis-core/lib/travis/addons.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'travis/notification' - -module Travis - module Addons - require 'travis/addons/archive' - require 'travis/addons/campfire' - require 'travis/addons/email' - require 'travis/addons/flowdock' - require 'travis/addons/github_status' - require 'travis/addons/hipchat' - require 'travis/addons/irc' - require 'travis/addons/pusher' - require 'travis/addons/states_cache' - require 'travis/addons/sqwiggle' - require 'travis/addons/webhook' - require 'travis/addons/slack' - require 'travis/addons/pushover' - - class << self - def register - constants(false).each do |name| - key = name.to_s.underscore - const = const_get(name) - handler = const.const_get(:EventHandler) rescue nil - Travis::Event::Subscription.register(key, handler) if handler - const.setup if const.respond_to?(:setup) - end - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/README.markdown b/vendor/travis-core/lib/travis/addons/README.markdown deleted file mode 100644 index 936031d5..00000000 --- a/vendor/travis-core/lib/travis/addons/README.markdown +++ /dev/null @@ -1,17 +0,0 @@ -# Travis Core Addons - -The Addons are event handlers that accepts events such as "build finished" and forwards them to different services. The different services are: - -- Campfire -- E-mail -- Flowdock -- GitHub Commit Statuses -- Hipchat -- IRC -- Pusher: Used to update our Web UI automatically. -- Sqwiggle -- States cache: Caches the state of each branch in Memcached for status images. -- Webhook -- Pushover - -To add a new notification service, an event handler and a task is needed. The event handler is run by [`travis-hub`](https://github.com/travis-ci/travis-hub) and has access to the database. This should check whether the event should be forwarded at all, and pull out any necessary configuration values. It should then asynchronously run the corresponding Task. The Task is run by [`travis-tasks`](https://github.com/travis-ci/travis-tasks) via Sidekiq and should do the actual API calls needed. The event handler should finish very quickly, while the task is allowed to take longer. diff --git a/vendor/travis-core/lib/travis/addons/archive.rb b/vendor/travis-core/lib/travis/addons/archive.rb deleted file mode 100644 index cc66d4a9..00000000 --- a/vendor/travis-core/lib/travis/addons/archive.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Travis - module Addons - module Archive - require 'travis/addons/archive/event_handler' - require 'travis/addons/archive/task' - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/archive/event_handler.rb b/vendor/travis-core/lib/travis/addons/archive/event_handler.rb deleted file mode 100644 index 725c251d..00000000 --- a/vendor/travis-core/lib/travis/addons/archive/event_handler.rb +++ /dev/null @@ -1,36 +0,0 @@ -require 'travis/addons/archive/task' -require 'travis/event/handler' -require 'travis/features' - -module Travis - module Addons - module Archive - class EventHandler < Event::Handler - EVENTS = /log:aggregated/ - - def handle? - Travis::Features.feature_active?(:log_archiving) - end - - def handle - Travis::Addons::Archive::Task.run(:archive, payload) - end - - def payload - @payload ||= { type: type, id: object.id, job_id: object.job_id } - end - - def type - @type ||= event.split(':').first - end - - class Instrument < Notification::Instrument::EventHandler - def notify_completed - publish(payload: handler.payload) - end - end - Instrument.attach_to(self) - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/archive/task.rb b/vendor/travis-core/lib/travis/addons/archive/task.rb deleted file mode 100644 index 37b974ee..00000000 --- a/vendor/travis-core/lib/travis/addons/archive/task.rb +++ /dev/null @@ -1,24 +0,0 @@ -require 'travis/task' - -module Travis - module Addons - module Archive - class Task < Travis::Task - def process - Travis.run_service(:"archive_#{payload[:type]}", id: payload[:id], job_id: payload[:job_id]) - end - - class Instrument < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<#{target.payload[:type].camelize} id=#{target.payload[:id]}>", - :object_type => target.payload[:type].camelize, - :object_id => target.payload[:id] - ) - end - end - Instrument.attach_to(self) - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/campfire.rb b/vendor/travis-core/lib/travis/addons/campfire.rb deleted file mode 100644 index 6aada6d5..00000000 --- a/vendor/travis-core/lib/travis/addons/campfire.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Travis - module Addons - module Campfire - module Instruments - require 'travis/addons/campfire/instruments' - end - - require 'travis/addons/campfire/event_handler' - - class Task < ::Travis::Task; end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/campfire/event_handler.rb b/vendor/travis-core/lib/travis/addons/campfire/event_handler.rb deleted file mode 100644 index 0a312c81..00000000 --- a/vendor/travis-core/lib/travis/addons/campfire/event_handler.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'travis/addons/campfire/instruments' -require 'travis/event/handler' - -module Travis - module Addons - module Campfire - - # Publishes a build notification to campfire rooms as defined in the - # configuration (`.travis.yml`). - # - # Campfire credentials are encrypted using the repository's ssl key. - class EventHandler < Event::Handler - API_VERSION = 'v2' - - EVENTS = /build:finished/ - - def handle? - !pull_request? && targets.present? && config.send_on_finished_for?(:campfire) - end - - def handle - Travis::Addons::Campfire::Task.run(:campfire, payload, targets: targets) - end - - def targets - @targets ||= config.notification_values(:campfire, :rooms) - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/campfire/instruments.rb b/vendor/travis-core/lib/travis/addons/campfire/instruments.rb deleted file mode 100644 index c3b55de9..00000000 --- a/vendor/travis-core/lib/travis/addons/campfire/instruments.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'travis/notification/instrument/event_handler' -require 'travis/notification/instrument/task' - -module Travis - module Addons - module Campfire - module Instruments - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish(:targets => handler.targets) - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<Build id=#{payload[:build][:id]}>", - :repository => payload[:repository][:slug], - # :request_id => payload['request'][:id], # TODO - :object_type => 'Build', - :object_id => payload[:build][:id], - :targets => task.targets, - :message => task.message - ) - end - end - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/email.rb b/vendor/travis-core/lib/travis/addons/email.rb deleted file mode 100644 index 743d3f3f..00000000 --- a/vendor/travis-core/lib/travis/addons/email.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Travis - module Addons - module Email - - require 'travis/addons/email/instruments' - require 'travis/addons/email/event_handler' - class Task < ::Travis::Task; end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/email/event_handler.rb b/vendor/travis-core/lib/travis/addons/email/event_handler.rb deleted file mode 100644 index afdd4170..00000000 --- a/vendor/travis-core/lib/travis/addons/email/event_handler.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'travis/addons/email/instruments' -require 'travis/event/handler' -require 'travis/model/broadcast' - -module Travis - module Addons - module Email - - # Sends out build notification emails using ActionMailer. - class EventHandler < Event::Handler - API_VERSION = 'v2' - - EVENTS = ['build:finished', 'build:canceled'] - - def handle? - !pull_request? && config.enabled?(:email) && config.send_on_finished_for?(:email) && recipients.present? - end - - def handle - Travis::Addons::Email::Task.run(:email, payload, recipients: recipients, broadcasts: broadcasts) - end - - def recipients - @recipients ||= begin - recipients = config.notification_values(:email, :recipients) - recipients = config.notifications[:recipients] if recipients.blank? # TODO deprecate recipients - recipients = default_recipients if recipients.blank? - Array(recipients).join(',').split(',').map(&:strip).select(&:present?).uniq - end - end - - private - - def pull_request? - build['pull_request'] - end - - def broadcasts - Broadcast.by_repo(object.repository).map do |broadcast| - { message: broadcast.message } - end - end - - def default_recipients - recipients = object.repository.users.map {|u| u.emails.map(&:email)}.flatten - recipients.keep_if do |r| - r == object.commit.author_email or - r == object.commit.committer_email - end - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/email/instruments.rb b/vendor/travis-core/lib/travis/addons/email/instruments.rb deleted file mode 100644 index 4cc5c3bd..00000000 --- a/vendor/travis-core/lib/travis/addons/email/instruments.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'travis/notification/instrument/event_handler' -require 'travis/notification/instrument/task' - -module Travis - module Addons - module Email - module Instruments - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish(:recipients => handler.recipients) - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<Build id=#{payload[:build][:id]}>", - :repository => payload[:repository][:slug], - # :request_id => payload['request_id'], # TODO - :object_type => 'Build', - :object_id => payload[:build][:id], - :email => task.type, - :recipients => task.recipients - ) - end - end - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/flowdock.rb b/vendor/travis-core/lib/travis/addons/flowdock.rb deleted file mode 100644 index bbd62f1d..00000000 --- a/vendor/travis-core/lib/travis/addons/flowdock.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Travis - module Addons - module Flowdock - require 'travis/addons/flowdock/instruments' - require 'travis/addons/flowdock/event_handler' - class Task < ::Travis::Task; end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/flowdock/event_handler.rb b/vendor/travis-core/lib/travis/addons/flowdock/event_handler.rb deleted file mode 100644 index 0743ae44..00000000 --- a/vendor/travis-core/lib/travis/addons/flowdock/event_handler.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'travis/addons/flowdock/instruments' -require 'travis/event/handler' - -module Travis - module Addons - module Flowdock - - # Publishes a build notification to Flowdock rooms as defined in the - # configuration (`.travis.yml`). - # - # Flowdock credentials are encrypted using the repository's ssl key. - class EventHandler < Event::Handler - API_VERSION = 'v2' - - EVENTS = /build:finished/ - - def initialize(*) - super - @payload = Api::Serialize.data(object, for: 'event', version: 'v0', params: data) - end - - def handle? - !pull_request? && targets.present? && config.send_on_finished_for?(:flowdock) - end - - def handle - Travis::Addons::Flowdock::Task.run(:flowdock, payload, targets: targets) - end - - def targets - @targets ||= config.notification_values(:flowdock, :rooms) - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/flowdock/instruments.rb b/vendor/travis-core/lib/travis/addons/flowdock/instruments.rb deleted file mode 100644 index 421132ed..00000000 --- a/vendor/travis-core/lib/travis/addons/flowdock/instruments.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'travis/notification/instrument/event_handler' -require 'travis/notification/instrument/task' - -module Travis - module Addons - module Flowdock - module Instruments - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish(:targets => handler.targets) - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<Build id=#{payload[:build][:id]}>", - :repository => payload[:repository][:slug], - # :request_id => payload['request'][:id], # TODO - :object_type => 'Build', - :object_id => payload[:build][:id], - :targets => task.targets, - :message => task.message - ) - end - end - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/github_status.rb b/vendor/travis-core/lib/travis/addons/github_status.rb deleted file mode 100644 index d3886d74..00000000 --- a/vendor/travis-core/lib/travis/addons/github_status.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Travis - module Addons - module GithubStatus - require 'travis/addons/github_status/instruments' - require 'travis/addons/github_status/event_handler' - class Task < ::Travis::Task; end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/github_status/event_handler.rb b/vendor/travis-core/lib/travis/addons/github_status/event_handler.rb deleted file mode 100644 index 2aae7fa5..00000000 --- a/vendor/travis-core/lib/travis/addons/github_status/event_handler.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'travis/addons/github_status/instruments' -require 'travis/event/handler' - -module Travis - module Addons - module GithubStatus - - # Adds a comment with a build notification to the pull-request the request - # belongs to. - class EventHandler < Event::Handler - API_VERSION = 'v2' - EVENTS = /build:(created|started|finished|canceled)/ - - def handle? - return token.present? unless multi_token? - - unless tokens.any? - error "No GitHub OAuth tokens found for #{object.repository.slug}" - end - - tokens.any? - end - - def handle - if multi_token? - Travis::Addons::GithubStatus::Task.run(:github_status, payload, tokens: tokens) - else - Travis::Addons::GithubStatus::Task.run(:github_status, payload, token: token) - end - end - - private - - def token - admin.try(:github_oauth_token) - end - - def tokens - @tokens ||= users.map { |user| { user.login => user.github_oauth_token } }.inject({}, :merge) - end - - def users - @users ||= [ - build_committer, - admin, - users_with_push_access, - ].flatten.compact - end - - def build_committer - user = User.with_email(object.commit.committer_email) - user if user && user.permission?(repository_id: object.repository.id, push: true) - end - - def admin - @admin ||= Travis.run_service(:find_admin, repository: object.repository) - rescue Travis::AdminMissing - nil - end - - def users_with_push_access - object.repository.users_with_permission(:push) - end - - def multi_token? - !Travis::Features.feature_deactivated?(:github_status_multi_tokens) - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/github_status/instruments.rb b/vendor/travis-core/lib/travis/addons/github_status/instruments.rb deleted file mode 100644 index 525742fa..00000000 --- a/vendor/travis-core/lib/travis/addons/github_status/instruments.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'travis/notification/instrument/event_handler' -require 'travis/notification/instrument/task' - -module Travis - module Addons - module GithubStatus - module Instruments - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<Build id=#{payload[:build][:id]}>", - :repository => payload[:repository][:slug], - # :request_id => payload['request_id'], # TODO - :object_type => 'Build', - :object_id => payload[:build][:id], - :url => task.url.to_s - ) - end - end - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/hipchat.rb b/vendor/travis-core/lib/travis/addons/hipchat.rb deleted file mode 100644 index b8664ff8..00000000 --- a/vendor/travis-core/lib/travis/addons/hipchat.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Travis - module Addons - module Hipchat - require 'travis/addons/hipchat/instruments' - require 'travis/addons/hipchat/event_handler' - class Task < ::Travis::Task; end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/hipchat/event_handler.rb b/vendor/travis-core/lib/travis/addons/hipchat/event_handler.rb deleted file mode 100644 index 73a8657e..00000000 --- a/vendor/travis-core/lib/travis/addons/hipchat/event_handler.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'travis/addons/hipchat/instruments' -require 'travis/event/handler' - -module Travis - module Addons - module Hipchat - - # Publishes a build notification to hipchat rooms as defined in the - # configuration (`.travis.yml`). - # - # Hipchat credentials are encrypted using the repository's ssl key. - class EventHandler < Event::Handler - API_VERSION = 'v2' - - EVENTS = /build:finished/ - - def handle? - enabled? && targets.present? && config.send_on_finished_for?(:hipchat) - end - - def handle - Travis::Addons::Hipchat::Task.run(:hipchat, payload, targets: targets) - end - - def enabled? - enabled = config.notification_values(:hipchat, :on_pull_requests) - enabled = true if enabled.nil? - pull_request? ? enabled : true - end - - def targets - @targets ||= config.notification_values(:hipchat, :rooms) - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/hipchat/instruments.rb b/vendor/travis-core/lib/travis/addons/hipchat/instruments.rb deleted file mode 100644 index b1fa6472..00000000 --- a/vendor/travis-core/lib/travis/addons/hipchat/instruments.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'travis/notification/instrument/event_handler' -require 'travis/notification/instrument/task' - -module Travis - module Addons - module Hipchat - module Instruments - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish(:targets => handler.targets) - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<Build id=#{payload[:build][:id]}>", - :repository => payload[:repository][:slug], - # :request_id => payload['request'][:id], # TODO - :object_type => 'Build', - :object_id => payload[:build][:id], - :targets => task.targets, - :message => task.message - ) - end - end - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/irc.rb b/vendor/travis-core/lib/travis/addons/irc.rb deleted file mode 100644 index f5fc6133..00000000 --- a/vendor/travis-core/lib/travis/addons/irc.rb +++ /dev/null @@ -1,10 +0,0 @@ -module Travis - module Addons - module Irc - require 'travis/addons/irc/instruments' - require 'travis/addons/irc/event_handler' - class Task < ::Travis::Task; end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/irc/event_handler.rb b/vendor/travis-core/lib/travis/addons/irc/event_handler.rb deleted file mode 100644 index dc50ae9b..00000000 --- a/vendor/travis-core/lib/travis/addons/irc/event_handler.rb +++ /dev/null @@ -1,32 +0,0 @@ -require 'travis/addons/irc/instruments' -require 'travis/event/handler' - -module Travis - module Addons - module Irc - - # Publishes a build notification to IRC channels as defined in the - # configuration (`.travis.yml`). - class EventHandler < Event::Handler - API_VERSION = 'v2' - - EVENTS = 'build:finished' - - def handle? - !pull_request? && channels.present? && config.send_on_finished_for?(:irc) - end - - def handle - Travis::Addons::Irc::Task.run(:irc, payload, channels: channels) - end - - def channels - @channels ||= config.notification_values(:irc, :channels) - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/irc/instruments.rb b/vendor/travis-core/lib/travis/addons/irc/instruments.rb deleted file mode 100644 index ee013770..00000000 --- a/vendor/travis-core/lib/travis/addons/irc/instruments.rb +++ /dev/null @@ -1,31 +0,0 @@ -require 'travis/notification/instrument/event_handler' -require 'travis/notification/instrument/task' - -module Travis - module Addons - module Irc - module Instruments - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish(:channels => handler.channels) - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<Build id=#{payload[:build][:id]}>", - :repository => payload[:repository][:slug], - # :request_id => payload['request_id'], # TODO - :object_type => 'Build', - :object_id => payload[:build][:id], - :channels => task.channels, - :messages => task.messages - ) - end - end - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/pusher.rb b/vendor/travis-core/lib/travis/addons/pusher.rb deleted file mode 100644 index 90564fc3..00000000 --- a/vendor/travis-core/lib/travis/addons/pusher.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Travis - module Addons - module Pusher - require 'travis/addons/pusher/instruments' - require 'travis/addons/pusher/event_handler' - - class Task < ::Travis::Task; end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/pusher/event_handler.rb b/vendor/travis-core/lib/travis/addons/pusher/event_handler.rb deleted file mode 100644 index 3c72efea..00000000 --- a/vendor/travis-core/lib/travis/addons/pusher/event_handler.rb +++ /dev/null @@ -1,57 +0,0 @@ -require 'travis/addons/pusher/instruments' -require 'travis/event/handler' - -module Travis - module Addons - module Pusher - - # Notifies registered clients about various state changes through Pusher. - class EventHandler < Event::Handler - EVENTS = [ - /^build:(created|received|started|finished|canceled)/, - /^job:test:(created|received|started|log|finished|canceled)/ - ] - - attr_reader :channels, :pusher_payload - - def initialize(*) - super - @pusher_payload = Api::Serialize.data(object, :for => 'pusher', :type => type, :params => data) if handle? - end - - def handle? - true - end - - def handle - Travis::Addons::Pusher::Task.run(queue, pusher_payload, :event => event) - end - - private - - def type - event.sub('test:', '').sub(':', '/') - end - - def queue - if Travis::Features.enabled_for_all?(:"pusher-live") || - Travis::Features.repository_active?(:"pusher-live", repository_id) - :"pusher-live" - else - :pusher - end - end - - def repository_id - if payload && payload['repository'] && payload['repository']['id'] - payload['repository']['id'] - elsif object && object.repository && object.repository.id - object.repository.id - end - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/pusher/instruments.rb b/vendor/travis-core/lib/travis/addons/pusher/instruments.rb deleted file mode 100644 index 97d5f5ff..00000000 --- a/vendor/travis-core/lib/travis/addons/pusher/instruments.rb +++ /dev/null @@ -1,42 +0,0 @@ -require 'travis/notification/instrument/event_handler' -require 'travis/notification/instrument/task' - -module Travis - module Addons - module Pusher - module Instruments - def self.publish?(event) - event.to_s != 'job:test:log' - end - - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish if Instruments.publish?(handler.event) - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<#{type.camelize} id=#{id}> (event: #{task.event}, channels: #{task.channels.join(', ')})", - :object_type => type.camelize, - :object_id => id, - :event => task.event, - :client_event => task.client_event, - :channels => task.channels - ) if Instruments.publish?(task.event) - end - - def type - @type ||= task.event.split(':').first - end - - def id - payload.key?(type.to_sym) ? payload[type.to_sym][:id] : payload[:id] - end - end - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/pushover.rb b/vendor/travis-core/lib/travis/addons/pushover.rb deleted file mode 100644 index 10cbd194..00000000 --- a/vendor/travis-core/lib/travis/addons/pushover.rb +++ /dev/null @@ -1,13 +0,0 @@ -module Travis - module Addons - module Pushover - module Instruments - require 'travis/addons/pushover/instruments' - end - - require 'travis/addons/pushover/event_handler' - - class Task < ::Travis::Task; end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/pushover/event_handler.rb b/vendor/travis-core/lib/travis/addons/pushover/event_handler.rb deleted file mode 100644 index 123e9495..00000000 --- a/vendor/travis-core/lib/travis/addons/pushover/event_handler.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'travis/addons/pushover/instruments' -require 'travis/event/handler' - -module Travis - module Addons - module Pushover - - # Publishes a build notification to pushover users as defined in the - # configuration (`.travis.yml`). - # - # Credentials are encrypted using the repository's ssl key. - class EventHandler < Event::Handler - API_VERSION = 'v2' - - EVENTS = /build:finished/ - - def handle? - !pull_request? && users.present? && api_key.present? && config.send_on_finished_for?(:pushover) - end - - def handle - Travis::Addons::Pushover::Task.run(:pushover, payload, users: users, api_key: api_key) - end - - def users - @users ||= config.notification_values(:pushover, :users) - end - - def api_key - @api_key ||= config.notifications[:pushover][:api_key] - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/pushover/instruments.rb b/vendor/travis-core/lib/travis/addons/pushover/instruments.rb deleted file mode 100644 index 6ed31392..00000000 --- a/vendor/travis-core/lib/travis/addons/pushover/instruments.rb +++ /dev/null @@ -1,30 +0,0 @@ -require 'travis/notification/instrument/event_handler' -require 'travis/notification/instrument/task' - -module Travis - module Addons - module Pushover - module Instruments - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish(:users => handler.users, :api_key => handler.api_key) - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<Build id=#{payload[:build][:id]}>", - :repository => payload[:repository][:slug], - :object_type => 'Build', - :object_id => payload[:build][:id], - :users => task.users, - :message => task.message, - :api_key => task.api_key - ) - end - end - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/slack.rb b/vendor/travis-core/lib/travis/addons/slack.rb deleted file mode 100644 index 1d682235..00000000 --- a/vendor/travis-core/lib/travis/addons/slack.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Travis - module Addons - module Slack - require 'travis/addons/slack/instruments' - require 'travis/addons/slack/event_handler' - - class Task < ::Travis::Task; end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/slack/event_handler.rb b/vendor/travis-core/lib/travis/addons/slack/event_handler.rb deleted file mode 100644 index 9cfa2c80..00000000 --- a/vendor/travis-core/lib/travis/addons/slack/event_handler.rb +++ /dev/null @@ -1,30 +0,0 @@ -module Travis - module Addons - module Slack - - # Publishes a build notification to Slack rooms as defined in the - # configuration (`.travis.yml`). - # - # Slack credentials are encrypted using the repository's ssl key. - class EventHandler < Event::Handler - API_VERSION = 'v2' - - EVENTS = /build:finished/ - - def handle? - targets.present? && config.send_on_finished_for?(:slack) - end - - def handle - Travis::Addons::Slack::Task.run(:slack, payload, targets: targets) - end - - def targets - @targets ||= config.notification_values(:slack, :rooms) - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/slack/instruments.rb b/vendor/travis-core/lib/travis/addons/slack/instruments.rb deleted file mode 100644 index ca3de728..00000000 --- a/vendor/travis-core/lib/travis/addons/slack/instruments.rb +++ /dev/null @@ -1,25 +0,0 @@ -module Travis - module Addons - module Slack - module Instruments - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish(:targets => handler.targets) - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<Build id=#{payload[:build][:id]}>", - :repository => payload[:repository][:slug], - :object_type => 'Build', - :object_id => payload[:build][:id], - :targets => task.targets - ) - end - end - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/sqwiggle.rb b/vendor/travis-core/lib/travis/addons/sqwiggle.rb deleted file mode 100644 index 17829b38..00000000 --- a/vendor/travis-core/lib/travis/addons/sqwiggle.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Travis - module Addons - module Sqwiggle - require 'travis/addons/sqwiggle/instruments' - require 'travis/addons/sqwiggle/event_handler' - - class Task < ::Travis::Task; end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/sqwiggle/event_handler.rb b/vendor/travis-core/lib/travis/addons/sqwiggle/event_handler.rb deleted file mode 100644 index a12ba383..00000000 --- a/vendor/travis-core/lib/travis/addons/sqwiggle/event_handler.rb +++ /dev/null @@ -1,30 +0,0 @@ -module Travis - module Addons - module Sqwiggle - - # Publishes a build notification to sqwiggle rooms as defined in the - # configuration (`.travis.yml`). - # - # sqwiggle credentials are encrypted using the repository's ssl key. - class EventHandler < Event::Handler - - EVENTS = /build:finished/ - - def handle? - !pull_request? && targets.present? && config.send_on_finished_for?(:sqwiggle) - end - - def handle - Travis::Addons::Sqwiggle::Task.run(:sqwiggle, payload, targets: targets) - end - - def targets - @targets ||= config.notification_values(:sqwiggle, :rooms) - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/sqwiggle/instruments.rb b/vendor/travis-core/lib/travis/addons/sqwiggle/instruments.rb deleted file mode 100644 index 6daa5d79..00000000 --- a/vendor/travis-core/lib/travis/addons/sqwiggle/instruments.rb +++ /dev/null @@ -1,29 +0,0 @@ -module Travis - module Addons - module Sqwiggle - module Instruments - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish(:targets => handler.targets) - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<Build id=#{payload[:build][:id]}>", - :repository => payload[:repository][:slug], - # :request_id => payload['request'][:id], # TODO - :object_type => 'Build', - :object_id => payload[:build][:id], - :targets => task.targets, - :message => task.message - ) - end - end - end - end - end -end - - diff --git a/vendor/travis-core/lib/travis/addons/states_cache.rb b/vendor/travis-core/lib/travis/addons/states_cache.rb deleted file mode 100644 index c33a1ea2..00000000 --- a/vendor/travis-core/lib/travis/addons/states_cache.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Travis - module Addons - module StatesCache - require 'travis/addons/states_cache/event_handler' - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/states_cache/event_handler.rb b/vendor/travis-core/lib/travis/addons/states_cache/event_handler.rb deleted file mode 100644 index a786287c..00000000 --- a/vendor/travis-core/lib/travis/addons/states_cache/event_handler.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'travis/event/handler' - -module Travis - module Addons - module StatesCache - class EventHandler < Event::Handler - EVENTS = /build:finished/ - - def handle? - states_cache_enabled = Travis::Features.feature_active?(:states_cache) - result = !pull_request? && states_cache_enabled - Travis.logger.info("[states-cache] Checking if event handler should be run for " + - "repo_id=#{repository_id} branch=#{branch} build_id=#{build['id']}, result: #{result}, " + - "pull_request: #{pull_request?} states_cache_enabled: #{states_cache_enabled}") - result - end - - def handle - Travis.logger.info("[states-cache] Running event handler for repo_id=#{repository_id} build_id=#{build['id']} branch=#{branch}") - cache.write(repository_id, branch, data) - rescue Exception => e - Travis.logger.error("[states-cache] An error occurred while trying to handle states cache update: #{e.message}\n#{e.backtrace}") - raise - end - - def cache - Travis.states_cache - end - - def repository_id - build['repository_id'] - end - - def branch - commit['branch'] - end - - def data - { - 'id' => build['id'], - 'state' => build['state'] - } - end - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/util.rb b/vendor/travis-core/lib/travis/addons/util.rb deleted file mode 100644 index 3a0e1075..00000000 --- a/vendor/travis-core/lib/travis/addons/util.rb +++ /dev/null @@ -1,7 +0,0 @@ -module Travis - module Addons - module Util - require 'travis/addons/util/template' - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/webhook.rb b/vendor/travis-core/lib/travis/addons/webhook.rb deleted file mode 100644 index 3c03922c..00000000 --- a/vendor/travis-core/lib/travis/addons/webhook.rb +++ /dev/null @@ -1,11 +0,0 @@ -module Travis - module Addons - module Webhook - require 'travis/addons/webhook/instruments' - require 'travis/addons/webhook/event_handler' - - class Task < ::Travis::Task; end - end - end -end - diff --git a/vendor/travis-core/lib/travis/addons/webhook/event_handler.rb b/vendor/travis-core/lib/travis/addons/webhook/event_handler.rb deleted file mode 100644 index 3a705090..00000000 --- a/vendor/travis-core/lib/travis/addons/webhook/event_handler.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'travis/addons/webhook/instruments' -require 'travis/event/handler' - -# TODO include_logs? has been removed. gotta be deprecated! -# -module Travis - module Addons - module Webhook - - # Sends build notifications to webhooks as defined in the configuration - # (`.travis.yml`). - class EventHandler < Event::Handler - EVENTS = /build:(started|finished)/ - - def initialize(*) - super - end - - def handle? - targets.present? && config.send_on?(:webhooks, event.split(':').last) - end - - def handle - Travis::Addons::Webhook::Task.run(:webhook, webhook_payload, targets: targets, token: request['token']) - end - - def webhook_payload - Api::Serialize.data(object, :for => 'webhook', :type => 'build/finished', :version => 'v1') - end - - def targets - @targets ||= config.notification_values(:webhooks, :urls) - end - - Instruments::EventHandler.attach_to(self) - end - end - end -end diff --git a/vendor/travis-core/lib/travis/addons/webhook/instruments.rb b/vendor/travis-core/lib/travis/addons/webhook/instruments.rb deleted file mode 100644 index 9552f04d..00000000 --- a/vendor/travis-core/lib/travis/addons/webhook/instruments.rb +++ /dev/null @@ -1,29 +0,0 @@ -require 'travis/notification/instrument/event_handler' -require 'travis/notification/instrument/task' - -module Travis - module Addons - module Webhook - module Instruments - class EventHandler < Notification::Instrument::EventHandler - def notify_completed - publish(:targets => handler.targets) - end - end - - class Task < Notification::Instrument::Task - def run_completed - publish( - :msg => "for #<Build id=#{payload[:id]}>", - :repository => payload[:repository].values_at(:owner_name, :name).join('/'), - :object_type => 'Build', - :object_id => payload[:id], - :targets => task.targets - ) - end - end - end - end - end -end - diff --git a/vendor/travis-core/lib/travis/services/cancel_build.rb b/vendor/travis-core/lib/travis/services/cancel_build.rb deleted file mode 100644 index 26f2a968..00000000 --- a/vendor/travis-core/lib/travis/services/cancel_build.rb +++ /dev/null @@ -1,78 +0,0 @@ -require 'travis/services/base' - -module Travis - module Services - class CancelBuild < Base - extend Travis::Instrumentation - - register :cancel_build - - attr_reader :source - - def initialize(*) - super - - @source = params.delete(:source) || 'unknown' - end - - def run - cancel if can_cancel? - end - instrument :run - - def messages - messages = [] - messages << { :notice => 'The build was successfully cancelled.' } if can_cancel? - messages << { :error => 'You are not authorized to cancel this build.' } unless authorized? - messages << { :error => "The build could not be cancelled." } unless build.cancelable? - messages - end - - def cancel - # build may have been retrieved with a :join query, so we need to reset the readonly status - build.send(:instance_variable_set, :@readonly, false) - build.cancel! - publish! - end - - def publish! - # TODO: I think that instead of keeping publish logic in both cancel build - # and cancel job services, we could call cancel_job service for each job - # in the matrix, which would put build in canceled state, even without calling - # cancel! on build explicitly. This may be a better way to handle cancelling - # build - build.matrix.each do |job| - Travis.logger.info("Publishing cancel_job message to worker.commands queue for Job##{job.id}") - publisher.publish(type: 'cancel_job', job_id: job.id, source: source) - end - - end - - def can_cancel? - authorized? && build.cancelable? - end - - def authorized? - current_user.permission?(:pull, :repository_id => build.repository_id) - end - - def build - @build ||= run_service(:find_build, params) - end - - def publisher - Travis::Amqp::FanoutPublisher.new('worker.commands') - end - - class Instrument < Notification::Instrument - def run_completed - publish( - :msg => "for <Build id=#{target.build.id}> (#{target.current_user.login})", - :result => result - ) - end - end - Instrument.attach_to(self) - end - end -end diff --git a/vendor/travis-core/lib/travis/services/cancel_job.rb b/vendor/travis-core/lib/travis/services/cancel_job.rb deleted file mode 100644 index 5be04197..00000000 --- a/vendor/travis-core/lib/travis/services/cancel_job.rb +++ /dev/null @@ -1,73 +0,0 @@ -require 'travis/notification' -require 'travis/services/base' - -module Travis - module Services - class CancelJob < Base - extend Travis::Instrumentation - - register :cancel_job - - attr_reader :source - - def initialize(*) - super - - @source = params.delete(:source) || 'unknown' - end - - def run - cancel if can_cancel? - end - instrument :run - - def messages - messages = [] - messages << { :notice => 'The job was successfully cancelled.' } if can_cancel? - messages << { :error => 'You are not authorized to cancel this job.' } unless authorized? - messages << { :error => "The job could not be cancelled because it is currently #{job.state}." } unless job.cancelable? - messages - end - - def cancel - # job may have been retrieved with a :join query, so we need to reset the readonly status - job.send(:instance_variable_set, :@readonly, false) - publish! - job.cancel! - end - - def can_cancel? - authorized? && job.cancelable? - end - - def authorized? - current_user.permission?(:pull, :repository_id => job.repository_id) - end - - def job - @job ||= run_service(:find_job, params) - end - - def publish! - Travis.logger.info("Publishing cancel_job message to worker.commands queue for Job##{job.id}") - publisher.publish(type: 'cancel_job', job_id: job.id, source: source) - end - - private - - def publisher - Travis::Amqp::FanoutPublisher.new('worker.commands') - end - - class Instrument < Notification::Instrument - def run_completed - publish( - :msg => "for <Job id=#{target.job.id}> (#{target.current_user.login})", - :result => result - ) - end - end - Instrument.attach_to(self) - end - end -end diff --git a/vendor/travis-core/lib/travis/services/reset_model.rb b/vendor/travis-core/lib/travis/services/reset_model.rb deleted file mode 100644 index f8a2a0db..00000000 --- a/vendor/travis-core/lib/travis/services/reset_model.rb +++ /dev/null @@ -1,74 +0,0 @@ -require 'travis/support/instrumentation' -require 'travis/services/base' - -module Travis - module Services - class ResetModel < Base - extend Travis::Instrumentation - - register :reset_model - - def run - reset if current_user && target && accept? - true - end - instrument :run - - def accept? - current_user && permission? && resetable? - end - - def messages - messages = [] - messages << { notice: "The #{type} was successfully restarted." } if accept? - messages << { error: 'You do not seem to have sufficient permissions.' } unless permission? - messages << { error: "This #{type} currently can not be restarted." } unless resetable? - messages - end - - def type - @type ||= params[:build_id] ? :build : :job - end - - def id - @id ||= params[:"#{type}_id"] - end - - private - - def reset - # target may have been retrieved with a :join query, so we need to reset the readonly status - target.send(:instance_variable_set, :@readonly, false) - target.reset!(reset_matrix: type == :build) - end - - def permission? - current_user.permission?(required_role, repository_id: target.repository_id) - end - - def resetable? - defined?(@resetable) ? @resetable : @resetable = target.resetable? - end - - def required_role - Travis.config.roles.reset_model - end - - def target - @target ||= service(:"find_#{type}", id: id).run - end - - class Instrument < Notification::Instrument - def run_completed - publish( - msg: "build_id=#{target.id} #{target.accept? ? 'accepted' : 'not accepted'}", - type: target.type, - id: target.id, - accept?: target.accept? - ) - end - end - Instrument.attach_to(self) - end - end -end diff --git a/vendor/travis-core/lib/travis/version.rb b/vendor/travis-core/lib/travis/version.rb deleted file mode 100644 index 1214aa54..00000000 --- a/vendor/travis-core/lib/travis/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module Travis - VERSION = "0.0.1" -end diff --git a/vendor/travis-core/travis-core.gemspec b/vendor/travis-core/travis-core.gemspec deleted file mode 100644 index 5eb06b14..00000000 --- a/vendor/travis-core/travis-core.gemspec +++ /dev/null @@ -1,48 +0,0 @@ -# encoding: utf-8 - -$:.unshift File.expand_path('../lib', __FILE__) -require 'travis/version' - -Gem::Specification.new do |s| - s.name = "travis-core" - s.version = Travis::VERSION - s.authors = ["Travis CI"] - s.email = "contact@travis-ci.org" - s.homepage = "https://github.com/travis-ci/travis-core" - s.summary = "The heart of Travis" - - s.files = Dir['{lib/**/*,spec/**/*,[A-Z]*}'] - s.platform = Gem::Platform::RUBY - s.require_path = 'lib' - s.rubyforge_project = '[none]' - - s.add_dependency 'rake' - s.add_dependency 'thor' - s.add_dependency 'activerecord', '~> 3.2.19' - s.add_dependency 'railties', '~> 3.2.19' - s.add_dependency 'rollout', '~> 1.1.0' - s.add_dependency 'coder', '~> 0.4.0' - s.add_dependency 'virtus', '~> 1.0.0' - - # travis - s.add_dependency 'travis-config', '~> 0.1.0' - - # db - s.add_dependency 'data_migrations', '~> 0.0.1' - s.add_dependency 'redis', '~> 3.0' - - - # structures - s.add_dependency 'hashr' - s.add_dependency 'metriks', '~> 0.9.7' - - # app - s.add_dependency 'simple_states', '~> 1.0.0' - - # apis - s.add_dependency 'pusher', '~> 0.14.0' - s.add_dependency 's3', '~> 0.3' - s.add_dependency 'gh' - s.add_dependency 'multi_json' - s.add_dependency 'google-api-client', '~> 0.9.4' -end