diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 11ff65b..20a4aac 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,19 +13,18 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - uses: cachix/install-nix-action@v15 + - uses: cachix/install-nix-action@v30 + - uses: DeterminateSystems/magic-nix-cache-action@main - name: Run linting run: nix develop -c make lint-ci tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: install dependencies - run: python3 -m pip install --user --upgrade poetry - - name: install - run: poetry install + - uses: cachix/install-nix-action@v30 + - uses: DeterminateSystems/magic-nix-cache-action@main - name: Run tests - run: make test + run: nix develop -c python -mpytest -vv -s nix-flake: runs-on: ubuntu-latest steps: diff --git a/flake.nix b/flake.nix index 86a3693..9b42444 100644 --- a/flake.nix +++ b/flake.nix @@ -8,17 +8,27 @@ inputs.flake-utils.follows = "flake-utils"; }; }; - outputs = { self, nixpkgs, flake-utils, poetry2nix }: - (flake-utils.lib.eachDefaultSystem (system: + outputs = + { + self, + nixpkgs, + flake-utils, + poetry2nix, + }: + (flake-utils.lib.eachDefaultSystem ( + system: let - pkgs = (import nixpkgs { - inherit system; - config = { }; - overlays = [ - poetry2nix.overlays.default - ]; - }); - overrides = pkgs.poetry2nix.overrides.withDefaults (self: super: + pkgs = ( + import nixpkgs { + inherit system; + config = { }; + overlays = [ + poetry2nix.overlays.default + ]; + } + ); + overrides = pkgs.poetry2nix.overrides.withDefaults ( + self: super: let buildSystems = { durations = [ "setuptools" ]; @@ -26,23 +36,25 @@ pytest-github-actions-annotate-failures = [ "setuptools" ]; flake8-black = [ "setuptools" ]; flake8-isort = [ "hatchling" ]; - docker = [ "hatchling" "hatch-vcs" ]; + docker = [ + "hatchling" + "hatch-vcs" + ]; }; in - pkgs.lib.mapAttrs - (attr: systems: super.${attr}.overridePythonAttrs - (old: { - nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems; - })) - buildSystems + pkgs.lib.mapAttrs ( + attr: systems: + super.${attr}.overridePythonAttrs (old: { + nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ map (a: self.${a}) systems; + }) + ) buildSystems ); in rec { - packages.default = pkgs.poetry2nix.mkPoetryApplication - { - projectDir = ./.; - inherit overrides; - }; + packages.default = pkgs.poetry2nix.mkPoetryApplication { + projectDir = ./.; + inherit overrides; + }; apps.default = { type = "app"; program = "${packages.default}/bin/pystarport"; @@ -53,6 +65,12 @@ projectDir = ./.; inherit overrides; }) + (pkgs.poetry2nix.mkPoetryEditablePackage { + projectDir = ./.; + editablePackageSources = { + pystarport = ./pystarport; + }; + }) ]; }; } diff --git a/pystarport/tests/test_expansion/test_expansion.py b/pystarport/tests/test_expansion/test_expansion.py index 0abd2aa..93b8398 100644 --- a/pystarport/tests/test_expansion/test_expansion.py +++ b/pystarport/tests/test_expansion/test_expansion.py @@ -53,8 +53,10 @@ def test_expansion(type, func): } } + path = Path(__file__).parent + # overriding dotenv with absolute path is expanded and has diff - dotenv = os.path.abspath("test_expansion/dotenv1") + dotenv = os.path.abspath(path / "dotenv1") config = func(cronos_has_dotenv, dotenv) assert DeepDiff( base_config, @@ -72,7 +74,7 @@ def test_expansion(type, func): } # overriding dotenv with absolute path is expanded and no diff - dotenv = os.path.abspath("test_expansion/dotenv") + dotenv = os.path.abspath(path / "dotenv") config = func(cronos_has_posix_no_dotenv, dotenv) assert not DeepDiff( base_config,