From ec41d4817ae0a72a59430d3efff270af25bee40d Mon Sep 17 00:00:00 2001 From: Tobias Pflug Date: Mon, 11 Jan 2021 17:29:43 +0000 Subject: [PATCH] buildPursPackage: fix compilation/test execution Compile all required sources and execute unit tests during the checkPhase. The `checkPhase` is now a required argument to `buildPursPackage`. It would be just always execute `npm run test` but this fails in cases where `spago test` is used which (always) tries to download remote files. --- marlowe-playground-client/default.nix | 1 + nix/lib/purescript.nix | 7 +++++-- plutus-playground-client/default.nix | 6 ++++++ plutus-scb-client/default.nix | 6 ++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/marlowe-playground-client/default.nix b/marlowe-playground-client/default.nix index edd564b6bd9..b6f402de488 100644 --- a/marlowe-playground-client/default.nix +++ b/marlowe-playground-client/default.nix @@ -39,6 +39,7 @@ let client = buildPursPackage { inherit webCommon nodeModules; src = ./.; + checkPhase = "npm run test"; name = "marlowe-playground-client"; psSrc = generated-purescript; packages = pkgs.callPackage ./packages.nix { }; diff --git a/nix/lib/purescript.nix b/nix/lib/purescript.nix index c921a859ba2..22236639c23 100644 --- a/nix/lib/purescript.nix +++ b/nix/lib/purescript.nix @@ -19,6 +19,8 @@ , webCommon # node_modules to use , nodeModules + # control execution of unit tests +, checkPhase }: let # Cleans the source based on the patterns in ./.gitignore and the additionalIgnores @@ -26,7 +28,7 @@ let in stdenv.mkDerivation { - inherit name; + inherit name checkPhase; src = cleanSrcs; buildInputs = [ nodeModules easyPS.purs easyPS.spago easyPS.psc-package ]; buildPhase = '' @@ -37,9 +39,10 @@ stdenv.mkDerivation { ln -s ${webCommon} ../web-common sh ${spagoPackages.installSpagoStyle} - sh ${spagoPackages.buildSpagoStyle} + sh ${spagoPackages.buildSpagoStyle} src/**/*.purs test/**/*.purs generated/**/*.purs ../web-common/**/*.purs ${nodejs}/bin/npm run webpack ''; + doCheck = true; installPhase = '' mv dist $out ''; diff --git a/plutus-playground-client/default.nix b/plutus-playground-client/default.nix index 09ada6c4458..8755c7cf9f0 100644 --- a/plutus-playground-client/default.nix +++ b/plutus-playground-client/default.nix @@ -37,6 +37,12 @@ let inherit webCommon nodeModules; src = ./.; name = "plutus-playground-client"; + # ideally we would just use `npm run test` but + # this executes `spago` which *always* attempts to download + # remote files (which obviously fails in sandboxed builds) + checkPhase = '' + node -e 'require("./output/Test.Main").main()' + ''; psSrc = generated-purescript; packages = pkgs.callPackage ./packages.nix { }; spagoPackages = pkgs.callPackage ./spago-packages.nix { }; diff --git a/plutus-scb-client/default.nix b/plutus-scb-client/default.nix index 3e984b27ba1..0fbcf612a06 100644 --- a/plutus-scb-client/default.nix +++ b/plutus-scb-client/default.nix @@ -19,6 +19,12 @@ let inherit webCommon nodeModules; src = ./.; name = "plutus-scb-client"; + # ideally we would just use `npm run test` but + # this executes `spago` which *always* attempts to download + # remote files (which obviously fails in sandboxed builds) + checkPhase = '' + node -e 'require("./output/Test.Main").main()' + ''; psSrc = generated-purescript; packages = pkgs.callPackage ./packages.nix { }; spagoPackages = pkgs.callPackage ./spago-packages.nix { };