This repository was 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
[DEVOPS-936] Hydra CI job for stylish-haskell #3166
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,36 @@ | ||
{ runCommand, hlint, src, lib }: | ||
|
||
let | ||
cleanSourceFilter = with lib; | ||
name: type: let baseName = baseNameOf (toString name); in ( | ||
(type == "regular" && hasSuffix ".hs" baseName) || | ||
(type == "regular" && hasSuffix ".yaml" baseName) || | ||
(type == "directory") | ||
); | ||
src' = builtins.filterSource cleanSourceFilter src; | ||
in | ||
runCommand "cardano-hlint-check" { buildInputs = [ hlint ]; } '' | ||
set +e | ||
# Networking is not in here, because it has a very different codestyle (doesn't use universum). | ||
# This is bad and should probably be fixed. | ||
projects=("util" "binary" "crypto" "core" "db" "lrc" "infra" "ssc" "txp" "update" "delegation" "node" "tools" "client" "generator" "auxx" "explorer" "wallet" "wallet-new") | ||
cd ${src'} | ||
hlint lib/src lib/test lib/bench "''${projects[@]}" | ||
EXIT_CODE=$? | ||
if [[ $EXIT_CODE != 0 ]] | ||
then | ||
echo '=====================================================================' | ||
echo 'Note: to ignore a particular hint (e.g. "Reduce duplication"), write' | ||
echo 'this in the source file:' | ||
tput bold | ||
echo '{-# ANN module ("HLint: ignore Reduce duplication" :: Text) #-}' | ||
tput sgr0 | ||
echo 'You can also apply it just to a particular function, which is better:' | ||
tput bold | ||
echo '{-# ANN funcName ("HLint: ignore Reduce duplication" :: Text) #-}' | ||
tput sgr0 | ||
exit $EXIT_CODE | ||
else | ||
echo $EXIT_CODE > $out | ||
fi | ||
'' |
This file contains hidden or 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,34 @@ | ||
{ runCommand, stylish-haskell, src, lib, git }: | ||
|
||
let | ||
cleanSourceFilter = with lib; | ||
name: type: let baseName = baseNameOf (toString name); in ( | ||
(type == "regular" && hasSuffix ".hs" baseName) || | ||
(type == "regular" && hasSuffix ".yaml" baseName) || | ||
(type == "directory") | ||
); | ||
src' = builtins.filterSource cleanSourceFilter src; | ||
in | ||
runCommand "cardano-stylish-check" { succeedOnFailure = true; buildInputs = [ stylish-haskell git ]; } '' | ||
set +e | ||
cp -a ${src'} tmp-cardano | ||
chmod -R 0755 tmp-cardano | ||
cd tmp-cardano | ||
git init | ||
git add -A | ||
find . -type f -name "*hs" -not -path '.git' -not -path '*.stack-work*' -not -name 'HLint.hs' -exec stylish-haskell -i {} \; | ||
git diff --exit-code | ||
EXIT_CODE=$? | ||
if [[ $EXIT_CODE != 0 ]] | ||
then | ||
mkdir -p $out/nix-support | ||
git diff > $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 "*** or apply the diff generated by hydra if you don't have nix." | ||
exit $EXIT_CODE | ||
else | ||
echo $EXIT_CODE > $out | ||
fi | ||
'' |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this use
lib.cleanSourceWith
(see example in #3174). That will work better with already filtered sources I think.