4 # $Id: send_tr_reports.pl,v 1.10 2010/09/03 20:48:26 eserte Exp $
7 # Copyright (C) 2008 Slaven Rezic. All rights reserved.
8 # This program is free software; you can redistribute it and/or
9 # modify it under the same terms as Perl itself.
11 # Mail: slaven@rezic.de
12 # WWW: http://www.rezic.de/eserte/
18 use Metabase
::Resource
::cpan
::distfile
;
22 my $opt_transport_uri;
23 GetOptions
("mail" => \
$use_mail,
24 "transport-uri=s" => \
$opt_transport_uri,
26 or die "usage: $0 [--mail] [--transport-uri=TRANSPORT-URI]";
28 $opt_transport_uri //= 'https://metabase.cpantesters.org/api/v1/';
29 my $reportdir = shift || "$ENV{HOME}/var/ctr";
31 my $sync_dir = "$reportdir/sync";
32 my $done_dir = "$reportdir/done";
33 my $process_dir = "$reportdir/process";
34 my $quarantine_dir = "$reportdir/quarantine";
37 warn "Create $sync_dir and move reports to this directory...";
39 for my $dir ($done_dir, $process_dir, $quarantine_dir) {
41 mkdir $dir or die "While creating $dir: $!";
45 my @files = map { $_->[0] }
46 sort { $b->[1] <=> $a->[1] }
48 glob("$sync_dir/pass.*.rpt"),
49 glob("$sync_dir/unknown.*.rpt"),
50 glob("$sync_dir/na.*.rpt"),
51 glob("$sync_dir/fail.*.rpt"),
53 FILE
: for my $filei (0..$#files) {
54 my $file = $files[$filei];
55 warn "File $file does not exist anymore?", next if !-r
$file;
56 warn sprintf "[%d/%d;%.4f]%s\n", 1+$filei, scalar @files, -M
$file, $file;
57 my $quarantine_file = $quarantine_dir . "/" . basename
($file);
58 if ($file =~ m
|/pass\
.-0\
.01\
.|) {
59 warn "skipping to avoid a CPAN::DistnameInfo bug (# 72512)";
60 rename $file, $quarantine_file or die "Could not rename...: $!";
64 open my $fh, $file or die "Could not open '$file': $!";
68 next unless /X-Test-Reporter-Distfile:\s*(\S+)/;
73 my $result = eval { Metabase
::Resource
::cpan
::distfile
->_validate_distfile($vdistro) };
75 warn "skipping to avoid killing the toolchain (see 2012-10-20 in 'upgradeadventures')";
76 rename $file, $quarantine_file or die "Could not rename...: $!";
81 my $process_file = $process_dir . "/" . basename
($file);
82 rename $file, $process_file
83 or die "Cannot move $file to $process_file: $!";
87 @tr_args = (from
=> "srezic\@cpan.org",
88 transport
=> "Net::SMTP",
92 @tr_args = (transport
=> 'Metabase',
94 uri
=> $opt_transport_uri,
95 id_file
=> '/home/sand/.metabase/id.json',
99 my $r = Test
::Reporter
->new(@tr_args)->read($process_file);
101 $r->{_subject
} =~ s{\n}{}g;
103 warn sprintf "Alert: renaming '$process_file' to '$file' for further considerations";
104 rename $process_file, $file or warn "Could not rename back: $!";
105 die "Alert: error while running $^X $0 against $file: " . $r->errstr . ". Stop.\n";
107 my $done_file = $done_dir . "/" . basename
($file);
108 rename $process_file, $done_file
109 or die "Cannot move $process_file to $done_file: $!";
116 See CPAN/CPAN::Reporter configuration below:
118 The good (non-fail) reports. On the windows machine
121 cd /cygdrive/c/Users/eserte/ctr
122 ls sync/* && echo "sync is not empty" || mv *.rpt sync/
123 rsync -v -a sync/*.rpt eserte@biokovo:var/ctr/new/ && mv sync/*.rpt done/
127 ctr_good_or_invalid.pl
130 Now review the fail reports on the windows machine. Invalid ones move
131 to the invalid/ subdirectory.
133 =head1 CPAN::REPORTER CONFIGURATION
135 In /cygdrive/c/Users/eserte/Documents/.cpanreporter/config.ini:
137 edit_report=default:no
138 email_from=srezic@cpan.org
139 send_report=default:yes
140 transport=File C:\Users\eserte\ctr
142 Basically the same configuration can be used for cygwin
143 ~/.cpanreporter/config.ini, just use the cygwin path style for the
146 edit_report=default:no
147 email_from=srezic@cpan.org
148 send_report=default:yes
149 transport=File /cygdrive/c/Users/eserte/ctr