From 80a2350a0aaec471477cf9413f68f4b2fe29eaaa Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 12 Nov 2008 11:09:21 +0000 Subject: [PATCH] --- .../lib/HydraFrontend/Controller/Root.pm | 25 ++++++++++ src/HydraFrontend/root/build.tt | 13 ++++- src/HydraFrontend/root/job.tt | 14 ++++-- src/HydraFrontend/root/project.tt | 48 +++++++++++++++++-- src/build.pl | 29 +++++++++-- src/runner.pl | 2 +- 6 files changed, 114 insertions(+), 17 deletions(-) diff --git a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm index b68aa9ff..3afdbe55 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm @@ -46,9 +46,32 @@ sub index :Path :Args(0) { sub project :Local { my ( $self, $c, $projectName ) = @_; $c->stash->{template} = 'project.tt'; + (my $project) = $c->model('DB::Projects')->search({ name => $projectName }); return error($c, "Project $projectName doesn't exist.") if !defined $project; + $c->stash->{project} = $project; + $c->model('DB::Builds')->search({project => $projectName}, {join => 'resultInfo', select => {sum => 'starttime'}}); + + $c->stash->{finishedBuilds} = $c->model('DB::Builds')->search( + {project => $projectName, finished => 1}); + + $c->stash->{succeededBuilds} = $c->model('DB::Builds')->search( + {project => $projectName, finished => 1, buildStatus => 0}, + {join => 'resultInfo'}); + + $c->stash->{scheduledBuilds} = $c->model('DB::Builds')->search( + {project => $projectName, finished => 0}); + + $c->stash->{busyBuilds} = $c->model('DB::Builds')->search( + {project => $projectName, finished => 0, busy => 1}, + {join => 'schedulingInfo'}); + + $c->stash->{totalBuildTime} = $c->model('DB::Builds')->search( + {project => $projectName}, + {join => 'resultInfo', select => {sum => 'stoptime - starttime'}, as => ['sum']}) + ->first->get_column('sum'); + $c->stash->{jobNames} = [$c->model('DB::Builds')->search({project => $projectName}, {select => [{distinct => 'attrname'}], as => ['attrname']})]; } @@ -81,6 +104,8 @@ sub build :Local { $c->stash->{build} = $build; $c->stash->{id} = $id; + $c->stash->{curTime} = time; + if (!$build->finished && $build->schedulingInfo->busy) { my $logfile = $build->schedulingInfo->logfile; $c->stash->{logtext} = `cat $logfile`; diff --git a/src/HydraFrontend/root/build.tt b/src/HydraFrontend/root/build.tt index 09838701..8ef44b8e 100644 --- a/src/HydraFrontend/root/build.tt +++ b/src/HydraFrontend/root/build.tt @@ -140,7 +140,7 @@ - + [% FOREACH step IN build.buildsteps -%] @@ -149,6 +149,13 @@ +
NrWhatStatus
NrWhatDurationStatus
Build of [% step.outpath %] + [% IF step.busy == 0 %] + [% step.stoptime - step.starttime %]s + [% ELSE %] + [% curTime - step.starttime %]s + [% END %] + [% IF step.busy == 1 %] Building @@ -202,6 +209,8 @@ [% END %] +[% IF build.buildlogs %] +

Logs

@@ -213,6 +222,8 @@ [% END -%]
+[% END %] + [% IF build.dependents %] diff --git a/src/HydraFrontend/root/job.tt b/src/HydraFrontend/root/job.tt index bebc0d4d..62d6aa8b 100644 --- a/src/HydraFrontend/root/job.tt +++ b/src/HydraFrontend/root/job.tt @@ -2,11 +2,15 @@

All builds for job [% projectName %]:[% jobName %]

- - - [% FOREACH build IN builds -%] - [% INCLUDE "short-build-info.tt" %] - [% END -%] +
IdProjectJobSystemTimestampDescription
+ + + + + [% FOREACH build IN builds -%] + [% INCLUDE "short-build-info.tt" %] + [% END -%] +
IdProjectJobSystemTimestampDescription
[% END %] diff --git a/src/HydraFrontend/root/project.tt b/src/HydraFrontend/root/project.tt index 2aed2db0..2efc06bc 100644 --- a/src/HydraFrontend/root/project.tt +++ b/src/HydraFrontend/root/project.tt @@ -9,11 +9,20 @@

Jobset [% jobset.name %]

-

- Description: [% jobset.description %] -
- Nix expression: [% jobset.nixexprpath %] in input [% jobset.nixexprinput %] -

+

Information

+ + + + + + + + + + +
Description:[% jobset.description %]
Nix expression:[% jobset.nixexprpath %] in input [% jobset.nixexprinput %]
+ +

Inputs

@@ -50,5 +59,34 @@ +

Statistics

+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Finished builds:[% finishedBuilds %]
Succeeded builds:[% succeededBuilds %]
Failed builds:[% finishedBuilds - succeededBuilds %]
Total build time:[% totalBuildTime %]s
Scheduled builds:[% scheduledBuilds %]
Currently executing builds:[% busyBuilds %]
+ [% END %] diff --git a/src/build.pl b/src/build.pl index 08e71d17..3436e4d3 100644 --- a/src/build.pl +++ b/src/build.pl @@ -59,6 +59,7 @@ sub doBuild { , outpath => $2 , logfile => $4 , busy => 1 + , starttime => time }); }); } @@ -71,6 +72,7 @@ sub doBuild { die unless $step; $step->busy(0); $step->status(0); + $step->stoptime(time); $step->update; }); } @@ -80,11 +82,28 @@ sub doBuild { my $drvPath = $1; (my $step) = $db->resultset('Buildsteps')->search( {id => $build->id, type => 0, drvpath => $drvPath}, {}); - die unless $step; - $step->busy(0); - $step->status(1); - $step->errormsg($4); - $step->update; + if ($step) { + die unless $step; + $step->busy(0); + $step->status(1); + $step->errormsg($4); + $step->stoptime(time); + $step->update; + } else { + $db->resultset('Buildsteps')->create( + { id => $build->id + , stepnr => $buildStepNr++ + , type => 0 # = build + , drvpath => $drvPath + , outpath => $2 + , logfile => $4 + , busy => 0 + , status => 1 + , starttime => time + , stoptime => time + , errormsg => $4 + }); + } }); } } diff --git a/src/runner.pl b/src/runner.pl index 438de2c9..e9e266e8 100644 --- a/src/runner.pl +++ b/src/runner.pl @@ -90,5 +90,5 @@ while (1) { warn $@ if $@; print "sleeping...\n"; - sleep(10); + sleep(5); }