forked from DGNum/colmena
integration-tests: Add flakes test
This commit is contained in:
parent
f849a757d2
commit
321d847563
6 changed files with 77 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
{
|
||||
apply = import ./apply;
|
||||
apply-local = import ./apply-local;
|
||||
parallel = import ./parallel;
|
||||
exec = import ./exec;
|
||||
flakes = import ./flakes;
|
||||
parallel = import ./parallel;
|
||||
}
|
||||
|
|
34
integration-tests/flakes/default.nix
Normal file
34
integration-tests/flakes/default.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
let
|
||||
tools = import ../tools.nix {
|
||||
targets = [ "alpha" ];
|
||||
};
|
||||
in tools.makeTest {
|
||||
name = "colmena-flakes";
|
||||
|
||||
bundle = ./.;
|
||||
|
||||
testScript = ''
|
||||
import re
|
||||
|
||||
with subtest("Lock flake dependencies"):
|
||||
# --impure required for path:/nixpkgs which is a symlink to a store path
|
||||
deployer.succeed("cd /tmp/bundle && nix --experimental-features \"nix-command flakes\" flake lock --impure")
|
||||
|
||||
with subtest("Deploy with a plain flake without git"):
|
||||
deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target")
|
||||
alpha.succeed("grep FIRST /etc/deployment")
|
||||
|
||||
with subtest("Deploy with a git flake"):
|
||||
deployer.succeed("sed -i s/FIRST/SECOND/g /tmp/bundle/probe.nix")
|
||||
|
||||
# don't put probe.nix in source control - should fail
|
||||
deployer.succeed("cd /tmp/bundle && git init && git add flake.nix flake.lock hive.nix tools.nix")
|
||||
logs = deployer.fail("cd /tmp/bundle && run-copy-stderr ${tools.colmenaExec} apply --on @target")
|
||||
assert re.search(r"probe.nix.*No such file or directory", logs)
|
||||
|
||||
# now it should succeed
|
||||
deployer.succeed("cd /tmp/bundle && git add probe.nix")
|
||||
deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target")
|
||||
alpha.succeed("grep SECOND /etc/deployment")
|
||||
'';
|
||||
}
|
15
integration-tests/flakes/flake.nix
Normal file
15
integration-tests/flakes/flake.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
description = "A simple deployment";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "path:/nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }: let
|
||||
pkgs = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
in {
|
||||
colmena = import ./hive.nix { inherit pkgs; };
|
||||
};
|
||||
}
|
21
integration-tests/flakes/hive.nix
Normal file
21
integration-tests/flakes/hive.nix
Normal file
|
@ -0,0 +1,21 @@
|
|||
{ pkgs }:
|
||||
|
||||
let
|
||||
tools = import ./tools.nix {
|
||||
insideVm = true;
|
||||
targets = [ "alpha" ];
|
||||
};
|
||||
in {
|
||||
meta = {
|
||||
nixpkgs = tools.pkgs;
|
||||
};
|
||||
|
||||
deployer = tools.getStandaloneConfigFor "deployer";
|
||||
alpha = {
|
||||
imports = [
|
||||
(tools.getStandaloneConfigFor "alpha")
|
||||
];
|
||||
|
||||
environment.etc."deployment".text = import ./probe.nix;
|
||||
};
|
||||
}
|
1
integration-tests/flakes/probe.nix
Normal file
1
integration-tests/flakes/probe.nix
Normal file
|
@ -0,0 +1 @@
|
|||
"FIRST"
|
|
@ -61,10 +61,12 @@ let
|
|||
];
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
environment.systemPackages = with pkgs; [
|
||||
git # for git flake tests
|
||||
|
||||
# HACK: copy stderr to both stdout and stderr
|
||||
# (the test framework only captures stdout, and only stderr appears on screen during the build)
|
||||
(pkgs.writeShellScriptBin "run-copy-stderr" ''
|
||||
(writeShellScriptBin "run-copy-stderr" ''
|
||||
exec "$@" 2> >(tee /dev/stderr)
|
||||
'')
|
||||
];
|
||||
|
|
Loading…
Reference in a new issue