CI #41
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: | |
branches: [master] | |
push: | |
branches: [master] | |
# additionally run once per week (At 00:00 on Sunday) to maintain cache | |
schedule: | |
- cron: "0 0 * * 0" | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: Build and test | |
runs-on: ubuntu-latest | |
env: | |
GHC_VERSION: 9.4.8 | |
STACK_LTS: "0" # actual value will be set in later steps | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup job-local environment | |
run: | | |
{ | |
echo "STACK_LTS=$(awk '/^resolver:/{print $2}' stack.yaml)" | |
} >> $GITHUB_ENV | |
- name: Cache GHC installation | |
uses: actions/cache@v3 | |
id: ghcup | |
with: | |
path: | | |
~/.ghcup/bin/* | |
~/.ghcup/cache/* | |
~/.ghcup/config.yaml | |
~/.ghcup/ghc/${{ env.GHC_VERSION }} | |
key: ghcup-${{ env.GHC_VERSION }} | |
- uses: haskell/actions/setup@v2 | |
if: steps.ghcup.outputs.cache-hit != 'true' | |
with: | |
ghc-version: ${{ env.GHC_VERSION }} | |
enable-stack: true | |
stack-version: "latest" | |
- name: Cache Pantry (Stackage package index) | |
id: pantry | |
uses: actions/cache@v3 | |
with: | |
path: ~/.stack/pantry | |
key: stackPantry-${{ env.GHC_VERSION }}-${{ env.STACK_LTS }} | |
restore-keys: | | |
stackPantry-${{ env.GHC_VERSION }}- | |
stackPantry- | |
- name: Recompute Stackage package index | |
if: steps.pantry.outputs.cache-hit != 'true' | |
run: stack update # populates ~/.stack/pantry | |
- name: Configure Stack | |
run: | | |
stack config set install-ghc false --global | |
stack config set system-ghc true --global | |
- name: Cache Haskell dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.stack/stack.sqlite3 | |
~/.stack/snapshots | |
# NOTE: the caching key structure: | |
# * ghc version -- helps maintain sleek size of the cache; | |
# * resolver version -- helps maintain sleek size of the cache; | |
# * lockfile hashsum -- as invalidation trigger of the correct granularity. | |
# Since this cache only stores built *dependency packages* (not project code!), | |
# we should invalidate/reupload it on each change to the dependency forest (≈lockfile). | |
# | |
# All this decides when cache gets REBUILT (invalidated & recreated): | |
key: haskellDeps-${{ env.GHC_VERSION }}-${{ env.STACK_LTS }}-${{ hashFiles('**/stack.yaml.lock') }} | |
restore-keys: | | |
haskellDeps-${{ env.GHC_VERSION }}-${{ env.STACK_LTS }}- | |
haskellDeps-${{ env.GHC_VERSION }}- | |
haskellDeps- | |
- name: Build & Test | |
run: | | |
stack build -j2 --fast --test --pedantic \ | |
--ghc-options="-j -O0" |