diff --git a/src/lib/Hydra/Schema/Builds.pm b/src/lib/Hydra/Schema/Builds.pm index def719e8..0c4a5777 100644 --- a/src/lib/Hydra/Schema/Builds.pm +++ b/src/lib/Hydra/Schema/Builds.pm @@ -388,6 +388,21 @@ __PACKAGE__->belongs_to( {}, ); +=head2 jobsetevalinputs + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "jobsetevalinputs", + "Hydra::Schema::JobsetEvalInputs", + { "foreign.dependency" => "self.id" }, + {}, +); + =head2 jobsetevalmembers Type: has_many @@ -429,8 +444,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-02-29 18:56:22 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:w16c86FRReLPdA8H0yTIRg +# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-04-15 16:38:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:AltTdmkzfwBMYToTkj84vA __PACKAGE__->has_many( "dependents", diff --git a/src/lib/Hydra/Schema/JobsetEvalInputs.pm b/src/lib/Hydra/Schema/JobsetEvalInputs.pm new file mode 100644 index 00000000..d5465a70 --- /dev/null +++ b/src/lib/Hydra/Schema/JobsetEvalInputs.pm @@ -0,0 +1,152 @@ +use utf8; +package Hydra::Schema::JobsetEvalInputs; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Hydra::Schema::JobsetEvalInputs + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("JobsetEvalInputs"); + +=head1 ACCESSORS + +=head2 eval + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +=head2 name + + data_type: 'text' + is_nullable: 0 + +=head2 altnr + + data_type: 'integer' + is_nullable: 0 + +=head2 type + + data_type: 'text' + is_nullable: 0 + +=head2 uri + + data_type: 'text' + is_nullable: 1 + +=head2 revision + + data_type: 'text' + is_nullable: 1 + +=head2 value + + data_type: 'text' + is_nullable: 1 + +=head2 dependency + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 1 + +=head2 path + + data_type: 'text' + is_nullable: 1 + +=head2 sha256hash + + data_type: 'text' + is_nullable: 1 + +=cut + +__PACKAGE__->add_columns( + "eval", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "name", + { data_type => "text", is_nullable => 0 }, + "altnr", + { data_type => "integer", is_nullable => 0 }, + "type", + { data_type => "text", is_nullable => 0 }, + "uri", + { data_type => "text", is_nullable => 1 }, + "revision", + { data_type => "text", is_nullable => 1 }, + "value", + { data_type => "text", is_nullable => 1 }, + "dependency", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, + "path", + { data_type => "text", is_nullable => 1 }, + "sha256hash", + { data_type => "text", is_nullable => 1 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("eval", "name", "altnr"); + +=head1 RELATIONS + +=head2 dependency + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "dependency", + "Hydra::Schema::Builds", + { id => "dependency" }, + { join_type => "LEFT" }, +); + +=head2 eval + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to("eval", "Hydra::Schema::JobsetEvals", { id => "eval" }, {}); + + +# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-04-15 16:38:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:PNxVBdoUNeUzf5BztiIhLw + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/src/lib/Hydra/Schema/JobsetEvals.pm b/src/lib/Hydra/Schema/JobsetEvals.pm index 27145d15..3dc74525 100644 --- a/src/lib/Hydra/Schema/JobsetEvals.pm +++ b/src/lib/Hydra/Schema/JobsetEvals.pm @@ -116,6 +116,21 @@ __PACKAGE__->belongs_to( {}, ); +=head2 jobsetevalinputs + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "jobsetevalinputs", + "Hydra::Schema::JobsetEvalInputs", + { "foreign.eval" => "self.id" }, + {}, +); + =head2 jobsetevalmembers Type: has_many @@ -142,8 +157,8 @@ Related object: L __PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }, {}); -# Created by DBIx::Class::Schema::Loader v0.07014 @ 2011-12-05 14:15:43 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eQtF5bcR/qZ625LxWBc7ug +# Created by DBIx::Class::Schema::Loader v0.07014 @ 2012-04-15 16:38:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Yt39QbkhH52hfpJZ4ZECeg __PACKAGE__->has_many( "buildIds", diff --git a/src/script/hydra-evaluator b/src/script/hydra-evaluator index 839418e0..22f34de6 100755 --- a/src/script/hydra-evaluator +++ b/src/script/hydra-evaluator @@ -171,6 +171,24 @@ sub checkJobset { while (my ($id, $new) = each %buildIds) { $ev->jobsetevalmembers->create({ build => $id, isnew => $new }); } + + foreach my $name (keys %{$inputInfo}) { + for (my $n = 0; $n < scalar(@{$inputInfo->{$name}}); $n++) { + my $input = $inputInfo->{$name}->[$n]; + $ev->jobsetevalinputs->create( + { name => $name + , altnr => $n + , type => $input->{type} + , uri => $input->{uri} + , revision => $input->{revision} + , value => $input->{value} + , dependency => $input->{id} + , path => $input->{storePath} || "" # !!! temporary hack + , sha256hash => $input->{sha256hash} + }); + } + } + print STDERR " created new eval ", $ev->id, "\n"; $ev->builds->update({iscurrent => 1}); } else { diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 1976aeb4..485e3315 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -443,6 +443,27 @@ create table JobsetEvals ( ); +create table JobsetEvalInputs ( + eval integer not null references JobsetEvals(id) on delete cascade, + name text not null, + altNr integer not null, + + -- Copied from the jobsetinputs from which the build was created. + type text not null, + uri text, + revision text, + value text, + dependency integer, -- build ID of the input, for type == 'build' + + path text, + + sha256hash text, + + primary key (eval, name, altNr), + foreign key (dependency) references Builds(id) +); + + create table JobsetEvalMembers ( eval integer not null references JobsetEvals(id) on delete cascade, build integer not null references Builds(id) on delete cascade, @@ -521,6 +542,7 @@ create index IndexCachedGitInputsOnHash on CachedGitInputs(uri, branch, sha256ha create index IndexCachedSubversionInputsOnUriRevision on CachedSubversionInputs(uri, revision); create index IndexCachedBazaarInputsOnUriRevision on CachedBazaarInputs(uri, revision); create index IndexJobsetEvalMembersOnBuild on JobsetEvalMembers(build); +create index IndexJobsetEvalMembersOnEval on JobsetEvalMembers(eval); create index IndexJobsetInputAltsOnInput on JobsetInputAlts(project, jobset, input); create index IndexJobsetInputAltsOnJobset on JobsetInputAlts(project, jobset); create index IndexProjectsOnEnabled on Projects(enabled); diff --git a/src/sql/upgrade-6.sql b/src/sql/upgrade-6.sql new file mode 100644 index 00000000..b961de1e --- /dev/null +++ b/src/sql/upgrade-6.sql @@ -0,0 +1,50 @@ +create index IndexJobsetEvalMembersOnEval on JobsetEvalMembers(eval); + +-- Inputs of jobset evals. +create table JobsetEvalInputs ( + eval integer not null references JobsetEvals(id) on delete cascade, + name text not null, + altNr integer not null, + + -- Copied from the jobsetinputs from which the build was created. + type text not null, + uri text, + revision text, + value text, + dependency integer, -- build ID of the input, for type == 'build' + + path text, + + sha256hash text, + + primary key (eval, name, altNr), + foreign key (dependency) references Builds(id) +); + +-- Reconstruct the repository inputs for pre-existing evals. This is +-- tricky (and not entirely possible) because builds are not uniquely +-- part of a single eval, so they may have different inputs. + +-- For Subversion or Bazaar inputs, pick the highest revision for each +-- input. +insert into JobsetEvalInputs (eval, name, altNr, type, uri, revision) + select e.id, b.name, 0, max(b.type), max(b.uri), max(b.revision) + from (select id from JobsetEvals where hasNewBuilds = 1) e + join JobsetEvalMembers m on e.id = m.eval + join BuildInputs b on b.build = m.build + where (b.type = 'svn' or b.type = 'svn-checkout' or b.type = 'bzr' or b.type = 'bzr-checkout') + group by e.id, b.name + having count(distinct type) = 1 and count(distinct uri) = 1; + +-- For other inputs there is no "best" revision to pick, so only do +-- the conversion if there is only one. +insert into JobsetEvalInputs (eval, name, altNr, type, uri, revision) + select e.id, b.name, 0, max(b.type), max(uri), max(revision) + from (select id from JobsetEvals where hasNewBuilds = 1) e + join JobsetEvalMembers m on e.id = m.eval + join BuildInputs b on b.build = m.build + where (b.type != 'svn' and b.type != 'svn-checkout' and b.type != 'bzr' and b.type != 'bzr-checkout') + and b.uri is not null and b.revision is not null + and not exists(select 1 from JobsetEvalInputs i where e.id = i.eval and b.name = i.name) + group by e.id, b.name + having count(distinct type) = 1 and count(distinct uri) = 1 and count(distinct revision) = 1;