From db0ef9e49b54969b8e7fd83d775dd2d74d1eaf43 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 27 Apr 2015 03:03:41 +0200 Subject: [PATCH] Tie custom channels into channel-contents.tt. We should now get an overview and help text on how to add a particular channel and also a bit of information about the builds that are required for a channel to get upgraded. Right now we only select the latest successful build in the latest successful evaluation, so if someone wants to have more information about which channel has failed, (s)he still has to look at the "Channels" tab of the jobset. We can make this more fancy at some later point if this is really needed, because right now we're only interested in the latest build, because it's the only thing necessary to deliver the channel contents. Signed-off-by: aszlig --- src/lib/Hydra/Base/Controller/NixChannel.pm | 1 + src/lib/Hydra/Controller/Channel.pm | 57 +++++++++++++++++++++ src/root/channel-contents.tt | 13 +++++ src/root/jobset-channels-tab.tt | 2 +- 4 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 src/lib/Hydra/Controller/Channel.pm diff --git a/src/lib/Hydra/Base/Controller/NixChannel.pm b/src/lib/Hydra/Base/Controller/NixChannel.pm index 19e5bf8e..3d68220c 100644 --- a/src/lib/Hydra/Base/Controller/NixChannel.pm +++ b/src/lib/Hydra/Base/Controller/NixChannel.pm @@ -130,6 +130,7 @@ sub channel_contents : Chained('nix') PathPart('') Args(0) { # garbage-collected. That should be true for the "latest" # channel. getChannelData($c, 0); + $c->stash->{genericChannel} = 1; $c->stash->{template} = 'channel-contents.tt'; $c->stash->{nixPkgs} = [sortPkgs @{$c->stash->{nixPkgs}}]; } diff --git a/src/lib/Hydra/Controller/Channel.pm b/src/lib/Hydra/Controller/Channel.pm new file mode 100644 index 00000000..033fc4de --- /dev/null +++ b/src/lib/Hydra/Controller/Channel.pm @@ -0,0 +1,57 @@ +package Hydra::Controller::Channel; + +use strict; +use warnings; +use base 'Hydra::Base::Controller::REST'; + + +sub channel : Chained('/') PathPart('channel/custom') CaptureArgs(3) { + my ($self, $c, $projectName, $jobsetName, $channelName) = @_; + + $c->stash->{project} = $c->model('DB::Projects')->find($projectName); + + notFound($c, "Project $projectName doesn't exist.") + if !$c->stash->{project}; + + $c->stash->{jobset} = $c->stash->{project}->jobsets->find({ + name => $jobsetName + }); + + notFound($c, "Jobset $jobsetName doesn't exist.") + if !$c->stash->{jobset}; + + my $lastSuccessful = $c->model('DB::Builds')->find( + { 'eval.hasnewbuilds' => 1 + , project => $projectName + , jobset => $jobsetName + , job => $channelName + , buildstatus => 0 + }, + { rows => 1, order_by => "eval.id desc" + , join => { jobsetevalmembers => 'eval' } + } + ); + + notFound($c, "Channel $channelName either doesn't exist ". + "or was never built successfully.") + if !$lastSuccessful; + + $c->stash->{lastSuccessful} = $lastSuccessful; +} + + +sub overview : Chained('channel') PathPart('') Args(0) { + my ($self, $c) = @_; + + $c->stash->{constituents} = [ + $c->stash->{lastSuccessful}->constituents_->search( + {}, {order_by => ["job"]} + ) + ]; + + $c->stash->{genericChannel} = 0; + $c->stash->{template} = 'channel-contents.tt'; +} + + +1; diff --git a/src/root/channel-contents.tt b/src/root/channel-contents.tt index b5f3d269..04619903 100644 --- a/src/root/channel-contents.tt +++ b/src/root/channel-contents.tt @@ -27,6 +27,7 @@ $ nix-env -u '*' nix-install-package program in your web browser, you can install the package simply by clicking on the packages below.

+[% IF genericChannel %]

Packages

@@ -69,5 +70,17 @@ install the package simply by clicking on the packages below.

+[% ELSE %] +[% PROCESS "product-list.tt" %] + +

Contents

+ +[% INCLUDE renderProductList build=lastSuccessful %] + +

Upgrades depend on the success/failure of the following constituents:

+ +[% INCLUDE renderBuildList builds=constituents %] + +[% END %] [% END %] diff --git a/src/root/jobset-channels-tab.tt b/src/root/jobset-channels-tab.tt index 27d1f4cf..c003d70e 100644 --- a/src/root/jobset-channels-tab.tt +++ b/src/root/jobset-channels-tab.tt @@ -22,7 +22,7 @@ [% FOREACH chan IN channels-%] - [% INCLUDE renderJobName project=project.name jobset=jobset.name job=chan %] + [% chan %] [% FOREACH eval IN evalIds %] [% r = evals.$eval.builds.$chan; IF r.id %][% INCLUDE renderBuildStatusIcon size=16 build=r %][% END %] [% END %]