tests: actually execute vars checks in CI

This commit is contained in:
DavHau
2025-05-31 14:56:48 +07:00
parent 4518bf6ca4
commit 60f07c3472
5 changed files with 11 additions and 9 deletions

View File

@@ -10,7 +10,7 @@ clanLib.test.makeTestClan {
nixosTest = ( nixosTest = (
{ ... }: { ... }:
{ {
name = "service-hello-test"; name = "hello-service";
clan = { clan = {
directory = ./.; directory = ./.;

View File

@@ -11,7 +11,7 @@ clanLib.test.makeTestClan {
nixosTest = ( nixosTest = (
{ ... }: { ... }:
{ {
name = "wifi"; name = "wifi-service";
clan = { clan = {
directory = ./.; directory = ./.;

View File

@@ -34,7 +34,7 @@ in
else if v == null then else if v == null then
throw "Please set either clan.self or clan.directory" throw "Please set either clan.self or clan.directory"
else else
"${v}" v
) lib.types.path; ) lib.types.path;
default = builtins.toString self; default = builtins.toString self;
defaultText = "Root directory of the flake"; defaultText = "Root directory of the flake";

View File

@@ -5,6 +5,7 @@
let let
inherit (lib) inherit (lib)
mkOption mkOption
removePrefix
types types
; ;
@@ -37,11 +38,13 @@ in
update-vars-script = "${self.packages.${pkgs.system}.generate-test-vars}/bin/generate-test-vars"; update-vars-script = "${self.packages.${pkgs.system}.generate-test-vars}/bin/generate-test-vars";
relativeDir = removePrefix ("${self}/") (toString test.config.clan.directory);
update-vars = pkgs.writeShellScriptBin "update-vars" '' update-vars = pkgs.writeShellScriptBin "update-vars" ''
${update-vars-script} $PRJ_ROOT/checks/${testName} ${testName} ${update-vars-script} $PRJ_ROOT/${relativeDir} ${testName}
''; '';
testSrc = lib.cleanSource (self + "/checks/${testName}"); testSrc = lib.cleanSource test.config.clan.directory;
vars-check = vars-check =
pkgs.runCommand "update-vars-check" pkgs.runCommand "update-vars-check"
@@ -67,9 +70,6 @@ in
}; };
} }
'' ''
# make the test depend on its vars-check derivation
echo ${vars-check} >/dev/null
${self.legacyPackages.${pkgs.system}.setupNixInNix} ${self.legacyPackages.${pkgs.system}.setupNixInNix}
cp -r ${testSrc} ./src cp -r ${testSrc} ./src
chmod +w -R ./src chmod +w -R ./src
@@ -182,6 +182,8 @@ in
# Harder to handle advanced setups (like TPM, LUKS, or LVM-on-LUKS) but not needed since we are in a test # Harder to handle advanced setups (like TPM, LUKS, or LVM-on-LUKS) but not needed since we are in a test
# No systemd journal logs from initrd. # No systemd journal logs from initrd.
boot.initrd.systemd.enable = false; boot.initrd.systemd.enable = false;
# make the test depend on its vars-check derivation
environment.variables.CLAN_VARS_CHECK = "${vars-check}";
} }
); );

View File

@@ -246,7 +246,7 @@ in
The path to the file containing the content of the generated value. The path to the file containing the content of the generated value.
This will be set automatically This will be set automatically
''; '';
type = nullOr str; type = nullOr path;
default = null; default = null;
}; };
path = lib.mkOption { path = lib.mkOption {