Skip to content

Commit

Permalink
ci: Improve cache keys and their restore prefixes
Browse files Browse the repository at this point in the history
The cache key for nix now depends on default.nix and shell.nix in the root folder and all
.patch files in the nix folder. Those may change the output of our nix derivations, so
must be included. At the same time, there is no reason to include the actions/setup-nix
folder. This would only lead to new caches being created every time we update one of the
dependent actions in this file. Finally, we never restore caches with a different id any-
more. There is no point in having the style job fall back to the static cache for example.

The cache keys for cabal can be more explicit: We only have one postgrest.cabal and one
relevant cabal.project file. We were missing the cabal.project.freeze file, though, which
affects the dependencies used, too.
  • Loading branch information
wolfgangwalther committed Feb 9, 2024
1 parent f9ee1f7 commit 066fa8b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions .github/actions/setup-nix/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ runs:
- name: Restore and cache Nix store
uses: nix-community/[email protected]
with:
key: cache-nix-${{ runner.os }}-id-${{ inputs.cache-id }}-${{ hashFiles('nix/**/*.nix', '.github/actions/setup-nix/*') }}
key: cache-nix-${{ runner.os }}-${{ inputs.cache }}-${{ hashFiles('**/*.nix', 'nix/**/*.patch') }}
restore-keys: |
cache-nix-${{ runner.os }}-id-${{ inputs.cache-id }}-
cache-nix-${{ runner.os }}-id-common-
cache-nix-${{ runner.os }}-
cache-nix-${{ runner.os }}-${{ inputs.cache }}-
- uses: cachix/cachix-action@v14
with:
name: postgrest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ jobs:
~/.cabal/packages
~/.cabal/store
dist-newstyle
key: cache-cabal-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('**/*.cabal', '**/cabal.project') }}
key: cache-cabal-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('postgrest.cabal', 'cabal.project', 'cabal.project.freeze') }}
restore-keys: |
cache-cabal-${{ runner.os }}-${{ matrix.ghc }}-
- name: Install dependencies
Expand Down

0 comments on commit 066fa8b

Please sign in to comment.