From c4e39d476937a384abe259a7509f6fcf1039b7a4 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 11 Oct 2013 12:01:52 +0200 Subject: [PATCH] Add one-shot jobsets There are jobsets that are evaluated only once, that is, after they've been evaluated, they're disabled automatically. This is primarily useful for doing releases: for instance, doing an evaluation with "officialRelease" set to "true" should be done only once. --- src/lib/Hydra/Controller/Job.pm | 6 +----- src/lib/Hydra/Controller/Jobset.pm | 5 +++-- src/lib/Hydra/Controller/Root.pm | 2 +- src/lib/Hydra/Helper/Nix.pm | 2 +- src/root/edit-jobset.tt | 13 ++++++++++--- src/root/jobset.tt | 8 ++++---- src/root/static/js/common.js | 12 +++++++++++- src/script/hydra-evaluator | 5 ++++- src/sql/hydra.sql | 2 +- 9 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/lib/Hydra/Controller/Job.pm b/src/lib/Hydra/Controller/Job.pm index fc37972d..66a12e5f 100644 --- a/src/lib/Hydra/Controller/Job.pm +++ b/src/lib/Hydra/Controller/Job.pm @@ -31,11 +31,7 @@ sub overview : Chained('job') PathPart('') Args(0) { $c->stash->{queuedBuilds} = [ $job->builds->search( { finished => 0 }, - { join => ['project'] - , order_by => ["priority DESC", "id"] - , '+select' => ['project.enabled'] - , '+as' => ['enabled'] - } + { order_by => ["priority DESC", "id"] } ) ]; # If this is an aggregate job, then get its constituents. diff --git a/src/lib/Hydra/Controller/Jobset.pm b/src/lib/Hydra/Controller/Jobset.pm index b8a149d2..a7c88c2a 100644 --- a/src/lib/Hydra/Controller/Jobset.pm +++ b/src/lib/Hydra/Controller/Jobset.pm @@ -197,14 +197,15 @@ sub updateJobset { my ($nixExprPath, $nixExprInput) = nixExprPathFromParams $c; - my $enabled = defined $c->stash->{params}->{enabled}; + my $enabled = int($c->stash->{params}->{enabled}); + die if $enabled < 0 || $enabled > 2; $jobset->update( { name => $jobsetName , description => trim($c->stash->{params}->{"description"}) , nixexprpath => $nixExprPath , nixexprinput => $nixExprInput - , enabled => $enabled ? 1 : 0 + , enabled => $enabled , enableemail => defined $c->stash->{params}->{enableemail} ? 1 : 0 , emailoverride => trim($c->stash->{params}->{emailoverride}) || "" , hidden => defined $c->stash->{params}->{visible} ? 0 : 1 diff --git a/src/lib/Hydra/Controller/Root.pm b/src/lib/Hydra/Controller/Root.pm index 6a2d3619..281cc90c 100644 --- a/src/lib/Hydra/Controller/Root.pm +++ b/src/lib/Hydra/Controller/Root.pm @@ -74,7 +74,7 @@ sub queue_GET { $self->status_ok( $c, entity => [$c->model('DB::Builds')->search( - {finished => 0}, { join => ['project'], order_by => ["priority DESC", "id"], columns => [@buildListColumns], '+select' => ['project.enabled'], '+as' => ['enabled'] })] + {finished => 0}, { order_by => ["priority DESC", "id"], columns => [@buildListColumns] })] ); } diff --git a/src/lib/Hydra/Helper/Nix.pm b/src/lib/Hydra/Helper/Nix.pm index 3b6afbf9..fe506750 100644 --- a/src/lib/Hydra/Helper/Nix.pm +++ b/src/lib/Hydra/Helper/Nix.pm @@ -540,7 +540,7 @@ sub grab { sub getTotalShares { my ($db) = @_; return $db->resultset('Jobsets')->search( - { 'project.enabled' => 1, 'me.enabled' => 1 }, + { 'project.enabled' => 1, 'me.enabled' => { '!=' => 0 } }, { join => 'project', select => { sum => 'schedulingshares' }, as => 'sum' })->single->get_column('sum'); } diff --git a/src/root/edit-jobset.tt b/src/root/edit-jobset.tt index c299f60f..8c2e9b87 100644 --- a/src/root/edit-jobset.tt +++ b/src/root/edit-jobset.tt @@ -49,11 +49,18 @@
+
- +
+ + + + +
+
+ +