Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
[DEVOPS-936] [DEVOPS-937] nix: use cleanSourceWith for source filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
rvl committed Jul 4, 2018
1 parent a38591c commit 76da2ba
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
10 changes: 6 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,12 @@ let
walletIntegrationTests = pkgs.callPackage ./scripts/test/wallet/integration { inherit gitrev; };
validateJson = pkgs.callPackage ./tools/src/validate-json {};
demoCluster = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev; };
tests = {
shellcheck = pkgs.callPackage ./scripts/test/shellcheck.nix { src = ./.; };
hlint = pkgs.callPackage ./scripts/test/hlint.nix { src = ./.; };
stylishHaskell = pkgs.callPackage ./scripts/test/stylish.nix { src = ./.; stylish-haskell = cardanoPkgs.stylish-haskell; };
tests = let
src = localLib.cleanSourceTree ./.;
in {
shellcheck = pkgs.callPackage ./scripts/test/shellcheck.nix { inherit src; };
hlint = pkgs.callPackage ./scripts/test/hlint.nix { inherit src; };
stylishHaskell = pkgs.callPackage ./scripts/test/stylish.nix { inherit (cardanoPkgs) stylish-haskell; inherit src; };
buildWalletIntegration = pkgs.callPackage ./scripts/test/wallet/integration/build-test.nix { inherit walletIntegrationTests pkgs; };
swaggerSchemaValidation = pkgs.callPackage ./scripts/test/wallet/swaggerSchemaValidation.nix { inherit gitrev; };
};
Expand Down
7 changes: 5 additions & 2 deletions scripts/test/hlint.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{ runCommand, hlint, src, lib }:

let
cleanSourceFilter = with lib;
# just haskell sources and the hlint config file
src' = lib.cleanSourceWith {
inherit src;
filter = with lib;
name: type: let baseName = baseNameOf (toString name); in (
(type == "regular" && hasSuffix ".hs" baseName) ||
(type == "regular" && hasSuffix ".yaml" baseName) ||
(type == "directory")
);
src' = builtins.filterSource cleanSourceFilter src;
};
in
runCommand "cardano-hlint-check" { buildInputs = [ hlint ]; } ''
set +e
Expand Down
7 changes: 5 additions & 2 deletions scripts/test/shellcheck.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{ runCommand, shellcheck, src, lib }:

let
cleanSourceFilter = with lib;
# just the shell scripts
src' = lib.cleanSourceWith {
inherit src;
filter = with lib;
name: type: let baseName = baseNameOf (toString name); in (
(type == "regular" && hasSuffix ".sh" baseName) ||
(type == "directory")
);
src' = builtins.filterSource cleanSourceFilter src;
};
in
runCommand "iohk-ops-shellcheck" { buildInputs = [ shellcheck ]; } ''
EXIT_STATUS=0
Expand Down
9 changes: 6 additions & 3 deletions scripts/test/stylish.nix
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
{ runCommand, stylish-haskell, src, lib, git }:

let
cleanSourceFilter = with lib;
# just haskell sources and the stylish-haskell config file
src' = lib.cleanSourceWith {
inherit src;
filter = with lib;
name: type: let baseName = baseNameOf (toString name); in (
(type == "regular" && hasSuffix ".hs" baseName) ||
(type == "regular" && hasSuffix ".yaml" baseName) ||
(type == "directory")
);
src' = builtins.filterSource cleanSourceFilter src;
};
in
runCommand "cardano-stylish-check" { succeedOnFailure = true; buildInputs = [ stylish-haskell git ]; } ''
set +e
Expand All @@ -16,7 +19,7 @@ runCommand "cardano-stylish-check" { succeedOnFailure = true; buildInputs = [ st
cd tmp-cardano
git init
git add -A
find . -type f -name "*hs" -not -path '.git' -not -path '*.stack-work*' -not -name 'HLint.hs' -exec stylish-haskell -i {} \;
find . -type f -name "*hs" -not -name 'HLint.hs' -exec stylish-haskell -i {} \;
git diff --exit-code
EXIT_CODE=$?
if [[ $EXIT_CODE != 0 ]]
Expand Down

0 comments on commit 76da2ba

Please sign in to comment.