Skip to content

Commit

Permalink
Try caching ghcup in CI
Browse files Browse the repository at this point in the history
This might avoid having to really use ghcup to install ghc and cabal.

Change-Id: Id000000006ec5f91636e503bb15f4ebeef74690d

Merge commit
  • Loading branch information
edmundnoble committed Jan 16, 2025
1 parent 464a9d7 commit f87d958
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 14 deletions.
50 changes: 39 additions & 11 deletions .github/workflows/applications.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
MATRIX="$(jq -c '.' <<EOF
{
# The first version in this list is the version to be used for release
"ghc": ["9.8.2", "9.10.1", "9.6.6"],
"ghc": ["9.10.1", "9.6.6"],
"cabal": ["3.12"],
"os": ["ubuntu-22.04"],
"use-freeze-file": ["false"],
Expand All @@ -153,7 +153,7 @@ jobs:
else
MATRIX="$(jq -c '.' <<EOF
{
"ghc": ["9.8.2", "9.10.1", "9.6.6"],
"ghc": ["9.10.1", "9.6.6"],
"cabal": ["3.12"],
"os": ["ubuntu-22.04"],
"use-freeze-file": ["false"],
Expand Down Expand Up @@ -247,9 +247,29 @@ jobs:
# done

# work around for https://github.com/haskell/actions/issues/187
- name: Set permissions for .ghcup
if: startsWith(matrix.os, 'ubuntu-')
run: sudo chown -R $USER /usr/local/.ghcup
- uses: actions/cache/restore@v4
name: Restore ghc & cabal binaries cache
id: ghc-cabal-cache
env:
key: ${{ runner.os }}-ghc-cabal
with:
path: |
/home/runner/.ghcup
key: ${{ env.key }}-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('bin/cabal', 'bin/ghc') }}
restore-keys: ${{ env.key }}-${{ matrix.os }}-${{ matrix.ghc }}-

- uses: actions/cache/restore@v4
name: Restore dist-newstyle cache
id: cabal-dist-cache
with:
path: |
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.*', '*.cabal', 'src/**', 'test/**') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.ghc }}-
- name: Install GHC and Cabal
id: setup
uses: haskell-actions/setup@v2
Expand All @@ -261,8 +281,19 @@ jobs:
echo "setup ghc-version: ${{ steps.setup.outputs.ghc-version }}"
echo "setup cabal-version: ${{ steps.setup.outputs.cabal-version }}"
echo "setup cabal-store: ${{ steps.setup.outputs.cabal-store }}"
which ghc
ghc --version
which cabal
cabal --version
- uses: actions/cache/save@v4
name: Cache ghc & cabal binaries
if: steps.ghc-cabal-cache.outputs.cache-hit != 'true'
with:
path: |
/home/runner/.ghcup
key: ${{ env.key }}-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('bin/cabal', 'bin/ghc') }}

- name: Install non-Haskell dependencies (ubuntu)
if: contains(matrix.os, 'ubuntu')
run: sudo apt-get install -y libgflags-dev liblz4-dev libzstd-dev libsnappy-dev libbz2-dev libmpfr-dev
Expand Down Expand Up @@ -317,15 +348,12 @@ jobs:
# dist cache
# the cache-key forces uploading of cache at least once a day, which ensures that
# upstream dependency changes are captured regularly.
- uses: actions/cache@v4
name: Cache dist-newstyle
- uses: actions/cache/save@v4
name: Save dist-newstyle cache
with:
path: |
dist-newstyle
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.use-freeze-file }}-2-${{ hashFiles('cabal.*', '*.cabal', 'src/**', 'test/**') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.use-freeze-file }}-2-
${{ matrix.os }}-${{ matrix.ghc }}-
key: ${{ steps.cabal-dist-cache.outputs.cache-primary-key }}

# Build
- name: Delete Freeze file if it exists
Expand Down
5 changes: 2 additions & 3 deletions .github/workflows/macos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
key: ${{ runner.os }}-${{ runner.arch }}-ghc-cabal
with:
path: |
/Users/runner/.ghcup
/home/runner/.ghcup
key: ${{ env.key }}-${{ hashFiles('bin/cabal', 'bin/ghc') }}
restore-keys: ${{ env.key }}-

Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
if: steps.ghc-cabal-cache.outputs.cache-hit != 'true'
with:
path: |
/Users/runner/.ghcup
/home/runner/.ghcup
key: ${{ steps.ghc-cabal-cache.outputs.cache-primary-key }}

- name: Install non-Haskell dependencies (macOS)
Expand Down Expand Up @@ -171,4 +171,3 @@ jobs:
exit 1
fi
mv cabal.project.freeze.backup cabal.project.freeze

0 comments on commit f87d958

Please sign in to comment.