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:
Graham Christensen 2022-01-14 12:05:35 -05:00 committed by GitHub
commit dc4a4aa038
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 111 additions and 7 deletions

View file

@ -33,7 +33,7 @@ our @EXPORT = qw(
# 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 {

View file

@ -568,7 +568,7 @@ sub readNixFile {
sub isLocalStore {
my $uri = getStoreUri();
return $uri =~ "^(local|daemon|auto)";
return $uri =~ "^(local|daemon|auto|file)";
}

View file

@ -584,7 +584,7 @@ sub makeSource {
sub makeQueries {
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(
"LatestSucceeded$name",
@ -594,7 +594,7 @@ sub makeQueries {
(select
(select max(b.id) from builds b
where
project = activeJobs.project and jobset = activeJobs.jobset
jobset_id = activeJobs.jobset_id
and job = activeJobs.job and system = activeJobs.system
and finished = 1 and buildstatus = 0
) as id
@ -606,7 +606,7 @@ QUERY
}
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('ForJob', "and jobset_id = ? and job = ?");
makeQueries('ForJobName', "and jobset_id = (select id from jobsets j where j.name = ?) and job = ?");

View file

@ -248,6 +248,11 @@ __PACKAGE__->many_to_many("usernames", "projectmembers", "username");
use JSON::MaybeXS;
sub builds {
my ($self) = @_;
return $self->jobsets->related_resultset('builds');
};
sub as_json {
my $self = shift;

View file

@ -131,7 +131,7 @@ BLOCK renderBuildListBody;
[% END %]
<td><a class="row-link" href="[% link %]">[% build.id %]</a></td>
[% 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 %]
<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>

View file

@ -36,7 +36,14 @@ my $constituents = request(GET $url,
);
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 ($buildB) = grep { $_->{nixname} eq "empty-dir-b" } @$data;

View 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;

View 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;

View 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;