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

Commit 964ba3e

Browse files
committed
[DEVOPS-936] hydra for hlint
1 parent 15dfbbf commit 964ba3e

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

default.nix

+1
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ let
156156
demoCluster = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev; };
157157
tests = {
158158
shellcheck = pkgs.callPackage ./scripts/test/shellcheck.nix { src = ./.; };
159+
hlint = pkgs.callPackage ./scripts/test/hlint.nix { src = ./.; };
159160
stylishHaskell = pkgs.callPackage ./scripts/test/stylish.nix { src = ./.; stylish-haskell = cardanoPkgs.stylish-haskell; };
160161
buildWalletIntegration = pkgs.callPackage ./scripts/test/wallet/integration/build-test.nix { inherit walletIntegrationTests pkgs; };
161162
swaggerSchemaValidation = pkgs.callPackage ./scripts/test/wallet/swaggerSchemaValidation.nix { inherit gitrev; };

scripts/test/hlint.nix

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{ runCommand, hlint, src, lib }:
2+
3+
let
4+
cleanSourceFilter = with lib;
5+
name: type: let baseName = baseNameOf (toString name); in (
6+
(type == "regular" && hasSuffix ".hs" baseName) ||
7+
(type == "regular" && hasSuffix ".yaml" baseName) ||
8+
(type == "directory")
9+
);
10+
src' = builtins.filterSource cleanSourceFilter src;
11+
in
12+
runCommand "cardano-hlint-check" { buildInputs = [ hlint ]; } ''
13+
set +e
14+
# Networking is not in here, because it has a very different codestyle (doesn't use universum).
15+
# This is bad and should probably be fixed.
16+
projects=("util" "binary" "crypto" "core" "db" "lrc" "infra" "ssc" "txp" "update" "delegation" "node" "tools" "client" "generator" "auxx" "explorer" "wallet" "wallet-new")
17+
cd ${src'}
18+
hlint lib/src lib/test lib/bench "''${projects[@]}"
19+
EXIT_CODE=$?
20+
if [[ $EXIT_CODE != 0 ]]
21+
then
22+
echo '====================================================================='
23+
echo 'Note: to ignore a particular hint (e.g. "Reduce duplication"), write'
24+
echo 'this in the source file:'
25+
tput bold
26+
echo '{-# ANN module ("HLint: ignore Reduce duplication" :: Text) #-}'
27+
tput sgr0
28+
echo 'You can also apply it just to a particular function, which is better:'
29+
tput bold
30+
echo '{-# ANN funcName ("HLint: ignore Reduce duplication" :: Text) #-}'
31+
tput sgr0
32+
exit $EXIT_CODE
33+
else
34+
echo $EXIT_CODE > $out
35+
fi
36+
''

0 commit comments

Comments
 (0)