diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/build-failed.sh | 11 | ||||
-rw-r--r-- | scripts/builder.pl | 77 | ||||
-rwxr-xr-x | scripts/capsule.sh | 69 |
3 files changed, 60 insertions, 97 deletions
diff --git a/scripts/build-failed.sh b/scripts/build-failed.sh index bddf4d0..ebd098a 100755 --- a/scripts/build-failed.sh +++ b/scripts/build-failed.sh @@ -1,11 +1,14 @@ COMMITER=$1 -MESSAGE=$2 -OUTPUT=$3 -SHA=$4 +PROJECT=$2 +MESSAGE=$3 +OUTPUT=$4 +SHA=$5 +CC_EMAIL=$6 echo " Message: $MESSAGE +Test Output: $OUTPUT -" | mail -s "[jitterbug] BUILD FAILED $SHA" --to $COMMITER +" | mail -c "$CC_EMAIL" -s "[jitterbug] FAIL $PROJECT @ $SHA" $COMMITER diff --git a/scripts/builder.pl b/scripts/builder.pl index fba8147..8b7ee2c 100644 --- a/scripts/builder.pl +++ b/scripts/builder.pl @@ -1,80 +1,9 @@ -#!/usr/bin/env perl +#!/usr/bin/perl use strict; use warnings; -use JSON; -use YAML qw/LoadFile Dump/; -use File::Spec; -use File::Path qw/rmtree/; -use File::Basename; -use Git::Repository; -use jitterbug::Schema; +use jitterbug::Builder; -$|++; +exit jitterbug::Builder->new->run; -my $conf_file = shift || die "config.yml is missing"; -my $conf = LoadFile($conf_file); -my $dbix_conf = $conf->{plugins}->{DBIC}->{schema}; -my $schema = jitterbug::Schema->connect( @{ $dbix_conf->{connect_info} } ); -my $interval = $conf->{jitterbug}->{builder}->{sleep} || 30; - -while (1) { - my $task = $schema->resultset('Task')->search()->single(); - - unless ($task) { - sleep $interval; - next; - } - - my $desc = JSON::decode_json($task->commit->content); - $desc->{build}->{start_time} = time(); - - my $report_path = File::Spec->catdir( $conf->{jitterbug}->{reports}->{dir}, - $task->project->name, $task->commit->sha256 ); - my $build_dir = File::Spec->catdir( $conf->{jitterbug}->{build}->{dir}, - $task->project->name ); - - my $repo = $task->project->url . '.git'; - my $r = Git::Repository->create( clone => $repo => $build_dir ); - $r->run( 'checkout', $task->commit->sha256 ); - - my $builder = $conf->{jitterbug}->{build_process}->{builder}; - my $res = `$builder $build_dir $report_path`; - - rmtree($build_dir); - - $desc->{build}->{end_time} = time(); - - my @versions = glob( $report_path . '/*' ); - foreach my $version (@versions) { - open my $fh, '<', $version; - my ($result, $lines); - while (<$fh>){ - $lines .= $_; - } - ($result) = $lines =~ /Result:\s(\w+)/; - my ( $name, ) = basename($version); - $name =~ s/\.txt//; - if ( !$result || ($result && $result !~ /PASS/ )) { - # mail author of the commit - $result = "FAIL"; - my $message = $desc->{message}; - my $commiter = $desc->{author}->{email}; - my $output = "Build failed"; - my $sha = $desc->{id}; - my $on_failure = - $conf->{jitterbug}->{build_process}->{on_failure}; - `$on_failure $commiter $message $output $sha`; - } - $desc->{build}->{version}->{$name} = $result; - close $fh; - } - - $task->commit->update({ - content => JSON::encode_json($desc), - }); - $task->delete(); - warn "done\n"; - sleep 5; -} diff --git a/scripts/capsule.sh b/scripts/capsule.sh index 1977313..abc632d 100755 --- a/scripts/capsule.sh +++ b/scripts/capsule.sh @@ -3,31 +3,62 @@ # first arg: build_dir # second arg: report path +function jitterbug_build () { + if [ -f 'dist.ini' ]; then + echo "Found dist.ini, using Dist::Zilla" + dzil authordeps | cpanm + cpanm --installdeps . + HARNESS_VERBOSE=1 dzil test >> $logfile 2>&1 + elif [ -f 'Build.PL' ]; then + echo "Found Build.PL, using Build.PL" + perl Build.PL + # ./Build installdeps is not available in older Module::Build's + cpanm --installdeps . + HARNESS_VERBOSE=1 ./Build test --verbose >> $logfile 2>&1 + elif [ -f 'Makefile.PL' ]; then + echo "Found Makefile.PL" + perl Makefile.PL + cpanm --installdeps . + HARNESS_VERBOSE=1 make test >> $logfile 2>&1 + elif [ -f 'setup.pir' ]; then + echo "Found setup.pir" + HARNESS_VERBOSE=1 parrot setup.pir test >> $logfile 2>&1 + elif [ -f 'setup.nqp' ]; then + echo "Found setup.nqp" + HARNESS_VERBOSE=1 parrot-nqp setup.nqp test >> $logfile 2>&1 + elif [ -f 'Configure.pl' ]; then + echo "Found Configure.pl" + perl Configure.pl + cpanm --installdeps . + HARNESS_VERBOSE=1 make test >> $logfile 2>&1 + fi +} + +# this is getting smelly builddir=$1 report_path=$2 +perlbrew=$3 +echo "Creating report_path=$report_path" mkdir -p $report_path cd $builddir -source $HOME/perl5/perlbrew/etc/bashrc - -for perl in $HOME/perl5/perlbrew/perls/perl-5.* -do - theperl="$(basename $perl)" - perlbrew switch $theperl +if [ $use_perlbrew ]; then + source $HOME/perl5/perlbrew/etc/bashrc + for perl in $HOME/perl5/perlbrew/perls/perl-5.* + do + theperl=$(perl -e 'print $^V') + logfile="$report_path/perl-$theperl.txt" - perlversion=$(perl -v) - logfile="$report_path/$theperl.txt" + echo ">perlbrew switch $theperl" + perlbrew switch $theperl + # TODO: check error condition - if [ -f 'dist.ini' ]; then - dzil authordeps | cpanm - cpanm --installdeps . - HARNESS_VERBOSE=1 dzil test >> $logfile 2>&1 - else - perl Makefile.PL - cpanm --installdeps . - make - HARNESS_VERBOSE=1 make test >> $logfile 2>&1 - fi -done + jitterbug_build + done +else + theperl=$(perl -e 'print $^V') + logfile="$report_path/perl-$theperl.txt" + jitterbug_build +fi |