diff --git a/default.nix b/default.nix index 49b6d613..2dcfc6fb 100644 --- a/default.nix +++ b/default.nix @@ -80,6 +80,7 @@ let inherit (import sources.cardano-repo-tool {inherit system;}) cardano-repo-tool; stack-cabal-sync-shell = pkgsDefault.callPackage ./pkgs/stack-cabal-sync-shell.nix { inherit cardano-repo-tool; }; supervisord = pkgsDefault.callPackage ./supervisord {}; + fixStylishHaskell = pkgsDefault.callPackage ./tests/fix-stylish-haskell.nix {}; # Check scripts check-hydra = __trace "check-hydra is deprecated. Please use hydraEvalErrors" pkgsDefault.callPackage ./ci/check-hydra.nix {}; @@ -189,7 +190,8 @@ let checkCabalProject hydraEvalErrors checkRepoTagsOnMasterBranches - checkStackProject; + checkStackProject + fixStylishHaskell; release-lib = ./lib/release-lib.nix; }; in self diff --git a/tests/fix-stylish-haskell.nix b/tests/fix-stylish-haskell.nix new file mode 100644 index 00000000..5e290397 --- /dev/null +++ b/tests/fix-stylish-haskell.nix @@ -0,0 +1,17 @@ +{ writeScriptBin, git, fd, stylish-haskell }: + +writeScriptBin "fix-stylish-haskell" '' + ${git}/bin/git diff > pre-stylish.diff + ${fd}/bin/fd --extension hs "$@" \ + --exec ${stylish-haskell}/bin/stylish-haskell -i {} + ${git}/bin/git diff > post-stylish.diff + diff pre-stylish.diff post-stylish.diff > /dev/null + if [ $? != 0 ] + then + echo "Changes by stylish have been made. Please commit them." + else + echo "No stylish changes were made." + fi + rm pre-stylish.diff post-stylish.diff + exit +'' diff --git a/tests/stylish-haskell.nix b/tests/stylish-haskell.nix index c4bce742..48799b35 100644 --- a/tests/stylish-haskell.nix +++ b/tests/stylish-haskell.nix @@ -31,7 +31,7 @@ runCommand "stylish-check" { diff -ur orig stylish > $out/stylish.diff echo "file none $out/stylish.diff" > $out/nix-support/hydra-build-products echo "*** Stylish-haskell found changes that need addressed first" - echo "*** Please run \`nix-shell -A fixStylishHaskell\` and commit changes" + echo "*** Please run `$(nix-build ./nix -A iohkNix.fixStylishHaskell)/bin/fix-stylish-haskell --exclude '*/dist/*' --exclude '*/docs/*'` and commit changes" echo "*** or apply the diff generated by hydra if you don't have nix." exit $EXIT_CODE else