cover.pl (1026B)
1 #!/usr/bin/env perl 2 3 use strict; 4 use warnings; 5 use feature 'say'; 6 7 use AWS::S3; 8 use Path::Tiny; 9 10 if (!@ARGV) { 11 die "Need to specify a build number to check coverage for.\n"; 12 } 13 14 my $build = shift; 15 my $base = qr!^[^/]+/sbotools/\Q$build\E/!; 16 17 if ( 18 ! length($ENV{S3_ID}) or 19 ! length($ENV{S3_KEY}) or 20 ! length($ENV{S3_BUCKET})) { 21 die "S3_ID and S3_KEY need to be defined in the environment.\n"; 22 } 23 24 print "Connecting to S3...\n"; 25 26 my $s3 = AWS::S3->new( 27 access_key_id => $ENV{S3_ID}, 28 secret_access_key => $ENV{S3_KEY}, 29 ); 30 31 my $bucket = $s3->bucket($ENV{S3_BUCKET}); 32 33 my $f_iter = $bucket->files( 34 page_size => 100, 35 page_number => 1, 36 pattern => qr!$base\Q$build.11\E/!, 37 ); 38 39 my $num = 0; 40 while (my @files = $f_iter->next_page) { 41 for my $file (@files) { 42 $num++; 43 print $file->key, "\n"; 44 45 my $local_fname = $file->key =~ s!$base!cover_db/!r; 46 my $path = path($local_fname)->absolute(); 47 48 $path->touchpath->spew_raw(${ $file->contents() }); 49 } 50 } 51 52 if ($num == 0) { 53 die "No files found for build number $build.\n"; 54 }