forked from flipstone/stack-lts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SC-39923] Adds stan and a wrapping script to run it
stan doesn't come with a way to produce a non-zero exit code when it finds issues, so I added a wrapping script that runs `stan report --json-output`, which saves an HTML report and outputs the report as JSON. The script will inspect the JSON and exit with 1 if there are any problems reported.
- Loading branch information
Showing
4 changed files
with
43 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ stack install \ | |
fourmolu \ | ||
ghcid \ | ||
hlint \ | ||
ShellCheck | ||
ShellCheck \ | ||
stan | ||
|
||
rm -rf .stack-work /root/.stack |
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,25 @@ | ||
#!/usr/bin/env sh | ||
|
||
echo "Running stan..." | ||
|
||
REPORT=$(stan report --json-output) | ||
EXIT_CODE=$? | ||
|
||
if [ "$EXIT_CODE" -ne 0 ]; then | ||
echo "$REPORT" | ||
exit $EXIT_CODE | ||
fi | ||
|
||
set -o errexit | ||
|
||
OBSERVATIONS=$(echo "$REPORT" | jq '.observations') | ||
LENGTH=$(echo "$OBSERVATIONS" | jq length) | ||
|
||
if [ "$LENGTH" -gt 0 ]; then | ||
echo "stan found the following problems:" | ||
echo "$OBSERVATIONS" | jq -r '.[] | "- \(.inspectionId): \(.srcSpan)"' | ||
echo "See stan.html or run 'stan' for more information." | ||
exit 1 | ||
else | ||
echo "stan found no problems." | ||
fi |
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