From 6465818b7c63204d54175c57906eacaa28ca5ec5 Mon Sep 17 00:00:00 2001 From: fonglh Date: Thu, 25 Oct 2018 15:08:34 +0800 Subject: [PATCH] Upload Capybara screenshots to S3 in the CI environment. --- Gemfile | 1 + Gemfile.lock | 17 +++++++++++++++++ spec/rails_helper.rb | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+) diff --git a/Gemfile b/Gemfile index 19c925913fb..4eb2569ba1e 100644 --- a/Gemfile +++ b/Gemfile @@ -116,6 +116,7 @@ group :test do gem 'capybara-selenium' gem 'chromedriver-helper' + gem 'aws-sdk-s3' # Make screen shots in tests, helps with the debugging of JavaScript tests. gem 'capybara-screenshot' end diff --git a/Gemfile.lock b/Gemfile.lock index 53e0982beb9..2ac00c059be 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -137,6 +137,21 @@ GEM autoprefixer-rails (9.4.4) execjs awesome_print (1.8.0) + aws-eventstream (1.0.1) + aws-partitions (1.106.0) + aws-sdk-core (3.35.0) + aws-eventstream (~> 1.0) + aws-partitions (~> 1.0) + aws-sigv4 (~> 1.0) + jmespath (~> 1.0) + aws-sdk-kms (1.11.0) + aws-sdk-core (~> 3, >= 3.26.0) + aws-sigv4 (~> 1.0) + aws-sdk-s3 (1.23.0) + aws-sdk-core (~> 3, >= 3.26.0) + aws-sdk-kms (~> 1) + aws-sigv4 (~> 1.0) + aws-sigv4 (1.0.3) baby_squeel (1.3.1) activerecord (>= 4.2.0) join_dependency (~> 0.1.2) @@ -283,6 +298,7 @@ GEM jbuilder (2.8.0) activesupport (>= 4.2.0) multi_json (>= 1.2) + jmespath (1.4.0) join_dependency (0.1.4) activerecord (>= 4.2.0) jquery-rails (4.3.3) @@ -548,6 +564,7 @@ DEPENDENCIES acts_as_tenant after_commit_action autoprefixer-rails + aws-sdk-s3 baby_squeel bootstrap-sass bootstrap-sass-extras (>= 0.0.7)! diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index a80a8d9a6f3..f90cdd63b39 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -59,4 +59,22 @@ # Old school have_tag, with_tag(and more) matchers for rspec 3 config.include RSpecHtmlMatchers + + # Upload Capybara screenshots to S3 in CI + if ENV['CI'] + Capybara::Screenshot.s3_configuration = { + s3_client_credentials: { + access_key_id: ENV['CAPYBARA_SCREENSHOT_ACCESS_KEY_ID'], + secret_access_key: ENV['CAPYBARA_SCREENSHOT_SECRET_ACCESS_KEY'], + region: ENV['CAPYBARA_SCREENSHOT_REGION'] + }, + bucket_name: ENV['CAPYBARA_SCREENSHOT_BUCKET_NAME'] + } + + Capybara::Screenshot.s3_object_configuration = { + acl: 'public-read' + } + + Capybara::Screenshot.prune_strategy = { keep: 10 } + end end