]> git.scottworley.com Git - pinch/commitdiff
Separate test and lint 1.4
authorScott Worley <scottworley@scottworley.com>
Thu, 11 Jun 2020 23:38:34 +0000 (16:38 -0700)
committerScott Worley <scottworley@scottworley.com>
Thu, 11 Jun 2020 23:38:34 +0000 (16:38 -0700)
Don't lint in package build.  Lint in git pre-commit hook.

default.nix
git-pre-commit-hook
test.sh

index 942ef10e60fd866634fbd59e724ab203b7489710..f8d040a973ef80a4cf1ade67fbd8b3b0a653b237 100644 (file)
@@ -1,11 +1,11 @@
-{ pkgs ? import <nixpkgs> { } }:
+{ pkgs ? import <nixpkgs> { }, 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";
   }) { }
index 7db6818fc588c12319dad91daa346aae73970c29..85b444576abb508a61b0e5d3ab7bd88397610c35 100755 (executable)
@@ -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 5df81bfee091044ea4d44c23627e3ab5fca8afb7..16d9c053d0844b04010d6a6a2b5e8c757a0187a1 100755 (executable)
--- 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