Support passing a jobset evaluation as an input

All successful, non-garbage-collected builds in the evaluation are
passed in a attribute set.  So if you declare a Hydra input named
‘foo’ of type ‘eval’, you get a set with members ‘foo.<jobname>’.  For
instance, if you passed a Nixpkgs eval as an input named ‘nixpkgs’,
then you could get the Firefox build for x86_64-linux as
‘nixpkgs.firefox.x86_64-linux’.

Inputs of type ‘eval’ can be specified in three ways:

* As the number of the evaluation.

* As a jobset identifier (‘<project>:<jobset>’), which will yield the
  latest finished evaluation of that jobset.  Note that there is no
  guarantee that any job in that evaluation has succeeded, so it might
  not be very useful.

* As a job identifier (‘<project>:<jobset>:<job>’), which will yield
  the latest finished evaluation of that jobset in which <job>
  succeeded.  In conjunction with aggregate jobs, this allows you to
  make sure that the evaluation contains the desired builds.
This commit is contained in:
Eelco Dolstra
2013-11-11 21:17:22 +00:00
parent 7b35e4d0de
commit 8f104396ec
5 changed files with 73 additions and 7 deletions

View File

@ -173,10 +173,16 @@ sub nixExprPathFromParams {
sub checkInputValue {
my ($c, $type, $value) = @_;
my ($c, $name, $type, $value) = @_;
$value = trim $value;
error($c, "Invalid Boolean value $value.") if
error($c, "The value $value of input $name is not a Boolean (true or false).") if
$type eq "boolean" && !($value eq "true" || $value eq "false");
error($c, "The value $value of input $name does not specify a Hydra evaluation. "
. "It should be either the number of a specific evaluation, the name of "
. "a jobset (given as <project>:<jobset>), or the name of a job (<project>:<jobset>:<job>).")
if $type eq "eval" && $value !~ /^\d+$/
&& $value !~ /^$projectNameRE:$jobsetNameRE$/
&& $value !~ /^$projectNameRE:$jobsetNameRE:$jobNameRE$/;
return $value;
}
@ -237,7 +243,7 @@ sub updateJobset {
my @values = ref($values) eq 'ARRAY' ? @{$values} : ($values);
my $altnr = 0;
foreach my $value (@values) {
$value = checkInputValue($c, $type, $value);
$value = checkInputValue($c, $name, $type, $value);
$input->jobsetinputalts->create({altnr => $altnr++, value => $value});
}
}
@ -294,7 +300,7 @@ sub evals_GET {
# Redirect to the latest finished evaluation of this jobset.
sub latest_eval : Chained('jobsetChain') PathPart('latest-eval') {
my ($self, $c, @args) = @_;
my $eval = getLatestFinishedEval($c, $c->stash->{jobset})
my $eval = getLatestFinishedEval($c->stash->{jobset})
or notFound($c, "No evaluation found.");
$c->res->redirect($c->uri_for($c->controller('JobsetEval')->action_for("view"), [$eval->id], @args, $c->req->params));
}

View File

@ -47,7 +47,7 @@ sub view : Chained('eval') PathPart('') Args(0) {
} elsif (defined $compare && $compare =~ /^($jobsetNameRE)$/) {
my $j = $c->stash->{project}->jobsets->find({name => $compare})
or notFound($c, "Jobset $compare doesn't exist.");
$eval2 = getLatestFinishedEval($c, $j);
$eval2 = getLatestFinishedEval($j);
} else {
notFound($c, "Unknown comparison source $compare.");
}

View File

@ -37,7 +37,8 @@ sub begin :Private {
'boolean' => 'Boolean',
'nix' => 'Nix expression',
'build' => 'Build output',
'sysbuild' => 'Build output (same system)'
'sysbuild' => 'Build output (same system)',
'eval' => 'Previous Hydra evaluation'
};
$_->supportedInputTypes($c->stash->{inputTypes}) foreach @{$c->hydra_plugins};