Skip to content

Commit

Permalink
CI: use preinstalled Stack; fix caching
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed Apr 3, 2024
1 parent f9f304a commit 2ac451c
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions .github/workflows/haskell.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Haskell CI
name: Stack CI

on:
push:
Expand All @@ -15,35 +15,51 @@ 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
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 }}

0 comments on commit 2ac451c

Please sign in to comment.