diff --git a/src/lib/Hydra/Helper/CatalystUtils.pm b/src/lib/Hydra/Helper/CatalystUtils.pm index 2b2b4f0b..cfa53e84 100644 --- a/src/lib/Hydra/Helper/CatalystUtils.pm +++ b/src/lib/Hydra/Helper/CatalystUtils.pm @@ -54,7 +54,7 @@ sub getLatestBuilds { { my $attrs = { project => $build->get_column('project') - , job => $build->job + , job => $build->get_column('job') , system => $build->system , finished => 1 }; diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 4f83ba10..f7428a4b 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -124,7 +124,7 @@ sub attrsToSQL { sub getPrimaryBuildsForReleaseSet { my ($project, $primaryJob) = @_; my @primaryBuilds = $project->builds->search( - { job => $primaryJob->job, finished => 1 }, + { job => $primaryJob->get_column('job'), finished => 1 }, { join => 'resultInfo', order_by => "timestamp DESC" , '+select' => ["resultInfo.releasename"], '+as' => ["releasename"] , where => \ attrsToSQL($primaryJob->attrs, "me.id") @@ -154,7 +154,7 @@ sub getRelease { # as input. If there are multiple, prefer successful # ones, and then oldest. !!! order_by buildstatus is hacky ($thisBuild) = $primaryBuild->dependentBuilds->search( - { job => $job->job, finished => 1 }, + { job => $job->get_column('job'), finished => 1 }, { join => 'resultInfo', rows => 1 , order_by => ["buildstatus", "timestamp"] , where => \ attrsToSQL($job->attrs, "build.id") diff --git a/src/lib/Hydra/Schema.pm b/src/lib/Hydra/Schema.pm index 3fa70881..cbbd2203 100644 --- a/src/lib/Hydra/Schema.pm +++ b/src/lib/Hydra/Schema.pm @@ -8,8 +8,8 @@ use base 'DBIx::Class::Schema'; __PACKAGE__->load_classes; -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oIv4qqdjLKRDgAYXHHTz8A +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aJVSTLLx1pgutjETaqTWXA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildInputs.pm b/src/lib/Hydra/Schema/BuildInputs.pm index 632d5b8f..a7668fde 100644 --- a/src/lib/Hydra/Schema/BuildInputs.pm +++ b/src/lib/Hydra/Schema/BuildInputs.pm @@ -36,8 +36,8 @@ __PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }); __PACKAGE__->belongs_to("dependency", "Hydra::Schema::Builds", { id => "dependency" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9gWr8DPEeH2BjoHT3nt0Lw +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uxfS8+GnU06sbx6nvWzTSQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildProducts.pm b/src/lib/Hydra/Schema/BuildProducts.pm index b7777030..b99eff40 100644 --- a/src/lib/Hydra/Schema/BuildProducts.pm +++ b/src/lib/Hydra/Schema/BuildProducts.pm @@ -35,8 +35,8 @@ __PACKAGE__->set_primary_key("build", "productnr"); __PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GsPyt1OUQHWN6z7mSpNW2g +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wnnwDGQMGr2YAu++PYRSuA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildResultInfo.pm b/src/lib/Hydra/Schema/BuildResultInfo.pm index b31e267b..66a31547 100644 --- a/src/lib/Hydra/Schema/BuildResultInfo.pm +++ b/src/lib/Hydra/Schema/BuildResultInfo.pm @@ -35,8 +35,8 @@ __PACKAGE__->set_primary_key("id"); __PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:zIpamqoL0AxNFDpQ/W1TVg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CGlUjhJozOA4VCYaFtyhqw __PACKAGE__->belongs_to( "failedDep", diff --git a/src/lib/Hydra/Schema/BuildSchedulingInfo.pm b/src/lib/Hydra/Schema/BuildSchedulingInfo.pm index 4e33b332..3bb47241 100644 --- a/src/lib/Hydra/Schema/BuildSchedulingInfo.pm +++ b/src/lib/Hydra/Schema/BuildSchedulingInfo.pm @@ -27,8 +27,8 @@ __PACKAGE__->set_primary_key("id"); __PACKAGE__->belongs_to("id", "Hydra::Schema::Builds", { id => "id" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:McWRZEMJtjFIcR4LplCc9A +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:X+Pz2XzTBNU3XdEcg49RyQ # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/BuildSteps.pm b/src/lib/Hydra/Schema/BuildSteps.pm index 42a73016..8d46bc88 100644 --- a/src/lib/Hydra/Schema/BuildSteps.pm +++ b/src/lib/Hydra/Schema/BuildSteps.pm @@ -35,7 +35,7 @@ __PACKAGE__->set_primary_key("build", "stepnr"); __PACKAGE__->belongs_to("build", "Hydra::Schema::Builds", { id => "build" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:zuyAJq4T5Ynsq920Pd7hLg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TtcOwOIZHO0vLSJ1CXF1bA 1; diff --git a/src/lib/Hydra/Schema/Builds.pm b/src/lib/Hydra/Schema/Builds.pm index b95c6b6f..d3bc72a9 100644 --- a/src/lib/Hydra/Schema/Builds.pm +++ b/src/lib/Hydra/Schema/Builds.pm @@ -44,6 +44,11 @@ __PACKAGE__->belongs_to( "Hydra::Schema::Jobsets", { name => "jobset", project => "project" }, ); +__PACKAGE__->belongs_to( + "job", + "Hydra::Schema::Jobs", + { jobset => "jobset", name => "job", project => "project" }, +); __PACKAGE__->has_many( "buildschedulinginfoes", "Hydra::Schema::BuildSchedulingInfo", @@ -76,8 +81,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6taCYZNB0HaY+fvDjUhrYQ +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xqKyjCWVdoTyQJC28K3WXA __PACKAGE__->has_many(dependents => 'Hydra::Schema::BuildInputs', 'dependency'); diff --git a/src/lib/Hydra/Schema/CachedPathInputs.pm b/src/lib/Hydra/Schema/CachedPathInputs.pm index 3041c54a..5fd4c66b 100644 --- a/src/lib/Hydra/Schema/CachedPathInputs.pm +++ b/src/lib/Hydra/Schema/CachedPathInputs.pm @@ -22,8 +22,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("srcpath", "sha256hash"); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Jhu1KxMfSF1Y1b4VGUqTzg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Eo9F2GRzgzTGGx15JWBv6Q # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/CachedSubversionInputs.pm b/src/lib/Hydra/Schema/CachedSubversionInputs.pm index 6618dc47..8cf91008 100644 --- a/src/lib/Hydra/Schema/CachedSubversionInputs.pm +++ b/src/lib/Hydra/Schema/CachedSubversionInputs.pm @@ -20,8 +20,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("uri", "revision"); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9aQa6Zo6z3lj/qFHNF5//w +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KeKwcnnPNoVO4eNr9+y+1g # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Jobs.pm b/src/lib/Hydra/Schema/Jobs.pm new file mode 100644 index 00000000..928be57c --- /dev/null +++ b/src/lib/Hydra/Schema/Jobs.pm @@ -0,0 +1,49 @@ +package Hydra::Schema::Jobs; + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("Jobs"); +__PACKAGE__->add_columns( + "project", + { data_type => "text", is_nullable => 0, size => undef }, + "jobset", + { data_type => "text", is_nullable => 0, size => undef }, + "name", + { data_type => "text", is_nullable => 0, size => undef }, + "active", + { data_type => "integer", is_nullable => 0, size => undef }, + "errormsg", + { data_type => "text", is_nullable => 0, size => undef }, + "firstevaltime", + { data_type => "integer", is_nullable => 0, size => undef }, + "lastevaltime", + { data_type => "integer", is_nullable => 0, size => undef }, +); +__PACKAGE__->set_primary_key("project", "jobset", "name"); +__PACKAGE__->has_many( + "builds", + "Hydra::Schema::Builds", + { + "foreign.job" => "self.name", + "foreign.jobset" => "self.jobset", + "foreign.project" => "self.project", + }, +); +__PACKAGE__->belongs_to("project", "Hydra::Schema::Projects", { name => "project" }); +__PACKAGE__->belongs_to( + "jobset", + "Hydra::Schema::Jobsets", + { name => "jobset", project => "project" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wJFyUvUACQHpaW/ktaYtOQ + + +# You can replace this text with custom content, and it will be preserved on regeneration +1; diff --git a/src/lib/Hydra/Schema/JobsetInputAlts.pm b/src/lib/Hydra/Schema/JobsetInputAlts.pm index 5365642c..8b3c489f 100644 --- a/src/lib/Hydra/Schema/JobsetInputAlts.pm +++ b/src/lib/Hydra/Schema/JobsetInputAlts.pm @@ -31,8 +31,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fBv361MRwuWvAJQnOLZDIw +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:V8h/34X4hs4PKhxKsFgy9w # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/JobsetInputs.pm b/src/lib/Hydra/Schema/JobsetInputs.pm index cb799c85..15d3f568 100644 --- a/src/lib/Hydra/Schema/JobsetInputs.pm +++ b/src/lib/Hydra/Schema/JobsetInputs.pm @@ -43,8 +43,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:S8AQqv8/GkLkXpPutV4N0A +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1XdnQh4HnXU/iOyNvv8QWg # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Jobsets.pm b/src/lib/Hydra/Schema/Jobsets.pm index 62ecd17e..9148a4a5 100644 --- a/src/lib/Hydra/Schema/Jobsets.pm +++ b/src/lib/Hydra/Schema/Jobsets.pm @@ -48,10 +48,18 @@ __PACKAGE__->has_many( "foreign.project" => "self.project", }, ); +__PACKAGE__->has_many( + "jobs", + "Hydra::Schema::Jobs", + { + "foreign.jobset" => "self.name", + "foreign.project" => "self.project", + }, +); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xYDUCEXRPeVdFJBQnG/Wog +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oZ81xw7qIjVkQKjRdOFW9A # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Projects.pm b/src/lib/Hydra/Schema/Projects.pm index 1118f798..6c33f2ee 100644 --- a/src/lib/Hydra/Schema/Projects.pm +++ b/src/lib/Hydra/Schema/Projects.pm @@ -33,6 +33,11 @@ __PACKAGE__->has_many( "Hydra::Schema::Jobsets", { "foreign.project" => "self.name" }, ); +__PACKAGE__->has_many( + "jobs", + "Hydra::Schema::Jobs", + { "foreign.project" => "self.name" }, +); __PACKAGE__->has_many( "releasesets", "Hydra::Schema::ReleaseSets", @@ -45,8 +50,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9ZqA/21u40pt4t85YrYbeg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:z+RXYaHk0RXJfFirBe175A # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/ReleaseSetJobs.pm b/src/lib/Hydra/Schema/ReleaseSetJobs.pm index 965a3c57..c8952f52 100644 --- a/src/lib/Hydra/Schema/ReleaseSetJobs.pm +++ b/src/lib/Hydra/Schema/ReleaseSetJobs.pm @@ -34,8 +34,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Ta71pOzVsej/w0FoHIUMbg +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:iWBkyucz/pXtzI+s0iP0EA # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/ReleaseSets.pm b/src/lib/Hydra/Schema/ReleaseSets.pm index 21818679..2e521e67 100644 --- a/src/lib/Hydra/Schema/ReleaseSets.pm +++ b/src/lib/Hydra/Schema/ReleaseSets.pm @@ -29,8 +29,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0DtIgm5jznjy1l3809b06Q +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:eeWkr8kYyCvFVDZ3YzpI1Q # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/SystemTypes.pm b/src/lib/Hydra/Schema/SystemTypes.pm index deb73e11..5b29d4b2 100644 --- a/src/lib/Hydra/Schema/SystemTypes.pm +++ b/src/lib/Hydra/Schema/SystemTypes.pm @@ -16,8 +16,8 @@ __PACKAGE__->add_columns( __PACKAGE__->set_primary_key("system"); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WUSl5Uivcl6E1KLxiq+89A +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:z83sYSKRnt5mc2etYvH6Zg # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/UserRoles.pm b/src/lib/Hydra/Schema/UserRoles.pm index 159b4206..3aaba9ff 100644 --- a/src/lib/Hydra/Schema/UserRoles.pm +++ b/src/lib/Hydra/Schema/UserRoles.pm @@ -17,8 +17,8 @@ __PACKAGE__->set_primary_key("username", "role"); __PACKAGE__->belongs_to("username", "Hydra::Schema::Users", { username => "username" }); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:x/HXSH7s3bgPJSLK71hV9w +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:WRiW+nBfh/X+TMqYu0PI6g # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/lib/Hydra/Schema/Users.pm b/src/lib/Hydra/Schema/Users.pm index c70a7171..a2dc1458 100644 --- a/src/lib/Hydra/Schema/Users.pm +++ b/src/lib/Hydra/Schema/Users.pm @@ -30,8 +30,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-12 17:44:15 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uP86PxN/ZWgy5PRVU7Qgow +# Created by DBIx::Class::Schema::Loader v0.04005 @ 2009-03-13 13:33:20 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Gw6X/Et2+whq/S7o63zF8Q # You can replace this text with custom content, and it will be preserved on regeneration diff --git a/src/root/build.tt b/src/root/build.tt index 60f87805..38ab2fba 100644 --- a/src/root/build.tt +++ b/src/root/build.tt @@ -189,7 +189,7 @@ [% type = input.type; inputTypes.$type %] [% IF input.type == "build" %] - Job [% input.dependency.project.name %]:[% input.dependency.job %] build [% input.dependency.id %] + Job [% PROCESS renderFullJobNameOfBuild build=input.dependency %] build [% input.dependency.id %] [% ELSIF input.type == "string" || input.type == "boolean" %] "[% input.value %]" [% ELSE %] @@ -300,7 +300,7 @@ [% FOREACH input IN build.dependents -%] - Job [% input.build.project.name %]:[% input.build.job %] build [% input.build.id %] + Job [% PROCESS renderFullJobNameOfBuild build=input.build %] build [% input.build.id %] [% input.name %] [% input.build.system %] [% PROCESS renderDateTime timestamp = input.build.timestamp %] diff --git a/src/root/common.tt b/src/root/common.tt index cf21652c..1232ead4 100644 --- a/src/root/common.tt +++ b/src/root/common.tt @@ -37,6 +37,13 @@ [% END %] +[% BLOCK renderFullJobNameOfBuild %] + + [% PROCESS renderFullJobName project=build.get_column("project") jobset = build.get_column("jobset") job = build.get_column("job") %] + +[% END %] + + [% BLOCK renderBuildList %] @@ -79,7 +86,7 @@ [% END %] diff --git a/src/script/hydra_scheduler.pl b/src/script/hydra_scheduler.pl index 4d24d2cc..b068056a 100755 --- a/src/script/hydra_scheduler.pl +++ b/src/script/hydra_scheduler.pl @@ -216,22 +216,28 @@ sub checkJob { if $job->{schedulingPriority} =~ /^\d+$/; $db->txn_do(sub { - if (scalar($db->resultset('Builds')->search( - { project => $project->name, jobset => $jobset->name - , job => $jobName, outPath => $outPath })) > 0) - { + # Mark this job as active in the database. + my $jobInDB = $jobset->jobs->update_or_create( + { name => $jobName + , active => 1 + , lastevaltime => time + }); + + $jobInDB->update({firstevaltime => time}) + unless defined $jobInDB->firstevaltime; + + # Have we already done this build (in this job)? + if (scalar($jobInDB->builds->search({outPath => $outPath})) > 0) { print "already scheduled/done\n"; return; } + # Nope, so add it. print "adding to queue\n"; - my $build = $db->resultset('Builds')->create( + my $build = $jobInDB->builds->create( { finished => 0 , timestamp => time() - , project => $project->name - , jobset => $jobset->name - , job => $jobName , description => $job->{description} , longdescription => $job->{longDescription} , license => $job->{license} @@ -242,18 +248,16 @@ sub checkJob { , system => $job->{system} }); - $db->resultset('BuildSchedulingInfo')->create( - { id => $build->id - , priority => $priority + $build->buildschedulinginfoes->create( + { priority => $priority , busy => 0 , locker => "" }); foreach my $arg (@{$job->{arg}}) { my $input = $inputInfo->{$arg->{name}}->[$arg->{altnr}] or die "invalid input"; - $db->resultset('BuildInputs')->create( - { build => $build->id - , name => $arg->{name} + $build->buildinputs_builds->create( + { name => $arg->{name} , type => $input->{type} , uri => $input->{uri} , revision => $input->{revision} @@ -337,10 +341,31 @@ sub checkJobSet { # Schedule each successfully evaluated job. foreach my $job (@{$jobs->{job}}) { + next if $job->{jobName} eq ""; print "considering job " . $job->{jobName} . "\n"; checkJob($project, $jobset, $inputInfo, $job); } + # Mark all existing jobs that we haven't seen as inactive. + my %jobNames; + $jobNames{$_->{jobName}}++ foreach @{$jobs->{job}}; + + my %failedJobNames; + push @{$failedJobNames{$_->{location}}}, $_->{msg} foreach @{$jobs->{error}}; + + $db->txn_do(sub { + foreach my $jobInDB ($jobset->jobs->all) { + print $jobInDB->name, "\n"; + $jobInDB->update({active => $jobNames{$jobInDB->name} || $failedJobNames{$jobInDB->name} ? 1 : 0}); + + if ($failedJobNames{$jobInDB->name}) { + $jobInDB->update({errormsg => join '\n', @{$failedJobNames{$jobInDB->name}}}); + } else { + $jobInDB->update({errormsg => undef}); + } + } + }); + # Store the errors messages for jobs that failed to evaluate. my $msg = ""; foreach my $error (@{$jobs->{error}}) { diff --git a/src/sql/hydra.sql b/src/sql/hydra.sql index 24a65291..93206968 100644 --- a/src/sql/hydra.sql +++ b/src/sql/hydra.sql @@ -27,7 +27,8 @@ create table Builds ( homepage text, -- meta.homepage foreign key (project) references Projects(name), -- ignored by sqlite - foreign key (project, jobset) references Jobsets(project, name) -- ignored by sqlite + foreign key (project, jobset) references Jobsets(project, name), -- ignored by sqlite + foreign key (project, jobset, job) references Jobs(project, jobset, name) -- ignored by sqlite ); @@ -253,6 +254,27 @@ create table JobsetInputAlts ( ); +create table Jobs ( + project text not null, + jobset text not null, + name text not null, + + -- `active' means the Nix expression for the jobset currently + -- contains this job. Otherwise it's a job that has been removed + -- from the expression. + active integer not null default 1, + + errorMsg text, -- evalution error for this job + + firstEvalTime integer, -- first time the scheduler saw this job + lastEvalTime integer, -- last time the scheduler saw this job + + primary key (project, jobset, name), + foreign key (project) references Projects(name) on delete cascade, -- ignored by sqlite + foreign key (project, jobset) references Jobsets(project, name) on delete cascade -- ignored by sqlite +); + + -- Cache for inputs of type "path" (used for testing Hydra), storing -- the SHA-256 hash and store path for each source path. Also stores -- the timestamp when we first saw the path have these contents, which
[% build.schedulingInfo.priority %] - [% PROCESS renderFullJobName project=build.get_column("project") jobset = build.get_column("jobset") job = build.job %] + [% PROCESS renderFullJobNameOfBuild %] [% build.resultInfo.releasename ? build.resultInfo.releasename : build.nixname %] [% build.system %]