This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CDEC-383] Add stylish-haskell to nix and CI
- Loading branch information
Showing
7 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bash | ||
|
||
# check and warn if commits don't conform to stylish-haskell | ||
|
||
set -xe | ||
|
||
fail_stylish_check() { | ||
# The '-w' option for 'git diff' is used because in some builds | ||
# (i.e. https://buildkite.com/input-output-hk/cardano-sl/builds/976#0fb162df-8f9b-42d7-9ca7-608a9ea06d4d) | ||
# the patch to 'default.nix' only suggests that whitespaces be added | ||
# (see https://gist.github.com/anonymous/f52dbb040db16034d303e27056a0a48e), without | ||
# which the build fails in the 'stack2nix' step. | ||
git diff --text > /tmp/stylish.patch | ||
buildkite-agent artifact upload /tmp/stylish.patch --job "$BUILDKITE_JOB_ID" | ||
echo "ERROR: you need to (run ./scripts/haskell/stylish-last-10.sh or apply the patch in the buildkite artifact) and commit the changes" >&2 | ||
exit 1 | ||
} | ||
|
||
# Get relative path to script directory | ||
haskellScriptDir=$(dirname -- "$(readlink -f -- "${BASH_SOURCE[0]}")")/haskell/ | ||
|
||
# shellcheck source=/dev/null | ||
source "${haskellScriptDir}stylish-last-10.sh" | ||
|
||
|
||
git diff --text --exit-code || fail_stylish_check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
let | ||
cardanoPkgs = import ../../. {}; | ||
pkgs = import ((import ../../lib.nix).fetchNixPkgs) { }; | ||
in pkgs.runCommand "name" { buildInputs = [ cardanoPkgs.stylish-haskell ]; } "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
nix-shell ${haskellScriptDir}shell-with-stylish.nix --run "\ | ||
git diff --diff-filter=AMR --name-only -r HEAD~10 |\ | ||
grep '.hs$' |\ | ||
xargs -I '{}' realpath --relative-to=. $(git rev-parse --show-toplevel)/'{}' |\ | ||
xargs -L 1 stylish-haskell -i" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters