Merge pull request #939 from regnat/include-localhost-features

Include localhost's features in the default machine file
This commit is contained in:
Eelco Dolstra 2021-04-28 12:25:21 +02:00 committed by GitHub
commit 8d6a5aac84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 3 deletions

View file

@ -156,7 +156,8 @@ void State::monitorMachinesFile()
if (machinesFiles.empty()) { if (machinesFiles.empty()) {
parseMachines("localhost " + parseMachines("localhost " +
(settings.thisSystem == "x86_64-linux" ? "x86_64-linux,i686-linux" : settings.thisSystem.get()) (settings.thisSystem == "x86_64-linux" ? "x86_64-linux,i686-linux" : settings.thisSystem.get())
+ " - " + std::to_string(settings.maxBuildJobs) + " 1"); + " - " + std::to_string(settings.maxBuildJobs) + " 1 "
+ concatStringsSep(",", settings.systemFeatures.get()));
return; return;
} }

View file

@ -34,7 +34,5 @@ dirs:
touch data/hydra.conf touch data/hydra.conf
mkdir -p nix mkdir -p nix
mkdir -p nix/etc/nix mkdir -p nix/etc/nix
touch nix/etc/nix/nix.conf
echo "sandbox = false" >> nix/etc/nix/nix.conf
mkdir -p nix/store mkdir -p nix/store
mkdir -p nix/var mkdir -p nix/var

30
t/default-machine-file.t Normal file
View file

@ -0,0 +1,30 @@
use feature 'unicode_strings';
use strict;
use Setup;
my %ctx = test_init();
require Hydra::Schema;
require Hydra::Model::DB;
use Test2::V0;
my $db = Hydra::Model::DB->new;
hydra_setup($db);
my $project = $db->resultset('Projects')->create({name => "tests", displayname => "", owner => "root"});
my $jobset = createBaseJobset("default-machine-file", "default-machine-file.nix", $ctx{jobsdir});
ok(evalSucceeds($jobset), "Evaluating jobs/default-machine-file.nix should exit with return code 0");
is(nrQueuedBuildsForJobset($jobset), 1, "Evaluating jobs/default-machine-file.nix should result in 1 build");
for my $build (queuedBuildsForJobset($jobset)) {
ok(runBuild($build), "Build '".$build->job."' from jobs/default-machine-file.nix should exit with code 0");
my $newbuild = $db->resultset('Builds')->find($build->id);
is($newbuild->finished, 1, "Build '".$build->job."' from jobs/default-machine-file.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/default-machine-file.nix should have buildstatus $expected.");
}
done_testing;

View file

@ -0,0 +1,9 @@
with import ./config.nix;
{
requireExperimentalFeatures =
mkDerivation {
name = "empty-dir";
builder = ./empty-dir-builder.sh;
requiredSystemFeatures = [ "test-system-feature" ];
};
}

View file

@ -48,6 +48,7 @@ sub test_init {
my $nixconf = "$ENV{'NIX_CONF_DIR'}/nix.conf"; my $nixconf = "$ENV{'NIX_CONF_DIR'}/nix.conf";
open(my $fh, '>', $nixconf) or die "Could not open file '$nixconf' $!"; open(my $fh, '>', $nixconf) or die "Could not open file '$nixconf' $!";
print $fh "sandbox = false\n"; print $fh "sandbox = false\n";
print $fh "system-features = test-system-feature\n";
print $fh $opts{'nix_config'} || ""; print $fh $opts{'nix_config'} || "";
close $fh; close $fh;