checks: run impure pytest tests in CI pipeline
All checks were successful
checks-impure / test (pull_request) Successful in 10s
checks / test (pull_request) Successful in 34s

This commit is contained in:
DavHau 2023-09-19 16:46:38 +02:00
parent 9cff6a39e8
commit 0ee6de86af
3 changed files with 33 additions and 2 deletions

View File

@ -2,6 +2,30 @@
perSystem = { pkgs, lib, self', ... }:
let
impureChecks = {
clan-pytest-impure = pkgs.writeShellScriptBin "clan-pytest-impure" ''
#!${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
pkgs.gitMinimal
pkgs.nix
self'.packages.clan-cli.checkPython
]}"
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 "" "$@"
'';
check-clan-template = pkgs.writeShellScriptBin "check-clan-template" ''
#!${pkgs.bash}/bin/bash
set -euo pipefail
@ -55,7 +79,7 @@
set -euo pipefail
${lib.concatMapStringsSep "\n" (name: ''
echo -e "\n\nrunning check ${name}\n"
${impureChecks.${name}}/bin/*
${impureChecks.${name}}/bin/* "$@"
'') (lib.attrNames impureChecks)}
'';
};

View File

@ -104,6 +104,7 @@ python3.pkgs.buildPythonPackage {
touch $out
'';
passthru.nixpkgs = nixpkgs;
passthru.checkPython = checkPython;
passthru.devDependencies = [
setuptools

View File

@ -1,10 +1,16 @@
import os
from pathlib import Path
import pytest
TEST_ROOT = Path(__file__).parent.resolve()
PROJECT_ROOT = TEST_ROOT.parent
CLAN_CORE = PROJECT_ROOT.parent.parent
CLAN_CORE_ = os.environ.get("CLAN_CORE")
if CLAN_CORE_:
CLAN_CORE = Path(CLAN_CORE_)
else:
CLAN_CORE = PROJECT_ROOT.parent.parent
@pytest.fixture(scope="session")