ci: add tests option

This commit is contained in:
lassulus 2017-12-31 13:30:17 +01:00
parent 9ee5c02e75
commit c4a8cc56ef

View File

@ -24,6 +24,13 @@ in
List of hosts that should be build List of hosts that should be build
''; '';
}; };
tests = mkOption {
type = types.listOf types.str;
default = [];
description = ''
List of tests that should be build
'';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -56,14 +63,14 @@ in
''; '';
scheduler = { scheduler = {
build-scheduler = '' build-scheduler = ''
# build all hosts
sched.append( sched.append(
schedulers.SingleBranchScheduler( schedulers.SingleBranchScheduler(
change_filter=util.ChangeFilter(branch_re=".*"), change_filter=util.ChangeFilter(branch_re=".*"),
treeStableTimer=${toString cfg.treeStableTimer}*60, treeStableTimer=${toString cfg.treeStableTimer}*60,
name="build-all-branches", name="build-all-branches",
builderNames=[ builderNames=[
"build-hosts" ${optionalString (cfg.hosts != []) ''"hosts",''}
${optionalString (cfg.tests != []) ''"tests",''}
] ]
) )
) )
@ -73,7 +80,8 @@ in
schedulers.ForceScheduler( schedulers.ForceScheduler(
name="force", name="force",
builderNames=[ builderNames=[
"build-hosts" ${optionalString (cfg.hosts != []) ''"hosts",''}
${optionalString (cfg.tests != []) ''"tests",''}
] ]
) )
) )
@ -91,7 +99,7 @@ in
factory.addStep(steps.ShellCommand(**kwargs)) factory.addStep(steps.ShellCommand(**kwargs))
''; '';
builder = { builder = {
build-hosts = '' hosts = mkIf (cfg.hosts != []) ''
f = util.BuildFactory() f = util.BuildFactory()
f.addStep(grab_repo) f.addStep(grab_repo)
@ -120,12 +128,42 @@ in
bu.append( bu.append(
util.BuilderConfig( util.BuilderConfig(
name="build-hosts", name="hosts",
slavenames=slavenames, slavenames=slavenames,
factory=f factory=f
) )
) )
'';
tests = mkIf (cfg.tests != []) ''
f = util.BuildFactory()
f.addStep(grab_repo)
def run_test(test):
addShell(f,
name="{}".format(test),
env={
"NIX_PATH": "secrets=/var/src/stockholm/null:/var/src",
"NIX_REMOTE": "daemon",
"dummy_secrets": "true",
},
command=[
"nix-build", "-I", "stockholm=.", "krebs/6tests",
"-A", "{}".format(test)
],
timeout=90001
)
${concatMapStringsSep "\n" (test:
"run_test(\"${test}\")"
) cfg.tests}
bu.append(
util.BuilderConfig(
name="tests",
slavenames=slavenames,
factory=f
)
)
''; '';
}; };
enable = true; enable = true;