From 066fa8b6aa78ed66c0dd0da59d81ab46815b18eb Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 6 Feb 2024 21:57:52 +0100 Subject: [PATCH] ci: Improve cache keys and their restore prefixes 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. --- .github/actions/setup-nix/action.yaml | 6 ++---- .github/workflows/ci.yaml | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/actions/setup-nix/action.yaml b/.github/actions/setup-nix/action.yaml index c8de447d33..779b324e06 100644 --- a/.github/actions/setup-nix/action.yaml +++ b/.github/actions/setup-nix/action.yaml @@ -20,11 +20,9 @@ runs: - name: Restore and cache Nix store uses: nix-community/cache-nix-action@v4.0.3 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 diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 84ad16b9d3..d2bb20cad4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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