* More release -> view.
This commit is contained in:
parent
8f9417f822
commit
321027b262
@ -180,4 +180,34 @@ sub get_builds : Chained('project') PathPart('') CaptureArgs(0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub create_view_submit : Chained('project') PathPart('create-view/submit') Args(0) {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
requireProjectOwner($c, $c->stash->{project});
|
||||||
|
|
||||||
|
my $viewName = $c->request->params->{name};
|
||||||
|
|
||||||
|
my $view;
|
||||||
|
txn_do($c->model('DB')->schema, sub {
|
||||||
|
# Note: $viewName is validated in updateView, which will abort
|
||||||
|
# the transaction if the name isn't valid.
|
||||||
|
$view = $c->stash->{project}->views->create({name => $viewName});
|
||||||
|
Hydra::Controller::View::updateView($c, $view);
|
||||||
|
});
|
||||||
|
|
||||||
|
$c->res->redirect($c->uri_for($c->controller('View')->action_for('view_view'),
|
||||||
|
[$c->stash->{project}->name, $view->name]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
sub create_view : Chained('project') PathPart('create-view') Args(0) {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
|
||||||
|
requireProjectOwner($c, $c->stash->{project});
|
||||||
|
|
||||||
|
$c->stash->{template} = 'edit-view.tt';
|
||||||
|
$c->stash->{create} = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
@ -30,18 +30,18 @@ sub getView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub updateReleaseSet {
|
sub updateView {
|
||||||
my ($c, $releaseSet) = @_;
|
my ($c, $view) = @_;
|
||||||
|
|
||||||
my $releaseSetName = trim $c->request->params->{name};
|
my $viewName = trim $c->request->params->{name};
|
||||||
error($c, "Invalid release set name: $releaseSetName")
|
error($c, "Invalid view name: $viewName")
|
||||||
unless $releaseSetName =~ /^[[:alpha:]][\w\-]*$/;
|
unless $viewName =~ /^[[:alpha:]][\w\-]*$/;
|
||||||
|
|
||||||
$releaseSet->update(
|
$view->update(
|
||||||
{ name => $releaseSetName
|
{ name => $viewName
|
||||||
, description => trim $c->request->params->{description} });
|
, description => trim $c->request->params->{description} });
|
||||||
|
|
||||||
$releaseSet->releasesetjobs->delete_all;
|
$view->viewjobs->delete_all;
|
||||||
|
|
||||||
foreach my $param (keys %{$c->request->params}) {
|
foreach my $param (keys %{$c->request->params}) {
|
||||||
next unless $param =~ /^job-(\d+)-name$/;
|
next unless $param =~ /^job-(\d+)-name$/;
|
||||||
@ -56,13 +56,13 @@ sub updateReleaseSet {
|
|||||||
my $jobName = $2;
|
my $jobName = $2;
|
||||||
|
|
||||||
error($c, "Jobset `$jobsetName' doesn't exist.")
|
error($c, "Jobset `$jobsetName' doesn't exist.")
|
||||||
unless $releaseSet->project->jobsets->find({name => $jobsetName});
|
unless $view->project->jobsets->find({name => $jobsetName});
|
||||||
|
|
||||||
# !!! We could check whether the job exists, but that would
|
# !!! We could check whether the job exists, but that would
|
||||||
# require the scheduler to have seen the job, which may not be
|
# require the scheduler to have seen the job, which may not be
|
||||||
# the case.
|
# the case.
|
||||||
|
|
||||||
$releaseSet->releasesetjobs->create(
|
$view->viewjobs->create(
|
||||||
{ jobset => $jobsetName
|
{ jobset => $jobsetName
|
||||||
, job => $jobName
|
, job => $jobName
|
||||||
, description => $description
|
, description => $description
|
||||||
@ -72,7 +72,7 @@ sub updateReleaseSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
error($c, "There must be one primary job.")
|
error($c, "There must be one primary job.")
|
||||||
if $releaseSet->releasesetjobs->search({isprimary => 1})->count != 1;
|
if $view->viewjobs->search({isprimary => 1})->count != 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ sub view_view : Chained('view') PathPart('') Args(0) {
|
|||||||
push @results, getRelease($_, $c->stash->{jobs}) foreach
|
push @results, getRelease($_, $c->stash->{jobs}) foreach
|
||||||
getPrimaryBuildsForReleaseSet($c->stash->{project}, $c->stash->{primaryJob}, $page, $resultsPerPage);
|
getPrimaryBuildsForReleaseSet($c->stash->{project}, $c->stash->{primaryJob}, $page, $resultsPerPage);
|
||||||
|
|
||||||
$c->stash->{baseUri} = $c->uri_for($self->action_for("view"), $c->stash->{project}->name, $c->stash->{view}->name);
|
$c->stash->{baseUri} = $c->uri_for($self->action_for("view_view"), $c->req->captures);
|
||||||
$c->stash->{results} = [@results];
|
$c->stash->{results} = [@results];
|
||||||
$c->stash->{page} = $page;
|
$c->stash->{page} = $page;
|
||||||
$c->stash->{totalResults} = getPrimaryBuildTotal($c->stash->{project}, $c->stash->{primaryJob});
|
$c->stash->{totalResults} = getPrimaryBuildTotal($c->stash->{project}, $c->stash->{primaryJob});
|
||||||
@ -113,6 +113,26 @@ sub edit : Chained('view') PathPart('edit') Args(0) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 delete : Chained('view') PathPart('delete') Args(0) {
|
||||||
|
my ($self, $c) = @_;
|
||||||
|
requireProjectOwner($c, $c->stash->{project});
|
||||||
|
txn_do($c->model('DB')->schema, sub {
|
||||||
|
$c->stash->{view}->delete;
|
||||||
|
});
|
||||||
|
$c->res->redirect($c->uri_for($c->controller('Project')->action_for('view'), [$c->stash->{project}->name]));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sub latest : Chained('view') PathPart('latest') {
|
sub latest : Chained('view') PathPart('latest') {
|
||||||
my ($self, $c, @args) = @_;
|
my ($self, $c, @args) = @_;
|
||||||
|
|
||||||
@ -121,14 +141,14 @@ sub latest : Chained('view') PathPart('latest') {
|
|||||||
my $latest = getLatestSuccessfulRelease(
|
my $latest = getLatestSuccessfulRelease(
|
||||||
$c->stash->{project}, $c->stash->{primaryJob}, $c->stash->{jobs});
|
$c->stash->{project}, $c->stash->{primaryJob}, $c->stash->{jobs});
|
||||||
error($c, "This view set has no successful results yet.") if !defined $latest;
|
error($c, "This view set has no successful results yet.") if !defined $latest;
|
||||||
return $c->res->redirect($c->uri_for("/view", $c->stash->{project}->name, $c->stash->{view}->name, $latest->id, @args));
|
$c->res->redirect($c->uri_for($self->action_for("view_view"), $c->req->captures, $latest->id, @args));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub result : Chained('view') PathPart('') {
|
sub result : Chained('view') PathPart('') {
|
||||||
my ($self, $c, $id, @args) = @_;
|
my ($self, $c, $id, @args) = @_;
|
||||||
|
|
||||||
$c->stash->{template} = 'release.tt';
|
$c->stash->{template} = 'view-result.tt';
|
||||||
|
|
||||||
# Note: we don't actually check whether $id is a primary build,
|
# Note: we don't actually check whether $id is a primary build,
|
||||||
# but who cares?
|
# but who cares?
|
||||||
@ -138,18 +158,18 @@ sub result : Chained('view') PathPart('') {
|
|||||||
, '+as' => ["releasename", "buildstatus"] })
|
, '+as' => ["releasename", "buildstatus"] })
|
||||||
or error($c, "Build $id doesn't exist.");
|
or error($c, "Build $id doesn't exist.");
|
||||||
|
|
||||||
$c->stash->{release} = getRelease($primaryBuild, $c->stash->{jobs});
|
$c->stash->{result} = getRelease($primaryBuild, $c->stash->{jobs});
|
||||||
|
|
||||||
# Provide a redirect to the specified job of this release. !!!
|
# Provide a redirect to the specified job of this view result.
|
||||||
# This isn't uniquely defined if there are multiple jobs with the
|
# !!! This isn't uniquely defined if there are multiple jobs with
|
||||||
# same name (e.g. builds for different platforms). However, this
|
# the same name (e.g. builds for different platforms). However,
|
||||||
# mechanism is primarily to allow linking to resources of which
|
# this mechanism is primarily to allow linking to resources of
|
||||||
# there is only one build, such as the manual of the latest
|
# which there is only one build, such as the manual of the latest
|
||||||
# release.
|
# view result.
|
||||||
if (scalar @args != 0) {
|
if (scalar @args != 0) {
|
||||||
my $jobName = shift @args;
|
my $jobName = shift @args;
|
||||||
(my $build, my @others) = grep { $_->{job}->job eq $jobName } @{$c->stash->{release}->{jobs}};
|
(my $build, my @others) = grep { $_->{job}->job eq $jobName } @{$c->stash->{result}->{jobs}};
|
||||||
notFound($c, "Release doesn't have a job named `$jobName'")
|
notFound($c, "View doesn't have a job named `$jobName'")
|
||||||
unless defined $build;
|
unless defined $build;
|
||||||
error($c, "Job `$jobName' isn't unique.") if @others;
|
error($c, "Job `$jobName' isn't unique.") if @others;
|
||||||
return $c->res->redirect($c->uri_for($c->controller('Build')->action_for('view_build'),
|
return $c->res->redirect($c->uri_for($c->controller('Build')->action_for('view_build'),
|
||||||
|
@ -159,7 +159,7 @@
|
|||||||
[% END %]
|
[% END %]
|
||||||
|
|
||||||
|
|
||||||
[% BLOCK renderReleaseJobName -%]
|
[% BLOCK renderViewJobName -%]
|
||||||
[% IF job.description; HTML.escape(job.description); ELSE %]<tt>[% job.job %]</tt> ([% job.attrs %])[% END -%]
|
[% IF job.description; HTML.escape(job.description); ELSE %]<tt>[% job.job %]</tt> ([% job.attrs %])[% END -%]
|
||||||
[% END -%]
|
[% END -%]
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
[% END %]
|
[% END %]
|
||||||
|
|
||||||
|
|
||||||
<form action="[% IF create %][% c.uri_for('/create-view' project.name 'submit') %][% ELSE %][% c.uri_for('/view' project.name view.name 'submit') %][% END %]" method="post">
|
<form 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">
|
||||||
|
|
||||||
<table class="layoutTable">
|
<table class="layoutTable">
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
[% releaseName = (release.releasename || "(No name)") -%]
|
|
||||||
[% WRAPPER layout.tt title="Release $releaseName" %]
|
|
||||||
[% PROCESS common.tt %]
|
|
||||||
[% PROCESS "product-list.tt" %]
|
|
||||||
[% USE HTML %]
|
|
||||||
|
|
||||||
<h1>Release <tt>[% releaseName %]</tt></h1>
|
|
||||||
|
|
||||||
<p><em>Released on [% INCLUDE renderDateTime timestamp = release.timestamp %].</em></p>
|
|
||||||
|
|
||||||
[% IF release.status == 1 %]
|
|
||||||
<p class="error">This is a failed release. One of its jobs has failed. See below for details.</p>
|
|
||||||
[% ELSIF release.status == 2 %]
|
|
||||||
<p class="error">This is an incomplete release. One of its jobs has not been built (yet). See below for details.</p>
|
|
||||||
[% END %]
|
|
||||||
|
|
||||||
[% FOREACH j IN release.jobs %]
|
|
||||||
|
|
||||||
<h2>
|
|
||||||
[% IF j.build %]<a href="[% c.uri_for('/build' j.build.id) %]">[% END %]
|
|
||||||
[% INCLUDE renderReleaseJobName job=j.job %]
|
|
||||||
[% IF j.build %]</a>[% END %]
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
[% IF j.build %]
|
|
||||||
|
|
||||||
[% IF j.build.resultInfo.buildstatus == 0 %]
|
|
||||||
|
|
||||||
[% INCLUDE renderProductList build=j.build latestRoot=['/release' project.name releaseSet.name 'latest' j.job.job] %]
|
|
||||||
|
|
||||||
[% ELSE %]
|
|
||||||
|
|
||||||
<p class="error">Build failed</p>
|
|
||||||
|
|
||||||
[% END %]
|
|
||||||
|
|
||||||
[% ELSE %]
|
|
||||||
|
|
||||||
<p class="error">Build not (yet) performed.</p>
|
|
||||||
|
|
||||||
[% END %]
|
|
||||||
|
|
||||||
[% END %]
|
|
||||||
|
|
||||||
[% END %]
|
|
45
src/root/view-result.tt
Normal file
45
src/root/view-result.tt
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
[% releaseName = (result.releasename || "(No name)") -%]
|
||||||
|
[% WRAPPER layout.tt title="View $releaseName" %]
|
||||||
|
[% PROCESS common.tt %]
|
||||||
|
[% PROCESS "product-list.tt" %]
|
||||||
|
[% USE HTML %]
|
||||||
|
|
||||||
|
<h1>View <tt>[% view.project.name %]:[% view.name %]</tt> result [% result.id %][% IF result.releasename %] (<tt>[% result.releasename %]</tt>)[% END %]</h1>
|
||||||
|
|
||||||
|
<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.resultInfo.buildstatus == 0 %]
|
||||||
|
|
||||||
|
[% INCLUDE renderProductList build=j.build latestRoot=['/view' project.name view.name 'latest' j.job.job] %]
|
||||||
|
|
||||||
|
[% ELSE %]
|
||||||
|
|
||||||
|
<p class="error">Build failed</p>
|
||||||
|
|
||||||
|
[% END %]
|
||||||
|
|
||||||
|
[% ELSE %]
|
||||||
|
|
||||||
|
<p class="error">Build not (yet) performed.</p>
|
||||||
|
|
||||||
|
[% END %]
|
||||||
|
|
||||||
|
[% END %]
|
||||||
|
|
||||||
|
[% END %]
|
@ -19,7 +19,7 @@
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Date</th>
|
<th>Date</th>
|
||||||
[% FOREACH j IN jobs %]
|
[% FOREACH j IN jobs %]
|
||||||
<th class="releaseSetJobName">[% INCLUDE renderReleaseJobName job=j %]</th>
|
<th class="releaseSetJobName">[% INCLUDE renderViewJobName job=j %]</th>
|
||||||
[% END %]
|
[% END %]
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user