Skip to content

Regularise era based command structure #1229

Regularise era based command structure

Regularise era based command structure #1229

name: Check Stylish Haskell
on:
merge_group:
pull_request:
# When pushing branches (and/or updating PRs), we do want to cancel previous
# build runs. We assume they are stale now; and do not want to spend CI time and
# resources on continuing to continue those runs. This is what the concurrency.group
# value lets us express. When using merge queues, we now have to consider
# - runs triggers by commits per pull-request
# we want to cancel any previous run. So they should all get the same group (per PR)
# - runs refs/heads/gh-readonly-queue/<target branch name> (they should all get their
# unique git ref, we don't want to cancel any of the ones in the queue)
# - if it's neither, we fall back to the run_id (this is a unique number for each
# workflow run; it does not change if you "rerun" a job)
concurrency:
group: ${{ github.workflow }}-${{ github.event.type }}-${{ startsWith(github.ref, 'refs/heads/gh-readonly-queue/') && github.ref || github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
check-stylish-haskell:
runs-on: ubuntu-latest
strategy:
fail-fast: false
env:
# Modify this value to "invalidate" the cabal cache.
CABAL_CACHE_VERSION: "2023-07-28"
STYLISH_HASKELL_VERSION: "0.14.4.0"
STYLISH_HASKELL_PATHS: >
cardano-api
steps:
- name: Download stylish-haskell
if: runner.os == 'Linux'
run: |
version="${{ env.STYLISH_HASKELL_VERSION }}"
curl -sL \
"https://github.com/haskell/stylish-haskell/releases/download/v$version/stylish-haskell-v$version-linux-x86_64.tar.gz" \
| tar -C "/tmp" -xz
echo "PATH=/tmp/stylish-haskell-v$version-linux-x86_64:$PATH" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Run stylish-haskell over all Haskell files (always succeeds)
run: |
git add .
git stash
for x in $(git ls-tree --full-tree --name-only -r HEAD ${{ env.STYLISH_HASKELL_PATHS }}); do
if [ "${x##*.}" == "hs" ]; then
if grep -qE '^#' $x; then
echo "$x contains CPP. Skipping."
else
stylish-haskell -i $x
fi
fi
done
git --no-pager diff
- name: Run stylish-haskell over all modified files
run: |
git add .
git stash
git fetch origin ${{ github.base_ref }} --unshallow
for x in $(git diff --name-only --diff-filter=ACMR origin/${{ github.base_ref }}..HEAD ${{ env.STYLISH_HASKELL_PATHS }}); do
if [ "${x##*.}" == "hs" ]; then
if grep -qE '^#' $x; then
echo "$x contains CPP. Skipping."
else
stylish-haskell -i $x
fi
fi
done
git --no-pager diff --exit-code