From e8e46135bed8fb6a1b99e0cb8e920ce92e512108 Mon Sep 17 00:00:00 2001 From: Ignacio Galindo Date: Wed, 17 Aug 2016 09:15:21 +0200 Subject: [PATCH 1/2] Test review apps --- Gemfile | 18 ++++--- app.json | 55 ++++++++++++++++++++ config/environments/review.rb | 90 +++++++++++++++++++++++++++++++++ config/initializers/omniauth.rb | 10 +++- 4 files changed, 165 insertions(+), 8 deletions(-) create mode 100644 app.json create mode 100644 config/environments/review.rb diff --git a/Gemfile b/Gemfile index 6ff1d5b..1539b63 100644 --- a/Gemfile +++ b/Gemfile @@ -27,6 +27,14 @@ gem 'lograge', '~> 0.4.1' gem 'omniauth-github', '~> 1.1.2' gem 'rake', '~> 10.5.0 ' +group :development do + gem 'dotenv-rails', '~> 2.0.0' + gem 'powder', '~> 0.3.0' + gem 'rails_best_practices', '~> 1.16.0' + gem 'spring', '~> 1.7.2' + gem 'spring-commands-rspec', '~> 1.0.4' +end + group :development, :test do gem 'capybara', '~> 2.4.4' gem 'capybara-webkit', '~> 1.4.1' @@ -37,17 +45,13 @@ group :development, :test do gem 'rspec-rails', '~> 3.5.1', require: false end -group :development do - gem 'dotenv-rails', '~> 2.0.0' - gem 'powder', '~> 0.3.0' - gem 'rails_best_practices', '~> 1.16.0' - gem 'spring', '~> 1.7.2' - gem 'spring-commands-rspec', '~> 1.0.4' -end group :production do gem 'airbrake', '~> 5.4.3' gem 'newrelic_rpm', '~> 3.16.0.318' +end + +group :production, :review do gem 'rails_12factor', '~> 0.0.3' end diff --git a/app.json b/app.json new file mode 100644 index 0000000..42a0665 --- /dev/null +++ b/app.json @@ -0,0 +1,55 @@ +{ + "name": "wdt-stage", + "description": "", + "scripts": { + "postdeploy": "rake db:setup" + }, + "env": { + "DATABASE_URL": { + "required": true + }, + "GITHUB_APP_NAME": { + "required": true + }, + "GITHUB_CLIENT_ID": { + "required": true + }, + "GITHUB_CLIENT_SECRET": { + "required": true + }, + "GOOGLE_MAPS_API_KEY": { + "required": true + }, + "LANG": { + "required": true + }, + "MAINTENANCE_PAGE_URL": { + "required": true + }, + "RACK_ENV": { + "required": true + }, + "RAILS_ENV": { + "required": "review" + }, + "RAILS_SERVE_STATIC_FILES": { + "required": true + }, + "SECRET_KEY_BASE": { + "generator": "secret" + } + }, + "formation": { + "web": { + "quantity": 1 + } + }, + "addons": [ + "heroku-postgresql" + ], + "buildpacks": [ + { + "url": "heroku/ruby" + } + ] +} diff --git a/config/environments/review.rb b/config/environments/review.rb new file mode 100644 index 0000000..c15015a --- /dev/null +++ b/config/environments/review.rb @@ -0,0 +1,90 @@ +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.cache_classes = true + + # Eager load code on boot. This eager loads most of Rails and + # your application in memory, allowing both threaded web servers + # and those relying on copy on write to perform better. + # Rake tasks automatically ignore this option for performance. + config.eager_load = true + + # Full error reports are disabled and caching is turned on. + config.consider_all_requests_local = false + config.action_controller.perform_caching = true + + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + + # Compress JavaScripts and CSS. + config.assets.js_compressor = :uglifier + # config.assets.css_compressor = :sass + + # Do not fallback to assets pipeline if a precompiled asset is missed. + config.assets.compile = true + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + + # Specifies the header that your server uses for sending files. + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug + + # Prepend all log lines with the following tags. + config.log_tags = [ :request_id ] + + # Use a different cache store in production. + # config.cache_store = :mem_cache_store + + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "wdt_#{Rails.env}" + config.action_mailer.perform_caching = false + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + # config.action_mailer.raise_delivery_errors = false + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners. + config.active_support.deprecation = :notify + + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false +end diff --git a/config/initializers/omniauth.rb b/config/initializers/omniauth.rb index 4d42557..2a3b163 100644 --- a/config/initializers/omniauth.rb +++ b/config/initializers/omniauth.rb @@ -4,8 +4,16 @@ config.path_prefix = '/admin/auth' end + options = { + scope: 'user:email,read:org' + } + + if Rails.env.review? + options[:redirect_uri] = "#{Rails.application.routes.url_helpers.root_url}/admin/auth/github/callback" + end + provider :github, Rails.application.secrets.github_client_id, Rails.application.secrets.github_client_secret, - scope: 'user:email,read:org' + options end From a5306639b11a35d6171483bb4b6c978cdaab7346 Mon Sep 17 00:00:00 2001 From: Ignacio Galindo Date: Wed, 17 Aug 2016 09:21:09 +0200 Subject: [PATCH 2/2] Ignore config analysis from codeclimate --- .codeclimate.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.codeclimate.yml b/.codeclimate.yml index 4112980..b8f2cec 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -30,6 +30,7 @@ exclude_paths: - app/assets/javascripts/app.js - bin/** - db/** + - config/** - public/assets/** - spec/** - UI/**