diff --git a/.github/workflows/format-tests.yml b/.github/workflows/format-tests.yml index 2c68cd3b..c3a3ca64 100644 --- a/.github/workflows/format-tests.yml +++ b/.github/workflows/format-tests.yml @@ -14,13 +14,17 @@ jobs: - uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4 with: python-version: "3.12.3" + - uses: cachix/install-nix-action@8887e596b4ee1134dae06b98d573bd674693f47c # v26 + - uses: cachix/cachix-action@18cf96c7c98e048e10a83abd92116114cd8504be # v14 + with: + name: linz + authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" + - name: Format + run: nix-shell --pure --run 'pre-commit run --all-files' - name: Install run: | pip install poetry poetry install --no-root - - name: Format - run: | - poetry run pre-commit run --all-files - name: Unit Tests run: | poetry run pytest --doctest-modules . diff --git a/.gitignore b/.gitignore index 02975fc3..688ecc73 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.pyc __pycache__ /.pytest_cache +/python Thumbs.db /.venv /.vscode diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 22b04176..60f8ff70 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,14 @@ repos: stages: [commit] types: [python] + - id: deadnix + name: deadnix + entry: deadnix + args: [--edit, --fail] + files: \.nix$ + language: system + stages: [commit] + - id: gitlint name: gitlint entry: gitlint @@ -34,6 +42,13 @@ repos: types: [python] require_serial: true + - id: nixfmt + name: nixfmt + entry: nixfmt + files: \.nix$ + language: system + stages: [commit] + - id: pylint name: pylint entry: pylint @@ -42,6 +57,15 @@ repos: types: [python] require_serial: true + - id: statix + name: statix + entry: statix + args: [check] + files: \.nix$ + pass_filenames: false + language: system + stages: [commit] + - repo: https://github.com/pre-commit/mirrors-prettier rev: a99a3fbe79a9d346cabd02a5e167ad0edafe616b # v2.3.0 hooks: diff --git a/poetry.lock b/poetry.lock index d54cb8ad..1ceb6d5b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1234,20 +1234,6 @@ numpy = ">=1.14,<3" docs = ["matplotlib", "numpydoc (==1.1.*)", "sphinx", "sphinx-book-theme", "sphinx-remove-toctrees"] test = ["pytest", "pytest-cov"] -[[package]] -name = "shellcheck-py" -version = "0.10.0.1" -description = "Python wrapper around invoking shellcheck (https://www.shellcheck.net/)" -optional = false -python-versions = ">=3.8" -files = [ - {file = "shellcheck_py-0.10.0.1-py2.py3-none-macosx_11_0_x86_64.whl", hash = "sha256:48f08965cafbb3363b265c4ef40628ffced19cb6fc7c4bb5ce72d32cbcfb4bb9"}, - {file = "shellcheck_py-0.10.0.1-py2.py3-none-macosx_14_0_arm64.whl", hash = "sha256:8f3bf12ee6d0845dd5ac1a7bac8c4b1fec0379e115950986883c9488af40ada7"}, - {file = "shellcheck_py-0.10.0.1-py2.py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c1c266f7f54cd286057c592ead3095f93d123acdcabf048879a7d8900c3aac7b"}, - {file = "shellcheck_py-0.10.0.1-py2.py3-none-win_amd64.whl", hash = "sha256:be73a16931c05f79643ff74b6519d1e1203b394583ab8c68a48a8e7f257d1090"}, - {file = "shellcheck_py-0.10.0.1.tar.gz", hash = "sha256:390826b340b8c19173922b0da5ef7b66ef34d4d087dc48aad3e01f7e77e164d9"}, -] - [[package]] name = "six" version = "1.16.0" @@ -1403,4 +1389,4 @@ files = [ [metadata] lock-version = "2.0" python-versions = "~3.12.3" -content-hash = "11678d25e9494ac7384858577c2f3d861fd360fea67f1359c8cfb18da2a21d6c" +content-hash = "466cf0546b48e4ecea9893709ea45bce9b067f1c943a7d53ddaf4a87eaa0926e" diff --git a/pyproject.toml b/pyproject.toml index bc080644..3fbb0542 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -57,4 +57,3 @@ pytest = "*" pytest-dependency = "*" pytest-mock = "*" pytest-subtests = "*" -shellcheck-py = "*" diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..451f905b --- /dev/null +++ b/shell.nix @@ -0,0 +1,48 @@ +let + pkgs = import (builtins.fetchTarball { + name = "nixos-unstable-2024-09-17"; + url = "https://github.com/nixos/nixpkgs/archive/345c263f2f53a3710abe117f28a5cb86d0ba4059.tar.gz"; + sha256 = "1llzyzw7a0jqdn7p3px0sqa35jg24v5pklwxdybwbmbyr2q8cf5j"; + }) { overlays = [ (_final: prev: { geos = prev.geos_3_11; }) ]; }; + poetry2nix = import (builtins.fetchTarball { + url = "https://github.com/nix-community/poetry2nix/archive/2024.9.1542864.tar.gz"; + sha256 = "06vz5hwylvjvx4ywbv4y3kadq8zxmvpf5h7pjy6w1yhkwpjd6k25"; + }) { inherit pkgs; }; + poetryPackages = poetry2nix.mkPoetryPackages { + projectDir = ./.; + python = pkgs.python312; + overrides = poetry2nix.overrides.withDefaults ( + final: prev: { + cryptography = prev.cryptography.overridePythonAttrs ( + # TODO: Remove when is in poetry2nix + old: { + nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ + final.distutils + ]; + } + ); + } + ); + }; + pythonWithPackages = poetryPackages.python.withPackages (_ps: poetryPackages.poetryPackages); +in +pkgs.mkShell { + packages = [ + pythonWithPackages + pkgs.bashInteractive + pkgs.cacert + pkgs.deadnix + pkgs.gcc # To install Python debugging in IDEA + pkgs.gdal + pkgs.gitFull + pkgs.nixfmt-rfc-style + pkgs.nodejs + pkgs.poetry + pkgs.shellcheck + pkgs.statix + pkgs.which + ]; + shellHook = '' + ln --force --no-target-directory --symbolic "${pkgs.lib.getExe pythonWithPackages}" python + ''; +}