forked from lix-project/hydra
* At top-level and for each project, provide two channels: "latest"
(containing the latest successful build of each job) and "all" (containing all successful builds ever).
This commit is contained in:
parent
4089859d33
commit
5162f05e2c
|
@ -2,7 +2,7 @@ package Hydra::Base::Controller::ListBuilds;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base 'Catalyst::Controller';
|
||||
use base 'Hydra::Base::Controller::NixChannel';
|
||||
use Hydra::Helper::Nix;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
|
||||
|
@ -35,4 +35,23 @@ sub all : Chained('get_builds') PathPart {
|
|||
}
|
||||
|
||||
|
||||
sub nix : Chained('get_builds') PathPart('channel') CaptureArgs(1) {
|
||||
my ($self, $c, $channelName) = @_;
|
||||
eval {
|
||||
if ($channelName eq "latest") {
|
||||
$c->stash->{channelName} = $c->stash->{channelBaseName} . "-latest";
|
||||
getChannelData($c, getLatestBuilds($c, $c->stash->{allBuilds}, {buildStatus => 0}));
|
||||
}
|
||||
elsif ($channelName eq "all") {
|
||||
$c->stash->{channelName} = $c->stash->{channelBaseName} . "-all";
|
||||
getChannelData($c, [$c->stash->{allBuilds}->all]);
|
||||
}
|
||||
else {
|
||||
error($c, "Unknown channel `$channelName'.");
|
||||
}
|
||||
};
|
||||
error($c, $@) if $@;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
|
|
@ -3,7 +3,6 @@ package Hydra::Controller::Project;
|
|||
use strict;
|
||||
use warnings;
|
||||
use base 'Hydra::Base::Controller::ListBuilds';
|
||||
use base 'Hydra::Base::Controller::NixChannel';
|
||||
use Hydra::Helper::Nix;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
|
||||
|
@ -225,21 +224,11 @@ sub updateProject {
|
|||
}
|
||||
|
||||
|
||||
# Hydra::Base::Controller::NixChannel needs this.
|
||||
sub nix : Chained('project') PathPart('channel/latest') CaptureArgs(0) {
|
||||
my ($self, $c) = @_;
|
||||
eval {
|
||||
$c->stash->{channelName} = $c->stash->{curProject}->name . "-latest";
|
||||
getChannelData($c, scalar $c->stash->{curProject}->builds);
|
||||
};
|
||||
error($c, $@) if $@;
|
||||
}
|
||||
|
||||
|
||||
# Hydra::Base::Controller::ListBuilds needs this.
|
||||
sub get_builds : Chained('project') PathPart('') CaptureArgs(0) {
|
||||
my ($self, $c) = @_;
|
||||
$c->stash->{allBuilds} = $c->stash->{curProject}->builds;
|
||||
$c->stash->{channelBaseName} = $c->stash->{curProject}->name;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package Hydra::Controller::Root;
|
|||
|
||||
use strict;
|
||||
use warnings;
|
||||
use base 'Hydra::Base::Controller::NixChannel';
|
||||
use base 'Hydra::Base::Controller::ListBuilds';
|
||||
use Hydra::Helper::Nix;
|
||||
use Hydra::Helper::CatalystUtils;
|
||||
|
@ -235,20 +234,11 @@ sub job :Local {
|
|||
}
|
||||
|
||||
|
||||
sub nix : Chained('/') PathPart('channel/latest') CaptureArgs(0) {
|
||||
my ($self, $c) = @_;
|
||||
eval {
|
||||
$c->stash->{channelName} = "hydra-all-latest";
|
||||
getChannelData($c, $c->model('DB::Builds'));
|
||||
};
|
||||
error($c, $@) if $@;
|
||||
}
|
||||
|
||||
|
||||
# Hydra::Base::Controller::ListBuilds needs this.
|
||||
sub get_builds : Chained('/') PathPart('') CaptureArgs(0) {
|
||||
my ($self, $c) = @_;
|
||||
$c->stash->{allBuilds} = $c->model('DB::Builds');
|
||||
$c->stash->{channelBaseName} = "everything";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -70,10 +70,8 @@ sub getLatestBuilds {
|
|||
sub getChannelData {
|
||||
my ($c, $builds) = @_;
|
||||
|
||||
my @builds = @{getLatestBuilds($c, $builds, {buildStatus => 0})};
|
||||
|
||||
my @storePaths = ();
|
||||
foreach my $build (@builds) {
|
||||
foreach my $build (@{$builds}) {
|
||||
# !!! better do this in getLatestBuilds with a join.
|
||||
next unless $build->buildproducts->find({type => "nix-build"});
|
||||
next unless isValidPath($build->outpath);
|
||||
|
|
Loading…
Reference in a new issue