-
-
Notifications
You must be signed in to change notification settings - Fork 304
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1349 from NixOS/ca-no-new-col
Allow building content-addressed derivations with hydra, minimally
- Loading branch information
Showing
12 changed files
with
184 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-- CA derivations do not have statically known output paths. The values | ||
-- are only filled in after the build runs. | ||
ALTER TABLE BuildStepOutputs ALTER COLUMN path DROP NOT NULL; | ||
ALTER TABLE BuildOutputs ALTER COLUMN path DROP NOT NULL; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
use feature 'unicode_strings'; | ||
use strict; | ||
use warnings; | ||
use Setup; | ||
|
||
my %ctx = test_init( | ||
nix_config => qq| | ||
experimental-features = ca-derivations | ||
|, | ||
); | ||
|
||
require Hydra::Schema; | ||
require Hydra::Model::DB; | ||
|
||
use JSON::MaybeXS; | ||
|
||
use HTTP::Request::Common; | ||
use Test2::V0; | ||
require Catalyst::Test; | ||
Catalyst::Test->import('Hydra'); | ||
|
||
my $db = Hydra::Model::DB->new; | ||
hydra_setup($db); | ||
|
||
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"}); | ||
|
||
my $jobset = createBaseJobset("content-addressed", "content-addressed.nix", $ctx{jobsdir}); | ||
|
||
ok(evalSucceeds($jobset), "Evaluating jobs/content-addressed.nix should exit with return code 0"); | ||
is(nrQueuedBuildsForJobset($jobset), 5, "Evaluating jobs/content-addressed.nix should result in 4 builds"); | ||
|
||
for my $build (queuedBuildsForJobset($jobset)) { | ||
ok(runBuild($build), "Build '".$build->job."' from jobs/content-addressed.nix should exit with code 0"); | ||
my $newbuild = $db->resultset('Builds')->find($build->id); | ||
is($newbuild->finished, 1, "Build '".$build->job."' from jobs/content-addressed.nix should be finished."); | ||
my $expected = $build->job eq "fails" ? 1 : $build->job =~ /with_failed/ ? 6 : 0; | ||
is($newbuild->buildstatus, $expected, "Build '".$build->job."' from jobs/content-addressed.nix should have buildstatus $expected."); | ||
|
||
my $response = request("/build/".$build->id); | ||
ok($response->is_success, "The 'build' page for build '".$build->job."' should load properly"); | ||
|
||
if ($newbuild->buildstatus == 0) { | ||
my $buildOutputs = $newbuild->buildoutputs; | ||
for my $output ($newbuild->buildoutputs) { | ||
# XXX: This hardcodes /nix/store/. | ||
# It's fine because in practice the nix store for the tests will be of | ||
# the form `/some/thing/nix/store/`, but it would be cleaner if there | ||
# was a way to query Nix for its store dir? | ||
like( | ||
$output->path, qr|/nix/store/|, | ||
"Output '".$output->name."' of build '".$build->job."' should be a valid store path" | ||
); | ||
} | ||
} | ||
|
||
} | ||
|
||
isnt(<$ctx{deststoredir}/realisations/*>, "", "The destination store should have the realisations of the built derivations registered"); | ||
|
||
done_testing; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use feature 'unicode_strings'; | ||
use strict; | ||
use warnings; | ||
use Setup; | ||
|
||
my %ctx = test_init(); | ||
|
||
require Hydra::Schema; | ||
require Hydra::Model::DB; | ||
|
||
use JSON::MaybeXS; | ||
|
||
use HTTP::Request::Common; | ||
use Test2::V0; | ||
require Catalyst::Test; | ||
Catalyst::Test->import('Hydra'); | ||
|
||
my $db = Hydra::Model::DB->new; | ||
hydra_setup($db); | ||
|
||
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"}); | ||
|
||
my $jobset = createBaseJobset("content-addressed", "content-addressed.nix", $ctx{jobsdir}); | ||
|
||
ok(evalSucceeds($jobset), "Evaluating jobs/content-addressed.nix without the experimental feature should exit with return code 0"); | ||
is(nrQueuedBuildsForJobset($jobset), 0, "Evaluating jobs/content-addressed.nix without the experimental Nix feature should result in 0 build"); | ||
|
||
done_testing; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
let cfg = import ./config.nix; in | ||
rec { | ||
empty_dir = | ||
cfg.mkContentAddressedDerivation { | ||
name = "empty-dir"; | ||
builder = ./empty-dir-builder.sh; | ||
}; | ||
|
||
fails = | ||
cfg.mkContentAddressedDerivation { | ||
name = "fails"; | ||
builder = ./fail.sh; | ||
}; | ||
|
||
succeed_with_failed = | ||
cfg.mkContentAddressedDerivation { | ||
name = "succeed-with-failed"; | ||
builder = ./succeed-with-failed.sh; | ||
}; | ||
|
||
caDependingOnCA = | ||
cfg.mkContentAddressedDerivation { | ||
name = "ca-depending-on-ca"; | ||
builder = ./dir-with-file-builder.sh; | ||
FOO = empty_dir; | ||
}; | ||
|
||
nonCaDependingOnCA = | ||
cfg.mkDerivation { | ||
name = "non-ca-depending-on-ca"; | ||
builder = ./dir-with-file-builder.sh; | ||
FOO = empty_dir; | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#! /bin/sh | ||
|
||
mkdir $out | ||
echo foo > $out/a-file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters