Skip to content

Commit f87d958

Browse files
committed
Try caching ghcup in CI
This might avoid having to really use ghcup to install ghc and cabal. Change-Id: Id000000006ec5f91636e503bb15f4ebeef74690d Merge commit
1 parent 464a9d7 commit f87d958

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

.github/workflows/applications.yml

+39-11
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ jobs:
135135
MATRIX="$(jq -c '.' <<EOF
136136
{
137137
# The first version in this list is the version to be used for release
138-
"ghc": ["9.8.2", "9.10.1", "9.6.6"],
138+
"ghc": ["9.10.1", "9.6.6"],
139139
"cabal": ["3.12"],
140140
"os": ["ubuntu-22.04"],
141141
"use-freeze-file": ["false"],
@@ -153,7 +153,7 @@ jobs:
153153
else
154154
MATRIX="$(jq -c '.' <<EOF
155155
{
156-
"ghc": ["9.8.2", "9.10.1", "9.6.6"],
156+
"ghc": ["9.10.1", "9.6.6"],
157157
"cabal": ["3.12"],
158158
"os": ["ubuntu-22.04"],
159159
"use-freeze-file": ["false"],
@@ -247,9 +247,29 @@ jobs:
247247
# done
248248

249249
# work around for https://github.com/haskell/actions/issues/187
250-
- name: Set permissions for .ghcup
251-
if: startsWith(matrix.os, 'ubuntu-')
252-
run: sudo chown -R $USER /usr/local/.ghcup
250+
- uses: actions/cache/restore@v4
251+
name: Restore ghc & cabal binaries cache
252+
id: ghc-cabal-cache
253+
env:
254+
key: ${{ runner.os }}-ghc-cabal
255+
with:
256+
path: |
257+
/home/runner/.ghcup
258+
key: ${{ env.key }}-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('bin/cabal', 'bin/ghc') }}
259+
restore-keys: ${{ env.key }}-${{ matrix.os }}-${{ matrix.ghc }}-
260+
261+
- uses: actions/cache/restore@v4
262+
name: Restore dist-newstyle cache
263+
id: cabal-dist-cache
264+
with:
265+
path: |
266+
~/.cabal/packages
267+
~/.cabal/store
268+
dist-newstyle
269+
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.*', '*.cabal', 'src/**', 'test/**') }}
270+
restore-keys: |
271+
${{ matrix.os }}-${{ matrix.ghc }}-
272+
253273
- name: Install GHC and Cabal
254274
id: setup
255275
uses: haskell-actions/setup@v2
@@ -261,8 +281,19 @@ jobs:
261281
echo "setup ghc-version: ${{ steps.setup.outputs.ghc-version }}"
262282
echo "setup cabal-version: ${{ steps.setup.outputs.cabal-version }}"
263283
echo "setup cabal-store: ${{ steps.setup.outputs.cabal-store }}"
284+
which ghc
264285
ghc --version
286+
which cabal
265287
cabal --version
288+
289+
- uses: actions/cache/save@v4
290+
name: Cache ghc & cabal binaries
291+
if: steps.ghc-cabal-cache.outputs.cache-hit != 'true'
292+
with:
293+
path: |
294+
/home/runner/.ghcup
295+
key: ${{ env.key }}-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('bin/cabal', 'bin/ghc') }}
296+
266297
- name: Install non-Haskell dependencies (ubuntu)
267298
if: contains(matrix.os, 'ubuntu')
268299
run: sudo apt-get install -y libgflags-dev liblz4-dev libzstd-dev libsnappy-dev libbz2-dev libmpfr-dev
@@ -317,15 +348,12 @@ jobs:
317348
# dist cache
318349
# the cache-key forces uploading of cache at least once a day, which ensures that
319350
# upstream dependency changes are captured regularly.
320-
- uses: actions/cache@v4
321-
name: Cache dist-newstyle
351+
- uses: actions/cache/save@v4
352+
name: Save dist-newstyle cache
322353
with:
323354
path: |
324355
dist-newstyle
325-
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.use-freeze-file }}-2-${{ hashFiles('cabal.*', '*.cabal', 'src/**', 'test/**') }}
326-
restore-keys: |
327-
${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.use-freeze-file }}-2-
328-
${{ matrix.os }}-${{ matrix.ghc }}-
356+
key: ${{ steps.cabal-dist-cache.outputs.cache-primary-key }}
329357

330358
# Build
331359
- name: Delete Freeze file if it exists

.github/workflows/macos.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
key: ${{ runner.os }}-${{ runner.arch }}-ghc-cabal
3333
with:
3434
path: |
35-
/Users/runner/.ghcup
35+
/home/runner/.ghcup
3636
key: ${{ env.key }}-${{ hashFiles('bin/cabal', 'bin/ghc') }}
3737
restore-keys: ${{ env.key }}-
3838

@@ -71,7 +71,7 @@ jobs:
7171
if: steps.ghc-cabal-cache.outputs.cache-hit != 'true'
7272
with:
7373
path: |
74-
/Users/runner/.ghcup
74+
/home/runner/.ghcup
7575
key: ${{ steps.ghc-cabal-cache.outputs.cache-primary-key }}
7676

7777
- name: Install non-Haskell dependencies (macOS)
@@ -171,4 +171,3 @@ jobs:
171171
exit 1
172172
fi
173173
mv cabal.project.freeze.backup cabal.project.freeze
174-

0 commit comments

Comments
 (0)