tests: actually execute vars checks in CI

This commit is contained in:
DavHau
2025-05-31 14:56:48 +07:00
parent 3c9c7341c1
commit d27834b565
5 changed files with 11 additions and 9 deletions

View File

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

View File

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

View File

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

View File

@@ -5,6 +5,7 @@
let
inherit (lib)
mkOption
removePrefix
types
;
@@ -37,11 +38,13 @@ in
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-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 =
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}
cp -r ${testSrc} ./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
# No systemd journal logs from initrd.
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.
This will be set automatically
'';
type = nullOr str;
type = nullOr path;
default = null;
};
path = lib.mkOption {