diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1890e07..1505e49 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,9 @@ jobs: authToken: '${{ secrets.CACHIX_AUTH_TOKEN_PUBLIC }}' - name: Run linters and unit tests the Nix way - run: nix flake check + run: | + nix flake check + nix run .#impure-checks impure_tests: name: Impure Tests diff --git a/Makefile b/Makefile index 8b423be..bdb4580 100644 --- a/Makefile +++ b/Makefile @@ -68,7 +68,7 @@ tesh: .PHONY: examples examples: - @echo "You need nix-shell to run 'make examples'" + @tesh examples/ .PHONY: test test: tests diff --git a/flake.nix b/flake.nix index 96a484e..0415e23 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ inputs.pre-commit-hooks-nix.flakeModule ]; systems = [ "x86_64-linux" "aarch64-darwin" ]; - perSystem = { config, self', inputs', pkgs, system, ... }: + perSystem = { config, self', inputs', pkgs, system, lib, ... }: let autoflake = pkgs.python3Packages.autoflake.overrideAttrs (old: { @@ -87,12 +87,22 @@ testEnv = inputs.poetry2nix.legacyPackages.${system}.mkPoetryEnv { projectDir = ./.; preferWheels = true; - # editablePackageSources = { - # src = ./src; - # }; }; + + impure-checks = pkgs.writeScriptBin "impure-checks" '' + export PATH="${lib.makeBinPath [ + pkgs.coreutils + pkgs.gnumake + pkgs.bash + pkgs.nix + self'.packages.testEnv + ]}" + make examples + ''; }; + # 'make lint' not needed since pre-commit is run by pre-commit flake-part + # 'make examples' is an impure test so it's done in `impure-checks` checks.tests = pkgs.runCommand "tests" { buildInputs = self'.devShells.default.buildInputs; } '' @@ -100,11 +110,9 @@ chmod +w -R ./source cd ./source export PYTHONPATH="$(realpath ./src)" - # make lint -> not needed since we already have pre-commit checks defined above make types make unit make tesh - # make examples -> doesn't work because we can't run `nix-shell` inside nix flake check cp -r htmlcov $out/ '';