From 43c19f0b3abe92381e7da9a4f079cefbe2b651db Mon Sep 17 00:00:00 2001 From: Enno Cramer Date: Fri, 11 Aug 2023 22:32:55 +0200 Subject: [PATCH] Update Github CI workflow to use checkout@v3 and haskell/setup@v2 --- .github/workflows/ci.yml | 67 +++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b336006..1ef5e1b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,11 +7,15 @@ 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 ] @@ -19,53 +23,58 @@ jobs: - 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