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;
use base 'Catalyst::Controller';
use Hydra::Helper::Nix;
use Hydra::Helper::CatalystUtils;
sub getView {
my ($c, $projectName, $viewName) = @_;
my $project = $c->model('DB::Projects')->find($projectName);
notFound($c, "Project $projectName doesn't exist.") if !defined $project;
$c->stash->{project} = $project;
(my $view) = $c->model('DB::Views')->find($projectName, $viewName);
notFound($c, "View $viewName doesn't exist.") if !defined $view;
$c->stash->{view} = $view;
(my $primaryJob) = $view->viewjobs->search({isprimary => 1});
#die "View $viewName doesn't have a primary job." if !defined $primaryJob;
my $jobs = [$view->viewjobs->search({},
{order_by => ["isprimary DESC", "job", "attrs"]})];
$c->stash->{jobs} = $jobs;
return ($project, $view, $primaryJob, $jobs);
}
sub updateView {
my ($c, $view) = @_;
my $viewName = trim $c->request->params->{name};
error($c, "Invalid view name: $viewName")
unless $viewName =~ /^[[:alpha:]][\w\-]*$/;
$view->update(
{ name => $viewName
, description => trim $c->request->params->{description} });
$view->viewjobs->delete;
foreach my $param (keys %{$c->request->params}) {
next unless $param =~ /^job-(\d+)-name$/;
my $baseName = $1;
my $name = trim $c->request->params->{"job-$baseName-name"};
my $description = trim $c->request->params->{"job-$baseName-description"};
my $attrs = trim $c->request->params->{"job-$baseName-attrs"};
$name =~ /^([\w\-]+):($jobNameRE)$/ or error($c, "Invalid job name: $name");
my $jobsetName = $1;
my $jobName = $2;
error($c, "Jobset `$jobsetName' doesn't exist.")
unless $view->project->jobsets->find({name => $jobsetName});
# !!! We could check whether the job exists, but that would
# require the evaluator to have seen the job, which may not be
# the case.
$view->viewjobs->create(
{ jobset => $jobsetName
, job => $jobName
, description => $description
, attrs => $attrs
, isprimary => $c->request->params->{"primary"} eq $baseName ? 1 : 0
});
}
error($c, "There must be one primary job.")
if $view->viewjobs->search({isprimary => 1})->count != 1;
}
sub view : Chained('/') PathPart('view') CaptureArgs(2) {
my ($self, $c, $projectName, $viewName) = @_;
my ($project, $view, $primaryJob, $jobs) = getView($c, $projectName, $viewName);
$c->stash->{project} = $project;
$c->stash->{view} = $view;
$c->stash->{primaryJob} = $primaryJob;
$c->stash->{jobs} = $jobs;
}
sub view_view : Chained('view') PathPart('') Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'view.tt';
my $resultsPerPage = 10;
my $page = int($c->req->param('page') || "1") || 1;
my @results = ();
push @results, getViewResult($_, $c->stash->{jobs}) foreach
getPrimaryBuildsForView($c->stash->{project}, $c->stash->{primaryJob}, $page, $resultsPerPage);
$c->stash->{baseUri} = $c->uri_for($self->action_for("view_view"), $c->req->captures);
$c->stash->{results} = [@results];
$c->stash->{page} = $page;
$c->stash->{totalResults} = getPrimaryBuildTotal($c->stash->{project}, $c->stash->{primaryJob});
$c->stash->{resultsPerPage} = $resultsPerPage;
}
sub edit : Chained('view') PathPart('edit') Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
$c->stash->{template} = 'edit-view.tt';
}
sub submit : Chained('view') PathPart('submit') Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
txn_do($c->model('DB')->schema, sub {
updateView($c, $c->stash->{view});
});
$c->res->redirect($c->uri_for($self->action_for("view_view"), $c->req->captures));
}
sub latest : Chained('view') PathPart('latest') {
my ($self, $c, @args) = @_;
# Redirect to the latest result in the view in which every build
# is successful.
my $latest = getLatestSuccessfulViewResult(
$c->stash->{project}, $c->stash->{primaryJob}, $c->stash->{jobs}, 0);
error($c, "This view set has no successful results yet.") if !defined $latest;
$c->res->redirect($c->uri_for($self->action_for("view_view"), $c->req->captures, $latest->id, @args, $c->req->params));
}
sub latest_finished : Chained('view') PathPart('latest-finished') {
my ($self, $c, @args) = @_;
# Redirect to the latest result in the view in which every build
# is successful *and* where the jobset evaluation has finished
# completely.
my $latest = getLatestSuccessfulViewResult(
$c->stash->{project}, $c->stash->{primaryJob}, $c->stash->{jobs}, 1);
error($c, "This view set has no successful results yet.") if !defined $latest;
$c->res->redirect($c->uri_for($self->action_for("view_view"), $c->req->captures, $latest->id, @args, $c->req->params));
}
sub result : Chained('view') PathPart('') {
my ($self, $c, $id, @args) = @_;
$c->stash->{template} = 'view-result.tt';
# Note: we don't actually check whether $id is a primary build,
# but who cares?
my $primaryBuild = $c->stash->{project}->builds->find($id)
or error($c, "Build $id doesn't exist.");
error($c, "The primary build of this view result did not provide a release name.")
unless $result->{releasename};
error($c, "A release named `" . $result->{releasename} . "' already exists.")
if $c->stash->{project}->releases->find({name => $result->{releasename}});
my $release;
txn_do($c->model('DB')->schema, sub {
$release = $c->stash->{project}->releases->create(
{ name => $result->{releasename}
, timestamp => time
});
foreach my $job (@{$result->{jobs}}) {
$release->releasemembers->create(
{ build => $job->{build}->id
, description => $job->{job}->description
});
}
});
$c->res->redirect($c->uri_for($c->controller('Release')->action_for('view'),
[$c->stash->{project}->name, $release->name]));
}
elsif (scalar @args >= 1 && $args[0] eq "eval") {
my $eval = $c->stash->{result}->{eval};
notFound($c, "This view result has no evaluation.") unless defined $eval;
$c->res->redirect($c->uri_for($c->controller('JobsetEval')->action_for("view"),
[$eval->id], @args[1..$#args], $c->req->params));
}
# Provide a redirect to the specified job of this view result
# through `http://.../view/$project/$viewName/$viewResult/$jobName'.
# Optionally, you can append `-$system' to the $jobName to get a
# build for a specific platform.
elsif (scalar @args != 0) {
my $jobName = shift @args;
my $system;
if ($jobName =~ /^($jobNameRE)-($systemRE)$/) {
$jobName = $1;
$system = $2;
}
(my $build, my @others) =
grep { $_->{job}->job eq $jobName && (!defined $system || ($_->{build} && $_->{build}->system eq $system)) }
@{$result->{jobs}};
notFound($c, "View doesn't have a job named ‘$jobName’" . ($system ? " for ‘$system’" : "") . ".")
unless defined $build;
error($c, "Job `$jobName' isn't unique.") if @others;
return $c->res->redirect($c->uri_for($c->controller('Build')->action_for('build'),
[$build->{build}->id], @args));
}
}
1;
my $result = getViewResult($primaryBuild, $c->stash->{jobs});
$c->stash->{result} = $result;
if (scalar @args == 1 && $args[0] eq "release") {
requireProjectOwner($c, $c->stash->{project});
my %jobNames;
$jobNames{$_->{job}->job}++ foreach @{$result->{jobs}};
$c->stash->{jobNames} = \%jobNames;
if (($c->request->params->{submit} || "") eq "delete") {
$c->stash->{view}->delete;
$c->res->redirect($c->uri_for($c->controller('Project')->action_for('project'),
[$c->stash->{project}->name]));
}
sub create_view_submit : Chained('projectChain') PathPart('create-view/submit') Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
my $viewName = $c->request->params->{name};
$c->res->redirect($c->uri_for($c->controller('View')->action_for('view_view'),
[$c->stash->{project}->name, $view->name]));
}
sub create_view : Chained('projectChain') PathPart('create-view') Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
$c->stash->{template} = 'edit-view.tt';
$c->stash->{create} = 1;
}
use utf8;
package Hydra::Schema::ViewJobs;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Hydra::Schema::ViewJobs
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 COMPONENTS LOADED
=over 4
=item * L<Hydra::Component::ToJSON>
=back
=cut
__PACKAGE__->load_components("+Hydra::Component::ToJSON");
=head1 TABLE: C<ViewJobs>
=cut
__PACKAGE__->table("ViewJobs");
=head1 ACCESSORS
=head2 project
data_type: 'text'
is_foreign_key: 1
is_nullable: 0
=head2 view_
data_type: 'text'
is_foreign_key: 1
is_nullable: 0
=head2 job
data_type: 'text'
is_nullable: 0
=head2 attrs
data_type: 'text'
is_nullable: 0
=head2 isprimary
data_type: 'integer'
default_value: 0
is_nullable: 0
=head2 description
data_type: 'text'
is_nullable: 1
=head2 jobset
data_type: 'text'
is_nullable: 0
=head2 autorelease
data_type: 'integer'
default_value: 0
is_nullable: 0
=cut
__PACKAGE__->add_columns(
"project",
{ data_type => "text", is_foreign_key => 1, is_nullable => 0 },
"view_",
{ data_type => "text", is_foreign_key => 1, is_nullable => 0 },
"job",
{ data_type => "text", is_nullable => 0 },
"attrs",
{ data_type => "text", is_nullable => 0 },
"isprimary",
{ data_type => "integer", default_value => 0, is_nullable => 0 },
"description",
{ data_type => "text", is_nullable => 1 },
"jobset",
{ data_type => "text", is_nullable => 0 },
"autorelease",
{ data_type => "integer", default_value => 0, is_nullable => 0 },
);
=head1 PRIMARY KEY
=over 4
=item * L</project>
=item * L</view_>
=item * L</job>
=item * L</attrs>
=back
=cut
__PACKAGE__->set_primary_key("project", "view_", "job", "attrs");
=head1 RELATIONS
=head2 project
Type: belongs_to
Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 view
Type: belongs_to
Related object: L<Hydra::Schema::Views>
=cut
__PACKAGE__->belongs_to(
"view",
"Hydra::Schema::Views",
{ name => "view_", project => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-06-13 01:54:50
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hz912vBfYw0rHslBPqJW2w
1;
use utf8;
package Hydra::Schema::Views;
# Created by DBIx::Class::Schema::Loader
# DO NOT MODIFY THE FIRST PART OF THIS FILE
=head1 NAME
Hydra::Schema::Views
=cut
use strict;
use warnings;
use base 'DBIx::Class::Core';
=head1 COMPONENTS LOADED
=over 4
=item * L<Hydra::Component::ToJSON>
=back
=cut
__PACKAGE__->load_components("+Hydra::Component::ToJSON");
=head1 TABLE: C<Views>
=cut
__PACKAGE__->table("Views");
=head1 ACCESSORS
=head2 project
data_type: 'text'
is_foreign_key: 1
is_nullable: 0
=head2 name
data_type: 'text'
is_nullable: 0
=head2 description
data_type: 'text'
is_nullable: 1
=head2 keep
data_type: 'integer'
default_value: 0
is_nullable: 0
=cut
__PACKAGE__->add_columns(
"project",
{ data_type => "text", is_foreign_key => 1, is_nullable => 0 },
"name",
{ data_type => "text", is_nullable => 0 },
"description",
{ data_type => "text", is_nullable => 1 },
"keep",
{ data_type => "integer", default_value => 0, is_nullable => 0 },
);
=head1 PRIMARY KEY
=over 4
=item * L</project>
=item * L</name>
=back
=cut
__PACKAGE__->set_primary_key("project", "name");
=head1 RELATIONS
=head2 project
Type: belongs_to
Related object: L<Hydra::Schema::Projects>
=cut
__PACKAGE__->belongs_to(
"project",
"Hydra::Schema::Projects",
{ name => "project" },
{ is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
);
=head2 viewjobs
Type: has_many
Related object: L<Hydra::Schema::ViewJobs>
=cut
__PACKAGE__->has_many(
"viewjobs",
"Hydra::Schema::ViewJobs",
{ "foreign.project" => "self.project", "foreign.view_" => "self.name" },
undef,
);
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2013-06-13 01:54:50
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:U23GZ3k5KZk2go6j2LYLHA
1;
{ "foreign.project" => "self.name" },
undef,
);
=head2 viewjobs
Type: has_many
Related object: L<Hydra::Schema::ViewJobs>
=cut
__PACKAGE__->has_many(
"viewjobs",
"Hydra::Schema::ViewJobs",
{ "foreign.project" => "self.name" },
undef,
);
=head2 views
Type: has_many
Related object: L<Hydra::Schema::Views>
=cut
__PACKAGE__->has_many(
"views",
"Hydra::Schema::Views",
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2014-04-23 22:48:21
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:l8eN9UAavdqnL7Sjv4rmFw
# Created by DBIx::Class::Schema::Loader v0.07033 @ 2014-04-23 23:13:08
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fkd9ruEoVSBGIktmAj4u4g
[% releaseName = (result.releasename || "(No name)") %]
[% WRAPPER layout.tt title="View $releaseName" %]
[% PROCESS common.tt %]
[% PROCESS "product-list.tt" %]
[% USE HTML %]
<p><em>Finished building on [% INCLUDE renderDateTime timestamp = result.timestamp %].</em></p>
[% IF result.status == 1 %]
<p class="error">Note: One or more of the jobs in the view did not build correctly. See below for details.</p>
[% ELSIF result.status == 2 %]
<p class="error">Note: One or more of the jobs in the view have not been built (yet). See below for details.</p>
[% END %]
[% FOREACH j IN result.jobs %]
<h2>
[% IF j.build %]<a href="[% c.uri_for('/build' j.build.id) %]">[% END %]
[% INCLUDE renderViewJobName job=j.job %]
[% IF j.build %]</a>[% END %]
</h2>
[% IF j.build %]
[% IF j.build.buildstatus == 0 %]
[% IF j.build.buildproducts %]
[% p = jobNames.${j.job.job} > 1 ? "-${j.build.system}" : "";
INCLUDE renderProductList build=j.build latestRoot=['/view' project.name view.name 'latest' "${j.job.job}${p}"]
%]
[% ELSE %]
<p><em>Succeeded.</em></p>
[% END %]
[% ELSE %]
<p class="error">Build failed</p>
[% END %]
[% ELSE %]
<p class="error">Build not (yet) performed.</p>
[% END %]
<br />
[% END %]
[% END %]
[% IF c.user_exists %]
<p>
<a class="btn" href="[% c.uri_for('/view' project.name view.name result.id 'release') %]">Release</a>
</p>
[% END %]
[% WRAPPER layout.tt title=(create ? "New view" : "View $project.name:$view.name") %]
[% PROCESS common.tt %]
[% USE HTML %]
[% BLOCK renderJob %]
<tr id="[% id %]" >
<td>
<button type="button" class="btn btn-warning" onclick='$(this).parents("tr").remove()'>
<i class="icon-trash icon-white"></i>
</button>
</td>
<td><input type="radio" id="[% "$baseName-primary" %]" name="primary" [% IF job.isprimary %]
checked="checked" [% END %] [% HTML.attributes(value => "$n") %] /></td>
<td><input type="text" class="string" [% HTML.attributes(id => "$baseName-name", name => "$baseName-name", value => "$job.jobset:$job.job") %] /></td>
<td><input type="text" class="string" [% HTML.attributes(id => "$baseName-description", name => "$baseName-description", value => job.description) %] /></td>
<td><input type="text" class="string" [% HTML.attributes(id => "$baseName-attrs", name => "$baseName-attrs", value => job.attrs) %] /></td>
</tr>
[% END %]
<form class="form-horizontal" action="[% IF create %][% c.uri_for('/project' project.name 'create-view/submit') %][% ELSE %][% c.uri_for('/view' project.name view.name 'submit') %][% END %]" method="post">
<fieldset>
<div class="control-group">
<label class="control-label">Identifier</label>
<div class="controls">
<input type="text" class="span3" name="name" [% HTML.attributes(value => view.name) %]/>
</div>
</div>
<div class="control-group">
<label class="control-label">Description</label>
<div class="controls">
<input type="text" class="span3" name="description" [% HTML.attributes(value => view.description) %]/>
</div>
</div>
<table class="table table-condensed table-striped">
<thead>
<tr>
<th></th>
<th>Primary job</th>
<th>Job name</th>
<th>Description</th>
<th>Constraint</th>
</tr>
</thead>
<tbody>
[% n = 0 %]
[% FOREACH j IN jobs %]
[% INCLUDE renderJob baseName="job-$n" job=j %]
[% n = n + 1 %]
[% END %]
</tbody>
</table>
<div class="form-actions">
<button type="submit" class="btn btn-primary">
<i class="icon-ok icon-white"></i>
[%IF create %]Create[% ELSE %]Apply changes[% END %]
</button>
[% IF !create %]
<button id="delete-view" type="submit" class="btn btn-danger" name="submit" value="delete">
<i class="icon-trash icon-white"></i>
Delete this view
</button>
<script type="text/javascript">
$("#delete-view").click(function() {
return confirm("Are you sure you want to delete this view?");
});
</script>
[% END %]
</div>
</form>
<table class="template"> <!-- dummy wrapper needed because “hidden” trs are visible anyway -->
[% INCLUDE renderJob job="" id="job-template" baseName="job-template" %]
</table>
<script type="text/javascript">
$(document).ready(function() {
var id = [% n %];
$(".add-job").click(function() {
var newnr = id++;
var newid = "job-" + newnr;
var x = $("#job-template").clone(true).attr("id", "").insertBefore($(this).parents("tr")).show();
$("#job-template-name", x).attr("name", newid + "-name");
$("#job-template-description", x).attr("name", newid + "-description");
$("#job-template-attrs", x).attr("name", newid + "-attrs");
$("#job-template-primary", x).attr("value", newnr);
return false;
});
});
</script>
[% END %]
<tr>
<td colspan="5" style="text-align: center;"><button type="button" class="add-job btn btn-success"><i class="icon-plus icon-white"></i> Add a job</button></td>
</tr>
[% WRAPPER layout.tt title="View $view.project.name:$view.name" %]
[% PROCESS common.tt %]
[% USE HTML %]
<p>
<a class="btn" href="[% c.uri_for('/view' project.name view.name "edit") %]"><i class="icon-edit"></i> Edit</a>
<a class="btn" href="[% c.uri_for('/view' project.name view.name "latest") %]"><i class="icon-share-alt"></i> Latest</a>
</p>
<p>Showing results [% (page - 1) * resultsPerPage + 1 %] - [% (page - 1) * resultsPerPage + results.size %] out of [% totalResults %].</p>
<table class="table table-condensed table-striped clickable-rows">
<thead>
<tr>
<th></th>
<th>#</th>
<th>Name</th>
<th>Date</th>
[% FOREACH j IN jobs %]
<th class="releaseSetJobName">[% INCLUDE renderViewJobName job=j %]</th>
[% END %]
</tr>
</thead>
<tbody>
[% FOREACH result IN results %]
<tr>
<td>
[% IF result.status == 0 %]
<img src="[% c.uri_for("/static/images/checkmark_16.png") %]" />
[% ELSIF result.status == 1 %]
<img src="[% c.uri_for("/static/images/error_16.png") %]" />
[% ELSIF result.status == 2 %]
<img src="[% c.uri_for("/static/images/help_16.png") %]" />
[% END %]
</td>
<td><a class="row-link" href="[% c.uri_for('/view' project.name view.name result.id) %]">[% result.id %]</a></td>
<td>
[% IF result.releasename %]
<tt>[% result.releasename %]</tt>
[% ELSE %]
<em>No name</em>
[% END %]
</td>
<td>[% INCLUDE renderDateTime timestamp=result.timestamp %]</td>
[% FOREACH j IN result.jobs %]
<td class="centered">
[% IF j.build %]
<a href="[% c.uri_for('/build' j.build.id) %]">
[% IF j.build.get_column('buildstatus') == 0 %]
<img src="[% c.uri_for("/static/images/checkmark_16.png") %]" />
[% ELSE %]
<img src="[% c.uri_for("/static/images/error_16.png") %]" />
[% END %]
</a>
[% END %]
</td>
[% END %]
</tr>
[% END %]
</tbody>
</table>
[% END %]
<ul class="pager">
[% IF page > 1 %]
<li class="previous"><a href="[% "$baseUri?page="; (page - 1) %]">Prev</a></li>
[% END %]
[% IF page * resultsPerPage < totalResults %]
<li class="next"><a href="[% "$baseUri?page="; (page + 1) %]">Next</a></li>
[% END %]
</ul>
<!--
[<a href="[% "$baseUri?page=1" %]">First</a>]
[% IF page > 1 %]
[<a href="[% "$baseUri?page="; (page - 1) %]">Prev</a>]
[% END %]
[% IF page * resultsPerPage < totalResults %]
[<a href="[% "$baseUri?page="; (page + 1) %]">Next</a>]
[% END %]
[<a href="[% "$baseUri?page="; (totalResults - 1) div resultsPerPage + 1 %]">Last</a>]
</p>
-->
<p>
<div id="tabs-views" class="tab-pane">
[% IF views.size > 0 %]
<p>Project <tt>[% project.name %]</tt> has the following views:</p>
<ul>
[% FOREACH view IN views %]
<li>
<a href="[% c.uri_for('/view' project.name view.name) %]"><tt>[% view.name %]</tt></a>
</li>
[% END %]
</ul>
[% ELSE %]
<p>Project <tt>[% project.name %]</tt> has no views.</p>
[% END %]
<!--
<p>
<a class="btn" href="[% c.uri_for('/project' project.name 'create-view') %]"><i class="icon-plus"></i> Create a new view</a>
</p>
-->
</div>
);
-- Views are a mechanism to automatically group related builds
-- together. A view definition consists of a build of some "primary"
-- job, plus all builds of the other jobs named in ViewJobs that have
-- that build as an input. If there are multiple builds matching a
-- ViewJob, then we take the oldest successful build, or the oldest
-- unsuccessful build if there is no successful build.
create table Views (
project text not null,
name text not null,
description text,
-- If true, don't garbage-collect builds included in this view.
keep integer not null default 0,
primary key (project, name),
foreign key (project) references Projects(name) on delete cascade on update cascade
create table ViewJobs (
project text not null,
view_ text not null,
job text not null,
-- A constraint on the job consisting of `name=value' pairs,
-- e.g. "system=i686-linux officialRelease=true". Should really
-- be a separate table but I'm lazy.
attrs text not null,
-- If set, this is the primary job for the view. There can be
-- only one such job per view.
isPrimary integer not null default 0,
description text,
jobset text not null,
-- If set, once there is a successful build for every job
-- associated with a build of the view's primary job, that set of
-- builds is automatically added as a release to the Releases
-- table.
autoRelease integer not null default 0,
primary key (project, view_, job, attrs),
foreign key (project) references Projects(name) on delete cascade on update cascade,
foreign key (project, view_) references Views(project, name) on delete cascade on update cascade
);
drop table ViewJobs;
drop table Views;