@@ -91,40 +91,48 @@ jobs:
91
91
runs-on : ubuntu-22.04
92
92
cache : |
93
93
~/.stack
94
- .stack-work
95
94
# no artifact for Linux, because we use the static build
96
95
97
96
- name : MacOS
98
97
runs-on : macos-12
99
98
cache : |
100
99
~/.stack
101
- .stack-work
102
100
artifact : postgrest-macos-x64
103
101
104
102
- name : Windows
105
103
runs-on : windows-2022
106
104
cache : |
107
105
~\AppData\Roaming\stack
108
106
~\AppData\Local\Programs\stack
109
- .stack-work
110
107
deps : Add-Content $env:GITHUB_PATH $env:PGBIN
111
108
artifact : postgrest-windows-x64
112
109
113
110
name : Stack - ${{ matrix.name }}
114
111
runs-on : ${{ matrix.runs-on }}
115
112
steps :
116
113
- uses : actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
117
- - name : Restore stack working files cache
114
+ - name : Install dependencies
115
+ if : matrix.deps
116
+ run : ${{ matrix.deps }}
117
+ - name : Restore ~/.stack cache
118
118
uses : actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
119
- id : restore-cache
119
+ id : restore-stack
120
120
with :
121
121
path : ${{ matrix.cache }}
122
- key : stack-${{ runner.os }}-${{ hashFiles('stack.yaml.lock') }}
122
+ key : stack-${{ runner.os }}-deps- ${{ hashFiles('stack.yaml.lock') }}-${{ hashFiles('postgrest.cabal ') }}
123
123
restore-keys : |
124
- stack-${{ runner.os }}-
125
- - name : Install dependencies
126
- if : matrix.deps
127
- run : ${{ matrix.deps }}
124
+ stack-${{ runner.os }}-deps-${{ hashFiles('stack.yaml.lock') }}-
125
+ stack-${{ runner.os }}-deps-
126
+ - name : Restore .stack-work cache
127
+ uses : actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
128
+ id : restore-stack-work
129
+ with :
130
+ path : .stack-work
131
+ key : stack-${{ runner.os }}-work-${{ hashFiles('stack.yaml.lock') }}-${{ hashFiles('postgrest.cabal') }}-${{ hashFiles('main/*.hs', 'src/**/*.hs') }}
132
+ restore-keys : |
133
+ stack-${{ runner.os }}-work-${{ hashFiles('stack.yaml.lock') }}-${{ hashFiles('postgrest.cabal') }}-
134
+ stack-${{ runner.os }}-work-${{ hashFiles('stack.yaml.lock') }}-
135
+ stack-${{ runner.os }}-work-
128
136
- name : Build with Stack
129
137
run : stack build --lock-file error-on-write --local-bin-path result --copy-bins
130
138
- name : Strip Executable
@@ -138,12 +146,18 @@ jobs:
138
146
result/postgrest
139
147
result/postgrest.exe
140
148
if-no-files-found : error
141
- - name : Save stack working files cache
149
+ - name : Save .stack-work cache
150
+ if : startsWith(github.ref, 'refs/heads/')
151
+ uses : actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
152
+ with :
153
+ path : .stack-work
154
+ key : ${{ steps.restore-stack-work.outputs.cache-primary-key }}
155
+ - name : Save ~/.stack cache
142
156
if : startsWith(github.ref, 'refs/heads/')
143
157
uses : actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
144
158
with :
145
159
path : ${{ matrix.cache }}
146
- key : ${{ steps.restore-cache .outputs.cache-primary-key }}
160
+ key : ${{ steps.restore-stack .outputs.cache-primary-key }}
147
161
148
162
149
163
freebsd :
@@ -177,29 +191,44 @@ jobs:
177
191
- name : Fix caching
178
192
run : |
179
193
mkdir ~/.cabal
180
- - name : Restore cache
194
+ - name : Restore .cabal cache
181
195
uses : actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
182
- id : restore-cache
196
+ id : restore-cabal
183
197
with :
184
198
path : |
185
199
~/.cabal/packages
186
200
~/.cabal/store
187
- dist-newstyle
188
- key : cabal-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('postgrest.cabal', 'cabal.project', 'cabal.project.freeze') }}
201
+ key : cabal-${{ runner.os }}-${{ matrix.ghc }}-cabal-${{ hashFiles('cabal.project', 'cabal.project.freeze') }}-${{ hashFiles('postgrest.cabal') }}
189
202
restore-keys : |
190
- cabal-${{ runner.os }}-${{ matrix.ghc }}-
203
+ cabal-${{ runner.os }}-${{ matrix.ghc }}-cabal-${{ hashFiles('cabal.project', 'cabal.project.freeze') }}-
204
+ cabal-${{ runner.os }}-${{ matrix.ghc }}-cabal-
205
+ - name : Restore dist-newstyle cache
206
+ uses : actions/cache/restore@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
207
+ id : restore-dist-newstyle
208
+ with :
209
+ path : dist-newstyle
210
+ key : cabal-${{ runner.os }}-${{ matrix.ghc }}-dist-newstyle-${{ hashFiles('cabal.project', 'cabal.project.freeze') }}-${{ hashFiles('postgrest.cabal') }}-${{ hashFiles('**/*.hs') }}
211
+ restore-keys : |
212
+ cabal-${{ runner.os }}-${{ matrix.ghc }}-dist-newstyle-${{ hashFiles('cabal.project', 'cabal.project.freeze') }}-${{ hashFiles('postgrest.cabal') }}-
213
+ cabal-${{ runner.os }}-${{ matrix.ghc }}-dist-newstyle-${{ hashFiles('cabal.project', 'cabal.project.freeze') }}-
214
+ cabal-${{ runner.os }}-${{ matrix.ghc }}-dist-newstyle-
191
215
- name : Install dependencies
192
216
run : |
193
217
cabal update
194
218
cabal build --only-dependencies --enable-tests --enable-benchmarks
195
219
- name : Build
196
220
run : cabal build --enable-tests --enable-benchmarks all
197
- - name : Save cache
221
+ - name : Save dist-newstyle cache
222
+ if : startsWith(github.ref, 'refs/heads/')
223
+ uses : actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
224
+ with :
225
+ path : dist-newstyle
226
+ key : ${{ steps.restore-dist-newstyle.outputs.cache-primary-key }}
227
+ - name : Save .cabal cache
198
228
if : startsWith(github.ref, 'refs/heads/')
199
229
uses : actions/cache/save@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
200
230
with :
201
231
path : |
202
232
~/.cabal/packages
203
233
~/.cabal/store
204
- dist-newstyle
205
- key : ${{ steps.restore-cache.outputs.cache-primary-key }}
234
+ key : ${{ steps.restore-cabal.outputs.cache-primary-key }}
0 commit comments