Skip to content

Instantly share code, notes, and snippets.

@vincentpaca
Last active January 21, 2016 06:07
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vincentpaca/667672d546105d5b9825 to your computer and use it in GitHub Desktop.
S3 concat
require 'aws-sdk'
s3 = Aws::S3::Resource.new(region: ENV['AWS_REGION'])
rspec_bucket = s3.bucket(ENV['RSPEC_BUCKET'])
cukes_bucket = s3.bucket(ENV['CUKES_BUCKET'])
rspec_objects = rspec_bucket.objects(prefix: ENV['CI_BUILD_NUMBER'])
cukes_objects = cukes_bucket.objects(prefix: ENV['CI_BUILD_NUMBER'])
test_group_threshold = ENV['TEST_GROUPS'].to_i
# When the number of logs fall below the test group threshold set above,
# use the logs from the init folder instead
rspec_logs = unless rspec_objects.count < test_group_threshold
puts "Using logs from #{ENV['CI_BUILD_NUMBER']} bucket..."
rspec_objects
else
puts "Using logs from #{ENV['LOG_INIT_BUCKET']} bucket..."
rspec_bucket.objects(prefix: ENV['LOG_INIT_BUCKET'])
end
# When the number of logs fall below the test group threshold set above,
# use the logs from the init folder instead
cukes_logs = unless cukes_objects.count < test_group_threshold
puts "Using logs from #{ENV['CI_BUILD_NUMBER']} bucket..."
cukes_objects
else
puts "Using logs from #{ENV['LOG_INIT_BUCKET']} bucket..."
cukes_bucket.objects(prefix: ENV['LOG_INIT_BUCKET'])
end
File.open(ENV['RSPEC_LOG_PATH'], 'wb') do |file|
rspec_logs.each do |obj|
file << obj.get.body.read
end
end
File.open(ENV['CUCUMBER_LOG_PATH'], 'wb') do |file|
cukes_logs.each do |obj|
file << obj.get.body.read
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment