forked from lix-project/hydra
This commit is contained in:
parent
f89757fbd4
commit
cf37152849
|
@ -122,8 +122,8 @@ sub nix : Chained('build') PathPart('nix') CaptureArgs(0) {
|
||||||
error($c, "Path " . $build->outpath . " is no longer available.")
|
error($c, "Path " . $build->outpath . " is no longer available.")
|
||||||
unless isValidPath($build->outpath);
|
unless isValidPath($build->outpath);
|
||||||
|
|
||||||
$c->stash->{name} = $build->nixname;
|
|
||||||
$c->stash->{storePaths} = [$build->outpath];
|
$c->stash->{storePaths} = [$build->outpath];
|
||||||
|
|
||||||
my $pkgName = $build->nixname . "-" . $build->system . ".nixpkg";
|
my $pkgName = $build->nixname . "-" . $build->system . ".nixpkg";
|
||||||
$c->stash->{nixPkgs} = {$pkgName => $build};
|
$c->stash->{nixPkgs} = {$pkgName => $build};
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package Hydra::Controller::Root;
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use base 'Catalyst::Controller';
|
use base 'Hydra::Base::Controller::Nix';
|
||||||
use Hydra::Helper::Nix;
|
use Hydra::Helper::Nix;
|
||||||
use Hydra::Helper::CatalystUtils;
|
use Hydra::Helper::CatalystUtils;
|
||||||
|
|
||||||
|
@ -97,12 +97,10 @@ sub queue :Local {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub showJobStatus {
|
# Return the latest build for each job.
|
||||||
|
sub getLatestBuilds {
|
||||||
my ($c, $builds) = @_;
|
my ($c, $builds) = @_;
|
||||||
$c->stash->{template} = 'jobstatus.tt';
|
return $builds->search({},
|
||||||
|
|
||||||
# Get the latest finished build for each unique job.
|
|
||||||
$c->stash->{latestBuilds} = [$builds->search({},
|
|
||||||
{ join => 'resultInfo'
|
{ join => 'resultInfo'
|
||||||
, where => {
|
, where => {
|
||||||
finished => { "!=", 0 },
|
finished => { "!=", 0 },
|
||||||
|
@ -111,7 +109,16 @@ sub showJobStatus {
|
||||||
"where project == me.project and attrName == me.attrName and finished != 0 and system == me.system)"),
|
"where project == me.project and attrName == me.attrName and finished != 0 and system == me.system)"),
|
||||||
}
|
}
|
||||||
, order_by => "project, attrname, system"
|
, order_by => "project, attrname, system"
|
||||||
})];
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub showJobStatus {
|
||||||
|
my ($c, $builds) = @_;
|
||||||
|
$c->stash->{template} = 'jobstatus.tt';
|
||||||
|
|
||||||
|
# Get the latest finished build for each unique job.
|
||||||
|
$c->stash->{latestBuilds} = [getLatestBuilds($c, $builds)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -538,6 +545,20 @@ sub job :Local {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub nix : Chained('/') PathPart('nix') CaptureArgs(0) {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
my @builds = getLatestBuilds($c, $c->model('DB::Builds'));
|
||||||
|
|
||||||
|
my @storePaths = ();
|
||||||
|
foreach my $build (@builds) {
|
||||||
|
push @storePaths, $build->outpath if isValidPath($build->outpath);
|
||||||
|
};
|
||||||
|
|
||||||
|
$c->stash->{storePaths} = [@storePaths];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub default :Path {
|
sub default :Path {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
notFound($c, "Page not found.");
|
notFound($c, "Page not found.");
|
||||||
|
@ -550,6 +571,10 @@ sub end : ActionClass('RenderView') {
|
||||||
if (scalar @{$c->error}) {
|
if (scalar @{$c->error}) {
|
||||||
$c->stash->{template} = 'error.tt';
|
$c->stash->{template} = 'error.tt';
|
||||||
$c->stash->{errors} = $c->error;
|
$c->stash->{errors} = $c->error;
|
||||||
|
if ($c->response->status >= 300) {
|
||||||
|
$c->stash->{httpStatus} =
|
||||||
|
$c->response->status . " " . HTTP::Status::status_message($c->response->status);
|
||||||
|
}
|
||||||
$c->clear_errors;
|
$c->clear_errors;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,15 +3,8 @@ package Hydra::View::NixManifest;
|
||||||
use strict;
|
use strict;
|
||||||
use base qw/Catalyst::View/;
|
use base qw/Catalyst::View/;
|
||||||
use IO::Pipe;
|
use IO::Pipe;
|
||||||
use IPC::Run;
|
|
||||||
use POSIX qw(dup2);
|
use POSIX qw(dup2);
|
||||||
|
|
||||||
sub captureStdoutStderr {
|
|
||||||
my $stdin = ""; my $stdout; my $stderr;
|
|
||||||
my $res = IPC::Run::run(\@_, \$stdin, \$stdout, \$stderr);
|
|
||||||
return ($res, $stdout, $stderr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
sub process {
|
sub process {
|
||||||
my ($self, $c) = @_;
|
my ($self, $c) = @_;
|
||||||
|
@ -20,8 +13,8 @@ sub process {
|
||||||
|
|
||||||
$c->response->content_type('text/x-nix-manifest');
|
$c->response->content_type('text/x-nix-manifest');
|
||||||
|
|
||||||
my @paths = split '\n', `nix-store --query --requisites @storePaths`
|
my @paths = split '\n', `nix-store --query --requisites @storePaths`;
|
||||||
or die "cannot query dependencies of path(s) @storePaths: $?";
|
die "cannot query dependencies of path(s) @storePaths: $?" if $? != 0;
|
||||||
|
|
||||||
my $manifest =
|
my $manifest =
|
||||||
"version {\n" .
|
"version {\n" .
|
||||||
|
@ -29,9 +22,8 @@ sub process {
|
||||||
"}\n";
|
"}\n";
|
||||||
|
|
||||||
foreach my $path (@paths) {
|
foreach my $path (@paths) {
|
||||||
my ($res, $out, $err) = captureStdoutStderr(qw(nix-store --query --references), $path);
|
my @refs = split '\n', `nix-store --query --references $path`;
|
||||||
die "cannot query references of `$path':\n$err" unless $res;
|
die "cannot query references of `$path': $?" if $? != 0;
|
||||||
my @refs = split '\n', $out;
|
|
||||||
|
|
||||||
my $hash = `nix-store --query --hash $path`
|
my $hash = `nix-store --query --hash $path`
|
||||||
or die "cannot query hash of `$path': $?";
|
or die "cannot query hash of `$path': $?";
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[% WRAPPER layout.tt title="Error" %]
|
[% WRAPPER layout.tt title="Error" %]
|
||||||
[% USE HTML %]
|
[% USE HTML %]
|
||||||
|
|
||||||
<h1>Error</h1>
|
<h1>[% IF httpStatus %][% httpStatus %][% ELSE %]Error[% END %]</h1>
|
||||||
|
|
||||||
<p>I'm very sorry, but an error occurred: <span class="error-msg">[% FOREACH error IN errors %] [% HTML.escape(error) %] [% END %]</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>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue