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 %] -
If you have Nix installed on your machine, this build and all - its dependencies can be unpacked into your local Nix store by - doing:
- -$ gunzip < [% HTML.escape(build.nixname) %].closure.gz | nix-store --import- - or to download and unpack in one command: - -
$ curl [% c.uri_for('/closure' build.id product.productnr) %] | gunzip | nix-store --import- -
The package can then be found in the path [% - product.path %]. If you get the error message “imported - archive lacks a signature”, you should make sure that you have - sufficient access rights to the Nix store, e.g., run the - command as root.
-URL: | -- - [% c.uri_for('/download' build.id product.productnr product.name) %] - - | -
---|---|
File size: | [% product.filesize %] bytes ([% mibs(product.filesize / (1024 * 1024)) %] MiB) |
SHA-1 hash: | [% product.sha1hash %] |
SHA-256 hash: | [% product.sha256hash %] |
Full path: | [% product.path %] |
If you have Nix installed on your machine, this build and all + its dependencies can be unpacked into your local Nix store by + doing:
+ +$ gunzip < [% HTML.escape(build.nixname) %].closure.gz | nix-store --import+ + or to download and unpack in one command: + +
$ curl [% c.uri_for('/closure' build.id product.productnr) %] | gunzip | nix-store --import+ +
The package can then be found in the path [% + product.path %]. If you get the error message “imported + archive lacks a signature”, you should make sure that you have + sufficient access rights to the Nix store, e.g., run the + command as root.
+URL: | ++ + [% c.uri_for('/download' build.id product.productnr product.name) %] + + | +
---|---|
File size: | [% product.filesize %] bytes ([% mibs(product.filesize / (1024 * 1024)) %] MiB) |
SHA-1 hash: | [% product.sha1hash %] |
SHA-256 hash: | [% product.sha256hash %] |
Full path: | [% product.path %] |
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 %] + +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 @@