From: Scott Worley Date: Thu, 11 Jun 2020 23:38:34 +0000 (-0700) Subject: Separate test and lint X-Git-Tag: 1.4 X-Git-Url: http://git.scottworley.com/pinch/commitdiff_plain/420bd8c9c431223f9299477dc885d2c9d9f077c5?ds=inline;hp=b365b52416a5c3d79b96ca9401b5031db4bddba2 Separate test and lint Don't lint in package build. Lint in git pre-commit hook. --- diff --git a/default.nix b/default.nix index 942ef10..f8d040a 100644 --- a/default.nix +++ b/default.nix @@ -1,11 +1,11 @@ -{ pkgs ? import { } }: +{ pkgs ? import { }, lint ? false }: pkgs.python3Packages.callPackage ({ lib, buildPythonPackage, nix, git, autopep8, mypy, pylint, }: buildPythonPackage rec { pname = "pinch"; version = "1.3"; src = lib.cleanSource ./.; - checkInputs = [ nix git autopep8 mypy pylint ]; + checkInputs = [ nix git mypy ] ++ lib.optionals lint [ autopep8 pylint ]; doCheck = true; checkPhase = "./test.sh"; }) { } diff --git a/git-pre-commit-hook b/git-pre-commit-hook index 7db6818..85b4445 100755 --- a/git-pre-commit-hook +++ b/git-pre-commit-hook @@ -17,6 +17,6 @@ D=$(mktemp -d) git checkout-index --prefix="$D/" -a pushd "$D" -nix-shell --run ./test.sh +nix-shell --arg lint true --run './test.sh lint' popd diff --git a/test.sh b/test.sh index 5df81bf..16d9c05 100755 --- a/test.sh +++ b/test.sh @@ -15,14 +15,18 @@ done find . -name '*_test.py' -print0 | xargs -0 -r -n1 python3 -find . -name '*.py' -print0 | xargs -0 pylint --reports=n --persistent=n --ignore-imports=y -d fixme,invalid-name,missing-docstring,subprocess-run-check,too-few-public-methods - -formatting_needs_fixing=$( - find . -name '*.py' -print0 | - xargs -P "$PARALLELISM" -0 -n1 autopep8 --diff -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -) -if [[ "$formatting_needs_fixing" ]];then - echo "Formatting needs fixing:" - echo "$formatting_needs_fixing" - exit 1 +if [ "$1" = lint ];then + + find . -name '*.py' -print0 | xargs -0 pylint --reports=n --persistent=n --ignore-imports=y -d fixme,invalid-name,missing-docstring,subprocess-run-check,too-few-public-methods + + formatting_needs_fixing=$( + find . -name '*.py' -print0 | + xargs -P "$PARALLELISM" -0 -n1 autopep8 --diff -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + ) + if [[ "$formatting_needs_fixing" ]];then + echo "Formatting needs fixing:" + echo "$formatting_needs_fixing" + exit 1 + fi + fi