From d6f71f224810a812886e2b726fbeedafa2ba3132 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 27 Nov 2008 18:27:19 +0000 Subject: [PATCH] * Showing releases. --- src/Hydra/lib/Hydra/Controller/Root.pm | 136 +++++++++++++++---------- src/Hydra/root/build.tt | 107 +------------------ src/Hydra/root/common.tt | 7 +- src/Hydra/root/layout.tt | 1 + src/Hydra/root/product-list.tt | 109 ++++++++++++++++++++ src/Hydra/root/release.tt | 43 ++++++++ src/Hydra/root/releases.tt | 12 +-- src/Hydra/root/static/css/hydra.css | 52 ++++------ 8 files changed, 267 insertions(+), 200 deletions(-) create mode 100644 src/Hydra/root/product-list.tt create mode 100644 src/Hydra/root/release.tt diff --git a/src/Hydra/lib/Hydra/Controller/Root.pm b/src/Hydra/lib/Hydra/Controller/Root.pm index da39d7e2..25e272c6 100644 --- a/src/Hydra/lib/Hydra/Controller/Root.pm +++ b/src/Hydra/lib/Hydra/Controller/Root.pm @@ -201,22 +201,76 @@ sub attrsToSQL { } +sub getReleaseSet { + my ($c, $projectName, $releaseName) = @_; + + my $project = $c->model('DB::Projects')->find($projectName); + die "Project $projectName doesn't exist." if !defined $project; + $c->stash->{curProject} = $project; + + (my $releaseSet) = $c->model('DB::Releasesets')->find($projectName, $releaseName); + die "Release set $releaseName doesn't exist." if !defined $releaseSet; + $c->stash->{releaseSet} = $releaseSet; + + (my $primaryJob) = $releaseSet->releasesetjobs->search({isprimary => 1}); + die "Release set $releaseName doesn't have a primary job." if !defined $primaryJob; + + $c->stash->{jobs} = [$releaseSet->releasesetjobs->search({}, + {order_by => ["isprimary DESC", "job", "attrs"]})]; + + return ($project, $releaseSet, $primaryJob); +} + + +sub getRelease { + my ($c, $primaryBuild) = @_; + + my @jobs = (); + + my $status = 0; # = okay + + foreach my $job (@{$c->stash->{jobs}}) { + my $thisBuild; + + if ($job->isprimary == 1) { + $thisBuild = $primaryBuild; + } else { + # Find a build of this job that had the primary build + # as input. If there are multiple, prefer successful + # ones, and then oldest. !!! order_by buildstatus is hacky + ($thisBuild) = $primaryBuild->dependentBuilds->search( + { attrname => $job->job, finished => 1 }, + { join => 'resultInfo', rows => 1 + , order_by => ["buildstatus", "timestamp"] + , where => \ attrsToSQL($job->attrs, "build.id") + }); + } + + if ($job->mayfail != 1) { + if (!defined $thisBuild) { + $status = 2 if $status == 0; # = unfinished + } elsif ($thisBuild->resultInfo->buildstatus != 0) { + $status = 1; # = failed + } + } + + push @jobs, { build => $thisBuild, job => $job }; + } + + return + { id => $primaryBuild->id + , releasename => $primaryBuild->get_column('releasename') + , jobs => [@jobs] + , status => $status + }; +} + + sub releases :Local { my ($self, $c, $projectName, $releaseName) = @_; $c->stash->{template} = 'releases.tt'; - my $project = $c->model('DB::Projects')->find($projectName); - return error($c, "Project $projectName doesn't exist.") if !defined $project; - $c->stash->{curProject} = $project; - - (my $releaseSet) = $c->model('DB::Releasesets')->find($projectName, $releaseName); - return error($c, "Release set $releaseName doesn't exist.") if !defined $releaseSet; - $c->stash->{releaseSet} = $releaseSet; - - (my $primaryJob) = $releaseSet->releasesetjobs->search({isprimary => 1}); - return error($c, "Release set $releaseName doesn't have a primary job.") if !defined $primaryJob; - - $c->stash->{jobs} = [$releaseSet->releasesetjobs->search({}, {order_by => "isprimary DESC"})]; + my ($project, $releaseSet, $primaryJob) = getReleaseSet($c, $projectName, $releaseName); my @primaryBuilds = $project->builds->search( { attrname => $primaryJob->job, finished => 1 }, @@ -226,52 +280,28 @@ sub releases :Local { }); my @releases = (); - - foreach my $primaryBuild (@primaryBuilds) { - my @jobs = (); - - my $status = 0; # = okay - - foreach my $job (@{$c->stash->{jobs}}) { - my $thisBuild; - - if ($job->isprimary == 1) { - $thisBuild = $primaryBuild; - } else { - # Find a build of this job that had the primary build - # as input. If there are multiple, prefer successful - # ones, and then oldest. !!! order_by buildstatus is hacky - ($thisBuild) = $primaryBuild->dependentBuilds->search( - { attrname => $job->job, finished => 1 }, - { join => 'resultInfo', rows => 1 - , order_by => ["buildstatus", "timestamp"] - , where => \ attrsToSQL($job->attrs, "build.id") - }); - } - - if ($job->mayfail != 1) { - if (!defined $thisBuild) { - $status = 2 if $status == 0; # = unfinished - } elsif ($thisBuild->resultInfo->buildstatus != 0) { - $status = 1; # = failed - } - } - - push @jobs, { build => $thisBuild }; - } - - push @releases, - { id => $primaryBuild->id - , releasename => $primaryBuild->get_column('releasename') - , jobs => [@jobs] - , status => $status - }; - } + push @releases, getRelease($c, $_) foreach @primaryBuilds; $c->stash->{releases} = [@releases]; } +sub release :Local { + my ($self, $c, $projectName, $releaseName, $releaseId) = @_; + $c->stash->{template} = 'release.tt'; + + my ($project, $releaseSet, $primaryJob) = getReleaseSet($c, $projectName, $releaseName); + + # Note: we don't actually check whether $releaseId is a primary + # build, but who cares? + my $primaryBuild = $project->builds->find($releaseId, + { join => 'resultInfo', '+select' => ["resultInfo.releasename"], '+as' => ["releasename"] }); + return error($c, "Release $releaseId doesn't exist.") if !defined $primaryBuild; + + $c->stash->{release} = getRelease($c, $primaryBuild); +} + + sub updateProject { my ($c, $project) = @_; my $projectName = trim $c->request->params->{name}; diff --git a/src/Hydra/root/build.tt b/src/Hydra/root/build.tt index 00f2fed6..983eae6c 100644 --- a/src/Hydra/root/build.tt +++ b/src/Hydra/root/build.tt @@ -1,5 +1,6 @@ [% WRAPPER layout.tt title="Build Information" %] [% PROCESS common.tt %] +[% PROCESS "product-list.tt" %] [% USE HTML %] [% USE mibs=format("%.2f") %] @@ -231,113 +232,9 @@ [% IF build.buildproducts %] -

Build products

- - - +[% PROCESS renderProductList %] [% END %] diff --git a/src/Hydra/root/common.tt b/src/Hydra/root/common.tt index 000fd1a5..f820822a 100644 --- a/src/Hydra/root/common.tt +++ b/src/Hydra/root/common.tt @@ -94,4 +94,9 @@ -[% END %] \ No newline at end of file +[% END %] + + +[% BLOCK renderReleaseJobName -%] +[% IF job.description; HTML.escape(job.description); ELSE %][% job.job %] ([% job.attrs %])[% END -%] +[% END -%] diff --git a/src/Hydra/root/layout.tt b/src/Hydra/root/layout.tt index ace544d5..b61871e6 100644 --- a/src/Hydra/root/layout.tt +++ b/src/Hydra/root/layout.tt @@ -101,6 +101,7 @@ [% END %] diff --git a/src/Hydra/root/product-list.tt b/src/Hydra/root/product-list.tt new file mode 100644 index 00000000..573b8fbc --- /dev/null +++ b/src/Hydra/root/product-list.tt @@ -0,0 +1,109 @@ +[% BLOCK renderProductList -%] + + + +[% END %] + + + diff --git a/src/Hydra/root/release.tt b/src/Hydra/root/release.tt new file mode 100644 index 00000000..38c49d8d --- /dev/null +++ b/src/Hydra/root/release.tt @@ -0,0 +1,43 @@ +[% releaseName = (release.releasename || "(No name)") -%] +[% WRAPPER layout.tt title="Release $releaseName" %] +[% PROCESS common.tt %] +[% PROCESS "product-list.tt" %] +[% USE HTML %] + +

Release [% releaseName %]

+ +[% IF release.status == 1 %] +

This is a failed release. One of its jobs has failed. See below for details.

+[% ELSIF release.status == 2 %] +

This is an incomplete release. One of its jobs has not been built (yet). See below for details.

+[% END %] + +[% FOREACH job IN release.jobs %] + +

+ [% IF job.build %][% END %] + [% INCLUDE renderReleaseJobName job=job.job %] + [% IF job.build %][% END %] +

+ + [% IF job.build %] + + [% IF job.build.resultInfo.buildstatus == 0 %] + + [% INCLUDE renderProductList build=job.build %] + + [% ELSE %] + +

Build failed

+ + [% END %] + + [% ELSE %] + +

Build not (yet) performed.

+ + [% END %] + +[% END %] + +[% END %] diff --git a/src/Hydra/root/releases.tt b/src/Hydra/root/releases.tt index 4c1e16ad..f6c96512 100644 --- a/src/Hydra/root/releases.tt +++ b/src/Hydra/root/releases.tt @@ -11,14 +11,15 @@ # Release [% FOREACH job IN jobs %] - [% IF job.description; HTML.escape(job.description); ELSE %][% job.job %] ([% job.attrs %])[% END %] + [% PROCESS renderReleaseJobName %] [% END %] - [% FOREACH release IN releases %] - + [% FOREACH release IN releases %] + [% link = c.uri_for('/release' releaseSet.project.name releaseSet.name release.id) %] + [% IF release.status == 0 %] @@ -28,7 +29,7 @@ [% END %] - [% release.id %] + [% release.id %] [% IF release.releasename %] [% release.releasename %] @@ -37,7 +38,7 @@ [% END %] [% FOREACH job IN release.jobs %] - + [% IF job.build %] [% IF job.build.resultInfo.buildstatus == 0 %] @@ -45,7 +46,6 @@ [% ELSE %] [% END %] - [% job.build.id %] [% END %] diff --git a/src/Hydra/root/static/css/hydra.css b/src/Hydra/root/static/css/hydra.css index 77e7fe4c..c7440931 100644 --- a/src/Hydra/root/static/css/hydra.css +++ b/src/Hydra/root/static/css/hydra.css @@ -52,8 +52,16 @@ td { vertical-align: top; } -th { +td.centered { + text-align: center; +} + +.layoutTable th { vertical-align: top; +} + +th { + vertical-align: center; background: #ffffc0; } @@ -116,27 +124,6 @@ span.system { font-style: italic; } -table.derivationList { - margin-left: 2em; - margin-right: 2em; -} - -table.derivationList, table.derivationList td, table.derivationList th { - border: 1px solid #808080; -} - -table.derivationList tr.odd { - background: #f0f0f0; -} - -table.derivationList td { - vertical-align: top; -} - -table.derivationList td.system { - font-style: italic; -} - a { text-decoration: none; } @@ -149,15 +136,6 @@ img { border-style: none; } -table.buildfarmResults td, table.buildfarmResults th { - border: none; -} - -td.buildfarmMainColumn { - background-color: #E0E0E0; - border: solid; -} - .error-msg { color: red; white-space: pre; @@ -210,10 +188,6 @@ ul.productList li { display: none; } -.template { - display: none; -} - div.jobset { border: solid black 1px; -moz-border-radius: 1em; @@ -273,6 +247,14 @@ table.tablesorter thead tr th { } +/* Overriding tablesorter... */ + +th.releaseSetJobName { + font-size: 60%; + padding: 0 0 0 0; +} + + /* Navbar */ #leftnavbar {