Skip to content

Commit

Permalink
Update Github CI workflow to use checkout@v3 and haskell/setup@v2
Browse files Browse the repository at this point in the history
  • Loading branch information
ennocramer committed Aug 11, 2023
1 parent 5120deb commit 43c19f0
Showing 1 changed file with 38 additions and 29 deletions.
67 changes: 38 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,74 @@ on:
- opened
- synchronize

permissions:
contents: read

jobs:
cabal:
build:
name: GHC ${{ matrix.ghc }} (${{ matrix.os }})

strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macOS-latest ]
ghc: [ 8.4.4, 8.6.5, 8.8.4, 8.10.7, 9.0.2, 9.2.8, 9.4.6, 9.6.2 ]
exclude:
- os: macOS-latest
ghc: 8.4.4

env:
ARGS: --enable-tests --enable-benchmarks

runs-on: ${{ matrix.os }}

steps:
- name: Environment
run: |
echo "matrix=${{ toJSON(matrix) }}"
echo "ARGS=$ARGS"
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Setup Haskell
uses: haskell/actions/setup@v1
id: setup-haskell-cabal
- name: Setup GHC/Cabal
uses: haskell/actions/setup@v2
id: setup
with:
ghc-version: ${{ matrix.ghc }}

- name: Cabal Update
run: cabal update
- name: Check Cabal File
run: cabal check

- name: Cabal Freeze
run: cabal freeze $ARGS

- name: Cache
uses: actions/cache@v2
- name: Configure
run: |
cabal configure --enable-test --enable-benchmarks --disable-documentation
cabal build --dry-run
# The last step generates dist-newstyle/cache/plan.json for the cache key.

- name: Restore Cache
uses: actions/cache/restore@v3
id: cache
env:
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
with:
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: ${{ env.key }}-

- name: Build Dependencies
run: cabal build $ARGS --only-dependencies
run: cabal build all --only-dependencies

# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
- name: Save Cache
uses: actions/cache/save@v3
# Caches are immutable, trying to save with the same key would error.
if: ${{ steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}

- name: Build Project
run: cabal build $ARGS
run: cabal build all

- name: Run Tests
run: cabal test $ARGS
run: cabal test all

- name: Generate Documentation
run: cabal haddock $ARGS

- name: Package Distribution
run: cabal sdist
run: cabal haddock all

0 comments on commit 43c19f0

Please sign in to comment.