-
Notifications
You must be signed in to change notification settings - Fork 105
112 lines (97 loc) · 4.3 KB
/
haskell.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Haskell CI
on:
push:
branches: [main]
pull_request:
branches: [main]
# INFO: The following configuration block ensures that only one build runs per branch,
# which may be desirable for projects with a costly build process.
# Remove this block from the CI workflow to let each CI job run to completion.
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: true
# INFO: The caching strategy was created following this post https://github.com/commercialhaskell/stack/issues/5754#issuecomment-1696156869
env:
#-- increment this if you think cache of GHC installation needs cold rebuild
MANUAL_CACHE_RESET_COMPILER: v0
#-- increment this if you think cache of .stack-work needs cold rebuild
MANUAL_CACHE_RESET_PRODUCTS: v0
#-- increment this to force-rebuild the cache of dependency packages
MANUAL_CACHE_RESET_TESTDEPS: v0
#-- should never be needed, as stackage snapshots are immutable
# MANUAL_CACHE_RESET_SNAPSHOT: v0
jobs:
build-haskell:
runs-on: ubuntu-latest
strategy:
matrix:
versions:
- { lts: "22.27", ghc: "9.6.5" }
steps:
- name: Cache GHC installation
uses: actions/cache@v4
id: ghcup
env:
MANUAL_RESET: ${{ env.MANUAL_CACHE_RESET_COMPILER }}
with:
path: |
~/.ghcup/bin/*
~/.ghcup/cache/*
~/.ghcup/config.yaml
~/.ghcup/ghc/${{ matrix.versions.ghc }}
key: CI-ghcup-${{ env.MANUAL_RESET }}--${{ matrix.versions.ghc }}
- uses: haskell-actions/setup@v2
if: steps.ghcup.outputs.cache-hit != 'true'
with:
ghc-version: ${{ matrix.versions.ghc }}
enable-stack: true
stack-version: 'latest'
cabal-update: false
- name: Cache Pantry (Stackage package index)
id: pantry
uses: actions/cache@v4
with:
path: ~/.stack/pantry
key: CI-pantry-${{ matrix.versions.lts }}
- name: Recompute Stackage package index
if: steps.pantry.outputs.cache-hit != 'true'
run: stack update # populates ~/.stack/pantry
- name: Cache Haskell dependencies
uses: actions/cache@v4
env:
MANUAL_RESET: ${{ env.MANUAL_CACHE_RESET_TESTDEPS }}
with:
#-- NOTE no, shouldn't cache the entire ~/.stack -- that'd be bad. just these 2:
path: |
~/.stack/stack.sqlite3
~/.stack/snapshots
#-- NOTE the caching key structure:
#-- * fixed ID string -- to indicate scope & purpose, descriptive;
#-- * manual reset -- on top level, stupid simple manual override;
#-- * 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: CI-testdeps-${{ env.MANUAL_RESET }}--${{ matrix.versions.lts }}--${{ hashFiles('stack-${{ matrix.versions.ghc }}.yaml.lock') }}
#-- All this adds fallbacks to UNPACK stale cache copies, prefix-matched:
restore-keys: |
CI-testdeps-${{ env.MANUAL_RESET }}--${{ matrix.versions.lts }}--
CI-testdeps-${{ env.MANUAL_RESET }}--
- name: Clone project
uses: actions/checkout@v2
- name: Cache per-branch Haskell project buildstate
uses: actions/cache@v4
env:
MANUAL_RESET: ${{ env.MANUAL_CACHE_RESET_PRODUCTS }}
with:
#-- I wasn't able to find the non absolute path and I decided to set the full path. This is britle
path: /home/runner/work/gogol/gogol/.stack-work
key: CI-builddir-${{ env.MANUAL_RESET }}--${{ matrix.versions.ghc }}--${{ github.head_ref }}
- name: Install dependencies
run: stack build --system-ghc --stack-yaml stack-${{ matrix.versions.ghc }}.yaml --only-dependencies
- name: Run tests
run: stack test --system-ghc --stack-yaml stack-${{ matrix.versions.ghc }}.yaml
- name: Build
run: stack build --system-ghc --stack-yaml stack-${{ matrix.versions.ghc }}.yaml