Fediversity/deployment/check/data-model/nixosTest.nix
2025-08-10 12:29:45 +02:00

62 lines
1.4 KiB
Nix

{
lib,
...
}:
{
_class = "nixosTest";
name = "deployment-model";
sourceFileset = lib.fileset.unions [
../../data-model.nix
../../function.nix
./constants.nix
./deployment.nix
];
nodes.deployer =
{ pkgs, ... }:
{
# FIXME: sad times
system.extraDependencies = with pkgs; [
jq
jq.inputDerivation
];
system.extraDependenciesFromModule =
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [
hello
cowsay
];
};
};
extraTestScript = ''
with subtest("Check the status before deployment"):
hello.fail("hello 1>&2")
cowsay.fail("cowsay 1>&2")
# SETTINGS.BIN_PATH
# CONFIG
env = {
"PATH": settings.bin_path,
# "TF_LOG": "info",
} | {
# pass in form info to our deployment
# FIXME: ensure sensitive info is protected
f"TF_VAR_{k}": v if isinstance(v, str) else json.dumps(v) for k, v in json.loads(config.model_dump_json()).items()
}
# USE ENV
# SETTINGS.REPO_DIR
with subtest("Run the deployment"):
deployer.succeed("cd ${settings.repo_dir}/infra/operator && tofu apply --auto-approve -lock=false -parallelism=1")
with subtest("Check the deployment"):
hello.succeed("hello 1>&2")
cowsay.succeed("cowsay hi 1>&2")
'';
}