graphql-engine/.github/workflows/server-format.yml
Antoine Leblanc 6494229f54 server: generalize functions (#393)
Co-authored-by: Vamshi Surabhi <0x777@users.noreply.github.com>
GitOrigin-RevId: 5d2140152a2a18601c785ea80a7689cbe3bd277e
2021-01-25 10:13:54 +00:00

35 lines
1.4 KiB
YAML

name: server format
on:
label:
pull_request:
paths:
- 'server/**'
jobs:
stylish-haskell:
runs-on: ubuntu-latest
if: "!contains(github.event.pull_request.labels.*.name, 'ignore-server-format-checks') && github.event.label.name != 'ignore-server-format-checks'"
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Run stylish-haskell
shell: bash
run: |
if git show -q --pretty=format:"%s" | grep -q "\[no-format\]"; then
echo "Found [no-format], skipping."
else
CHANGED_HS_FILES=$(git diff --name-only origin/${{github.base_ref}}...${{github.sha}} -- "./server/*.hs" | xargs -i -d '\n' sh -c 'ls -d {} 2>/dev/null || true' | sed 's%^server/%%')
echo "Changed Haskell files are:"
echo "$CHANGED_HS_FILES"
cd server
curl -sL https://raw.github.com/jaspervdj/stylish-haskell/master/scripts/latest.sh | sh -s $(echo $CHANGED_HS_FILES) -i
if [ -n "$(git status --porcelain)" ] ; then
echo "Files that needed formatting:"
git diff --name-only --diff-filter=M
for hfile in $(git status --porcelain | sed -n 's/^ M //p'); do
echo "::warning file=server/$hfile::This file needs to be formatted using stylish-haskell.\nRun `cd server && stylish-haskell $hfile` to do so."
done
fi
fi