Skip to content

Commit

Permalink
Test make examples in nix flake check
Browse files Browse the repository at this point in the history
  • Loading branch information
zupo committed Oct 20, 2023
1 parent c11f5ee commit 918837d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ tesh:

.PHONY: examples
examples:
@echo "You need nix-shell to run 'make examples'"
@tesh examples/

.PHONY: test
test: tests
Expand Down
20 changes: 14 additions & 6 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -87,24 +87,32 @@
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;
} ''
cp -r ${./.} ./source
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/
'';

Expand Down

0 comments on commit 918837d

Please sign in to comment.