make all pytest dependencies also available to impure tests
This commit is contained in:
parent
4096ea3adb
commit
18c360f729
|
@ -8,13 +8,12 @@
|
||||||
|
|
||||||
export TMPDIR=$(${pkgs.coreutils}/bin/mktemp -d)
|
export TMPDIR=$(${pkgs.coreutils}/bin/mktemp -d)
|
||||||
trap "${pkgs.coreutils}/bin/chmod -R +w '$TMPDIR'; ${pkgs.coreutils}/bin/rm -rf '$TMPDIR'" EXIT
|
trap "${pkgs.coreutils}/bin/chmod -R +w '$TMPDIR'; ${pkgs.coreutils}/bin/rm -rf '$TMPDIR'" EXIT
|
||||||
|
export PATH="${lib.makeBinPath ([
|
||||||
export PATH="${lib.makeBinPath [
|
|
||||||
pkgs.coreutils
|
pkgs.coreutils
|
||||||
pkgs.gitMinimal
|
pkgs.gitMinimal
|
||||||
pkgs.nix
|
pkgs.nix
|
||||||
self'.packages.clan-cli.checkPython
|
self'.packages.clan-cli.checkPython
|
||||||
]}"
|
] ++ self'.packages.clan-cli.pytestDependencies)}"
|
||||||
|
|
||||||
export CLAN_CORE=$TMPDIR/CLAN_CORE
|
export CLAN_CORE=$TMPDIR/CLAN_CORE
|
||||||
cp -r ${self} $CLAN_CORE
|
cp -r ${self} $CLAN_CORE
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
treefmt.programs.mypy.enable = true;
|
treefmt.programs.mypy.enable = true;
|
||||||
treefmt.programs.mypy.directories = {
|
treefmt.programs.mypy.directories = {
|
||||||
"pkgs/clan-cli".extraPythonPackages = self'.packages.clan-cli.testDependencies;
|
"pkgs/clan-cli".extraPythonPackages = self'.packages.clan-cli.pytestDependencies;
|
||||||
};
|
};
|
||||||
|
|
||||||
treefmt.settings.formatter.nix = {
|
treefmt.settings.formatter.nix = {
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{ age
|
{ age
|
||||||
|
, lib
|
||||||
, argcomplete
|
, argcomplete
|
||||||
, fastapi
|
, fastapi
|
||||||
, uvicorn
|
, uvicorn
|
||||||
|
@ -20,7 +21,11 @@
|
||||||
, rsync
|
, rsync
|
||||||
, pkgs
|
, pkgs
|
||||||
, ui-assets
|
, ui-assets
|
||||||
, lib
|
, bash
|
||||||
|
, sshpass
|
||||||
|
, zbar
|
||||||
|
, tor
|
||||||
|
, git
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
||||||
|
@ -30,16 +35,35 @@ let
|
||||||
uvicorn # optional dependencies: if not enabled, webui subcommand will not work
|
uvicorn # optional dependencies: if not enabled, webui subcommand will not work
|
||||||
];
|
];
|
||||||
|
|
||||||
testDependencies = [
|
pytestDependencies = runtimeDependencies ++ dependencies ++ [
|
||||||
pytest
|
pytest
|
||||||
pytest-cov
|
pytest-cov
|
||||||
pytest-subprocess
|
pytest-subprocess
|
||||||
pytest-parallel
|
pytest-parallel
|
||||||
openssh
|
openssh
|
||||||
|
git
|
||||||
stdenv.cc
|
stdenv.cc
|
||||||
];
|
];
|
||||||
|
|
||||||
checkPython = python3.withPackages (_ps: dependencies ++ testDependencies);
|
# Optional dependencies for clan cli, we re-expose them here to make sure they all build.
|
||||||
|
runtimeDependencies = [
|
||||||
|
bash
|
||||||
|
nix
|
||||||
|
zerotierone
|
||||||
|
bubblewrap
|
||||||
|
openssh
|
||||||
|
sshpass
|
||||||
|
zbar
|
||||||
|
tor
|
||||||
|
age
|
||||||
|
rsync
|
||||||
|
sops
|
||||||
|
git
|
||||||
|
];
|
||||||
|
|
||||||
|
runtimeDependenciesAsSet = builtins.listToAttrs (builtins.map (p: lib.nameValuePair (lib.getName p.name) p) runtimeDependencies);
|
||||||
|
|
||||||
|
checkPython = python3.withPackages (_ps: pytestDependencies);
|
||||||
|
|
||||||
# - vendor the jsonschema nix lib (copy instead of symlink).
|
# - vendor the jsonschema nix lib (copy instead of symlink).
|
||||||
source = runCommand "clan-cli-source" { } ''
|
source = runCommand "clan-cli-source" { } ''
|
||||||
|
@ -73,6 +97,7 @@ let
|
||||||
--experimental-features 'nix-command flakes' \
|
--experimental-features 'nix-command flakes' \
|
||||||
--override-input nixpkgs ${pkgs.path}
|
--override-input nixpkgs ${pkgs.path}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
in
|
in
|
||||||
python3.pkgs.buildPythonPackage {
|
python3.pkgs.buildPythonPackage {
|
||||||
name = "clan-cli";
|
name = "clan-cli";
|
||||||
|
@ -85,25 +110,24 @@ python3.pkgs.buildPythonPackage {
|
||||||
];
|
];
|
||||||
propagatedBuildInputs = dependencies;
|
propagatedBuildInputs = dependencies;
|
||||||
|
|
||||||
passthru.tests.clan-pytest = runCommand "clan-pytest"
|
# also re-expose dependencies so we test them in CI
|
||||||
{
|
passthru.tests = (lib.mapAttrs' (n: lib.nameValuePair "package-${n}") runtimeDependenciesAsSet) // {
|
||||||
nativeBuildInputs = [ age zerotierone bubblewrap sops nix openssh rsync stdenv.cc ];
|
clan-pytest = runCommand "clan-pytest" { nativeBuildInputs = [ checkPython ] ++ pytestDependencies; } ''
|
||||||
} ''
|
cp -r ${source} ./src
|
||||||
cp -r ${source} ./src
|
chmod +w -R ./src
|
||||||
chmod +w -R ./src
|
cd ./src
|
||||||
cd ./src
|
|
||||||
|
|
||||||
# git is needed for test_git.py
|
export NIX_STATE_DIR=$TMPDIR/nix IN_NIX_SANDBOX=1
|
||||||
export PATH="${lib.makeBinPath [pkgs.git]}:$PATH"
|
${checkPython}/bin/python -m pytest -m "not impure" -s ./tests
|
||||||
|
touch $out
|
||||||
export NIX_STATE_DIR=$TMPDIR/nix IN_NIX_SANDBOX=1
|
'';
|
||||||
${checkPython}/bin/python -m pytest -m "not impure" -s ./tests
|
};
|
||||||
touch $out
|
|
||||||
'';
|
|
||||||
passthru.clan-openapi = runCommand "clan-openapi" { } ''
|
passthru.clan-openapi = runCommand "clan-openapi" { } ''
|
||||||
cp -r ${source} ./src
|
cp -r ${source} ./src
|
||||||
chmod +w -R ./src
|
chmod +w -R ./src
|
||||||
cd ./src
|
cd ./src
|
||||||
|
export PATH=${checkPython}/bin:$PATH
|
||||||
|
|
||||||
${checkPython}/bin/python ./bin/gen-openapi --out $out/openapi.json --app-dir . clan_cli.webui.app:app
|
${checkPython}/bin/python ./bin/gen-openapi --out $out/openapi.json --app-dir . clan_cli.webui.app:app
|
||||||
touch $out
|
touch $out
|
||||||
'';
|
'';
|
||||||
|
@ -113,9 +137,10 @@ python3.pkgs.buildPythonPackage {
|
||||||
passthru.devDependencies = [
|
passthru.devDependencies = [
|
||||||
setuptools
|
setuptools
|
||||||
wheel
|
wheel
|
||||||
] ++ testDependencies;
|
] ++ pytestDependencies;
|
||||||
|
|
||||||
passthru.testDependencies = dependencies ++ testDependencies;
|
passthru.pytestDependencies = pytestDependencies;
|
||||||
|
passthru.runtimeDependencies = runtimeDependencies;
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
cp -r ${nixpkgs} $out/${python3.sitePackages}/clan_cli/nixpkgs
|
cp -r ${nixpkgs} $out/${python3.sitePackages}/clan_cli/nixpkgs
|
||||||
|
|
|
@ -10,19 +10,6 @@
|
||||||
clan-openapi = self'.packages.clan-cli.clan-openapi;
|
clan-openapi = self'.packages.clan-cli.clan-openapi;
|
||||||
default = self'.packages.clan-cli;
|
default = self'.packages.clan-cli;
|
||||||
|
|
||||||
## Optional dependencies for clan cli, we re-expose them here to make sure they all build.
|
|
||||||
inherit (pkgs)
|
|
||||||
age
|
|
||||||
bash
|
|
||||||
bubblewrap
|
|
||||||
git
|
|
||||||
openssh
|
|
||||||
rsync
|
|
||||||
sops
|
|
||||||
sshpass
|
|
||||||
tor
|
|
||||||
zbar
|
|
||||||
;
|
|
||||||
# Override license so that we can build zerotierone without
|
# Override license so that we can build zerotierone without
|
||||||
# having to re-import nixpkgs.
|
# having to re-import nixpkgs.
|
||||||
zerotierone = pkgs.zerotierone.overrideAttrs (_old: { meta = { }; });
|
zerotierone = pkgs.zerotierone.overrideAttrs (_old: { meta = { }; });
|
||||||
|
|
Loading…
Reference in New Issue
Block a user