1
1
mirror of https://github.com/nmattia/niv.git synced 2024-09-05 20:15:26 +03:00

Add CI check for formatting

This commit is contained in:
Nicolas Mattia 2020-07-24 13:06:32 +02:00
parent 15c82fd184
commit ab9cc41caf
2 changed files with 25 additions and 1 deletions

View File

@ -198,6 +198,24 @@ rec
tests-github = pkgs.callPackage ./tests/github { inherit niv; };
tests-git = pkgs.callPackage ./tests/git { inherit niv; };
fmt-check =
pkgs.stdenv.mkDerivation
{
name = "fmt-check";
buildInputs = [ pkgs.ormolu pkgs.glibcLocales ];
src = niv-source;
phases = [ "unpackPhase" "checkPhase" ];
LANG = "en_US.UTF-8";
checkPhase = ''
cp ${./script/fmt} ./fmt
patchShebangs ./fmt
chmod +x fmt
bash fmt -c
touch $out
'';
doCheck = true;
};
readme = pkgs.runCommand "README.md" { nativeBuildInputs = [ niv ]; }
''
cp ${./README.tpl.md} $out

View File

@ -1,4 +1,9 @@
#!/usr/bin/env bash
#!/usr/bin/env nix-shell
#!nix-shell -i bash
#!nix-shell -I nixpkgs=./nix
#!nix-shell -p ormolu
#!nix-shell -p glibcLocales
#!nix-shell --keep GITHUB_TOKEN
###
### fmt - Format Haskell files with Ormolu
###
@ -40,6 +45,7 @@ fmt() {
if [ "$mode" == "check" ]; then
exit 1
fi
echo "Please run ./script/fmt"
fi
}