From 0dfcd0ede18ce468ce6bcc436e7b0028ae6ffd7c Mon Sep 17 00:00:00 2001 From: Andreas Abel Date: Wed, 3 Apr 2024 16:32:49 +0200 Subject: [PATCH] CI: use preinstalled Stack; fix caching --- .github/workflows/haskell.yml | 47 ++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index b7a837c4..f4bbd05c 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -1,4 +1,4 @@ -name: Haskell CI +name: Stack CI on: push: @@ -15,35 +15,54 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Install required libraries run: >- sudo apt install z3 + # Use preinstalled Stack. Should Stack fail to be installed, use the setup action: + # - name: Setup Haskell + # uses: haskell-actions/setup@v2 + # with: + # enable-stack: true + # stack-no-global: true - - name: Cache Stack build artifacts (user + project) - uses: actions/cache@v3 + - name: Restore Stack build artifacts (user + project) + uses: actions/cache/restore@v4 + id: cache with: path: | ~/.stack .stack-work - # best effort for cache: tie it to Stack resolver and package config - key: ${{ runner.os }}-stack-${{ hashFiles('stack.yaml.lock', 'package.yaml') }} + # Write a fresh cache each time + key: ${{ runner.os }}-stack-${{ github.sha }} restore-keys: | ${{ runner.os }}-stack - - - name: Setup Haskell - uses: actions/setup-haskell@v1 - - - name: Install GHC using Stack - if: steps.ghc.outputs.cache-hit != 'true' - run: stack setup --install-ghc - + - name: Setup Stack + run: stack setup + + - name: Build dependencies + run: stack test --only-dependencies + - name: Build run: stack build + - name: Build tests + run: stack test --no-run-tests + - name: Run tests run: stack test + + # Always cache dependencies. + # This makes esp. sense now that some tests are broken. + - name: Cache Stack build artifacts (user + project) + uses: actions/cache/save@v4 + if: always() && steps.cache.outputs.cache-hit != 'true' + with: + path: | + ~/.stack + .stack-work + key: ${{ steps.cache.outputs.cache-primary-key }}