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

Commit 3f5dd5f

Browse files
committed
[DEVOPS-936] hydra for hlint
1 parent 3cf1fa3 commit 3f5dd5f

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

.buildkite/pipeline.yml

-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
steps:
2-
- label: 'hlint'
3-
command: 'scripts/ci/nix-shell.sh -p hlint moreutils --run scripts/haskell/lint.sh'
4-
agents:
5-
system: x86_64-linux
6-
72
- label: 'stack2nix'
83
command: 'scripts/ci/nix-shell.sh -p cabal2nix stack cabal-install ghc moreutils expect -Q -j 4 --run scripts/check-stack2nix.sh'
94
agents:

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

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
# Networking is not in here, because it has a very different codestyle (doesn't use universum).
14+
# This is bad and should probably be fixed.
15+
projects=("util" "binary" "crypto" "core" "db" "lrc" "infra" "ssc" "txp" "update" "delegation" "node" "tools" "client" "generator" "auxx" "explorer" "wallet" "wallet-new")
16+
cd ${src'}
17+
hlint lib/src lib/test lib/bench "''${projects[@]}"
18+
EXIT_CODE=$?
19+
if [[ $EXIT_CODE != 0 ]]
20+
then
21+
echo '====================================================================='
22+
echo 'Note: to ignore a particular hint (e.g. "Reduce duplication"), write'
23+
echo 'this in the source file:'
24+
tput bold
25+
echo '{-# ANN module ("HLint: ignore Reduce duplication" :: Text) #-}'
26+
tput sgr0
27+
echo 'You can also apply it just to a particular function, which is better:'
28+
tput bold
29+
echo '{-# ANN funcName ("HLint: ignore Reduce duplication" :: Text) #-}'
30+
tput sgr0
31+
exit $EXIT_CODE
32+
else
33+
echo $EXIT_CODE > $out
34+
fi
35+
''

0 commit comments

Comments
 (0)