* Provide a channel for each project containing all the latest

succesful builds for each job in the project (under
  http://server/project/<name>/channel/latest).
This commit is contained in:
Eelco Dolstra 2009-03-04 13:08:09 +00:00
parent af936d7c91
commit dad2f31099
3 changed files with 37 additions and 16 deletions

View file

@ -3,6 +3,7 @@ package Hydra::Controller::Project;
use strict; use strict;
use warnings; use warnings;
use base 'Hydra::Base::Controller::ListBuilds'; use base 'Hydra::Base::Controller::ListBuilds';
use base 'Hydra::Base::Controller::NixChannel';
use Hydra::Helper::Nix; use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils; use Hydra::Helper::CatalystUtils;
@ -224,6 +225,17 @@ 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. # Hydra::Base::Controller::ListBuilds needs this.
sub get_builds : Chained('project') PathPart('') CaptureArgs(0) { sub get_builds : Chained('project') PathPart('') CaptureArgs(0) {
my ($self, $c) = @_; my ($self, $c) = @_;

View file

@ -237,22 +237,11 @@ sub job :Local {
sub nix : Chained('/') PathPart('channel/latest') CaptureArgs(0) { sub nix : Chained('/') PathPart('channel/latest') CaptureArgs(0) {
my ($self, $c) = @_; my ($self, $c) = @_;
eval {
$c->stash->{channelName} = "hydra-all-latest"; $c->stash->{channelName} = "hydra-all-latest";
getChannelData($c, $c->model('DB::Builds'));
my @builds = @{getLatestBuilds($c, $c->model('DB::Builds'), {buildStatus => 0})};
my @storePaths = ();
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);
push @storePaths, $build->outpath;
my $pkgName = $build->nixname . "-" . $build->system . "-" . $build->id . ".nixpkg";
$c->stash->{nixPkgs}->{$pkgName} = $build;
}; };
error($c, $@) if $@;
$c->stash->{storePaths} = [@storePaths];
} }

View file

@ -3,10 +3,11 @@ package Hydra::Helper::CatalystUtils;
use strict; use strict;
use Exporter; use Exporter;
use Readonly; use Readonly;
use Hydra::Helper::Nix;
our @ISA = qw(Exporter); our @ISA = qw(Exporter);
our @EXPORT = qw( our @EXPORT = qw(
getBuild getBuildStats getLatestBuilds getBuild getBuildStats getLatestBuilds getChannelData
error notFound error notFound
requireLogin requireProjectOwner requireAdmin requireLogin requireProjectOwner requireAdmin
trim trim
@ -66,6 +67,25 @@ sub getLatestBuilds {
} }
sub getChannelData {
my ($c, $builds) = @_;
my @builds = @{getLatestBuilds($c, $builds, {buildStatus => 0})};
my @storePaths = ();
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);
push @storePaths, $build->outpath;
my $pkgName = $build->nixname . "-" . $build->system . "-" . $build->id . ".nixpkg";
$c->stash->{nixPkgs}->{$pkgName} = $build;
};
$c->stash->{storePaths} = [@storePaths];
}
sub error { sub error {
my ($c, $msg) = @_; my ($c, $msg) = @_;
$c->error($msg); $c->error($msg);