-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmoke.pl
249 lines (205 loc) · 6.65 KB
/
smoke.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/usr/bin/env perl
use strict;
use warnings;
# first attempt to build a smoke client for padre
# install WWW::Mechanize and TAP::Harness::Archive,
# install MIME::Lite
# fetch the smolder_smoke_signal script from the Smolder package
# and put it in the PATH
# TODO: check out App-Smolder-Report or Create Smolder::Client
# TODO: include the plugins as well in the smoking
# these two are actually needed externally but we load
# them here now to make sure the user does not forget to install them
use TAP::Harness::Archive;
use WWW::Mechanize;
use Capture::Tiny qw(capture_merged);
use Data::Dumper qw(Dumper);
use Getopt::Long qw(GetOptions);
use MIME::Lite;
my $path;
my $help;
my $sleep;
my $force;
my $verbose;
my $to;
my $display = 0;
#my $smolder;
my $all;
GetOptions(
'path=s' => \$path,
'to=s' => \$to,
'help' => \$help,
'sleep=s' => \$sleep,
'force' => \$force,
'verbose' => \$verbose,
'all' => \$all,
# 'smolder=s' => \$smolder,
) or usage();
usage() if $help;
usage('Needs --path') if not $path;
usage('Needs --to') if not $to;
#usage('Needs --smolder') if not $smolder;
my %MAIL = (
adamk => '[email protected]',
Sewi => '[email protected]',
waxhead => '[email protected]',
# adamk => '[email protected]',
# Sewi => '[email protected]',
# waxhead => '[email protected]',
);
if ($all) {
$ENV{AUTOMATED_TESTING} = 1;
$ENV{RELEASE_TESTING} = 1;
}
chdir $path;
#open my $fh, '<', 'smoke.conf' or usage("Need to have a smoke.conf");
#my $username = <$fh>;
#my $password = <$fh>;
#chomp $username;
#chomp $password;
my $SVN = 'svn';
my $MAKE = $^O =~ /Win32/i ? 'dmake' : 'make';
my $platform = $^O;
my $output;
while (1) {
print "\n";
print scalar localtime;
$output = '';
my ( $old_rev, $old_author ) = svn_revision();
my @diff = qx{$SVN diff -rHEAD};
my $status = '';
if ( @diff or $force ) {
print " - running\n";
#print "status @diff";
system "$MAKE realclean";
_system("$SVN up");
my ( $rev, $author ) = svn_revision();
if ( $rev == $old_rev and not $force ) {
$output .= "\n\nSome serious trouble as we could not update from SVN (rev $rev)\n";
$status = "FAIL - could not update svn";
next; # Let's not send an e-mail now
}
if ( not $status ) {
my $make_out = _system("$^X Makefile.PL");
if ( $make_out =~ /Warning: prerequisite (.*)/ ) {
$output = "\n\nThere seem to be at least one missing prerequisite:\n$1";
$output .= "\n\nThere might be more missing\n";
$status = "FAIL - missing prereq";
# TODO, list al the missing prereqs
}
}
if ( not $status ) {
_system($MAKE);
}
if ( not $status ) {
my $file = 'tap.tar.gz';
unlink $file;
my $test_out = _system("prove --merge -ba $file t/ xt/");
#my $test_out = "FAIL";
if ( $test_out =~ /Result: FAIL|FAILED|Bailout called/ ) {
$status = "FAIL - testing";
} elsif ( not $display ) {
if ( $^O ne 'MSWin32' && defined( $ENV{DISPLAY} ) ) {
$output .= "\n***Turn off DISPLAY for packagers disttest-ing.\n";
# DISPLAY is turned off here to make sure disttest runs without it for various packagers ( such a Fedora )
# which require tests to pass, so any tests that fail here complaining it's needs a DISPLAY variable set
# needs to be updated with a check for DISPLAY and skip when missing.
require Env::Sanctify;
my $sanctify = Env::Sanctify->sanctify( sanctify => ['DISPLAY'] );
my $nodisplay_test_out = _system("prove -b t/ xt/");
$sanctify->restore();
if ( $nodisplay_test_out =~ /Result: FAIL|FAILED|Bailout called|Error/ ) {
$status = "FAIL - testing";
}
}
}
#_system("$^X $smolder --server smolder.plusthree.com --username $username --password $password --file $file --project Padre --revision $rev --platform $platform");
#$output .= "\nReports are at http://smolder.plusthree.com/app/public_projects/smoke_reports/11\n";
}
$status ||= "SUCCESS";
send_message( $rev, $author, "rev $rev - $platform - $status", $output );
} else {
print " - skipping\n";
}
} continue {
last if not $sleep;
sleep $sleep;
$force = 0;
}
sub svn_revision {
#my ($rev) = map {/(\d+)/} grep {/^Last Changed Rev:/} qx{$SVN info};
my @info = qx{$SVN info};
my ($rev) = map {/(\d+)/} grep {/^Revision:/} @info;
my ($author) = map {/:\s*(\w+)/} grep {/^Last Changed Author:/} @info;
return ( $rev, $author );
}
sub _system {
my $cmd = shift;
# Let's not send out the password of the smoke server to the mailing list
if ( $cmd !~ /--password/ ) {
$output .= "\n\n$cmd\n\n";
}
print "$cmd\n" if $verbose;
my $out = capture_merged { system $cmd; };
#print $out if $verbose;
$output .= $out;
return $out;
}
sub send_message {
my ( $rev, $author, $status, $text ) = @_;
my %message = (
From => "<svn\@perlide.org>",
To => $to,
Subject => "Padre Smoke test $status",
Type => 'multipart/mixed',
);
if ( $MAIL{$author} ) {
$message{CC} = $MAIL{$author};
}
#print Dumper \%message;
my $msg = MIME::Lite->new(%message);
$msg->attach(
Type => 'TEXT',
Data => $text,
);
# when there is no connection this call throws an exception
# don't let it ruin the next party...
eval { $msg->send( 'smtp', 'mail.perlide.org', Debug => 0 ); };
if ($@) {
warn $@;
}
return;
}
sub usage {
my $msg = shift;
if ($msg) {
print "\nERROR: $msg\n\n";
}
print <<"END";
Usage: $0
--path PATH/TO/SVN/DIR
--to EMAIL where to send the report (e.g. gabor\@perl.org.il or padre-commit\@perlide.org)
--help this help
--sleep N after each run sleep N and then rerun (without this runs only once)
--force force a build and report even if there were no changes (for the first run only)
--verbose print output to screen
--all Enable AUTOMATED_TESTING and RELEASE_TESTING
Setup:
Install command line Subversion client.
(For windows download it from http://www.collab.net/downloads/subversion/
where free registration required)
Manually check out the svn repository of Padre:
svn co https://github.com/PadreIDE/Padre
Make sure all the prereqisites are installed
Then you can run this script with --path pointing to the Padre directory,
--to being your e-mail
provide --sleep 60 if you would like to have the script executed every 60 second
END
exit;
}
# --smolder PATH path to the smolder_smoke_signal script
# In the new Padre/ directory create file called smoke.conf with
# your username and password on http://smolder.plusthree.com/ in the file
# Make sure they are associated with the Padre project on that smolder installation
# username
# password