Backwards compatible formatting #793
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
name: Backwards compatible formatting | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 0 * * *' # nightly | |
jobs: | |
format_compat: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- | |
name: cabal | |
repo: haskell/cabal | |
ref: Cabal-v3.12.0.0 | |
args: Cabal Cabal-syntax cabal-install | |
- | |
name: swarm | |
repo: swarm-game/swarm | |
ref: 0.4.0.0 | |
args: src app test | |
name: 'format_compat: ${{ matrix.name }}' | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Check out Fourmolu | |
uses: actions/checkout@v4 | |
with: | |
path: fourmolu | |
- | |
uses: actions/cache@v4 | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-format_compat-${{ hashFiles('fourmolu/stack.yaml', 'fourmolu/fourmolu.cabal') }} | |
- | |
name: Install fourmolu | |
working-directory: fourmolu | |
run: | | |
stack install | |
echo "${HOME}/.local/bin" >> "${GITHUB_PATH}" | |
- | |
name: Check out ${{ matrix.repo }} | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ matrix.repo }} | |
ref: ${{ matrix.ref }} | |
path: target/ | |
- | |
name: Run fourmolu | |
working-directory: target | |
run: | | |
git apply --allow-empty ../fourmolu/compat-tests/${{ matrix.name }}.diff | |
fourmolu -i ${{ matrix.args }} | |
git -c 'diff.algorithm=histogram' diff > ${{ matrix.name }}.diff | |
- | |
name: Compare diff | |
run: diff -u fourmolu/compat-tests/${{ matrix.name }}.diff target/${{ matrix.name }}.diff | |
- | |
if: always() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.name }}-compat-diff | |
path: target/${{ matrix.name }}.diff |