Branch: refs/heads/master
Home: https://github.com/NixOS/hydra
Commit: fd50ac1d4eafcfe675464487baa4d7c7e74a7751
https://github.com/NixOS/hydra/commit/fd50ac1d4eafcfe675464487baa4d7c7e74a7751
Author: Eelco Dolstra <[email protected]>
Date: 2012-04-15 (Sun, 15 Apr 2012)
Changed paths:
M src/lib/Hydra/Schema/Builds.pm
A src/lib/Hydra/Schema/JobsetEvalInputs.pm
M src/lib/Hydra/Schema/JobsetEvals.pm
M src/script/hydra-evaluator
M src/sql/hydra.sql
A src/sql/upgrade-6.sql
Log Message:
-----------
Store the inputs of each evaluation in the database
Achtung: this requires a schema upgrade via "hydra-init".
diff --git a/src/lib/Hydra/Schema/Builds.pm b/src/lib/Hydra/Schema/Builds.pm
index def719e..0c4a577 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<Hydra::Schema::JobsetEvalInputs>
+
+=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 0000000..d5465a7
--- /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<JobsetEvalInputs>
+
+=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</eval>
+
+=item * L</name>
+
+=item * L</altnr>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key("eval", "name", "altnr");
+
+=head1 RELATIONS
+
+=head2 dependency
+
+Type: belongs_to
+
+Related object: L<Hydra::Schema::Builds>
+
+=cut
+
+__PACKAGE__->belongs_to(
+ "dependency",
+ "Hydra::Schema::Builds",
+ { id => "dependency" },
+ { join_type => "LEFT" },
+);
+
+=head2 eval
+
+Type: belongs_to
+
+Related object: L<Hydra::Schema::JobsetEvals>
+
+=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 27145d1..3dc7452 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<Hydra::Schema::JobsetEvalInputs>
+
+=cut
+
+__PACKAGE__->has_many(
+ "jobsetevalinputs",
+ "Hydra::Schema::JobsetEvalInputs",
+ { "foreign.eval" => "self.id" },
+ {},
+);
+
=head2 jobsetevalmembers
Type: has_many
@@ -142,8 +157,8 @@ Related object: L<Hydra::Schema::Projects>
__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 839418e..22f34de 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 1976aeb..485e331 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 0000000..b961de1
--- /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;
================================================================
_______________________________________________
nix-commits mailing list
[email protected]
http://lists.science.uu.nl/mailman/listinfo/nix-commits