diff options
| -rw-r--r-- | Build.PL | 1 | ||||
| -rw-r--r-- | config.yml | 1 | ||||
| -rw-r--r-- | lib/jitterbug/Builder.pm | 52 | ||||
| -rw-r--r-- | public/js/common.js | 2 | ||||
| -rwxr-xr-x | scripts/capsule.sh | 2 |
5 files changed, 51 insertions, 7 deletions
@@ -24,6 +24,7 @@ my $builder = Module::Build->new( 'Dancer::Template::Xslate' => 0, 'Dancer::Plugin::DBIC' => 0, 'DBIx::Class' => 0, + 'DateTime::Format::SQLite' => 0, 'SQL::Translator' => 0, 'Digest::MD5' => 0, 'App::perlbrew' => 0, @@ -32,6 +32,7 @@ jitterbug: on_pass_from_email: donotreply@example.com on_pass_header: on_pass_footer: + reuse_repo: 1 options: perlbrew: 1 email_on_pass: 0 diff --git a/lib/jitterbug/Builder.pm b/lib/jitterbug/Builder.pm index 461945c..02c07bd 100644 --- a/lib/jitterbug/Builder.pm +++ b/lib/jitterbug/Builder.pm @@ -12,10 +12,11 @@ use Getopt::Long qw/:config no_ignore_case/; use File::Basename; use Git::Repository; use jitterbug::Schema; +use Cwd; #use Data::Dumper; local $| = 1; -use constant DEBUG => 0; +use constant DEBUG => $ENV{DEBUG} || 0; sub new { my $self = bless {} => shift; @@ -85,6 +86,7 @@ sub run_task { my $desc = JSON::decode_json( $task->commit->content ); my $conf = $self->{'conf'}; + my $buildconf = $conf->{'jitterbug'}{'build_process'}; my $project = $task->project; my $dt = DateTime->now(); @@ -98,11 +100,10 @@ sub run_task { $project->name, $task->commit->sha256, ); + my $dir = $conf->{'jitterbug'}{'build'}{'dir'}; + mkdir $dir unless -d $dir; - my $build_dir = dir( - $conf->{'jitterbug'}{'build'}{'dir'}, - $project->name, - ); + my $build_dir = dir($dir, $project->name); debug("Removing $build_dir"); rmtree($build_dir, { error => \my $err } ); @@ -110,11 +111,46 @@ sub run_task { $self->sleep(1); # avoid race conditions + my $r; my $repo = $task->project->url . '.git'; - my $r = Git::Repository->create( clone => $repo => $build_dir ); + unless ($buildconf->{reuse_repo}) { + debug("Removing $build_dir"); + rmtree($build_dir, { error => \my $err } ); + warn @$err if @$err; + $r = Git::Repository->create( clone => $repo => $build_dir ); + } else { + # If this is the first time, the repo won't exist yet + debug("build_dir = $build_dir"); + if( -d $build_dir ){ + my $pwd = getcwd; + chdir $build_dir; + # TODO: Error Checking + debug("Cleaning git repo"); + system("git clean -dfx"); + debug("Fetching new commits into $repo"); + system("git fetch"); + debug("Checking out correct commit"); + system("git checkout " . $task->commit->sha256 ); + chdir $pwd; + $r = Git::Repository->new( work_tree => $build_dir ); + } else { + debug("Creating new repo"); + my $pwd = getcwd; + debug("pwd=$pwd"); + chdir $build_dir; + system("git clone $repo $build_dir"); + #$r = Git::Repository->create( clone => $repo => $build_dir ); + chdir $pwd; + } + } + $self->sleep(1); # avoid race conditions debug("Checking out " . $task->commit->sha256 . " from $repo into $build_dir\n"); - $r->run( 'checkout', $task->commit->sha256 ); + # $r->run( 'checkout', $task->commit->sha256 ); + my $pwd = getcwd; + chdir $build_dir; + system("git checkout " . $task->commit->sha256 ); + chdir $pwd; my $builder = $conf->{'jitterbug'}{'projects'}{$project->name}{'builder'} || $conf->{'jitterbug'}{'build_process'}{'builder'}; @@ -144,6 +180,8 @@ sub run_task { while (<$fh>){ $lines .= $_; } + # if $result is undefined, either there was a build failure + # or the test output is not from a TAP harness ($result) = $lines =~ /Result:\s(\w+)/; my ( $name, ) = basename($version); $name =~ s/\.txt//; diff --git a/public/js/common.js b/public/js/common.js index 646f80e..93c080a 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -4,6 +4,7 @@ $(document).ready(function() { var class = "#commits-day-" + day; $(class).toggle(); }); + /* This times out on large test outputs $('.builds a').click(function() { var url = $(this).attr("href"); var id = $(this).parents('.commit').attr('id'); @@ -12,4 +13,5 @@ $(document).ready(function() { }); return false; }) + */ }) diff --git a/scripts/capsule.sh b/scripts/capsule.sh index 30c3877..9fca79e 100755 --- a/scripts/capsule.sh +++ b/scripts/capsule.sh @@ -20,6 +20,8 @@ function jitterbug_build () { perl Build.PL >> $logfile 2>&1 # ./Build installdeps is not available in older Module::Build's cpanm --installdeps . >> $logfile 2>&1 + # Run this again in case our Build is out of date (suboptimal) + perl Build.PL >> $logfile 2>&1 HARNESS_VERBOSE=1 ./Build test --verbose >> $logfile 2>&1 elif [ -f 'Makefile.PL' ]; then echo "Found Makefile.PL" |
