From f1eb6aadd89a9479e6e8860503b4c9e0e25700cf Mon Sep 17 00:00:00 2001 From: EDWIN PHILIP <38521046+EdwinPhilip@users.noreply.github.com> Date: Mon, 11 Mar 2024 10:37:08 +0000 Subject: [PATCH] update cache_files_list to list file only for specific test_suit_id --- lib/rspec_tracer/remote_cache/aws.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/rspec_tracer/remote_cache/aws.rb b/lib/rspec_tracer/remote_cache/aws.rb index 82ab149..065029d 100644 --- a/lib/rspec_tracer/remote_cache/aws.rb +++ b/lib/rspec_tracer/remote_cache/aws.rb @@ -8,6 +8,8 @@ class AwsError < StandardError; end def initialize @s3_bucket, @s3_path = setup_s3 @aws_cli = RSpecTracer.use_local_aws ? 'awslocal' : 'aws' + @use_test_suite_id_cache = ENV['USE_TEST_SUITE_ID_CACHE'] == 'true' + @test_suite_id = ENV['TEST_SUITE_ID'] if @use_test_suite_id_cache end def branch_refs?(branch_name) @@ -60,7 +62,11 @@ def upload_branch_refs(branch_name, file_name) end def cache_files_list(ref) - prefix = "s3://#{@s3_bucket}/#{@s3_path}/#{ref}/" + if @use_test_suite_id_cache && !@test_suite_id.nil? + prefix = "s3://#{@s3_bucket}/#{@s3_path}/#{ref}/#{@test_suite_id}/" + else + prefix = "s3://#{@s3_bucket}/#{@s3_path}/#{ref}/" + end `#{@aws_cli} s3 ls #{prefix} --recursive`.chomp.split("\n") end