New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the project name to declarative inputs #717
Conversation
I don't really understand what this is changing. Can you give a concrete explanation (docs, maybe, even) of what this enables, which couldn't be done before, and how to use it? |
@grahamc This makes https://github.com/dasJ/hydra-configs2 work. Currently, we need one spec JSON for every Hydra project we want to configure from the same repository. This is because the Nix expression that is called in .jobsets cannot differentiate between projects. This is what I did here which inputs the project name into the expression. However, this PR does so automatically by adding a second input to the .jobsets evaluation: |
Got it. Cool! Can you add some information to that effect around here? https://github.com/NixOS/hydra/blob/master/doc/manual/declarative-projects.xml#L181 |
3afd4b8
to
e6ba22b
Compare
@grahamc done |
src/script/hydra-eval-jobset
Outdated
@@ -587,6 +587,7 @@ sub checkJobsetWrapped { | |||
updateDeclarativeJobset($db, $project, ".jobsets", $declSpec); | |||
$jobset->discard_changes; | |||
$inputInfo->{"declInput"} = [ $declInput ]; | |||
$inputInfo->{"projectName"} = [ fetchInput($plugins, $db, $project, $jobset, "", "string", $project->name, 0) ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It really threw me for a loop why this code is so complicated, but this is just making:
$inputInfo ->{"projectName"} = [ { "value" => $project->name, } ]
which is used later on by inputsToArgs:
my $alt = $inputInfo->{$input}->[0];
if ($alt->{type} eq "string") {
push @res, "--argstr", $input, $alt->{value};
}
which is so complicated because of the support for "alternative" inputs, a largely and perhaps totally dead feature.
Can you rebase on master then ping me on IRC when the tests pass? From e6ba22b96b9bc7b5646fdf3cd454dd8cb54b460d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Janne=20He=C3=9F?= <janne@hess.ooo>
Date: Tue, 18 Feb 2020 02:16:18 +0100
Subject: [PATCH] Add the project name to declarative inputs
This allows for more generic declarative configurations which can be
shared between projects.
---
doc/manual/declarative-projects.xml | 3 ++-
src/script/hydra-eval-jobset | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/doc/manual/declarative-projects.xml b/doc/manual/declarative-projects.xml
index df909a89..8287e011 100644
--- a/doc/manual/declarative-projects.xml
+++ b/doc/manual/declarative-projects.xml
@@ -179,7 +179,8 @@
file as the jobset configuration for this evaluation. In addition
to any inputs specified in the spec file, hydra will also pass the
<literal>declInput</literal> argument corresponding to the input
- fetched in step 1.
+ fetched in step 1 and the <literal>projectName</literal> argument
+ containing the project's name.
</para>
</listitem>
<listitem>
diff --git a/src/script/hydra-eval-jobset b/src/script/hydra-eval-jobset
index ff76f4ef..3bd53faa 100755
--- a/src/script/hydra-eval-jobset
+++ b/src/script/hydra-eval-jobset
@@ -560,7 +560,7 @@ sub checkJobsetWrapped {
if ($jobsetsJobset) {
my @declInputs = fetchInput($plugins, $db, $project, $jobset, "decl", $project->decltype, $project->declvalue, 0);
my $declInput = @declInputs[0] or die "cannot find the input containing the declarative project specification\n";
- die "multiple alternatives for the input containing the declarative project specificaiton are not supported\n"
+ die "multiple alternatives for the input containing the declarative project specification are not supported\n"
if scalar @declInputs != 1;
my $declFile = $declInput->{storePath} . "/" . $project->declfile;
my $declText = read_file($declFile)
@@ -587,6 +587,7 @@ sub checkJobsetWrapped {
updateDeclarativeJobset($db, $project, ".jobsets", $declSpec);
$jobset->discard_changes;
$inputInfo->{"declInput"} = [ $declInput ];
+ $inputInfo->{"projectName"} = [ fetchInput($plugins, $db, $project, $jobset, "", "string", $project->name, 0) ];
}
} else {
die "Declarative specification file $declFile is not a dictionary"
--
2.28.0 |
This allows for more generic declarative configurations which can be shared between projects.
Thanks for rebasing! |
``` Mar 10 16:22:35 hydra-b hydra-evaluator[41419]: DBIx::Class::Storage::DBI::_dbh_execute(): DBI Exception: DBD::Pg::st execute failed: ERROR: null value in column "type" violates not-null constraint Mar 10 16:22:35 hydra-b hydra-evaluator[41419]: DETAIL: Failing row contains (62358, projectName, 0, null, null, null, hackworthltd, null, , null). [for Statement "INSERT INTO jobsetevalinputs ( altnr, dependency, eval, name, path, revision, sha256hash, type, uri, value) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 1='0', 2=undef, 3='62358', 4='projectName', 5='', 6=undef, 7=undef, 8=undef, 9=undef, 10='hackworthltd'] at /nix/store/cmqblv437mp57yz5lwvkzcqca4ldf3r5-hydra-0.1.20210308.ebf1cd2/bin/.hydra-eval-jobset-wrapped line 793 Mar 10 16:22:35 hydra-b hydra-evaluator[25828]: evaluation of jobset ‘hackworthltd:.jobsets (jobset#1)’ failed with exit code 1 ``` Use the abstraction for creating inputs for simulating the project name input. Co-authored-by: Graham Christensen <graham@grahamc.com>
Fixup #717 "Add the project name to declarative inputs"
This allows for more generic declarative configurations which can be
shared between projects.