forked from lix-project/hydra
* Put actions related to builds under /build (e.g. /log/<buildid>
becomes /build/<buildid>/log).
This commit is contained in:
parent
f8e162cb18
commit
16acb2754c
|
@ -5,10 +5,8 @@ use warnings;
|
||||||
use parent 'Catalyst::Controller';
|
use parent 'Catalyst::Controller';
|
||||||
use Hydra::Helper::Nix;
|
use Hydra::Helper::Nix;
|
||||||
|
|
||||||
#
|
|
||||||
# Sets the actions in this controller to be registered with no prefix
|
# Put this controller at top-level.
|
||||||
# so they function identically to actions created in MyApp.pm
|
|
||||||
#
|
|
||||||
__PACKAGE__->config->{namespace} = '';
|
__PACKAGE__->config->{namespace} = '';
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,9 +24,8 @@ sub begin :Private {
|
||||||
|
|
||||||
sub error {
|
sub error {
|
||||||
my ($c, $msg) = @_;
|
my ($c, $msg) = @_;
|
||||||
$c->stash->{template} = 'error.tt';
|
$c->error($msg);
|
||||||
$c->stash->{error} = $msg;
|
$c->detach;
|
||||||
$c->response->status(404);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -572,23 +569,34 @@ sub job :Local {
|
||||||
sub default :Path {
|
sub default :Path {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
error($c, "Page not found.");
|
error($c, "Page not found.");
|
||||||
|
$c->response->status(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub build :Local {
|
sub build : Chained('/') PathPart CaptureArgs(1) {
|
||||||
my ($self, $c, $id) = @_;
|
my ($self, $c, $id) = @_;
|
||||||
|
|
||||||
my $build = getBuild($c, $id);
|
|
||||||
return error($c, "Build with ID $id doesn't exist.") if !defined $build;
|
|
||||||
|
|
||||||
$c->stash->{curProject} = $build->project;
|
|
||||||
|
|
||||||
$c->stash->{template} = 'build.tt';
|
|
||||||
$c->stash->{build} = $build;
|
|
||||||
$c->stash->{id} = $id;
|
$c->stash->{id} = $id;
|
||||||
|
|
||||||
|
$c->stash->{build} = getBuild($c, $id);
|
||||||
|
|
||||||
|
if (!defined $c->stash->{build}) {
|
||||||
|
error($c, "Build with ID $id doesn't exist.");
|
||||||
|
$c->response->status(404);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$c->stash->{curProject} = $c->stash->{build}->project;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub view_build : Chained('build') PathPart('') Args(0) {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
my $build = $c->stash->{build};
|
||||||
|
|
||||||
|
$c->stash->{template} = 'build.tt';
|
||||||
$c->stash->{curTime} = time;
|
$c->stash->{curTime} = time;
|
||||||
|
|
||||||
$c->stash->{available} = isValidPath $build->outpath;
|
$c->stash->{available} = isValidPath $build->outpath;
|
||||||
|
|
||||||
if (!$build->finished && $build->schedulingInfo->busy) {
|
if (!$build->finished && $build->schedulingInfo->busy) {
|
||||||
|
@ -598,35 +606,13 @@ sub build :Local {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub log :Local {
|
sub view_nixlog : Chained('build') PathPart('nixlog') Args(1) {
|
||||||
my ($self, $c, $id) = @_;
|
my ($self, $c, $stepnr) = @_;
|
||||||
|
|
||||||
my $build = getBuild($c, $id);
|
my $step = $c->stash->{build}->buildsteps->find({stepnr => $stepnr});
|
||||||
return error($c, "Build $id doesn't exist.") if !defined $build;
|
return error($c, "Build doesn't have a build step $stepnr.") if !defined $step;
|
||||||
|
|
||||||
return error($c, "Build $id didn't produce a log.") if !defined $build->resultInfo->logfile;
|
|
||||||
|
|
||||||
$c->stash->{template} = 'log.tt';
|
$c->stash->{template} = 'log.tt';
|
||||||
$c->stash->{build} = $build;
|
|
||||||
|
|
||||||
# !!! should be done in the view (as a TT plugin).
|
|
||||||
$c->stash->{logtext} = loadLog($c, $build->resultInfo->logfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sub nixlog :Local {
|
|
||||||
my ($self, $c, $id, $stepnr) = @_;
|
|
||||||
|
|
||||||
my $build = getBuild($c, $id);
|
|
||||||
return error($c, "Build with ID $id doesn't exist.") if !defined $build;
|
|
||||||
|
|
||||||
my $step = $build->buildsteps->find({stepnr => $stepnr});
|
|
||||||
return error($c, "Build $id doesn't have a build step $stepnr.") if !defined $step;
|
|
||||||
|
|
||||||
return error($c, "Build step $stepnr of build $id does not have a log file.") if $step->logfile eq "";
|
|
||||||
|
|
||||||
$c->stash->{template} = 'log.tt';
|
|
||||||
$c->stash->{build} = $build;
|
|
||||||
$c->stash->{step} = $step;
|
$c->stash->{step} = $step;
|
||||||
|
|
||||||
# !!! should be done in the view (as a TT plugin).
|
# !!! should be done in the view (as a TT plugin).
|
||||||
|
@ -634,6 +620,18 @@ sub nixlog :Local {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub view_log : Chained('build') PathPart('log') Args(0) {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
return error($c, "Build didn't produce a log.") if !defined $c->stash->{build}->resultInfo->logfile;
|
||||||
|
|
||||||
|
$c->stash->{template} = 'log.tt';
|
||||||
|
|
||||||
|
# !!! should be done in the view (as a TT plugin).
|
||||||
|
$c->stash->{logtext} = loadLog($c, $c->stash->{build}->resultInfo->logfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub loadLog {
|
sub loadLog {
|
||||||
my ($c, $path) = @_;
|
my ($c, $path) = @_;
|
||||||
|
|
||||||
|
@ -648,14 +646,11 @@ sub loadLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub download :Local {
|
sub download : Chained('build') PathPart('download') {
|
||||||
my ($self, $c, $id, $productnr, $filename, @path) = @_;
|
my ($self, $c, $productnr, $filename, @path) = @_;
|
||||||
|
|
||||||
my $build = getBuild($c, $id);
|
my $product = $c->stash->{build}->buildproducts->find({productnr => $productnr});
|
||||||
return error($c, "Build with ID $id doesn't exist.") if !defined $build;
|
return error($c, "Build doesn't have a product $productnr.") if !defined $product;
|
||||||
|
|
||||||
my $product = $build->buildproducts->find({productnr => $productnr});
|
|
||||||
return error($c, "Build $id doesn't have a product $productnr.") if !defined $product;
|
|
||||||
|
|
||||||
return error($c, "Product " . $product->path . " has disappeared.") unless -e $product->path;
|
return error($c, "Product " . $product->path . " has disappeared.") unless -e $product->path;
|
||||||
|
|
||||||
|
@ -748,7 +743,15 @@ sub nar :Local {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub end : ActionClass('RenderView') {}
|
sub end : ActionClass('RenderView') {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
if (scalar @{$c->error}) {
|
||||||
|
$c->stash->{template} = 'error.tt';
|
||||||
|
$c->stash->{errors} = $c->error;
|
||||||
|
$c->clear_errors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -121,7 +121,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>Logfile:</th>
|
<th>Logfile:</th>
|
||||||
<td>
|
<td>
|
||||||
<a href="[% c.uri_for('/log' build.id) %]"><strong>Available</strong></a>
|
<a href="[% c.uri_for('build' build.id 'log') %]"><strong>Available</strong></a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
@ -178,8 +178,9 @@
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
[% FOREACH step IN build.buildsteps -%]
|
[% FOREACH step IN build.buildsteps -%]
|
||||||
|
[% log = c.uri_for('build' build.id 'nixlog' step.stepnr) %]
|
||||||
<tr class="[% IF step.logfile %]clickable[% END %]"
|
<tr class="[% IF step.logfile %]clickable[% END %]"
|
||||||
[% IF step.logfile %] onclick="window.location = '[% c.uri_for('/nixlog' build.id step.stepnr) %]'" [% END %]>
|
[% IF step.logfile %] onclick="window.location = '[% log %]'" [% END %]>
|
||||||
<td>[% step.stepnr %]</td>
|
<td>[% step.stepnr %]</td>
|
||||||
<td>
|
<td>
|
||||||
[% IF step.type == 0 %]
|
[% IF step.type == 0 %]
|
||||||
|
@ -212,7 +213,7 @@
|
||||||
<span class="error">Failed: [% HTML.escape(step.errormsg) %]</span>
|
<span class="error">Failed: [% HTML.escape(step.errormsg) %]</span>
|
||||||
[% END %]
|
[% END %]
|
||||||
[% IF step.logfile %]
|
[% IF step.logfile %]
|
||||||
(<a href="[% c.uri_for('/nixlog' build.id step.stepnr) %]">log</a>)
|
(<a href="[% log %]">log</a>)
|
||||||
[% END %]
|
[% END %]
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
|
|
||||||
<h1>Error</h1>
|
<h1>Error</h1>
|
||||||
|
|
||||||
<p>I'm very sorry, but an error occurred: <span class="error-msg">[% HTML.escape(error) %]</span></p>
|
<p>I'm very sorry, but an error occurred: <span class="error-msg">[% FOREACH error IN errors %] [% HTML.escape(error) %] [% END %]</span></p>
|
||||||
|
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
|
@ -5,13 +5,16 @@
|
||||||
<ul class="productList">
|
<ul class="productList">
|
||||||
|
|
||||||
[% FOREACH product IN build.buildproducts -%]
|
[% FOREACH product IN build.buildproducts -%]
|
||||||
|
|
||||||
|
[% uri = c.uri_for('build' build.id 'download' product.productnr product.name) %]
|
||||||
|
|
||||||
[% SWITCH product.type %]
|
[% SWITCH product.type %]
|
||||||
|
|
||||||
[% CASE "nix-build" %]
|
[% CASE "nix-build" %]
|
||||||
|
|
||||||
<li class="product">
|
<li class="product">
|
||||||
<a href="[% c.uri_for('/nixpkg' build.id) %]">
|
[% uri = c.uri_for('nixpkg' build.id) %]
|
||||||
|
<a href="[% uri %]">
|
||||||
<img src="/static/images/nix-build.png" alt="Source" />
|
<img src="/static/images/nix-build.png" alt="Source" />
|
||||||
One-click install of Nix package <tt>[% build.nixname %]</tt>
|
One-click install of Nix package <tt>[% build.nixname %]</tt>
|
||||||
</a>
|
</a>
|
||||||
|
@ -25,7 +28,7 @@
|
||||||
browser. Alternatively, you can install it from the
|
browser. Alternatively, you can install it from the
|
||||||
command-line:
|
command-line:
|
||||||
|
|
||||||
<pre>$ nix-install-package --non-interactive --url [% c.uri_for('/nixpkg' build.id) %]</pre>
|
<pre>$ nix-install-package --non-interactive --url [% uri %]</pre>
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -76,7 +79,7 @@
|
||||||
[% CASE "file" %]
|
[% CASE "file" %]
|
||||||
|
|
||||||
<li class="product">
|
<li class="product">
|
||||||
<a href="[% c.uri_for('/download' build.id product.productnr product.name) %]">
|
<a href="[% uri %]">
|
||||||
[% SWITCH product.subtype %]
|
[% SWITCH product.subtype %]
|
||||||
[% CASE "source-dist" %]
|
[% CASE "source-dist" %]
|
||||||
<img src="/static/images/source-dist.png" alt="Source" /> Source distribution <tt>[% product.name %]</tt>
|
<img src="/static/images/source-dist.png" alt="Source" /> Source distribution <tt>[% product.name %]</tt>
|
||||||
|
@ -96,8 +99,8 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th>URL:</th>
|
<th>URL:</th>
|
||||||
<td>
|
<td>
|
||||||
<a href="[% c.uri_for('/download' build.id product.productnr product.name) %]">
|
<a href="[% uri %]">
|
||||||
<tt>[% c.uri_for('/download' build.id product.productnr product.name) %]</tt>
|
<tt>[% uri %]</tt>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -112,7 +115,7 @@
|
||||||
[% CASE "report" %]
|
[% CASE "report" %]
|
||||||
|
|
||||||
<li class="product">
|
<li class="product">
|
||||||
<a href="[% c.uri_for('/download' build.id product.productnr product.name) %]">
|
<a href="[% uri %]">
|
||||||
<img src="/static/images/report.png" alt="Report" />
|
<img src="/static/images/report.png" alt="Report" />
|
||||||
[% SWITCH product.subtype %]
|
[% SWITCH product.subtype %]
|
||||||
[% CASE "coverage" %]
|
[% CASE "coverage" %]
|
||||||
|
@ -126,7 +129,7 @@
|
||||||
[% CASE "doc" %]
|
[% CASE "doc" %]
|
||||||
|
|
||||||
<li class="product">
|
<li class="product">
|
||||||
<a href="[% c.uri_for('/download' build.id product.productnr product.name) %]">
|
<a href="[% uri %]">
|
||||||
<img src="/static/images/document.png" alt="Document" />
|
<img src="/static/images/document.png" alt="Document" />
|
||||||
[% SWITCH product.subtype %]
|
[% SWITCH product.subtype %]
|
||||||
[% CASE "readme" %]
|
[% CASE "readme" %]
|
||||||
|
|
Loading…
Reference in a new issue