forked from lix-project/hydra
Merge pull request #1108 from DeterminateSystems/builds-project-jobset/Project-Build
Builds table: replace some project and jobset references in the Projects and Builds controllers
This commit is contained in:
commit
dc4a4aa038
|
@ -33,7 +33,7 @@ our @EXPORT = qw(
|
||||||
|
|
||||||
|
|
||||||
# Columns from the Builds table needed to render build lists.
|
# Columns from the Builds table needed to render build lists.
|
||||||
Readonly::Array our @buildListColumns => ('id', 'finished', 'timestamp', 'stoptime', 'project', 'jobset', 'job', 'nixname', 'system', 'buildstatus', 'releasename');
|
Readonly::Array our @buildListColumns => ('id', 'finished', 'timestamp', 'stoptime', 'project', 'jobset', 'jobset_id', 'job', 'nixname', 'system', 'buildstatus', 'releasename');
|
||||||
|
|
||||||
|
|
||||||
sub getBuild {
|
sub getBuild {
|
||||||
|
|
|
@ -568,7 +568,7 @@ sub readNixFile {
|
||||||
|
|
||||||
sub isLocalStore {
|
sub isLocalStore {
|
||||||
my $uri = getStoreUri();
|
my $uri = getStoreUri();
|
||||||
return $uri =~ "^(local|daemon|auto)";
|
return $uri =~ "^(local|daemon|auto|file)";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -584,7 +584,7 @@ sub makeSource {
|
||||||
sub makeQueries {
|
sub makeQueries {
|
||||||
my ($name, $constraint) = @_;
|
my ($name, $constraint) = @_;
|
||||||
|
|
||||||
my $activeJobs = "(select distinct project, jobset, job, system from Builds where isCurrent = 1 $constraint)";
|
my $activeJobs = "(select distinct jobset_id, job, system from Builds where isCurrent = 1 $constraint)";
|
||||||
|
|
||||||
makeSource(
|
makeSource(
|
||||||
"LatestSucceeded$name",
|
"LatestSucceeded$name",
|
||||||
|
@ -594,7 +594,7 @@ sub makeQueries {
|
||||||
(select
|
(select
|
||||||
(select max(b.id) from builds b
|
(select max(b.id) from builds b
|
||||||
where
|
where
|
||||||
project = activeJobs.project and jobset = activeJobs.jobset
|
jobset_id = activeJobs.jobset_id
|
||||||
and job = activeJobs.job and system = activeJobs.system
|
and job = activeJobs.job and system = activeJobs.system
|
||||||
and finished = 1 and buildstatus = 0
|
and finished = 1 and buildstatus = 0
|
||||||
) as id
|
) as id
|
||||||
|
@ -606,7 +606,7 @@ QUERY
|
||||||
}
|
}
|
||||||
|
|
||||||
makeQueries('', "");
|
makeQueries('', "");
|
||||||
makeQueries('ForProject', "and project = ?");
|
makeQueries('ForProject', "and jobset_id in (select id from jobsets j where j.project = ?)");
|
||||||
makeQueries('ForJobset', "and jobset_id = ?");
|
makeQueries('ForJobset', "and jobset_id = ?");
|
||||||
makeQueries('ForJob', "and jobset_id = ? and job = ?");
|
makeQueries('ForJob', "and jobset_id = ? and job = ?");
|
||||||
makeQueries('ForJobName', "and jobset_id = (select id from jobsets j where j.name = ?) and job = ?");
|
makeQueries('ForJobName', "and jobset_id = (select id from jobsets j where j.name = ?) and job = ?");
|
||||||
|
|
|
@ -248,6 +248,11 @@ __PACKAGE__->many_to_many("usernames", "projectmembers", "username");
|
||||||
|
|
||||||
use JSON::MaybeXS;
|
use JSON::MaybeXS;
|
||||||
|
|
||||||
|
sub builds {
|
||||||
|
my ($self) = @_;
|
||||||
|
return $self->jobsets->related_resultset('builds');
|
||||||
|
};
|
||||||
|
|
||||||
sub as_json {
|
sub as_json {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ BLOCK renderBuildListBody;
|
||||||
[% END %]
|
[% END %]
|
||||||
<td><a class="row-link" href="[% link %]">[% build.id %]</a></td>
|
<td><a class="row-link" href="[% link %]">[% build.id %]</a></td>
|
||||||
[% IF !hideJobName %]
|
[% IF !hideJobName %]
|
||||||
<td><a href="[%link%]">[% IF !hideJobsetName %][%build.get_column("project")%]:[%build.get_column("jobset")%]:[% END %][%build.get_column("job")%]</td>
|
<td><a href="[%link%]">[% IF !hideJobsetName %][%build.jobset.get_column("project")%]:[%build.jobset.get_column("name")%]:[% END %][%build.get_column("job")%]</td>
|
||||||
[% END %]
|
[% END %]
|
||||||
<td class="nowrap">[% t = showSchedulingInfo ? build.timestamp : build.stoptime; IF t; INCLUDE renderRelativeDate timestamp=(showSchedulingInfo ? build.timestamp : build.stoptime); ELSE; "-"; END %]</td>
|
<td class="nowrap">[% t = showSchedulingInfo ? build.timestamp : build.stoptime; IF t; INCLUDE renderRelativeDate timestamp=(showSchedulingInfo ? build.timestamp : build.stoptime); ELSE; "-"; END %]</td>
|
||||||
<td>[% !showSchedulingInfo and build.get_column('releasename') ? build.get_column('releasename') : build.nixname %]</td>
|
<td>[% !showSchedulingInfo and build.get_column('releasename') ? build.get_column('releasename') : build.nixname %]</td>
|
||||||
|
|
|
@ -36,7 +36,14 @@ my $constituents = request(GET $url,
|
||||||
);
|
);
|
||||||
|
|
||||||
ok($constituents->is_success, "Getting the constituent builds");
|
ok($constituents->is_success, "Getting the constituent builds");
|
||||||
my $data = decode_json($constituents->content);
|
|
||||||
|
my $data;
|
||||||
|
my $valid_json = lives { $data = decode_json($constituents->content); };
|
||||||
|
ok($valid_json, "We get back valid JSON.");
|
||||||
|
if (!$valid_json) {
|
||||||
|
use Data::Dumper;
|
||||||
|
print STDERR Dumper $constituents->content;
|
||||||
|
}
|
||||||
|
|
||||||
my ($buildA) = grep { $_->{nixname} eq "empty-dir-a" } @$data;
|
my ($buildA) = grep { $_->{nixname} eq "empty-dir-a" } @$data;
|
||||||
my ($buildB) = grep { $_->{nixname} eq "empty-dir-b" } @$data;
|
my ($buildB) = grep { $_->{nixname} eq "empty-dir-b" } @$data;
|
||||||
|
|
31
t/Hydra/Controller/Job/builds.t
Normal file
31
t/Hydra/Controller/Job/builds.t
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Setup;
|
||||||
|
use Test2::V0;
|
||||||
|
use Catalyst::Test ();
|
||||||
|
use HTTP::Request::Common;
|
||||||
|
|
||||||
|
my $ctx = test_context();
|
||||||
|
|
||||||
|
Catalyst::Test->import('Hydra');
|
||||||
|
|
||||||
|
my $builds = $ctx->makeAndEvaluateJobset(
|
||||||
|
expression => "basic.nix",
|
||||||
|
build => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
my $build = $builds->{"empty_dir"};
|
||||||
|
my $jobset = $build->jobset;
|
||||||
|
my $project = $build->project;
|
||||||
|
|
||||||
|
subtest "/job/PROJECT/JOBSET/JOB/all" => sub {
|
||||||
|
my $response = request(GET '/job/' . $project->name . '/' . $jobset->name . '/' . $build->job . '/all');
|
||||||
|
ok($response->is_success, "The page showing the job's builds returns 200.");
|
||||||
|
};
|
||||||
|
|
||||||
|
subtest "/job/PROJECT/JOBSET/JOB/channel/latest" => sub {
|
||||||
|
my $response = request(GET '/job/' . $project->name . '/' . $jobset->name . '/' . $build->job . '/channel/latest');
|
||||||
|
ok($response->is_success, "The page showing the job's channel returns 200.");
|
||||||
|
};
|
||||||
|
|
||||||
|
done_testing;
|
31
t/Hydra/Controller/Jobset/builds.t
Normal file
31
t/Hydra/Controller/Jobset/builds.t
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Setup;
|
||||||
|
use Test2::V0;
|
||||||
|
use Catalyst::Test ();
|
||||||
|
use HTTP::Request::Common;
|
||||||
|
|
||||||
|
my $ctx = test_context();
|
||||||
|
|
||||||
|
Catalyst::Test->import('Hydra');
|
||||||
|
|
||||||
|
my $builds = $ctx->makeAndEvaluateJobset(
|
||||||
|
expression => "basic.nix",
|
||||||
|
build => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
my $build = $builds->{"empty_dir"};
|
||||||
|
my $project = $build->project;
|
||||||
|
my $jobset = $build->jobset;
|
||||||
|
|
||||||
|
subtest "/jobset/PROJECT/JOBSET/all" => sub {
|
||||||
|
my $response = request(GET '/jobset/' . $project->name . '/' . $jobset->name . '/all');
|
||||||
|
ok($response->is_success, "The page showing the jobset's builds returns 200.");
|
||||||
|
};
|
||||||
|
|
||||||
|
subtest "/jobset/PROJECT/JOBSET/channel/latest" => sub {
|
||||||
|
my $response = request(GET '/jobset/' . $project->name . '/' . $jobset->name . '/channel/latest');
|
||||||
|
ok($response->is_success, "The page showing the jobset's builds returns 200.");
|
||||||
|
};
|
||||||
|
|
||||||
|
done_testing;
|
30
t/Hydra/Controller/Project/builds.t
Normal file
30
t/Hydra/Controller/Project/builds.t
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Setup;
|
||||||
|
use Test2::V0;
|
||||||
|
use Catalyst::Test ();
|
||||||
|
use HTTP::Request::Common;
|
||||||
|
|
||||||
|
my $ctx = test_context();
|
||||||
|
|
||||||
|
Catalyst::Test->import('Hydra');
|
||||||
|
|
||||||
|
my $builds = $ctx->makeAndEvaluateJobset(
|
||||||
|
expression => "basic.nix",
|
||||||
|
build => 1
|
||||||
|
);
|
||||||
|
|
||||||
|
my $build = $builds->{"empty_dir"};
|
||||||
|
my $project = $build->project;
|
||||||
|
|
||||||
|
subtest "/project/PROJECT/all" => sub {
|
||||||
|
my $response = request(GET '/project/' . $project->name . '/all');
|
||||||
|
ok($response->is_success, "The page showing the project's builds returns 200.");
|
||||||
|
};
|
||||||
|
|
||||||
|
subtest "/project/PROJECT/channel/latest" => sub {
|
||||||
|
my $response = request(GET '/project/' . $project->name . '/channel/latest');
|
||||||
|
ok($response->is_success, "The page showing the project's builds returns 200.");
|
||||||
|
};
|
||||||
|
|
||||||
|
done_testing;
|
Loading…
Reference in a new issue