Skip to content

Commit

Permalink
buildPursPackage: fix compilation/test execution
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gilligan committed Jan 12, 2021
1 parent e73ba57 commit ec41d48
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions marlowe-playground-client/default.nix
Expand Up @@ -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 { };
Expand Down
7 changes: 5 additions & 2 deletions nix/lib/purescript.nix
Expand Up @@ -19,14 +19,16 @@
, 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
cleanSrcs = nix-gitignore.gitignoreSource [ "/*.adoc" "/*.nix" ] src;

in
stdenv.mkDerivation {
inherit name;
inherit name checkPhase;
src = cleanSrcs;
buildInputs = [ nodeModules easyPS.purs easyPS.spago easyPS.psc-package ];
buildPhase = ''
Expand All @@ -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
'';
Expand Down
6 changes: 6 additions & 0 deletions plutus-playground-client/default.nix
Expand Up @@ -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 { };
Expand Down
6 changes: 6 additions & 0 deletions plutus-scb-client/default.nix
Expand Up @@ -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 { };
Expand Down

0 comments on commit ec41d48

Please sign in to comment.