fix impure tests
This commit is contained in:
parent
56bcd0cf0b
commit
17520e2553
|
@ -6,31 +6,20 @@
|
|||
#!${pkgs.bash}/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
export TMPDIR=$(${pkgs.coreutils}/bin/mktemp -d)
|
||||
trap "${pkgs.coreutils}/bin/chmod -R +w '$TMPDIR'; ${pkgs.coreutils}/bin/rm -rf '$TMPDIR'" EXIT
|
||||
export PATH="${lib.makeBinPath ([
|
||||
pkgs.coreutils
|
||||
export PATH="${lib.makeBinPath [
|
||||
pkgs.gitMinimal
|
||||
pkgs.nix
|
||||
self'.packages.clan-cli.checkPython
|
||||
] ++ self'.packages.clan-cli.pytestDependencies)}"
|
||||
|
||||
export CLAN_CORE=$TMPDIR/CLAN_CORE
|
||||
cp -r ${self} $CLAN_CORE
|
||||
chmod +w -R $CLAN_CORE
|
||||
|
||||
cp -r ${self'.packages.clan-cli.src} $TMPDIR/src
|
||||
chmod +w -R $TMPDIR/src
|
||||
cd $TMPDIR/src
|
||||
|
||||
python -m pytest -m "impure" -s ./tests --workers "" "$@"
|
||||
]}"
|
||||
ROOT=$(git rev-parse --show-toplevel)
|
||||
cd "$ROOT/pkgs/clan-cli"
|
||||
nix develop "$ROOT#clan-cli" -c bash -c 'TMPDIR=/tmp python -m pytest -m impure -s ./tests'
|
||||
'';
|
||||
check-clan-template = pkgs.writeShellScriptBin "check-clan-template" ''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
set -euo pipefail
|
||||
set -euox pipefail
|
||||
|
||||
export TMPDIR=$(${pkgs.coreutils}/bin/mktemp -d)
|
||||
trap "${pkgs.coreutils}/bin/chmod -R +w '$TMPDIR'; ${pkgs.coreutils}/bin/rm -rf '$TMPDIR'" EXIT
|
||||
export CLANTMP=$(${pkgs.coreutils}/bin/mktemp -d)
|
||||
trap "${pkgs.coreutils}/bin/chmod -R +w '$CLANTMP'; ${pkgs.coreutils}/bin/rm -rf '$CLANTMP'" EXIT
|
||||
|
||||
export PATH="${lib.makeBinPath [
|
||||
pkgs.coreutils
|
||||
|
@ -43,7 +32,7 @@
|
|||
self'.packages.clan-cli
|
||||
]}"
|
||||
|
||||
cd $TMPDIR
|
||||
cd $CLANTMP
|
||||
|
||||
echo initialize new clan
|
||||
nix flake init -t ${self}#new-clan
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import argparse
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
from ..dirs import get_clan_flake_toplevel
|
||||
from ..dirs import get_clan_flake_toplevel, module_root
|
||||
from ..errors import ClanError
|
||||
from ..nix import nix_build, nix_config, nix_eval
|
||||
|
||||
|
@ -22,6 +23,9 @@ def upload_secrets(machine: str) -> None:
|
|||
text=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
env = os.environ.copy()
|
||||
env["PYTHONPATH"] = str(module_root().parent) # TODO do this in the clanCore module
|
||||
host = json.loads(
|
||||
subprocess.run(
|
||||
nix_eval(
|
||||
|
@ -41,6 +45,7 @@ def upload_secrets(machine: str) -> None:
|
|||
secret_upload_script,
|
||||
host,
|
||||
],
|
||||
env=env,
|
||||
)
|
||||
|
||||
if secret_upload.returncode != 0:
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
, zbar
|
||||
, tor
|
||||
, git
|
||||
, ipdb
|
||||
}:
|
||||
let
|
||||
|
||||
|
@ -43,6 +44,7 @@ let
|
|||
openssh
|
||||
git
|
||||
stdenv.cc
|
||||
ipdb # used for debugging
|
||||
];
|
||||
|
||||
# Optional dependencies for clan cli, we re-expose them here to make sure they all build.
|
||||
|
|
|
@ -1,26 +1,16 @@
|
|||
{ nix-unit, clan-cli, ui-assets, python3, system, ruff, mkShell, writeScriptBin }:
|
||||
{ nix-unit, clan-cli, ui-assets, system, mkShell, writeScriptBin, openssh }:
|
||||
let
|
||||
pythonWithDeps = python3.withPackages (
|
||||
ps:
|
||||
clan-cli.propagatedBuildInputs
|
||||
++ clan-cli.devDependencies
|
||||
++ [
|
||||
ps.pip
|
||||
ps.ipdb
|
||||
]
|
||||
);
|
||||
checkScript = writeScriptBin "check" ''
|
||||
nix build .#checks.${system}.{treefmt,clan-pytest} -L "$@"
|
||||
'';
|
||||
in
|
||||
mkShell {
|
||||
packages = [
|
||||
ruff
|
||||
nix-unit
|
||||
pythonWithDeps
|
||||
openssh
|
||||
clan-cli.checkPython
|
||||
];
|
||||
# sets up an editable install and add enty points to $PATH
|
||||
PYTHONPATH = "${pythonWithDeps}/${pythonWithDeps.sitePackages}";
|
||||
PYTHONBREAKPOINT = "ipdb.set_trace";
|
||||
|
||||
shellHook = ''
|
||||
|
|
|
@ -59,6 +59,7 @@ def sshd_config(project_root: Path, test_root: Path) -> Iterator[SshdConfig]:
|
|||
MaxStartups 64:30:256
|
||||
AuthorizedKeysFile {host_key}.pub
|
||||
AcceptEnv REALPATH
|
||||
PasswordAuthentication no
|
||||
"""
|
||||
)
|
||||
login_shell = dir / "shell"
|
||||
|
@ -109,7 +110,6 @@ def sshd(
|
|||
) -> Iterator[Sshd]:
|
||||
import subprocess
|
||||
|
||||
subprocess.run(["echo", "hello"], check=True)
|
||||
port = unused_tcp_port()
|
||||
sshd = shutil.which("sshd")
|
||||
assert sshd is not None, "no sshd binary found"
|
||||
|
@ -123,6 +123,7 @@ def sshd(
|
|||
)
|
||||
|
||||
while True:
|
||||
print(sshd_config.path)
|
||||
if (
|
||||
subprocess.run(
|
||||
[
|
||||
|
@ -137,7 +138,7 @@ def sshd(
|
|||
"-p",
|
||||
str(port),
|
||||
"true",
|
||||
]
|
||||
],
|
||||
).returncode
|
||||
== 0
|
||||
):
|
||||
|
|
|
@ -5,25 +5,29 @@
|
|||
# this placeholder is replaced by the path to nixpkgs
|
||||
inputs.clan-core.url = "__CLAN_CORE__";
|
||||
|
||||
outputs = { self, clan-core }: {
|
||||
nixosConfigurations = clan-core.lib.buildClan {
|
||||
directory = self;
|
||||
machines = {
|
||||
vm1 = { modulesPath, ... }: {
|
||||
imports = [ "${toString modulesPath}/virtualisation/qemu-vm.nix" ];
|
||||
clan.networking.deploymentAddress = "__CLAN_DEPLOYMENT_ADDRESS__";
|
||||
sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__";
|
||||
outputs = { self, clan-core }:
|
||||
let
|
||||
clan = clan-core.lib.buildClan {
|
||||
directory = self;
|
||||
machines = {
|
||||
vm1 = { modulesPath, ... }: {
|
||||
imports = [ "${toString modulesPath}/virtualisation/qemu-vm.nix" ];
|
||||
clan.networking.deploymentAddress = "__CLAN_DEPLOYMENT_ADDRESS__";
|
||||
sops.age.keyFile = "__CLAN_SOPS_KEY_PATH__";
|
||||
|
||||
clanCore.secrets.testpassword = {
|
||||
generator = ''
|
||||
echo "secret1" > "$secrets/secret1"
|
||||
echo "fact1" > "$facts/fact1"
|
||||
'';
|
||||
secrets.secret1 = { };
|
||||
facts.fact1 = { };
|
||||
clanCore.secrets.testpassword = {
|
||||
generator = ''
|
||||
echo "secret1" > "$secrets/secret1"
|
||||
echo "fact1" > "$facts/fact1"
|
||||
'';
|
||||
secrets.secret1 = { };
|
||||
facts.fact1 = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
inherit (clan) nixosConfigurations clanInternals;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ if TYPE_CHECKING:
|
|||
|
||||
|
||||
@pytest.mark.impure
|
||||
def test_upload_secret(
|
||||
def test_secrets_upload(
|
||||
monkeypatch: pytest.MonkeyPatch,
|
||||
test_flake_with_core: Path,
|
||||
host_group: HostGroup,
|
||||
|
|
Loading…
Reference in New Issue
Block a user