diff --git a/Gemfile b/Gemfile index 1729301f..0195fe79 100644 --- a/Gemfile +++ b/Gemfile @@ -12,6 +12,7 @@ gem "amazing_print", "~> 1.5" gem "aws-sdk-s3", "~> 1.8", require: false gem "baseline", github: "fastruby/baseline" gem "bootsnap", "~> 1.17", require: false +gem "coverband", "~> 6.1" gem "bootstrap", "~> 5.3.3" gem "cgi" gem "dartsass-rails", "~> 0.5" diff --git a/Gemfile.lock b/Gemfile.lock index e41b2c11..decdc7ef 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -129,6 +129,9 @@ GEM choice (0.2.0) concurrent-ruby (1.3.5) connection_pool (2.5.4) + coverband (6.2.0) + base64 + redis (>= 3.0) crack (1.0.0) bigdecimal rexml @@ -449,6 +452,7 @@ DEPENDENCIES bootsnap (~> 1.17) bootstrap (~> 5.3.3) cgi + coverband (~> 6.1) dartsass-rails (~> 0.5) database_cleaner-active_record dotenv (~> 3.1.2) diff --git a/Gemfile.next.lock b/Gemfile.next.lock index 69498936..f56402c4 100644 --- a/Gemfile.next.lock +++ b/Gemfile.next.lock @@ -131,6 +131,9 @@ GEM choice (0.2.0) concurrent-ruby (1.3.5) connection_pool (2.5.4) + coverband (6.2.0) + base64 + redis (>= 3.0) crack (1.0.0) bigdecimal rexml @@ -454,6 +457,7 @@ DEPENDENCIES bootsnap (~> 1.17) bootstrap (~> 5.3.3) cgi + coverband (~> 6.1) dartsass-rails (~> 0.5) database_cleaner-active_record dotenv (~> 3.1.2) diff --git a/config/initializers/coverband.rb b/config/initializers/coverband.rb new file mode 100644 index 00000000..558ccdbc --- /dev/null +++ b/config/initializers/coverband.rb @@ -0,0 +1,9 @@ +Coverband.configure do |config| + config.store = Coverband::Adapters::RedisStore.new( + Redis.new(url: ENV["REDIS_URL"], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE }) + ) + config.track_views = true + config.background_reporting_enabled = true + config.web_enable_clear = true + config.ignore = %w[config/boot.rb config/environment.rb config/puma.rb bin/] +end diff --git a/config/routes.rb b/config/routes.rb index 23f49094..aace51f9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ require "sidekiq/web" require "sidekiq-scheduler/web" +require "coverband" if Rails.env.production? Sidekiq::Web.use Rack::Auth::Basic do |username, password| @@ -9,10 +10,19 @@ }.map { ActiveSupport::SecurityUtils.secure_compare _1, ENV.fetch(_2) } .all? end + + Coverband::Reporters::Web.use Rack::Auth::Basic do |username, password| + { + username => "COVERBAND_USERNAME", + password => "COVERBAND_PASSWORD" + }.map { ActiveSupport::SecurityUtils.secure_compare _1, ENV.fetch(_2) } + .all? + end end Rails.application.routes.draw do mount Sidekiq::Web => "sidekiq" + mount Coverband::Reporters::Web.new, at: "/coverband" get '/sitemap.xml', to: 'sitemaps#show' get "/robots.txt" => "static#robots"