From 14fd6a5430ea2f79bc70dc954efb8bb7c61c5eef Mon Sep 17 00:00:00 2001 From: bohendo Date: Tue, 3 Jan 2023 12:55:15 -0500 Subject: [PATCH 01/11] init nix build & shell files --- .gitignore | 1 - artur-default.nix | 40 ++++++++++++++++++++++++++++++++++ crytic-compile.nix | 17 +++++++++++++++ default.nix | 2 ++ shell.nix | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 113 insertions(+), 1 deletion(-) create mode 100644 artur-default.nix create mode 100644 crytic-compile.nix create mode 100644 default.nix create mode 100644 shell.nix diff --git a/.gitignore b/.gitignore index 6407522a..44bdd7de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -*.nix *.pyc .idea/ __pycache__/ diff --git a/artur-default.nix b/artur-default.nix new file mode 100644 index 00000000..d09fccfe --- /dev/null +++ b/artur-default.nix @@ -0,0 +1,40 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, pythonOlder +, pysha3 +, setuptools +}: + +buildPythonPackage rec { + pname = "crytic-compile"; + version = "0.2.4"; + format = "setuptools"; + + disabled = pythonOlder "3.6"; + + src = fetchFromGitHub { + owner = "crytic"; + repo = "crytic-compile"; + rev = "refs/tags/${version}"; + hash = "sha256-phb4Y8CUxuHsNt43oKsgDAZTraNauPkcYQtzcsiWyy8="; + }; + + propagatedBuildInputs = [ + pysha3 + setuptools + ]; + + doCheck = false; + + pythonImportsCheck = [ + "crytic_compile" + ]; + + meta = with lib; { + description = "Abstraction layer for smart contract build systems"; + homepage = "https://github.com/crytic/crytic-compile"; + license = licenses.agpl3Plus; + maintainers = with maintainers; [ SuperSandro2000 arturcygan ]; + }; +} diff --git a/crytic-compile.nix b/crytic-compile.nix new file mode 100644 index 00000000..5b43cb61 --- /dev/null +++ b/crytic-compile.nix @@ -0,0 +1,17 @@ +{ pkgs ? import {} }: + +let + inherit (pkgs) python38Packages; +in + python38Packages.buildPythonPackage rec { + pname = "crytic-compile"; + version = "0.2.5"; + format = "pyproject"; + src = ./.; + propagatedBuildInputs = with python38Packages; [ + pycryptodome + setuptools + ]; + pythonRelaxDeps = true; + doCheck = false; + } diff --git a/default.nix b/default.nix new file mode 100644 index 00000000..9fd1d26c --- /dev/null +++ b/default.nix @@ -0,0 +1,2 @@ +{ pkgs ? import {} }: +pkgs.callPackage ./crytic-compile.nix {} diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..3032647d --- /dev/null +++ b/shell.nix @@ -0,0 +1,54 @@ +{ pkgs ? import {} }: + +pkgs.python38Packages.buildPythonPackage rec { + name = "crytic-compile"; + src = ./crytic_compile; + propagatedBuildInputs = with pkgs.python38Packages; [ pycryptodome setuptools ]; +} + +# let +# mach-nix = import (builtins.fetchGit { +# url = "https://github.com/DavHau/mach-nix"; +# ref = "refs/tags/3.5.0"; +# }) {}; +# in +# mach-nix.mkPythonShell { +# requirements = '' +# pycryptodome +# setuptools +# ''; +# } + +# pkgs.mkShell { +# python = pkgs.python38.withPackages (ps: with ps; [ +# pip +# ]); +# +# shellHook = '' +# echo hello crytic-compile shell +# ''; +# +# packages = [ +# +# # (pkgs.python38Packages.buildPythonPackage rec { +# # name = "crytic-compile"; +# # src = ./crytic_compile; +# # propagatedBuildInputs = with pkgs.python38Packages; [ pycryptodome setuptools ]; +# # }) +# +# # (pkgs.python38Packages.buildPythonPackage rec { +# # pname = "crytic-compile"; +# # version = "0.2.5"; +# # format = "setuptools"; +# # src = ./.; +# # propagatedBuildInputs = with pkgs.python38Packages; [ pycryptodome setuptools ]; +# # doCheck = false; +# # pythonRelaxDeps = true; +# # }) +# +# (pkgs.python38.withPackages (ps: with ps; [ pip ])) +# pkgs.black +# pkgs.pylint +# pkgs.solc-select +# ]; +# } From fd79655f5fa3f2a85987d3541c09a920b91224a2 Mon Sep 17 00:00:00 2001 From: bohendo Date: Tue, 3 Jan 2023 13:07:44 -0500 Subject: [PATCH 02/11] init justfile --- justfile | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 justfile diff --git a/justfile b/justfile new file mode 100644 index 00000000..602a34fc --- /dev/null +++ b/justfile @@ -0,0 +1,43 @@ + +shell: + nix-shell shell.nix + +build: + nix-build default.nix + +install: + nix-env -e $(nix-env -q | grep "crytic-compile") + nix-env -i ./result + + + +lint: black pylint darglint mypy + +black: + nix-build nix/black.nix + ./result/bin/black crytic_compile --config pyproject.toml + +pylint: + nix-build nix/pylint.nix + ./result/bin/pylint crytic_compile --rcfile pyproject.toml + +darglint: + nix-build nix/darglint.nix + ./result/bin/darglint crytic_compile + +mypy: + nix-build nix/mypy.nix + ./result/bin/mypy crytic_compile + + + +test: test-hardhat test-monorepo test-brownie + +test-monorepo: + bash scripts/ci_test_monorepo.sh + +test-hardhat: + bash scripts/ci_test_hardhat.sh + +test-brownie: + bash scripts/ci_test_brownie.sh From ecbaeed0115e9c2559c20083ea06f5b0700b2132 Mon Sep 17 00:00:00 2001 From: bohendo Date: Tue, 3 Jan 2023 13:17:57 -0500 Subject: [PATCH 03/11] init nix files for lint utils --- nix/black.nix | 39 +++++++++++++++++++++++++++++++++++++++ nix/brownie.nix | 21 +++++++++++++++++++++ nix/darglint.nix | 17 +++++++++++++++++ nix/mypy.nix | 40 ++++++++++++++++++++++++++++++++++++++++ nix/pylint.nix | 15 +++++++++++++++ 5 files changed, 132 insertions(+) create mode 100644 nix/black.nix create mode 100644 nix/brownie.nix create mode 100644 nix/darglint.nix create mode 100644 nix/mypy.nix create mode 100644 nix/pylint.nix diff --git a/nix/black.nix b/nix/black.nix new file mode 100644 index 00000000..752d9b49 --- /dev/null +++ b/nix/black.nix @@ -0,0 +1,39 @@ +# +# let +# mach-nix = import (builtins.fetchGit { +# url = "https://github.com/DavHau/mach-nix"; +# ref = "refs/tags/3.5.0"; +# }) {}; +# pkgs = import {}; +# in +# mach-nix.buildPythonPackage rec { +# pname = "black"; +# version = "22.3.0"; +# src = pkgs.fetchFromGitHub { +# owner = "psf"; +# repo = "black"; +# rev = "refs/tags/v${version}"; +# hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; +# }; +# providers = { +# _default = "nixpkgs,sdist,wheel"; +# astroid = "conda"; +# }; +# } + +let + pkgs = import ( + # commit hash from: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=black + # fetchTarball "https://github.com/NixOS/nixpkgs/archive/ff8b619cfecb98bb94ae49ca7ceca937923a75fa.tar.gz" + fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf972dc380f36a3bf83db052380e55f0eaa7dcb6.tar.gz" + ) {}; + black = pkgs.python3Packages.black.overrideAttrs (_: rec { + version = "22.3.0"; + src = pkgs.fetchFromGitHub { + owner = "psf"; + repo = "black"; + rev = "refs/tags/v${version}"; + hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; + }; + }); +in black diff --git a/nix/brownie.nix b/nix/brownie.nix new file mode 100644 index 00000000..9d9f871e --- /dev/null +++ b/nix/brownie.nix @@ -0,0 +1,21 @@ +let + mach-nix = import (builtins.fetchGit { + url = "https://github.com/DavHau/mach-nix"; + ref = "refs/tags/3.5.0"; + }) {}; + pkgs = import {}; +in + mach-nix.buildPythonPackage rec { + pname = "eth-brownie"; + version = "1.19.2"; + src = pkgs.fetchFromGitHub { + owner = "eth-brownie"; + repo = "brownie"; + rev = "refs/tags/v${version}"; + hash = "sha256-nKBijlGznWMYpulz0RNZK2tevASzkeC5rEw6NvazSXI="; + }; + providers = { + _default = "nixpkgs,sdist,wheel"; + aiohttp = "nixpkgs,sdist,wheel,conda"; + }; + } diff --git a/nix/darglint.nix b/nix/darglint.nix new file mode 100644 index 00000000..a3e88c98 --- /dev/null +++ b/nix/darglint.nix @@ -0,0 +1,17 @@ +let + mach-nix = import (builtins.fetchGit { + url = "https://github.com/DavHau/mach-nix"; + ref = "refs/tags/3.5.0"; + }) {}; + pkgs = import {}; +in + mach-nix.buildPythonPackage rec { + pname = "darglint"; + version = "1.8.0"; + src = pkgs.fetchFromGitHub { + owner = "terrencepreilly"; + repo = "darglint"; + rev = "refs/tags/v${version}"; + hash = "sha256:u/U0Plk1QTqqSCuuXdcQhaGGxyscdUDYabUzjJeISlw="; + }; + } diff --git a/nix/mypy.nix b/nix/mypy.nix new file mode 100644 index 00000000..b93cd6bb --- /dev/null +++ b/nix/mypy.nix @@ -0,0 +1,40 @@ +# let +# mach-nix = import (builtins.fetchGit { +# url = "https://github.com/DavHau/mach-nix"; +# ref = "refs/tags/3.5.0"; +# }) {}; +# pkgs = import {}; +# in +# mach-nix.buildPythonPackage rec { +# pname = "mypy"; +# version = "2.13.4"; +# src = pkgs.fetchFromGitHub { +# owner = "python"; +# repo = "mypy"; +# rev = "refs/tags/v${version}"; +# hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; +# }; +# patches = []; +# providers = { +# _default = "nixpkgs,sdist,wheel"; +# astroid = "conda"; +# }; +# } + +let + pkgs = import ( + # commit hash from: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=mypy + fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf972dc380f36a3bf83db052380e55f0eaa7dcb6.tar.gz" + # fetchTarball "https://github.com/NixOS/nixpkgs/archive/ff8b619cfecb98bb94ae49ca7ceca937923a75fa.tar.gz" + ) {}; + mypy = pkgs.python3Packages.mypy.overrideAttrs (_: rec { + version = "2.13.4"; + src = pkgs.fetchFromGitHub { + owner = "python"; + repo = "mypy"; + rev = "refs/tags/v${version}"; + hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; + }; + patches = []; + }); +in mypy diff --git a/nix/pylint.nix b/nix/pylint.nix new file mode 100644 index 00000000..1664e75d --- /dev/null +++ b/nix/pylint.nix @@ -0,0 +1,15 @@ +let + pkgs = import ( + # commit hash from: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=pylint + fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf972dc380f36a3bf83db052380e55f0eaa7dcb6.tar.gz" + ) {}; + pylint = pkgs.python3Packages.pylint.overrideAttrs (_: rec { + version = "2.13.4"; + src = pkgs.fetchFromGitHub { + owner = "PyCQA"; + repo = "pylint"; + rev = "refs/tags/v${version}"; + hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; + }; + }); +in pylint From 11dae0dc51c7fc467cc56c53cd69a74654e3c678 Mon Sep 17 00:00:00 2001 From: bohendo Date: Tue, 3 Jan 2023 16:26:00 -0500 Subject: [PATCH 04/11] fix local linters --- default.nix | 2 +- artur-default.nix => derivation.nix | 0 nix/black.nix | 59 ++++++++--------- crytic-compile.nix => nix/crytic-compile.nix | 3 +- nix/mypy.nix | 67 +++++++++++++++----- scripts/ci_test_hardhat.sh | 4 +- 6 files changed, 83 insertions(+), 52 deletions(-) rename artur-default.nix => derivation.nix (100%) rename crytic-compile.nix => nix/crytic-compile.nix (92%) diff --git a/default.nix b/default.nix index 9fd1d26c..2052e94d 100644 --- a/default.nix +++ b/default.nix @@ -1,2 +1,2 @@ { pkgs ? import {} }: -pkgs.callPackage ./crytic-compile.nix {} +pkgs.callPackage ./nix/crytic-compile.nix {} diff --git a/artur-default.nix b/derivation.nix similarity index 100% rename from artur-default.nix rename to derivation.nix diff --git a/nix/black.nix b/nix/black.nix index 752d9b49..4adcfb2e 100644 --- a/nix/black.nix +++ b/nix/black.nix @@ -1,13 +1,30 @@ -# +{ pkgs ? import {} }: + +pkgs.python38Packages.buildPythonPackage rec { + pname = "black"; + version = "22.3.0"; + src = pkgs.python38Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-NQILiIbAIs7ZKCtRtah1ttGrDDh7MaBluE23wzCFynk="; + }; + doCheck = false; + propagatedBuildInputs = with pkgs.python38Packages; [ + platformdirs + typing-extensions + click + tomli + mypy-extensions + pathspec + ]; +} + # let -# mach-nix = import (builtins.fetchGit { -# url = "https://github.com/DavHau/mach-nix"; -# ref = "refs/tags/3.5.0"; -# }) {}; -# pkgs = import {}; -# in -# mach-nix.buildPythonPackage rec { -# pname = "black"; +# pkgs = import ( +# # commit hash from: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=black +# # fetchTarball "https://github.com/NixOS/nixpkgs/archive/ff8b619cfecb98bb94ae49ca7ceca937923a75fa.tar.gz" +# fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf972dc380f36a3bf83db052380e55f0eaa7dcb6.tar.gz" +# ) {}; +# black = pkgs.python3Packages.black.overrideAttrs (_: rec { # version = "22.3.0"; # src = pkgs.fetchFromGitHub { # owner = "psf"; @@ -15,25 +32,5 @@ # rev = "refs/tags/v${version}"; # hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; # }; -# providers = { -# _default = "nixpkgs,sdist,wheel"; -# astroid = "conda"; -# }; -# } - -let - pkgs = import ( - # commit hash from: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=black - # fetchTarball "https://github.com/NixOS/nixpkgs/archive/ff8b619cfecb98bb94ae49ca7ceca937923a75fa.tar.gz" - fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf972dc380f36a3bf83db052380e55f0eaa7dcb6.tar.gz" - ) {}; - black = pkgs.python3Packages.black.overrideAttrs (_: rec { - version = "22.3.0"; - src = pkgs.fetchFromGitHub { - owner = "psf"; - repo = "black"; - rev = "refs/tags/v${version}"; - hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; - }; - }); -in black +# }); +# in black diff --git a/crytic-compile.nix b/nix/crytic-compile.nix similarity index 92% rename from crytic-compile.nix rename to nix/crytic-compile.nix index 5b43cb61..58620b97 100644 --- a/crytic-compile.nix +++ b/nix/crytic-compile.nix @@ -7,8 +7,9 @@ in pname = "crytic-compile"; version = "0.2.5"; format = "pyproject"; - src = ./.; + src = ../.; propagatedBuildInputs = with python38Packages; [ + cbor2 pycryptodome setuptools ]; diff --git a/nix/mypy.nix b/nix/mypy.nix index b93cd6bb..48c0894b 100644 --- a/nix/mypy.nix +++ b/nix/mypy.nix @@ -1,3 +1,36 @@ +{ pkgs ? import {} }: + +pkgs.python39Packages.buildPythonPackage rec { + pname = "mypy"; + version = "0.942"; + src = pkgs.python39Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-F+RGSf7JLp+CECtIo797SlUQrQzSL6IaEEgmtdtJA+I="; + }; + doCheck = false; + buildInputs = with pkgs.python39Packages; [ setuptools ]; + + python = pkgs.python39.withPackages (ps: with ps; [ + types-setuptools + ]); + + propagatedBuildInputs = with pkgs.python39Packages; [ + mypy-extensions + tomli + types-setuptools + typing-extensions + # (pkgs.python39Packages.buildPythonPackage rec { + # pname = "types-pkg-resources"; + # version = "0.1.3"; + # src = pkgs.python39Packages.fetchPypi { + # inherit pname version; + # sha256 = "sha256-NQILiIbAIs7ZKCtRtah1ttGrDDh7MaBluE23wzCFynk="; + # }; + # doCheck = false; + # }) + ]; +} + # let # mach-nix = import (builtins.fetchGit { # url = "https://github.com/DavHau/mach-nix"; @@ -21,20 +54,20 @@ # }; # } -let - pkgs = import ( - # commit hash from: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=mypy - fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf972dc380f36a3bf83db052380e55f0eaa7dcb6.tar.gz" - # fetchTarball "https://github.com/NixOS/nixpkgs/archive/ff8b619cfecb98bb94ae49ca7ceca937923a75fa.tar.gz" - ) {}; - mypy = pkgs.python3Packages.mypy.overrideAttrs (_: rec { - version = "2.13.4"; - src = pkgs.fetchFromGitHub { - owner = "python"; - repo = "mypy"; - rev = "refs/tags/v${version}"; - hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; - }; - patches = []; - }); -in mypy +# let +# pkgs = import ( +# # commit hash from: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=mypy +# fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf972dc380f36a3bf83db052380e55f0eaa7dcb6.tar.gz" +# # fetchTarball "https://github.com/NixOS/nixpkgs/archive/ff8b619cfecb98bb94ae49ca7ceca937923a75fa.tar.gz" +# ) {}; +# mypy = pkgs.python3Packages.mypy.overrideAttrs (_: rec { +# version = "2.13.4"; +# src = pkgs.fetchFromGitHub { +# owner = "python"; +# repo = "mypy"; +# rev = "refs/tags/v${version}"; +# hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; +# }; +# patches = []; +# }); +# in mypy diff --git a/scripts/ci_test_hardhat.sh b/scripts/ci_test_hardhat.sh index 28f74b80..9ec3fea4 100755 --- a/scripts/ci_test_hardhat.sh +++ b/scripts/ci_test_hardhat.sh @@ -7,6 +7,6 @@ cd tests/hardhat || exit 255 npm install if ! crytic-compile . -then echo "Monorepo test failed" && exit 255 -else echo "Monorepo test passed" && exit 0 +then echo "Hardhat test failed" && exit 255 +else echo "Hardhat test passed" && exit 0 fi From 5c1174daed31e65aa15385455cc66ce96b9e7f76 Mon Sep 17 00:00:00 2001 From: bohendo Date: Tue, 3 Jan 2023 16:41:43 -0500 Subject: [PATCH 05/11] clean up local linters --- nix/black.nix | 17 --------------- nix/darglint.nix | 28 ++++++++++-------------- nix/mypy.nix | 56 ------------------------------------------------ nix/pylint.nix | 43 ++++++++++++++++++++++++++----------- 4 files changed, 42 insertions(+), 102 deletions(-) diff --git a/nix/black.nix b/nix/black.nix index 4adcfb2e..c2a07da7 100644 --- a/nix/black.nix +++ b/nix/black.nix @@ -17,20 +17,3 @@ pkgs.python38Packages.buildPythonPackage rec { pathspec ]; } - -# let -# pkgs = import ( -# # commit hash from: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=black -# # fetchTarball "https://github.com/NixOS/nixpkgs/archive/ff8b619cfecb98bb94ae49ca7ceca937923a75fa.tar.gz" -# fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf972dc380f36a3bf83db052380e55f0eaa7dcb6.tar.gz" -# ) {}; -# black = pkgs.python3Packages.black.overrideAttrs (_: rec { -# version = "22.3.0"; -# src = pkgs.fetchFromGitHub { -# owner = "psf"; -# repo = "black"; -# rev = "refs/tags/v${version}"; -# hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; -# }; -# }); -# in black diff --git a/nix/darglint.nix b/nix/darglint.nix index a3e88c98..617b4876 100644 --- a/nix/darglint.nix +++ b/nix/darglint.nix @@ -1,17 +1,11 @@ -let - mach-nix = import (builtins.fetchGit { - url = "https://github.com/DavHau/mach-nix"; - ref = "refs/tags/3.5.0"; - }) {}; - pkgs = import {}; -in - mach-nix.buildPythonPackage rec { - pname = "darglint"; - version = "1.8.0"; - src = pkgs.fetchFromGitHub { - owner = "terrencepreilly"; - repo = "darglint"; - rev = "refs/tags/v${version}"; - hash = "sha256:u/U0Plk1QTqqSCuuXdcQhaGGxyscdUDYabUzjJeISlw="; - }; - } +{ pkgs ? import {} }: + +pkgs.python38Packages.buildPythonPackage rec { + pname = "darglint"; + version = "1.8.0"; + src = pkgs.python38Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-qmBe9HgXptFHl9MrOQRm7atiF2jqTKXMDzxU9tjcrsg="; + }; + doCheck = false; +} diff --git a/nix/mypy.nix b/nix/mypy.nix index 48c0894b..83f8086b 100644 --- a/nix/mypy.nix +++ b/nix/mypy.nix @@ -8,66 +8,10 @@ pkgs.python39Packages.buildPythonPackage rec { sha256 = "sha256-F+RGSf7JLp+CECtIo797SlUQrQzSL6IaEEgmtdtJA+I="; }; doCheck = false; - buildInputs = with pkgs.python39Packages; [ setuptools ]; - - python = pkgs.python39.withPackages (ps: with ps; [ - types-setuptools - ]); - propagatedBuildInputs = with pkgs.python39Packages; [ mypy-extensions tomli types-setuptools typing-extensions - # (pkgs.python39Packages.buildPythonPackage rec { - # pname = "types-pkg-resources"; - # version = "0.1.3"; - # src = pkgs.python39Packages.fetchPypi { - # inherit pname version; - # sha256 = "sha256-NQILiIbAIs7ZKCtRtah1ttGrDDh7MaBluE23wzCFynk="; - # }; - # doCheck = false; - # }) ]; } - -# let -# mach-nix = import (builtins.fetchGit { -# url = "https://github.com/DavHau/mach-nix"; -# ref = "refs/tags/3.5.0"; -# }) {}; -# pkgs = import {}; -# in -# mach-nix.buildPythonPackage rec { -# pname = "mypy"; -# version = "2.13.4"; -# src = pkgs.fetchFromGitHub { -# owner = "python"; -# repo = "mypy"; -# rev = "refs/tags/v${version}"; -# hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; -# }; -# patches = []; -# providers = { -# _default = "nixpkgs,sdist,wheel"; -# astroid = "conda"; -# }; -# } - -# let -# pkgs = import ( -# # commit hash from: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=mypy -# fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf972dc380f36a3bf83db052380e55f0eaa7dcb6.tar.gz" -# # fetchTarball "https://github.com/NixOS/nixpkgs/archive/ff8b619cfecb98bb94ae49ca7ceca937923a75fa.tar.gz" -# ) {}; -# mypy = pkgs.python3Packages.mypy.overrideAttrs (_: rec { -# version = "2.13.4"; -# src = pkgs.fetchFromGitHub { -# owner = "python"; -# repo = "mypy"; -# rev = "refs/tags/v${version}"; -# hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; -# }; -# patches = []; -# }); -# in mypy diff --git a/nix/pylint.nix b/nix/pylint.nix index 1664e75d..9f6548c9 100644 --- a/nix/pylint.nix +++ b/nix/pylint.nix @@ -1,15 +1,34 @@ +{ pkgs ? import {} }: let - pkgs = import ( - # commit hash from: https://lazamar.co.uk/nix-versions/?channel=nixpkgs-unstable&package=pylint - fetchTarball "https://github.com/NixOS/nixpkgs/archive/bf972dc380f36a3bf83db052380e55f0eaa7dcb6.tar.gz" - ) {}; - pylint = pkgs.python3Packages.pylint.overrideAttrs (_: rec { + astroid = pkgs.python38Packages.buildPythonPackage rec { + pname = "astroid"; + version = "2.11.7"; + src = pkgs.python38Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-uyRhXHf0g3xwdmnRaQczE3SuipZGUKZpmdo/XKaNyUY="; + }; + doCheck = false; + propagatedBuildInputs = with pkgs.python38Packages; [ + lazy-object-proxy + typing-extensions + wrapt + ]; + }; +in + pkgs.python38Packages.buildPythonPackage rec { + pname = "pylint"; version = "2.13.4"; - src = pkgs.fetchFromGitHub { - owner = "PyCQA"; - repo = "pylint"; - rev = "refs/tags/v${version}"; - hash = "sha256-CMbw6D6szQvur+13halZrskSV/9rDaThMGLeGxfjqWo="; + src = pkgs.python38Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-fMbQxPYd/0QPnti2V/Ts1hXc/jU0WVPrex3HSv6QHXo="; }; - }); -in pylint + doCheck = false; + propagatedBuildInputs = with pkgs.python38Packages; [ + isort + tomli + mccabe + platformdirs + dill + astroid + ]; + } From 2f92bfebd7cdb743fcc47340044fec0f7b73e083 Mon Sep 17 00:00:00 2001 From: bohendo Date: Tue, 3 Jan 2023 16:42:11 -0500 Subject: [PATCH 06/11] clean up justfile --- justfile | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/justfile b/justfile index 602a34fc..1c8f53ae 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,5 @@ -shell: +dev: nix-shell shell.nix build: @@ -10,25 +10,31 @@ install: nix-env -i ./result - -lint: black pylint darglint mypy +lint: black darglint mypy pylint black: - nix-build nix/black.nix + @echo -e "\nBuilding black.." + nix-build nix/black.nix > /dev/null + @echo "Running black.." ./result/bin/black crytic_compile --config pyproject.toml -pylint: - nix-build nix/pylint.nix - ./result/bin/pylint crytic_compile --rcfile pyproject.toml - darglint: - nix-build nix/darglint.nix + @echo -e "\nBuilding darglint.." + nix-build nix/darglint.nix > /dev/null + @echo "Running darglint.." ./result/bin/darglint crytic_compile mypy: - nix-build nix/mypy.nix + @echo -e "\nBuilding mypy.." + nix-build nix/mypy.nix > /dev/null + @echo "Running mypy.." ./result/bin/mypy crytic_compile +pylint: + @echo -e "\nBuilding pylint.." + nix-build nix/pylint.nix > /dev/null + @echo "Running pylint.." + ./result/bin/pylint crytic_compile --rcfile pyproject.toml test: test-hardhat test-monorepo test-brownie From a15db2e3b3744d5a0bd940d34e0f330818f95143 Mon Sep 17 00:00:00 2001 From: bohendo Date: Tue, 3 Jan 2023 16:45:24 -0500 Subject: [PATCH 07/11] init simplified lint CI workflow --- .github/workflows/lint.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..1f12fcc3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,28 @@ +--- +name: Lint Code Base + +defaults: + run: + # To load bashrc + shell: bash -ieo pipefail {0} + +on: + pull_request: + branches: [master, dev] + +jobs: + lint: + name: Lint Code Base + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up nix + uses: cachix/install-nix-action@v18 + + - name: Install just + run: nix-env -iA nixpkgs.just + + - name: Lint everything + run: just lint From b6d682cecd148fbf3b480f0bc225c62157d4a1f9 Mon Sep 17 00:00:00 2001 From: bohendo Date: Wed, 4 Jan 2023 11:57:08 -0500 Subject: [PATCH 08/11] fix linter CI workflows use python 3.9 in some linters consolidate linter CI workflows debug lint ci rm custom bash setup set NIX_PATH setup cachix give cachix a name set nixpkgs channel rm nix path setter log linter versions enable cachix pin nixpkgs in mypy disable non-lint workflows for easier ci debugging install mypy types before linting tweak type installation make mypy noninteractive clean up hack mypy linter --- .github/workflows/black.yml | 45 -------------------------- .github/workflows/ci.yml | 5 --- .github/workflows/darglint.yml | 23 ------------- .github/workflows/etherscan.yml | 6 ---- .github/workflows/lint.yml | 25 +++++++-------- .github/workflows/linter.yml | 57 --------------------------------- .github/workflows/mypy.yml | 45 -------------------------- .github/workflows/pylint.yml | 46 -------------------------- .github/workflows/pytest.yml | 12 ++----- justfile | 7 +++- mypy.ini | 4 --- nix/black.nix | 7 ++-- nix/mypy.nix | 1 - nix/pylint.nix | 12 +++---- pyproject.toml | 4 --- 15 files changed, 31 insertions(+), 268 deletions(-) delete mode 100644 .github/workflows/black.yml delete mode 100644 .github/workflows/darglint.yml delete mode 100644 .github/workflows/linter.yml delete mode 100644 .github/workflows/mypy.yml delete mode 100644 .github/workflows/pylint.yml diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml deleted file mode 100644 index a04bb8cc..00000000 --- a/.github/workflows/black.yml +++ /dev/null @@ -1,45 +0,0 @@ ---- -name: Black - -defaults: - run: - # To load bashrc - shell: bash -ieo pipefail {0} - -on: - pull_request: - branches: [master, dev] - -jobs: - build: - name: Black - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - name: Install dependencies - run: | - pip install . - pip install deepdiff numpy - - mkdir -p .github/linters - cp pyproject.toml .github/linters - - - name: Black - uses: github/super-linter/slim@v4.9.2 - if: always() - env: - # run linter on everything to catch preexisting problems - VALIDATE_ALL_CODEBASE: true - DEFAULT_BRANCH: master - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Run only black - VALIDATE_PYTHON_BLACK: true - PYTHON_BLACK_CONFIG_FILE: pyproject.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b0d9849..9c60f4df 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,11 +5,6 @@ on: push: branches: - master - - dev - pull_request: - schedule: - # run CI every day even if no PRs/merges occur - - cron: '0 12 * * *' jobs: tests: diff --git a/.github/workflows/darglint.yml b/.github/workflows/darglint.yml deleted file mode 100644 index 11fb4145..00000000 --- a/.github/workflows/darglint.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: Darglint - -on: - push: - branches: - - master - - dev - pull_request: - branches: [master, dev] - -jobs: - tests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - name: Run Tests - run: | - bash scripts/ci_darglint.sh diff --git a/.github/workflows/etherscan.yml b/.github/workflows/etherscan.yml index c4db3ae0..f795956b 100644 --- a/.github/workflows/etherscan.yml +++ b/.github/workflows/etherscan.yml @@ -5,12 +5,6 @@ on: push: branches: - master - - dev - pull_request: - branches: [ master, dev ] - schedule: - # run CI every day even if no PRs/merges occur - - cron: '0 12 * * *' jobs: tests: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1f12fcc3..c954878f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,28 +1,27 @@ --- name: Lint Code Base -defaults: - run: - # To load bashrc - shell: bash -ieo pipefail {0} - on: pull_request: branches: [master, dev] jobs: lint: - name: Lint Code Base runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + type: ["black", "darglint", "mypy", "pylint"] steps: - name: Checkout Code uses: actions/checkout@v3 - - name: Set up nix uses: cachix/install-nix-action@v18 - - - name: Install just - run: nix-env -iA nixpkgs.just - - - name: Lint everything - run: just lint + with: + nix_path: nixpkgs=channel:nixos-unstable + - uses: cachix/cachix-action@v11 + with: + name: crytic-compile + authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' + - name: run linter + run: nix-shell -p just --run "just ${{ matrix.type }}" diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml deleted file mode 100644 index 89e64263..00000000 --- a/.github/workflows/linter.yml +++ /dev/null @@ -1,57 +0,0 @@ ---- -name: Lint Code Base - -defaults: - run: - # To load bashrc - shell: bash -ieo pipefail {0} - -on: - pull_request: - branches: [master, dev] - -jobs: - build: - name: Lint Code Base - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - name: Install dependencies - run: | - pip install . - pip install deepdiff numpy - - mkdir -p .github/linters - cp pyproject.toml .github/linters - - - name: Lint everything else - uses: github/super-linter/slim@v4.9.2 - if: always() - env: - # run linter on everything to catch preexisting problems - VALIDATE_ALL_CODEBASE: true - DEFAULT_BRANCH: master - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Always false - VALIDATE_PYTHON: false - VALIDATE_PYTHON_PYLINT: false - VALIDATE_PYTHON_BLACK: false - VALIDATE_PYTHON_ISORT: false - # Always false - VALIDATE_JSON: false - VALIDATE_JAVASCRIPT_STANDARD: false - VALIDATE_PYTHON_FLAKE8: false - VALIDATE_DOCKERFILE: false - VALIDATE_DOCKERFILE_HADOLINT: false - VALIDATE_EDITORCONFIG: false - VALIDATE_JSCPD: false - VALIDATE_PYTHON_MYPY: false - SHELLCHECK_OPTS: "-e SC1090 -e SC2181 -e SC2103" diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml deleted file mode 100644 index 71b350a9..00000000 --- a/.github/workflows/mypy.yml +++ /dev/null @@ -1,45 +0,0 @@ ---- -name: Mypy - -defaults: - run: - # To load bashrc - shell: bash -ieo pipefail {0} - -on: - pull_request: - branches: [master, dev] - -jobs: - build: - name: Mypy - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - name: Install dependencies - run: | - pip install . - pip install types-setuptools - - mkdir -p .github/linters - cp mypy.ini .github/linters - - - name: Mypy - uses: github/super-linter/slim@v4.9.2 - if: always() - env: - # run linter on everything to catch preexisting problems - VALIDATE_ALL_CODEBASE: true - DEFAULT_BRANCH: master - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Run only black - VALIDATE_PYTHON_MYPY: true - PYTHON_MYPY_CONFIG_FILE: mypy.ini diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml deleted file mode 100644 index 0571c3bd..00000000 --- a/.github/workflows/pylint.yml +++ /dev/null @@ -1,46 +0,0 @@ ---- -name: Pylint - -defaults: - run: - # To load bashrc - shell: bash -ieo pipefail {0} - -on: - pull_request: - branches: [master, dev] - -jobs: - build: - name: Pylint - runs-on: ubuntu-latest - - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Set up Python 3.8 - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - name: Install dependencies - run: | - pip install . - pip install deepdiff numpy - - mkdir -p .github/linters - cp pyproject.toml .github/linters - - - name: Pylint - uses: github/super-linter/slim@v4.9.2 - if: always() - env: - # run linter on everything to catch preexisting problems - VALIDATE_ALL_CODEBASE: true - DEFAULT_BRANCH: master - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - # Run only pylint - VALIDATE_PYTHON: true - VALIDATE_PYTHON_PYLINT: true - PYTHON_PYLINT_CONFIG_FILE: pyproject.toml diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index a3a0a636..a2572ddf 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -8,13 +8,7 @@ defaults: on: push: branches: - - main - - dev - pull_request: - branches: [main, dev] - schedule: - # run CI every day even if no PRs/merges occur - - cron: '0 12 * * *' + - master jobs: tests: @@ -23,7 +17,7 @@ jobs: steps: - uses: actions/checkout@v1 - name: Set up Python 3.8 - uses: actions/setup-python@v1 + uses: actions/setup-python@v2 with: python-version: 3.8 @@ -35,4 +29,4 @@ jobs: pip install solc-select - name: Run Tests run: | - pytest tests/test_metadata.py \ No newline at end of file + pytest tests/test_metadata.py diff --git a/justfile b/justfile index 1c8f53ae..9b023975 100644 --- a/justfile +++ b/justfile @@ -16,24 +16,29 @@ black: @echo -e "\nBuilding black.." nix-build nix/black.nix > /dev/null @echo "Running black.." + ./result/bin/black --version ./result/bin/black crytic_compile --config pyproject.toml darglint: @echo -e "\nBuilding darglint.." nix-build nix/darglint.nix > /dev/null @echo "Running darglint.." + ./result/bin/darglint --version ./result/bin/darglint crytic_compile mypy: @echo -e "\nBuilding mypy.." nix-build nix/mypy.nix > /dev/null @echo "Running mypy.." - ./result/bin/mypy crytic_compile + ./result/bin/mypy --version + # TODO: remove --no-site-packages flag once type libs are properly loaded + ./result/bin/mypy --no-site-packages crytic_compile pylint: @echo -e "\nBuilding pylint.." nix-build nix/pylint.nix > /dev/null @echo "Running pylint.." + ./result/bin/pylint --version ./result/bin/pylint crytic_compile --rcfile pyproject.toml diff --git a/mypy.ini b/mypy.ini index f4ab5f1b..8dd020bf 100644 --- a/mypy.ini +++ b/mypy.ini @@ -9,7 +9,3 @@ disallow_untyped_decorators = true warn_redundant_casts = true warn_no_return = true warn_unreachable = true - - - - diff --git a/nix/black.nix b/nix/black.nix index c2a07da7..772ce588 100644 --- a/nix/black.nix +++ b/nix/black.nix @@ -9,11 +9,12 @@ pkgs.python38Packages.buildPythonPackage rec { }; doCheck = false; propagatedBuildInputs = with pkgs.python38Packages; [ - platformdirs - typing-extensions click - tomli mypy-extensions pathspec + platformdirs + setuptools_scm + tomli + typing-extensions ]; } diff --git a/nix/mypy.nix b/nix/mypy.nix index 83f8086b..6ecd5991 100644 --- a/nix/mypy.nix +++ b/nix/mypy.nix @@ -1,5 +1,4 @@ { pkgs ? import {} }: - pkgs.python39Packages.buildPythonPackage rec { pname = "mypy"; version = "0.942"; diff --git a/nix/pylint.nix b/nix/pylint.nix index 9f6548c9..1bbc0aa6 100644 --- a/nix/pylint.nix +++ b/nix/pylint.nix @@ -1,29 +1,29 @@ { pkgs ? import {} }: let - astroid = pkgs.python38Packages.buildPythonPackage rec { + astroid = pkgs.python39Packages.buildPythonPackage rec { pname = "astroid"; version = "2.11.7"; - src = pkgs.python38Packages.fetchPypi { + src = pkgs.python39Packages.fetchPypi { inherit pname version; sha256 = "sha256-uyRhXHf0g3xwdmnRaQczE3SuipZGUKZpmdo/XKaNyUY="; }; doCheck = false; - propagatedBuildInputs = with pkgs.python38Packages; [ + propagatedBuildInputs = with pkgs.python39Packages; [ lazy-object-proxy typing-extensions wrapt ]; }; in - pkgs.python38Packages.buildPythonPackage rec { + pkgs.python39Packages.buildPythonPackage rec { pname = "pylint"; version = "2.13.4"; - src = pkgs.python38Packages.fetchPypi { + src = pkgs.python39Packages.fetchPypi { inherit pname version; sha256 = "sha256-fMbQxPYd/0QPnti2V/Ts1hXc/jU0WVPrex3HSv6QHXo="; }; doCheck = false; - propagatedBuildInputs = with pkgs.python38Packages; [ + propagatedBuildInputs = with pkgs.python39Packages; [ isort tomli mccabe diff --git a/pyproject.toml b/pyproject.toml index 89638915..979560f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,7 +28,3 @@ disallow_untyped_decorators = true warn_redundant_casts = true warn_no_return = true warn_unreachable = true - - - - From 776b6937fb0b0d305dc6ade61a91e18d8d8fa094 Mon Sep 17 00:00:00 2001 From: bohendo Date: Thu, 5 Jan 2023 11:13:04 -0500 Subject: [PATCH 09/11] revert mypy hack --- justfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/justfile b/justfile index 9b023975..772be032 100644 --- a/justfile +++ b/justfile @@ -31,8 +31,7 @@ mypy: nix-build nix/mypy.nix > /dev/null @echo "Running mypy.." ./result/bin/mypy --version - # TODO: remove --no-site-packages flag once type libs are properly loaded - ./result/bin/mypy --no-site-packages crytic_compile + ./result/bin/mypy crytic_compile pylint: @echo -e "\nBuilding pylint.." From 8968298649d1c4d14fca3ed94a9b0df9d38f73f9 Mon Sep 17 00:00:00 2001 From: bohendo Date: Fri, 6 Jan 2023 18:03:15 -0500 Subject: [PATCH 10/11] fix mypy --- justfile | 8 ++++---- nix/mypy.nix | 32 ++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/justfile b/justfile index 772be032..55a023d9 100644 --- a/justfile +++ b/justfile @@ -14,28 +14,28 @@ lint: black darglint mypy pylint black: @echo -e "\nBuilding black.." - nix-build nix/black.nix > /dev/null + nix-build nix/black.nix @echo "Running black.." ./result/bin/black --version ./result/bin/black crytic_compile --config pyproject.toml darglint: @echo -e "\nBuilding darglint.." - nix-build nix/darglint.nix > /dev/null + nix-build nix/darglint.nix @echo "Running darglint.." ./result/bin/darglint --version ./result/bin/darglint crytic_compile mypy: @echo -e "\nBuilding mypy.." - nix-build nix/mypy.nix > /dev/null + nix-build nix/mypy.nix @echo "Running mypy.." ./result/bin/mypy --version ./result/bin/mypy crytic_compile pylint: @echo -e "\nBuilding pylint.." - nix-build nix/pylint.nix > /dev/null + nix-build nix/pylint.nix @echo "Running pylint.." ./result/bin/pylint --version ./result/bin/pylint crytic_compile --rcfile pyproject.toml diff --git a/nix/mypy.nix b/nix/mypy.nix index 6ecd5991..10e4ce58 100644 --- a/nix/mypy.nix +++ b/nix/mypy.nix @@ -1,16 +1,20 @@ { pkgs ? import {} }: -pkgs.python39Packages.buildPythonPackage rec { - pname = "mypy"; - version = "0.942"; - src = pkgs.python39Packages.fetchPypi { - inherit pname version; - sha256 = "sha256-F+RGSf7JLp+CECtIo797SlUQrQzSL6IaEEgmtdtJA+I="; + +let + mypy = pkgs.python39Packages.buildPythonPackage rec { + pname = "mypy"; + version = "0.942"; + src = pkgs.python39Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-F+RGSf7JLp+CECtIo797SlUQrQzSL6IaEEgmtdtJA+I="; + }; + doCheck = false; + propagatedBuildInputs = with pkgs.python39Packages; [ + mypy-extensions + tomli + typing-extensions + ]; }; - doCheck = false; - propagatedBuildInputs = with pkgs.python39Packages; [ - mypy-extensions - tomli - types-setuptools - typing-extensions - ]; -} + +in + pkgs.python39.withPackages(ps: with ps; [ mypy types-setuptools ]) From 7b311cba6bfa3d6786a9cfdfd6df087386ef34d7 Mon Sep 17 00:00:00 2001 From: bohendo Date: Wed, 1 Feb 2023 15:08:51 -0500 Subject: [PATCH 11/11] consolidate nix stuff into one flake.nix file --- .github/workflows/black.yml | 45 +++++++++ .github/workflows/ci.yml | 1 - .github/workflows/darglint.yml | 23 +++++ .github/workflows/lint.yml | 27 ------ .github/workflows/linter.yml | 57 ++++++++++++ .github/workflows/mypy.yml | 45 +++++++++ .github/workflows/pylint.yml | 46 ++++++++++ default.nix | 2 - derivation.nix | 40 -------- flake.lock | 42 +++++++++ flake.nix | 161 +++++++++++++++++++++++++++++++++ justfile | 81 +++++++++++------ mypy.ini | 4 + nix/black.nix | 20 ---- nix/brownie.nix | 21 ----- nix/crytic-compile.nix | 18 ---- nix/darglint.nix | 11 --- nix/mypy.nix | 20 ---- nix/pylint.nix | 34 ------- pyproject.toml | 4 + scripts/ci_test_hardhat.sh | 4 +- 21 files changed, 482 insertions(+), 224 deletions(-) create mode 100644 .github/workflows/black.yml create mode 100644 .github/workflows/darglint.yml delete mode 100644 .github/workflows/lint.yml create mode 100644 .github/workflows/linter.yml create mode 100644 .github/workflows/mypy.yml create mode 100644 .github/workflows/pylint.yml delete mode 100644 default.nix delete mode 100644 derivation.nix create mode 100644 flake.lock create mode 100644 flake.nix delete mode 100644 nix/black.nix delete mode 100644 nix/brownie.nix delete mode 100644 nix/crytic-compile.nix delete mode 100644 nix/darglint.nix delete mode 100644 nix/mypy.nix delete mode 100644 nix/pylint.nix diff --git a/.github/workflows/black.yml b/.github/workflows/black.yml new file mode 100644 index 00000000..a04bb8cc --- /dev/null +++ b/.github/workflows/black.yml @@ -0,0 +1,45 @@ +--- +name: Black + +defaults: + run: + # To load bashrc + shell: bash -ieo pipefail {0} + +on: + pull_request: + branches: [master, dev] + +jobs: + build: + name: Black + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + pip install . + pip install deepdiff numpy + + mkdir -p .github/linters + cp pyproject.toml .github/linters + + - name: Black + uses: github/super-linter/slim@v4.9.2 + if: always() + env: + # run linter on everything to catch preexisting problems + VALIDATE_ALL_CODEBASE: true + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Run only black + VALIDATE_PYTHON_BLACK: true + PYTHON_BLACK_CONFIG_FILE: pyproject.toml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 66b913c8..4c92657c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,6 @@ on: - master - dev pull_request: - branches: [ master, dev ] schedule: # run CI every day even if no PRs/merges occur - cron: '0 12 * * *' diff --git a/.github/workflows/darglint.yml b/.github/workflows/darglint.yml new file mode 100644 index 00000000..11fb4145 --- /dev/null +++ b/.github/workflows/darglint.yml @@ -0,0 +1,23 @@ +--- +name: Darglint + +on: + push: + branches: + - master + - dev + pull_request: + branches: [master, dev] + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + - name: Run Tests + run: | + bash scripts/ci_darglint.sh diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index c954878f..00000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,27 +0,0 @@ ---- -name: Lint Code Base - -on: - pull_request: - branches: [master, dev] - -jobs: - lint: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - type: ["black", "darglint", "mypy", "pylint"] - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - name: Set up nix - uses: cachix/install-nix-action@v18 - with: - nix_path: nixpkgs=channel:nixos-unstable - - uses: cachix/cachix-action@v11 - with: - name: crytic-compile - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - - name: run linter - run: nix-shell -p just --run "just ${{ matrix.type }}" diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml new file mode 100644 index 00000000..89e64263 --- /dev/null +++ b/.github/workflows/linter.yml @@ -0,0 +1,57 @@ +--- +name: Lint Code Base + +defaults: + run: + # To load bashrc + shell: bash -ieo pipefail {0} + +on: + pull_request: + branches: [master, dev] + +jobs: + build: + name: Lint Code Base + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + pip install . + pip install deepdiff numpy + + mkdir -p .github/linters + cp pyproject.toml .github/linters + + - name: Lint everything else + uses: github/super-linter/slim@v4.9.2 + if: always() + env: + # run linter on everything to catch preexisting problems + VALIDATE_ALL_CODEBASE: true + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Always false + VALIDATE_PYTHON: false + VALIDATE_PYTHON_PYLINT: false + VALIDATE_PYTHON_BLACK: false + VALIDATE_PYTHON_ISORT: false + # Always false + VALIDATE_JSON: false + VALIDATE_JAVASCRIPT_STANDARD: false + VALIDATE_PYTHON_FLAKE8: false + VALIDATE_DOCKERFILE: false + VALIDATE_DOCKERFILE_HADOLINT: false + VALIDATE_EDITORCONFIG: false + VALIDATE_JSCPD: false + VALIDATE_PYTHON_MYPY: false + SHELLCHECK_OPTS: "-e SC1090 -e SC2181 -e SC2103" diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml new file mode 100644 index 00000000..71b350a9 --- /dev/null +++ b/.github/workflows/mypy.yml @@ -0,0 +1,45 @@ +--- +name: Mypy + +defaults: + run: + # To load bashrc + shell: bash -ieo pipefail {0} + +on: + pull_request: + branches: [master, dev] + +jobs: + build: + name: Mypy + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + pip install . + pip install types-setuptools + + mkdir -p .github/linters + cp mypy.ini .github/linters + + - name: Mypy + uses: github/super-linter/slim@v4.9.2 + if: always() + env: + # run linter on everything to catch preexisting problems + VALIDATE_ALL_CODEBASE: true + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Run only black + VALIDATE_PYTHON_MYPY: true + PYTHON_MYPY_CONFIG_FILE: mypy.ini diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml new file mode 100644 index 00000000..0571c3bd --- /dev/null +++ b/.github/workflows/pylint.yml @@ -0,0 +1,46 @@ +--- +name: Pylint + +defaults: + run: + # To load bashrc + shell: bash -ieo pipefail {0} + +on: + pull_request: + branches: [master, dev] + +jobs: + build: + name: Pylint + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Set up Python 3.8 + uses: actions/setup-python@v4 + with: + python-version: 3.8 + + - name: Install dependencies + run: | + pip install . + pip install deepdiff numpy + + mkdir -p .github/linters + cp pyproject.toml .github/linters + + - name: Pylint + uses: github/super-linter/slim@v4.9.2 + if: always() + env: + # run linter on everything to catch preexisting problems + VALIDATE_ALL_CODEBASE: true + DEFAULT_BRANCH: master + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # Run only pylint + VALIDATE_PYTHON: true + VALIDATE_PYTHON_PYLINT: true + PYTHON_PYLINT_CONFIG_FILE: pyproject.toml diff --git a/default.nix b/default.nix deleted file mode 100644 index 2052e94d..00000000 --- a/default.nix +++ /dev/null @@ -1,2 +0,0 @@ -{ pkgs ? import {} }: -pkgs.callPackage ./nix/crytic-compile.nix {} diff --git a/derivation.nix b/derivation.nix deleted file mode 100644 index d09fccfe..00000000 --- a/derivation.nix +++ /dev/null @@ -1,40 +0,0 @@ -{ lib -, buildPythonPackage -, fetchFromGitHub -, pythonOlder -, pysha3 -, setuptools -}: - -buildPythonPackage rec { - pname = "crytic-compile"; - version = "0.2.4"; - format = "setuptools"; - - disabled = pythonOlder "3.6"; - - src = fetchFromGitHub { - owner = "crytic"; - repo = "crytic-compile"; - rev = "refs/tags/${version}"; - hash = "sha256-phb4Y8CUxuHsNt43oKsgDAZTraNauPkcYQtzcsiWyy8="; - }; - - propagatedBuildInputs = [ - pysha3 - setuptools - ]; - - doCheck = false; - - pythonImportsCheck = [ - "crytic_compile" - ]; - - meta = with lib; { - description = "Abstraction layer for smart contract build systems"; - homepage = "https://github.com/crytic/crytic-compile"; - license = licenses.agpl3Plus; - maintainers = with maintainers; [ SuperSandro2000 arturcygan ]; - }; -} diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..3e8ec6f8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,42 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1671636183, + "narHash": "sha256-dboEYqb7vnH9pVEwgaWz7dzVi7eh6N5tRuhJ/nluoCg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "60ff1ccd98a2f81347457a473c7a96b9b6166c88", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..db02fa03 --- /dev/null +++ b/flake.nix @@ -0,0 +1,161 @@ +{ + description = "Cross-platform smart-contract compiler"; + + # Flake inputs + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + # Flake outputs + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + version = "0.2.5"; + in + rec { + + # Provide packages for selected system types. + packages = { + + default = packages.crytic-compile; + + crytic-compile = pkgs.callPackage pkgs.python38Packages.buildPythonPackage rec { + pname = "crytic-compile"; + inherit version; + format = "pyproject"; + src = ./.; + propagatedBuildInputs = with pkgs.python38Packages; [ + cbor2 + pycryptodome + setuptools + wheel + ]; + pythonRelaxDeps = true; + doCheck = false; + }; + + # Custom derivations to set linters to specific versions + black = pkgs.callPackage pkgs.python38Packages.buildPythonPackage rec { + pname = "black"; + version = "22.3.0"; + src = pkgs.python38Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-NQILiIbAIs7ZKCtRtah1ttGrDDh7MaBluE23wzCFynk="; + }; + doCheck = false; + propagatedBuildInputs = with pkgs.python38Packages; [ + click + mypy-extensions + pathspec + platformdirs + setuptools_scm + tomli + typing-extensions + ]; + }; + + darglint = pkgs.callPackage pkgs.python38Packages.buildPythonPackage rec { + pname = "darglint"; + version = "1.8.0"; + src = pkgs.python38Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-qmBe9HgXptFHl9MrOQRm7atiF2jqTKXMDzxU9tjcrsg="; + }; + doCheck = false; + }; + + mypy = pkgs.python39.withPackages(ps: with ps; [ + types-setuptools + setuptools + (pkgs.python39Packages.buildPythonPackage rec { + pname = "mypy"; + version = "0.942"; + src = pkgs.python39Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-F+RGSf7JLp+CECtIo797SlUQrQzSL6IaEEgmtdtJA+I="; + }; + doCheck = false; + propagatedBuildInputs = with pkgs.python39Packages; [ + mypy-extensions + tomli + typing-extensions + ]; + }) + ]); + + pylint = pkgs.callPackage pkgs.python39Packages.buildPythonPackage rec { + pname = "pylint"; + version = "2.13.4"; + src = pkgs.python39Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-fMbQxPYd/0QPnti2V/Ts1hXc/jU0WVPrex3HSv6QHXo="; + }; + doCheck = false; + propagatedBuildInputs = with pkgs.python39Packages; [ + isort + tomli + mccabe + platformdirs + dill + (pkgs.python39Packages.buildPythonPackage rec { + pname = "astroid"; + version = "2.11.7"; + src = pkgs.python39Packages.fetchPypi { + inherit pname version; + sha256 = "sha256-uyRhXHf0g3xwdmnRaQczE3SuipZGUKZpmdo/XKaNyUY="; + }; + doCheck = false; + propagatedBuildInputs = with pkgs.python39Packages; [ + lazy-object-proxy + typing-extensions + wrapt + ]; + }) + ]; + }; + + }; + + apps = { + default = { + type = "app"; + program = "${self.packages.${system}.crytic-compile}/bin/crytic-compile"; + }; + }; + + # Development environment output + devShells = { + default = pkgs.mkShell { + # The Nix packages provided in the environment + src = ./crytic_compile; + packages = with pkgs; [ + packages.black + packages.darglint + packages.mypy + packages.pylint + # not-reloadable version of crytic-compile (not ideal!) + packages.crytic-compile + # # hot-reloadable version of crytic-compile (hopefully!) + # # currently broken bc crytic_compile/platform clobbers the platform module of the std lib + # (pkgs.python38Packages.buildPythonPackage rec { + # name = "crytic-compile"; + # src = ./crytic_compile; + # propagatedBuildInputs = with pkgs.python38Packages; [ + # cbor2 + # pycryptodome + # setuptools + # ]; + # }) + python38 + virtualenv + python38Packages.pip + python38Packages.pycryptodome + python38Packages.setuptools + ]; + }; + }; + + }); + } diff --git a/justfile b/justfile index 55a023d9..d7231b30 100644 --- a/justfile +++ b/justfile @@ -1,9 +1,9 @@ dev: - nix-shell shell.nix + nix develop build: - nix-build default.nix + nix build .#crytic-compile install: nix-env -e $(nix-env -q | grep "crytic-compile") @@ -13,41 +13,66 @@ install: lint: black darglint mypy pylint black: - @echo -e "\nBuilding black.." - nix-build nix/black.nix - @echo "Running black.." - ./result/bin/black --version - ./result/bin/black crytic_compile --config pyproject.toml + @echo + nix develop --command black --version + nix develop --command black crytic_compile --config pyproject.toml darglint: - @echo -e "\nBuilding darglint.." - nix-build nix/darglint.nix - @echo "Running darglint.." - ./result/bin/darglint --version - ./result/bin/darglint crytic_compile + @echo + nix develop --command darglint --version + nix develop --command darglint crytic_compile mypy: - @echo -e "\nBuilding mypy.." - nix-build nix/mypy.nix - @echo "Running mypy.." - ./result/bin/mypy --version - ./result/bin/mypy crytic_compile + @echo + nix develop --command mypy --version + nix develop --command mypy crytic_compile pylint: - @echo -e "\nBuilding pylint.." - nix-build nix/pylint.nix - @echo "Running pylint.." - ./result/bin/pylint --version - ./result/bin/pylint crytic_compile --rcfile pyproject.toml + @echo + nix develop --command pylint --version + nix develop --command pylint crytic_compile --rcfile pyproject.toml -test: test-hardhat test-monorepo test-brownie +test: test-hardhat test-monorepo -test-monorepo: - bash scripts/ci_test_monorepo.sh +test-brownie: + echo "brownie tests not supported yet" + +test-buidler: + echo "buidler tests not supported yet" + +test-dapp: + echo "dapp tests not supported yet" + +test-embark: + echo "embark tests not supported yet" + +test-etherlime: + echo "etherlime tests not supported yet" + +test-etherscan: + echo "etherscan tests not supported yet" + +test-foundry: + echo "foundry tests not supported yet" test-hardhat: - bash scripts/ci_test_hardhat.sh + @echo + nix develop --command bash scripts/ci_test_hardhat.sh + +test-monorepo: + @echo + nix develop --command bash scripts/ci_test_monorepo.sh + +test-solc: + echo "solc tests not supported yet" + +test-standard: + echo "standard tests not supported yet" + +test-truffle: + echo "truffle tests not supported yet" + +test-waffle: + echo "waffle tests not supported yet" -test-brownie: - bash scripts/ci_test_brownie.sh diff --git a/mypy.ini b/mypy.ini index 8dd020bf..f4ab5f1b 100644 --- a/mypy.ini +++ b/mypy.ini @@ -9,3 +9,7 @@ disallow_untyped_decorators = true warn_redundant_casts = true warn_no_return = true warn_unreachable = true + + + + diff --git a/nix/black.nix b/nix/black.nix deleted file mode 100644 index 772ce588..00000000 --- a/nix/black.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ pkgs ? import {} }: - -pkgs.python38Packages.buildPythonPackage rec { - pname = "black"; - version = "22.3.0"; - src = pkgs.python38Packages.fetchPypi { - inherit pname version; - sha256 = "sha256-NQILiIbAIs7ZKCtRtah1ttGrDDh7MaBluE23wzCFynk="; - }; - doCheck = false; - propagatedBuildInputs = with pkgs.python38Packages; [ - click - mypy-extensions - pathspec - platformdirs - setuptools_scm - tomli - typing-extensions - ]; -} diff --git a/nix/brownie.nix b/nix/brownie.nix deleted file mode 100644 index 9d9f871e..00000000 --- a/nix/brownie.nix +++ /dev/null @@ -1,21 +0,0 @@ -let - mach-nix = import (builtins.fetchGit { - url = "https://github.com/DavHau/mach-nix"; - ref = "refs/tags/3.5.0"; - }) {}; - pkgs = import {}; -in - mach-nix.buildPythonPackage rec { - pname = "eth-brownie"; - version = "1.19.2"; - src = pkgs.fetchFromGitHub { - owner = "eth-brownie"; - repo = "brownie"; - rev = "refs/tags/v${version}"; - hash = "sha256-nKBijlGznWMYpulz0RNZK2tevASzkeC5rEw6NvazSXI="; - }; - providers = { - _default = "nixpkgs,sdist,wheel"; - aiohttp = "nixpkgs,sdist,wheel,conda"; - }; - } diff --git a/nix/crytic-compile.nix b/nix/crytic-compile.nix deleted file mode 100644 index 58620b97..00000000 --- a/nix/crytic-compile.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ pkgs ? import {} }: - -let - inherit (pkgs) python38Packages; -in - python38Packages.buildPythonPackage rec { - pname = "crytic-compile"; - version = "0.2.5"; - format = "pyproject"; - src = ../.; - propagatedBuildInputs = with python38Packages; [ - cbor2 - pycryptodome - setuptools - ]; - pythonRelaxDeps = true; - doCheck = false; - } diff --git a/nix/darglint.nix b/nix/darglint.nix deleted file mode 100644 index 617b4876..00000000 --- a/nix/darglint.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ pkgs ? import {} }: - -pkgs.python38Packages.buildPythonPackage rec { - pname = "darglint"; - version = "1.8.0"; - src = pkgs.python38Packages.fetchPypi { - inherit pname version; - sha256 = "sha256-qmBe9HgXptFHl9MrOQRm7atiF2jqTKXMDzxU9tjcrsg="; - }; - doCheck = false; -} diff --git a/nix/mypy.nix b/nix/mypy.nix deleted file mode 100644 index 10e4ce58..00000000 --- a/nix/mypy.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ pkgs ? import {} }: - -let - mypy = pkgs.python39Packages.buildPythonPackage rec { - pname = "mypy"; - version = "0.942"; - src = pkgs.python39Packages.fetchPypi { - inherit pname version; - sha256 = "sha256-F+RGSf7JLp+CECtIo797SlUQrQzSL6IaEEgmtdtJA+I="; - }; - doCheck = false; - propagatedBuildInputs = with pkgs.python39Packages; [ - mypy-extensions - tomli - typing-extensions - ]; - }; - -in - pkgs.python39.withPackages(ps: with ps; [ mypy types-setuptools ]) diff --git a/nix/pylint.nix b/nix/pylint.nix deleted file mode 100644 index 1bbc0aa6..00000000 --- a/nix/pylint.nix +++ /dev/null @@ -1,34 +0,0 @@ -{ pkgs ? import {} }: -let - astroid = pkgs.python39Packages.buildPythonPackage rec { - pname = "astroid"; - version = "2.11.7"; - src = pkgs.python39Packages.fetchPypi { - inherit pname version; - sha256 = "sha256-uyRhXHf0g3xwdmnRaQczE3SuipZGUKZpmdo/XKaNyUY="; - }; - doCheck = false; - propagatedBuildInputs = with pkgs.python39Packages; [ - lazy-object-proxy - typing-extensions - wrapt - ]; - }; -in - pkgs.python39Packages.buildPythonPackage rec { - pname = "pylint"; - version = "2.13.4"; - src = pkgs.python39Packages.fetchPypi { - inherit pname version; - sha256 = "sha256-fMbQxPYd/0QPnti2V/Ts1hXc/jU0WVPrex3HSv6QHXo="; - }; - doCheck = false; - propagatedBuildInputs = with pkgs.python39Packages; [ - isort - tomli - mccabe - platformdirs - dill - astroid - ]; - } diff --git a/pyproject.toml b/pyproject.toml index 979560f0..89638915 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -28,3 +28,7 @@ disallow_untyped_decorators = true warn_redundant_casts = true warn_no_return = true warn_unreachable = true + + + + diff --git a/scripts/ci_test_hardhat.sh b/scripts/ci_test_hardhat.sh index 9ec3fea4..28f74b80 100755 --- a/scripts/ci_test_hardhat.sh +++ b/scripts/ci_test_hardhat.sh @@ -7,6 +7,6 @@ cd tests/hardhat || exit 255 npm install if ! crytic-compile . -then echo "Hardhat test failed" && exit 255 -else echo "Hardhat test passed" && exit 0 +then echo "Monorepo test failed" && exit 255 +else echo "Monorepo test passed" && exit 0 fi