split of linting from test

This commit is contained in:
Jörg Thalheim 2023-05-23 15:47:34 +02:00
parent 310012412a
commit 7f308330d5
4 changed files with 59 additions and 37 deletions

View file

@ -4,19 +4,26 @@
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = nixpkgs.legacyPackages.${system};
in {
packages = {
default = pkgs.callPackage ./default.nix { };
test-runner = pkgs.callPackage ./run-tests.nix {};
};
devShells.default = pkgs.callPackage ./shell.nix { };
apps.test-runner = {
type = "app";
program = "${self.packages.${system}.test-runner}";
};
}) // {
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages = {
default = pkgs.callPackage ./default.nix { };
test-runner = pkgs.callPackage ./test-runner.nix { };
test-runner-unstable = pkgs.callPackage ./test-runner.nix { };
};
devShells.default = pkgs.callPackage ./shell.nix { };
apps.test-runner = {
type = "app";
program = "${self.packages.${system}.test-runner}";
};
checks = {
lint = pkgs.callPackage ./lint.nix { };
};
}) // {
overlay = final: prev: {
nix-direnv = final.callPackage ./default.nix { };
};

24
lint.nix Normal file
View file

@ -0,0 +1,24 @@
{ shellcheck
, mypy
, python3
, lib
, ruff
, runCommand
}:
runCommand "lint" {} ''
set -e
mkdir source
cp -r ${./.}/* source
chmod +w source
cd source
echo run shellcheck
${shellcheck}/bin/shellcheck direnvrc
echo run black
${lib.getExe python3.pkgs.black} --check .
echo run ruff
${lib.getExe ruff} tests
echo run mypy
${lib.getExe mypy} tests
touch $out
''

View file

@ -1,24 +0,0 @@
{
writeScript,
shellcheck,
direnv,
mypy,
python3,
lib,
ruff
}:
writeScript "run-tests" ''
set -e
PATH="''${PATH}''${PATH:+":"}${direnv}/bin"
echo run shellcheck
${shellcheck}/bin/shellcheck direnvrc
echo run black
LC_ALL=en_US.utf-8 ${lib.getExe python3.pkgs.black} --check .
echo run ruff
${lib.getExe ruff} tests
echo run mypy
${lib.getExe mypy} tests
echo run unittest
${lib.getExe python3.pkgs.pytest} .
''

15
test-runner.nix Normal file
View file

@ -0,0 +1,15 @@
{ writeScript
, direnv
, python3
, lib
, nix
, coreutils
, gnugrep
}:
writeScript "test-runner" ''
set -e
export PATH=${lib.makeBinPath [ direnv nix coreutils gnugrep ]}
echo run unittest
${lib.getExe python3.pkgs.pytest} .
''