# Github cache action

**URL:** <https://discourse.haskell.org/t/github-cache-action/9926>\
**Category:** Learn\
**Created:** [July 10, 2024, 5:32pm UTC](https://discourse.haskell.org/t/github-cache-action/9926 "2024-07-10T17:32:24Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![BebeSparkelSparkel](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@BebeSparkelSparkel](https://discourse.haskell.org/u/BebeSparkelSparkel)\
**Post date:** [August 20, 2024, 11:39am UTC](https://discourse.haskell.org/t/github-cache-action/9926/21 "2024-08-20T11:39:00Z")

</div>

> [@ulidtko](#):
>
> Concoct a universal CI for _any_ Haskell repo? Hell no.

Just for the common cases. This also documents templates that can be modified for the more unique scenarios.

---

<div class="post-metadata">

**Author:** ![mihaimaruseac](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/mihaimaruseac/32/5460_2.png) [@mihaimaruseac](https://discourse.haskell.org/u/mihaimaruseac)\
**Post date:** [August 20, 2024, 1:15pm UTC](https://discourse.haskell.org/t/github-cache-action/9926/22 "2024-08-20T13:15:51Z")

</div>

[hindent](https://github.com/mihaimaruseac/hindent) also uses 4 caches:

- 2 caches for Cabal: [hindent/.github/workflows/presubmit-cabal.yaml at 0d2bd1ffa083bb2315401ac229b5feae38a34daa · mihaimaruseac/hindent · GitHub](https://github.com/mihaimaruseac/hindent/blob/0d2bd1ffa083bb2315401ac229b5feae38a34daa/.github/workflows/presubmit-cabal.yaml#L46-L60)

```haskell
      - name: Cache dist-newstyle
        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
        with:
          path: dist-newstyle
          key: dist-newstyle-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('internal/**','src/ **','app/**','tests/ **','benchmarks/**') }}
          restore-keys: |
            dist-newstyle-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal') }}-
            dist-newstyle-${{ matrix.os }}-${{ matrix.ghc }}-

      - name: Cache ~/.cabal/store
        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
        with:
          path: ${{ steps.setup-haskell.outputs.cabal-store }}
          key: cabal-store-${{ matrix.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal') }}
          restore-keys: cabal-store-${{ matrix.os }}-${{ matrix.ghc }}-

```

- 2 caches for Stack: [hindent/.github/workflows/presubmit-stack.yaml at 0d2bd1ffa083bb2315401ac229b5feae38a34daa · mihaimaruseac/hindent · GitHub](https://github.com/mihaimaruseac/hindent/blob/0d2bd1ffa083bb2315401ac229b5feae38a34daa/.github/workflows/presubmit-stack.yaml#L38-L52)

```haskell
      - name: Cache .stack-work
        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
        with:
          path: .stack-work
          key: stack-work-${{ matrix.os }}-${{ matrix.resolver }}-${{ hashFiles('stack.yaml', '**/*.cabal') }}-${{ hashFiles('internal/**','src/ **','app/**','tests/ **','benchmarks/**') }}
          restore-keys: |
            stack-work-${{ matrix.os }}-${{ matrix.resolver }}-${{ hashFiles('stack.yaml', '**/*.cabal') }}-
            stack-work-${{ matrix.os }}-${{ matrix.resolver }}-

      - name: Cache ~/.stack
        uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2
        with:
          path: ${{ steps.setup-haskell.outputs.stack-root }}
          key: stack-root-${{ matrix.os }}-${{ matrix.resolver }}-${{ hashFiles('stack.yaml', '**/*.cabal') }}
          restore-keys: stack-root-${{ matrix.os }}-${{ matrix.resolver }}-

```

[Previous page](https://discourse.haskell.org/t/github-cache-action/9926.md?page=1)
