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

Commit ef8d1eb

Browse files
authored
Merge pull request #3189 from input-output-hk/devops-936-fix-stylish-script
[DEVOPS-936] Fix tests.stylishHaskell output when files are utf-8
2 parents ef15b92 + 8ac1594 commit ef8d1eb

File tree

5 files changed

+24
-18
lines changed

5 files changed

+24
-18
lines changed

default.nix

+1-2
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,10 @@ let
157157
tests = {
158158
shellcheck = pkgs.callPackage ./scripts/test/shellcheck.nix { src = ./.; };
159159
hlint = pkgs.callPackage ./scripts/test/hlint.nix { src = ./.; };
160-
stylishHaskell = pkgs.callPackage ./scripts/test/stylish.nix { src = ./.; stylish-haskell = cardanoPkgs.stylish-haskell; };
160+
stylishHaskell = pkgs.callPackage ./scripts/test/stylish.nix { src = ./.; stylish-haskell = cardanoPkgs.stylish-haskell; inherit localLib; };
161161
buildWalletIntegration = pkgs.callPackage ./scripts/test/wallet/integration/build-test.nix { inherit walletIntegrationTests pkgs; };
162162
swaggerSchemaValidation = pkgs.callPackage ./scripts/test/wallet/swaggerSchemaValidation.nix { inherit gitrev; };
163163
};
164-
fixStylishHaskell = pkgs.callPackage ./scripts/haskell/stylish.nix { stylish-haskell = cardanoPkgs.stylish-haskell; };
165164
cardano-sl-explorer-frontend = (import ./explorer/frontend {
166165
inherit system config gitrev pkgs;
167166
cardano-sl-explorer = cardanoPkgs.cardano-sl-explorer-static;

lib.nix

+9
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,13 @@ in lib // (rec {
1818
inherit fetchNixPkgs;
1919
isCardanoSL = lib.hasPrefix "cardano-sl";
2020
isBenchmark = args: !((args.isExecutable or false) || (args.isLibrary or true));
21+
22+
# Insert this into builder scripts where programs require a UTF-8
23+
# locale to work.
24+
utf8LocaleSetting = ''
25+
export LC_ALL=en_GB.UTF-8
26+
export LANG=en_GB.UTF-8
27+
'' + lib.optionalString (pkgs.glibcLocales != null) ''
28+
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive"
29+
'';
2130
})

scripts/launch/connect-to-cluster/default.nix

-6
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,6 @@ let
6767
"--configuration-file ${environments.${environment}.confFile or "${configFiles}/lib/configuration.yaml"}"
6868
"--configuration-key ${environments.${environment}.confKey}"
6969
];
70-
utf8LocaleSetting = ''
71-
export LC_ALL=en_GB.UTF-8
72-
export LANG=en_GB.UTF-8
73-
'' + optionalString (pkgs.glibcLocales != null) ''
74-
export LOCALE_ARCHIVE="${pkgs.glibcLocales}/lib/locale/locale-archive"
75-
'';
7670

7771
in pkgs.writeScript "${executable}-connect-to-${environment}" ''
7872
#!${pkgs.stdenv.shell} -e

scripts/launch/demo-cluster/default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ in pkgs.writeScript "demo-cluster" ''
109109
110110
done
111111
${ifWallet ''
112-
export LC_ALL=C.UTF-8
112+
${utf8LocaleSetting}
113113
echo Launching wallet node: ${demoWallet}
114114
${demoWallet} --runtime-args "--system-start $system_start" &> /dev/null &
115115
wallet_pid=$!

scripts/test/stylish.nix

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ runCommand, stylish-haskell, src, lib, git }:
1+
{ runCommand, stylish-haskell, src, lib, localLib, diffutils }:
22

33
let
44
cleanSourceFilter = with lib;
@@ -9,20 +9,24 @@ let
99
);
1010
src' = builtins.filterSource cleanSourceFilter src;
1111
in
12-
runCommand "cardano-stylish-check" { succeedOnFailure = true; buildInputs = [ stylish-haskell git ]; } ''
12+
runCommand "cardano-stylish-check" {
13+
succeedOnFailure = true;
14+
buildInputs = [ stylish-haskell diffutils ];
15+
} ''
1316
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
17+
${localLib.utf8LocaleSetting}
18+
cp -a ${src'} orig
19+
cp -a ${src'} stylish
20+
chmod -R +w stylish
21+
cd stylish
1922
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
23+
cd ..
24+
diff --brief --recursive orig stylish > /dev/null
2125
EXIT_CODE=$?
2226
if [[ $EXIT_CODE != 0 ]]
2327
then
2428
mkdir -p $out/nix-support
25-
git diff > $out/stylish.diff
29+
diff -ur orig stylish > $out/stylish.diff
2630
echo "file none $out/stylish.diff" > $out/nix-support/hydra-build-products
2731
echo "*** Stylish-haskell found changes that need addressed first"
2832
echo "*** Please run \`nix-shell -A fixStylishHaskell\` and commit changes"

0 commit comments

Comments
 (0)