Merge pull request #380 from fourmolu/column-limit-block-args #588
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: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
workflow_call: | |
outputs: | |
version: | |
value: ${{ jobs.build_prod.outputs.version }} | |
jobs: | |
check_generated_files: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
name: Check that generated files are up-to-date | |
run: | | |
config/generate.sh | |
git diff --exit-code | |
cabal_test: | |
strategy: | |
matrix: | |
ghc_version: | |
- '9.4' | |
- '9.6' | |
- '9.8' | |
name: 'cabal_test: ghc-${{ matrix.ghc_version }}' | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
uses: haskell-actions/setup@v2 | |
with: | |
ghc-version: ${{ matrix.ghc_version }} | |
- | |
name: cabal configure | |
run: | |
cabal configure | |
--enable-tests | |
--test-show-details=streaming | |
--flag dev | |
- | |
run: cabal update | |
- | |
run: cabal freeze | |
- | |
name: Invalidate cache every month | |
run: echo "CURR_MONTH=$(date +%B)" | tee -a "$GITHUB_ENV" | |
- | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cabal/store | |
key: ${{ runner.os }}-cabal-cache-${{ env.CURR_MONTH }}-${{ matrix.ghc_version }}-${{ hashFiles('cabal.project.freeze') }} | |
restore-keys: | | |
${{ runner.os }}-cabal-cache-${{ env.CURR_MONTH }}-${{ matrix.ghc_version }}- | |
- | |
run: cabal install --overwrite-policy=always alex happy | |
- | |
run: cabal test | |
stack_test: | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
name: 'stack_test: ${{ matrix.os }}' | |
runs-on: ${{ matrix.os }} | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
uses: actions/cache@v3 | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-stack_test-${{ hashFiles('stack.yaml', 'fourmolu.cabal') }} | |
- | |
run: stack test --fast | |
build_haddock: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
uses: actions/cache@v3 | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-build_haddock-${{ hashFiles('stack.yaml', 'fourmolu.cabal') }} | |
- | |
name: Build haddock | |
# just a sanity check, so no need to build third-party docs | |
run: stack haddock --fast --no-haddock-deps | |
- | |
name: Bundle haddock docs | |
run: tar czf fourmolu-docs.tar.gz -C "$(find .stack-work/dist -regex '.*/doc/html/[^/]*')" . | |
- | |
uses: actions/upload-artifact@v3 | |
with: | |
name: fourmolu-docs | |
path: fourmolu-docs.tar.gz | |
build_prod: | |
strategy: | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
name: 'build_prod: ${{ matrix.os }}' | |
runs-on: ${{ matrix.os }} | |
env: | |
FOURMOLU_REV: ${{ github.sha }} | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
uses: actions/cache@v3 | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-build_prod-${{ hashFiles('stack.yaml', 'fourmolu.cabal') }} | |
- | |
name: Build | |
run: | | |
ARGS=( | |
# install binary to ./bin/ | |
--copy-bins --local-bin-path ./bin/ | |
# not using `dev` flag or testing; done in `stack_test` + `os_test` | |
) | |
stack build "${ARGS[@]}" | |
- | |
uses: haskell-actions/parse-cabal-file@v1 | |
id: cabal_file | |
with: | |
cabal_file: fourmolu.cabal | |
- | |
name: Rename binary | |
run: | | |
set -x | |
case ${{ runner.os }} in | |
(Linux) os=linux ;; | |
(macOS) os=osx ;; | |
(*) echo 'Unknown OS' >&1; exit 1 ;; | |
esac | |
case ${{ runner.arch }} in | |
(X64) arch=x86_64 ;; | |
(*) echo 'Unknown architecture' >&1; exit 1 ;; | |
esac | |
cp bin/fourmolu bin/fourmolu-$version-$os-$arch | |
env: | |
version: ${{ steps.cabal_file.outputs.version }} | |
- | |
name: Store binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: fourmolu-binary-${{ matrix.os }} | |
path: bin/fourmolu-* | |
outputs: | |
version: ${{ steps.cabal_file.outputs.version }} | |
lint: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
uses: actions/cache@v3 | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-lint-stack-${{ hashFiles('stack.yaml', 'fourmolu.cabal') }} | |
- | |
name: Build Fourmolu executable | |
run: stack build --fast :fourmolu | |
- | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pre-commit | |
key: ${{ runner.os }}-lint-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | |
- | |
name: Install pre-commit | |
run: pip install pre-commit | |
- | |
name: Run pre-commit | |
run: pre-commit run --all-files --show-diff-on-failure | |
check_sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
uses: actions/cache@v3 | |
with: | |
path: ~/.stack | |
key: ${{ runner.os }}-check_sdist-${{ hashFiles('stack.yaml') }} | |
- | |
name: Create sdist bundle | |
run: stack sdist --test-tarball --tar-dir . | |
- | |
uses: actions/upload-artifact@v3 | |
with: | |
name: fourmolu-sdist | |
path: fourmolu-*.tar.gz | |
check_redundant_examples: | |
runs-on: ubuntu-latest | |
steps: | |
- | |
uses: actions/checkout@v4 | |
- | |
run: scripts/clean_redundant_examples.py | |
- | |
run: git diff --exit-code data/examples/ |