Hlint all Haskell code

So far we've only used `hlint` to lint the OSS code. This moves some things around to lint the Pro code as well.

Note that the CI action only runs `hlint` on Haskell files that are _changed_ by a PR, relative to its merge-base (usually `main`).

As a reminder, you can use the `ignore-server-hlint-checks` label to prevent this from blocking a merge.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3383
GitOrigin-RevId: d5779c63d780f526a1d58ae4107f0d5262a23ec1
This commit is contained in:
Auke Booij 2022-01-18 05:05:12 +01:00 committed by hasura-bot
parent 501cb32604
commit a7dbe95666
4 changed files with 4 additions and 4 deletions

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-20.04
if: "!contains(github.event.pull_request.labels.*.name, 'ignore-server-hlint-checks') && github.event.label.name != 'ignore-server-hlint-checks'"
env:
working-directory: ./server
working-directory: .
HLINT_BASE_URL: https://dl.haskellworks.io/binaries/hlint
HLINT_VERSION: 3.1.6
HLINT_ARCH: x86_64
@ -31,7 +31,7 @@ jobs:
- name: Run hlint
shell: bash
run: |
CHANGED_HS_FILES=$(git diff --name-only origin/${{github.base_ref}}...${{github.sha}} -- "${{env.working-directory}}/*.hs" | xargs -i -d '\n' sh -c 'ls -d {} 2>/dev/null || true')
CHANGED_HS_FILES=$(git diff --name-only origin/${{github.base_ref}}...${{github.sha}} -- "${{env.working-directory}}/server/*.hs" | xargs -i -d '\n' sh -c 'ls -d {} 2>/dev/null || true')
echo "$CHANGED_HS_FILES"
JQ_SCRIPT='.[] | "::" + (if (.severity=="Warning" or .severity=="Error") then "error" else "warning" end) + " file=\(.file),line=\(.startLine),col=\(.startColumn)::\(.severity):" + " \(.hint)%0AFound:%0A \(.from | gsub("\n";"%0A "))%0A" + try ("Perhaps:%0A " + (.to | gsub("\n";"%0A ")) + "%0A") catch "" + try (if .note | length > 0 then "Note:%0A " + (.note | join("\n") | gsub("\n";"%0A ")) else "" end) catch ""'
if [[ "$CHANGED_HS_FILES" ]]

View File

@ -486,7 +486,7 @@ elif [ "$MODE" = "test" ]; then
if [ "$RUN_HLINT" = true ]; then
if command -v hlint >/dev/null; then
(cd "$PROJECT_ROOT/server" && hlint src-*)
hlint "${PROJECT_ROOT}/server/src-"*
else
echo_warn "hlint is not installed: skipping"
fi

View File

@ -189,7 +189,7 @@ are not met.
`-Werror` to `ghc-options` in your `cabal.project` is a good way of checking
this.)
- No lint failures: Use [hlint](https://github.com/ndmitchell/hlint) with our
custom config to validate your code, using `hlint --hint=server/.hlint.yaml`.
custom config to validate your code, using `hlint --hint=../.hlint.yaml`.
- Consistent formatting: Use [ormolu](https://github.com/tweag/ormolu) to
format your code. `ormolu -ei '*.hs'` will format all files with a `.hs`
extension in the current directory.