diff --git a/Gemfile b/Gemfile index 9cef1b4c..da99c923 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,6 @@ gem 'travis-amqp', github: 'travis-ci/travis-amqp' gem 'travis-config', '~> 0.1.0' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil gem 'travis-yaml', github: 'travis-ci/travis-yaml' -gem 'travis-migrations', github: 'travis-ci/travis-migrations' gem 'mustermann', github: 'rkh/mustermann' gem 'sinatra' gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil @@ -37,6 +36,10 @@ gem 'stackprof' gem 'jemalloc' gem 'customerio' +group :development, :test do + gem 'travis-migrations', github: 'travis-ci/travis-migrations' +end + group :test do gem 'rspec', '~> 2.13' gem 'rspec-its' diff --git a/README.md b/README.md index 5f6aaee5..bf00f730 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ This is the app running on https://api.travis-ci.org/ ### Database setup -NB detail for how `rake` sets up the database can be found in the `Rakefile`. In the `namespace :db` block you will see the database name for development is hardcoded to `travis-development`. If you are using a different configuration you will have to make your own adjustments. +NB detail for how `rake` sets up the database can be found in the `Rakefile`. In the `namespace :db` block you will see the database name is configured using the environment variable RAILS_ENV. If you are using a different configuration you will have to make your own adjustments. 1. `bundle exec rake db:create` 2. for testing 'RAILS_ENV=test bundle exec rake db:create --trace' diff --git a/Rakefile b/Rakefile index 93c7d171..5d4cd585 100644 --- a/Rakefile +++ b/Rakefile @@ -1,45 +1,34 @@ -require 'rake' -require 'travis/migrations' - -task default: :spec - namespace :db do - if ENV["RAILS_ENV"] == 'test' - desc 'Create and migrate the test database' - task :create do - sh 'createdb travis_test' rescue nil - sh "psql -q travis_test < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql" - end - else - desc 'Create and migrate the development database' - task :create do - sh 'createdb travis_development' rescue nil - sh "psql -q travis_development < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql" - end + env = ENV["RAILS_ENV"] + fail "Cannot run rake db:create in production." if env == 'production' + desc "Create and migrate the #{env} database" + task :create do + sh "createdb travis_#{env}" rescue nil + sh "psql -q travis_#{env} < #{Gem.loaded_specs['travis-migrations'].full_gem_path}/db/structure.sql" end end desc "generate gemspec" task 'travis-api.gemspec' do - content = File.read 'travis-api.gemspec' + content = File.read 'travis-api.gemspec' - fields = { - authors: `git shortlog -sn`.scan(/[^\d\s].*/), - email: `git shortlog -sne`.scan(/[^<]+@[^>]+/), - files: `git ls-files`.split("\n").reject { |f| f =~ /^(\.|Gemfile)/ } - } + fields = { + authors: `git shortlog -sn`.scan(/[^\d\s].*/), + email: `git shortlog -sne`.scan(/[^<]+@[^>]+/), + files: `git ls-files`.split("\n").reject { |f| f =~ /^(\.|Gemfile)/ } + } - fields.each do |field, values| - updated = " s.#{field} = [" - updated << values.map { |v| "\n %p" % v }.join(',') - updated << "\n ]" - content.sub!(/ s\.#{field} = \[\n( .*\n)* \]/, updated) - end + fields.each do |field, values| + updated = " s.#{field} = [" + updated << values.map { |v| "\n %p" % v }.join(',') + updated << "\n ]" + content.sub!(/ s\.#{field} = \[\n( .*\n)* \]/, updated) + end - File.open('travis-api.gemspec', 'w') { |f| f << content } - end + File.open('travis-api.gemspec', 'w') { |f| f << content } +end +task default: 'travis-api.gemspec' - task default: 'travis-api.gemspec' - - tasks_path = File.expand_path('../lib/tasks/*.rake', __FILE__) - Dir.glob(tasks_path).each { |r| import r } +## can this be removed? what other rakefiles need to be included? +# tasks_path = File.expand_path('../lib/tasks/*.rake', __FILE__) +# Dir.glob(tasks_path).each { |r| import r } diff --git a/travis-api.gemspec b/travis-api.gemspec index 92ee8839..472324a1 100644 --- a/travis-api.gemspec +++ b/travis-api.gemspec @@ -11,75 +11,85 @@ Gem::Specification.new do |s| s.authors = [ "Konstantin Haase", "Piotr Sarnacki", + "carlad", "Sven Fuchs", "Hiro Asari", "Mathias Meyer", "Josh Kalderimis", "Henrik Hodne", - "carlad", "Tyranja", - "Andre Arko", "Dan Buch", + "Andre Arko", "C. Scott Ananian", "Erik Michaels-Ober", "Brian Ford", + "Lisa P", "Steve Richert", + "Bryan Goldstein", + "Dan Rice", + "James Dennes", + "María de Antón", + "Nick Schonning", + "Patrick Williams", "Puneeth Chaganti", "Thais Camilo and Konstantin Haase", "Tim Carey-Smith", - "Bryan Goldstein", "Zachary Scott", - "James Dennes", - "rainsun", - "Nick Schonning", - "Patrick Williams", - "Dan Rice" + "rainsun" ] s.email = [ "konstantin.mailinglists@googlemail.com", "drogus@gmail.com", "me@svenfuchs.com", + "carla@travis-ci.com", "asari.ruby@gmail.com", "meyer@paperplanes.de", "josh.kalderimis@gmail.com", "me@henrikhodne.com", + "carlad@users.noreply.github.com", "henrik@hodne.io", - "konstantin.haase@gmail.com", "carla@travis-ci.org", + "konstantin.haase@gmail.com", "tyranja@cassiopeia.uberspace.de", "andre@arko.net", - "svenfuchs@artweb-design.de", "dan@travis-ci.org", - "sferik@gmail.com", + "svenfuchs@artweb-design.de", "cscott@cscott.net", - "henrik@travis-ci.com", - "steve.richert@gmail.com", + "sferik@gmail.com", "bford@engineyard.com", + "henrik@travis-ci.com", + "mail@lislis.de", + "steve.richert@gmail.com", + "brysgo@gmail.com", + "dan@meatballhat.com", + "dan@zoombody.com", + "jdennes@gmail.com", + "MariadeAnton@users.noreply.github.com", + "nschonni@gmail.com", "patrick@bittorrent.com", "punchagan@muse-amuse.in", - "carlad@users.noreply.github.com", - "dan@zoombody.com", - "rainsuner@gmail.com", "dev+narwen+rkh@rkh.im", "tim@spork.in", - "brysgo@gmail.com", "e@zzak.io", - "jdennes@gmail.com", - "nschonni@gmail.com", - "dan@meatballhat.com" + "rainsuner@gmail.com" ] s.files = [ "CONTRIBUTING.md", + "LICENSE", "Procfile", "README.md", "Rakefile", "bin/start-nginx", "config.ru", "config/database.yml", + "config/mime.types", + "config/nginx.conf.erb", "config/puma-config.rb", + "config/ruby_config.sh", "config/unicorn.rb", + "lib/active_record_postgres_variables.rb", "lib/conditional_skylight.rb", "lib/tasks/build_update_branch.rake", "lib/tasks/build_update_pull_request_data.rake", @@ -141,6 +151,7 @@ Gem::Specification.new do |s| "lib/travis/api/app/responders/xml.rb", "lib/travis/api/app/services/schedule_request.rb", "lib/travis/api/app/stack_instrumentation.rb", + "lib/travis/api/attack.rb", "lib/travis/api/instruments.rb", "lib/travis/api/serializer.rb", "lib/travis/api/v2.rb", @@ -184,6 +195,7 @@ Gem::Specification.new do |s| "lib/travis/api/v3/extensions/encrypted_column.rb", "lib/travis/api/v3/features.rb", "lib/travis/api/v3/github.rb", + "lib/travis/api/v3/metrics.rb", "lib/travis/api/v3/model.rb", "lib/travis/api/v3/models.rb", "lib/travis/api/v3/models/account.rb", @@ -201,14 +213,30 @@ Gem::Specification.new do |s| "lib/travis/api/v3/models/repository.rb", "lib/travis/api/v3/models/request.rb", "lib/travis/api/v3/models/ssl_key.rb", + "lib/travis/api/v3/models/star.rb", "lib/travis/api/v3/models/subscription.rb", "lib/travis/api/v3/models/token.rb", "lib/travis/api/v3/models/user.rb", "lib/travis/api/v3/opt_in.rb", + "lib/travis/api/v3/paginator.rb", + "lib/travis/api/v3/paginator/url_generator.rb", + "lib/travis/api/v3/permissions.rb", + "lib/travis/api/v3/permissions/account.rb", + "lib/travis/api/v3/permissions/build.rb", + "lib/travis/api/v3/permissions/generic.rb", + "lib/travis/api/v3/permissions/job.rb", + "lib/travis/api/v3/permissions/organization.rb", + "lib/travis/api/v3/permissions/repository.rb", + "lib/travis/api/v3/permissions/user.rb", "lib/travis/api/v3/queries.rb", "lib/travis/api/v3/queries/accounts.rb", "lib/travis/api/v3/queries/branch.rb", + "lib/travis/api/v3/queries/branches.rb", + "lib/travis/api/v3/queries/broadcasts.rb", "lib/travis/api/v3/queries/build.rb", + "lib/travis/api/v3/queries/builds.rb", + "lib/travis/api/v3/queries/job.rb", + "lib/travis/api/v3/queries/jobs.rb", "lib/travis/api/v3/queries/organization.rb", "lib/travis/api/v3/queries/organizations.rb", "lib/travis/api/v3/queries/owner.rb", @@ -224,15 +252,24 @@ Gem::Specification.new do |s| "lib/travis/api/v3/renderer/accounts.rb", "lib/travis/api/v3/renderer/avatar_url.rb", "lib/travis/api/v3/renderer/branch.rb", + "lib/travis/api/v3/renderer/branches.rb", + "lib/travis/api/v3/renderer/broadcast.rb", + "lib/travis/api/v3/renderer/broadcasts.rb", "lib/travis/api/v3/renderer/build.rb", + "lib/travis/api/v3/renderer/builds.rb", "lib/travis/api/v3/renderer/collection_renderer.rb", + "lib/travis/api/v3/renderer/commit.rb", "lib/travis/api/v3/renderer/error.rb", + "lib/travis/api/v3/renderer/job.rb", + "lib/travis/api/v3/renderer/jobs.rb", + "lib/travis/api/v3/renderer/lint.rb", "lib/travis/api/v3/renderer/model_renderer.rb", "lib/travis/api/v3/renderer/organization.rb", "lib/travis/api/v3/renderer/organizations.rb", "lib/travis/api/v3/renderer/owner.rb", "lib/travis/api/v3/renderer/repositories.rb", "lib/travis/api/v3/renderer/repository.rb", + "lib/travis/api/v3/renderer/request.rb", "lib/travis/api/v3/renderer/requests.rb", "lib/travis/api/v3/renderer/user.rb", "lib/travis/api/v3/result.rb", @@ -245,19 +282,34 @@ Gem::Specification.new do |s| "lib/travis/api/v3/services.rb", "lib/travis/api/v3/services/accounts/for_current_user.rb", "lib/travis/api/v3/services/branch/find.rb", + "lib/travis/api/v3/services/branches/find.rb", + "lib/travis/api/v3/services/broadcasts/for_current_user.rb", + "lib/travis/api/v3/services/build/cancel.rb", "lib/travis/api/v3/services/build/find.rb", + "lib/travis/api/v3/services/build/restart.rb", + "lib/travis/api/v3/services/builds/find.rb", + "lib/travis/api/v3/services/job/cancel.rb", + "lib/travis/api/v3/services/job/debug.rb", + "lib/travis/api/v3/services/job/find.rb", + "lib/travis/api/v3/services/job/restart.rb", + "lib/travis/api/v3/services/jobs/find.rb", + "lib/travis/api/v3/services/lint/lint.rb", "lib/travis/api/v3/services/organization/find.rb", "lib/travis/api/v3/services/organization/sync.rb", "lib/travis/api/v3/services/organizations/for_current_user.rb", "lib/travis/api/v3/services/owner/find.rb", "lib/travis/api/v3/services/repositories/for_current_user.rb", + "lib/travis/api/v3/services/repositories/for_owner.rb", "lib/travis/api/v3/services/repository/disable.rb", "lib/travis/api/v3/services/repository/enable.rb", "lib/travis/api/v3/services/repository/find.rb", + "lib/travis/api/v3/services/repository/star.rb", + "lib/travis/api/v3/services/repository/unstar.rb", "lib/travis/api/v3/services/requests/create.rb", "lib/travis/api/v3/services/requests/find.rb", "lib/travis/api/v3/services/user/current.rb", "lib/travis/api/v3/services/user/find.rb", + "lib/travis/api/v3/services/user/sync.rb", "lib/travis/api/workers/build_cancellation.rb", "lib/travis/api/workers/build_restart.rb", "lib/travis/api/workers/job_cancellation.rb", @@ -280,6 +332,8 @@ Gem::Specification.new do |s| "script/console", "script/repos_stats.rb", "script/server", + "script/web_concurrency", + "spec/active_record_postgres_variables_spec.rb", "spec/integration/error_handling_spec.rb", "spec/integration/formats_handling_spec.rb", "spec/integration/responders_spec.rb", @@ -344,7 +398,7 @@ Gem::Specification.new do |s| "spec/unit/endpoint/lint_spec.rb", "spec/unit/endpoint/logs_spec.rb", "spec/unit/endpoint/repos_spec.rb", - "spec/unit/endpoint/requests_spec.rb", + "spec/unit/endpoint/requests/throttle_spec.rb", "spec/unit/endpoint/users_spec.rb", "spec/unit/endpoint_spec.rb", "spec/unit/extensions/expose_pattern_spec.rb", @@ -358,20 +412,40 @@ Gem::Specification.new do |s| "spec/unit/middleware/user_agent_tracker_spec.rb", "spec/unit/responders/json_spec.rb", "spec/unit/responders/service_spec.rb", + "spec/v3/error_handling_spec.rb", "spec/v3/extensions/belongs_to_spec.rb", + "spec/v3/metrics_spec.rb", "spec/v3/renderer/avatar_url_spec.rb", "spec/v3/result_spec.rb", "spec/v3/service_index_spec.rb", "spec/v3/services/accounts/for_current_user_spec.rb", "spec/v3/services/branch/find_spec.rb", + "spec/v3/services/branches/find_spec.rb", + "spec/v3/services/broadcasts/for_current_user_spec.rb", + "spec/v3/services/build/cancel_spec.rb", + "spec/v3/services/build/find_spec.rb", + "spec/v3/services/build/restart_spec.rb", + "spec/v3/services/builds/find_spec.rb", + "spec/v3/services/job/cancel_spec.rb", + "spec/v3/services/job/debug_sepc.rb", + "spec/v3/services/job/find_spec.rb", + "spec/v3/services/job/restart_spec.rb", + "spec/v3/services/jobs/find_spec.rb", + "spec/v3/services/lint/lint_spec.rb", "spec/v3/services/organization/find_spec.rb", "spec/v3/services/organizations/for_current_user_spec.rb", "spec/v3/services/owner/find_spec.rb", "spec/v3/services/repositories/for_current_user_spec.rb", + "spec/v3/services/repositories/for_owner_spec.rb", + "spec/v3/services/repository/disable_spec.rb", + "spec/v3/services/repository/enable_spec.rb", "spec/v3/services/repository/find_spec.rb", + "spec/v3/services/repository/star_spec.rb", + "spec/v3/services/repository/unstar_spec.rb", "spec/v3/services/requests/create_spec.rb", "spec/v3/services/user/current_spec.rb", "spec/v3/services/user/find_spec.rb", + "spec/v3/services/user/sync_spec.rb", "tmp/.gitkeep", "travis-api.gemspec" ]