graphql-engine/.github/workflows/hlint.yml
Auke Booij a4113eb9a6
add hlint config, run hlint through a github action, add to dev.sh (#5957)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-10-16 13:55:18 +02:00

33 lines
1.4 KiB
YAML

name: server lint
on:
pull_request:
paths:
- 'server/**'
jobs:
hlint:
runs-on: ubuntu-20.04
env:
working-directory: ./server
HLINT_BASE_URL: https://dl.haskellworks.io/binaries/hlint
HLINT_VERSION: 3.1.6
HLINT_ARCH: x86_64
HLINT_OS: linux
HLINT_URL: $HLINT_BASE_URL/hlint-${HLINT_VERSION}-${HLINT_ARCH}-${HLINT_OS}.tar.gz
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download hlint
working-directory: ${{env.working-directory}}
run: |
echo "Downloading from ${{env.HLINT_URL}}"
curl "${{env.HLINT_URL}}" -o "./hlint-${{env.HLINT_VERSION}}-${{env.HLINT_ARCH}}-${{env.HLINT_OS}}.tar.gz"
tar -zxvf "./hlint-${{env.HLINT_VERSION}}-${{env.HLINT_ARCH}}-${{env.HLINT_OS}}.tar.gz" -C "."
- name: Run hlint
shell: bash
run: git diff --name-only origin/${{github.base_ref}}..${{github.sha}} -- ${{env.working-directory}} | grep -E '\.hs$|\.lhs$' | xargs -d '\n' find 2>/dev/null | xargs -d '\n' ${{env.working-directory}}/hlint --json --hint=${{env.working-directory}}/.hlint.yaml | jq -r '.[] | "::" + (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 "))) catch ""'