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

Commit 2945b4c

Browse files
committed
[DEVOPS-936] Hydra CI job for sylish-haskell
1 parent e7b1f1d commit 2945b4c

File tree

4 files changed

+45
-8
lines changed

4 files changed

+45
-8
lines changed

default.nix

+8-4
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,14 @@ let
153153
other = rec {
154154
validateJson = pkgs.callPackage ./tools/src/validate-json {};
155155
demoCluster = pkgs.callPackage ./scripts/launch/demo-cluster { inherit gitrev; };
156-
shellcheckTests = pkgs.callPackage ./scripts/test/shellcheck.nix { src = ./.; };
157-
swaggerSchemaValidation = pkgs.callPackage ./scripts/test/wallet/swaggerSchemaValidation.nix { inherit gitrev; };
158-
walletIntegrationTests = pkgs.callPackage ./scripts/test/wallet/integration { inherit gitrev; };
159-
buildWalletIntegrationTests = pkgs.callPackage ./scripts/test/wallet/integration/build-test.nix { inherit walletIntegrationTests pkgs; };
156+
tests = {
157+
shellcheck = pkgs.callPackage ./scripts/test/shellcheck.nix { src = ./.; };
158+
stylishHaskell = pkgs.callPackage ./scripts/test/stylish.nix { src = ./.; stylish-haskell = cardanoPkgs.stylish-haskell; };
159+
walletIntegration = pkgs.callPackage ./scripts/test/wallet/integration { inherit gitrev; };
160+
buildWalletIntegration = pkgs.callPackage ./scripts/test/wallet/integration/build-test.nix { inherit walletIntegration pkgs; };
161+
swaggerSchemaValidation = pkgs.callPackage ./scripts/test/wallet/swaggerSchemaValidation.nix { inherit gitrev; };
162+
};
163+
fixStylishHaskell = pkgs.callPackage ./scripts/haskell/stylish.nix { stylish-haskell = cardanoPkgs.stylish-haskell; };
160164
cardano-sl-explorer-frontend = (import ./explorer/frontend {
161165
inherit system config gitrev pkgs;
162166
cardano-sl-explorer = cardanoPkgs.cardano-sl-explorer-static;

release.nix

+2-4
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ let
6060
inherit (mapped'.connectScripts."${cluster}") wallet explorer;
6161
};
6262
nixosTests = import ./nixos-tests;
63-
shellcheckTests = iohkPkgs.shellcheckTests;
64-
swaggerSchemaValidation = iohkPkgs.swaggerSchemaValidation;
65-
walletIntegrationTests = iohkPkgs.buildWalletIntegrationTests;
63+
tests = iohkPkgs.tests;
6664
makeRelease = cluster: {
6765
name = cluster;
6866
value = {
@@ -71,7 +69,7 @@ let
7169
};
7270
};
7371
in mapped // {
74-
inherit walletIntegrationTests swaggerSchemaValidation shellcheckTests;
72+
inherit tests;
7573
nixpkgs = let
7674
wrapped = pkgs.runCommand "nixpkgs" {} ''
7775
ln -sv ${fixedNixpkgs} $out

scripts/haskell/stylish.nix

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{ stylish-haskell, writeScriptBin }:
2+
3+
writeScriptBin "cardano-stylish-cleanup" ''
4+
find . -type f -name "*hs" -not -path '.git' -not -path '*.stack-work*' -not -name 'HLint.hs' -exec ${stylish-haskell}/bin/stylish-haskell -i {} \;
5+
''

scripts/test/stylish.nix

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{ runCommand, stylish-haskell, src, lib, git }:
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-stylish-check" { buildInputs = [ stylish-haskell git ]; } ''
13+
set +e
14+
cp -a ${src'} tmp-cardano
15+
chmod -R 0755 tmp-cardano
16+
cd tmp-cardano
17+
git init
18+
git add -A
19+
find . -type f -name "*hs" -not -path '.git' -not -path '*.stack-work*' -not -name 'HLint.hs' -exec stylish-haskell -i {} \;
20+
git diff --exit-code
21+
EXIT_CODE=$?
22+
if [[ $EXIT_CODE != 0 ]]
23+
then
24+
echo "*** Stylish-haskell found changes that need addressed first"
25+
echo "*** Please run scripts/haskell/stylish.sh and commit changes"
26+
exit $EXIT_CODE
27+
else
28+
echo $EXIT_CODE > $out
29+
fi
30+
''

0 commit comments

Comments
 (0)