Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Add cache action? #216

Open
ulysses4ever opened this issue Mar 16, 2023 · 1 comment
Open

Add cache action? #216

ulysses4ever opened this issue Mar 16, 2023 · 1 comment
Labels
enhancement New feature or request re: cache Concerning caching

Comments

@ulysses4ever
Copy link
Contributor

I'm very illiterate in caching of haskell builds in GHA, so take with a grain of salt. Not small part of it is ugly and bulky incantations people usually use there. E.g cabal's workflow:

      - if: ${{ runner.os != 'Windows' }}
        uses: actions/cache@v3
        with:
          # validate.sh uses a special build dir
          path: |
            ${{ steps.setup-haskell.outputs.cabal-store }}
            dist-*
          key: ${{ runner.os }}-${{ matrix.ghc }}-20220419-${{ github.sha }}
          restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-20220419-

Julia (the language) had very nice cache action that makes the task a one liner and hides complexity. Could we have the same? https://github.com/julia-actions/cache

@andreasabel andreasabel added the re: cache Concerning caching label Mar 16, 2023
@andreasabel
Copy link
Member

andreasabel commented Mar 16, 2023

Indeed bulky, see my recent recipe:

actions/setup/README.md

Lines 154 to 174 in f102749

- name: Restore cached dependencies
uses: actions/cache/restore@v3
id: cache
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-cabal-${{ env.CABAL_VERSION }}-plan-${{ hashFiles('**/plan.json') }}
restore-keys: |
${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-cabal-${{ env.CABAL_VERSION }}-
- name: Install dependencies
run: cabal build all --only-dependencies
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
- name: Save cached dependencies
uses: actions/cache/save@v3
# Caches are immutable, trying to save with the same key would error.
if: ${{ !steps.cache.outputs.cache-hit
|| steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }}
with:
path: ${{ steps.setup.outputs.cabal-store }}
key: ${{ steps.cache.outputs.cache-primary-key }}

There is an old PR #11 which could maybe be revived:

I think a caching option should enable the user to state whether dist-newstyle should be cached or not, as it can be too big (like 0.5G for Agda).

@andreasabel andreasabel added the enhancement New feature or request label Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request re: cache Concerning caching
Projects
None yet
Development

No branches or pull requests

2 participants