From 39b7d16f15f20c429e264040547755afda7eac98 Mon Sep 17 00:00:00 2001 From: Dominic Clark Date: Tue, 18 Jun 2024 21:56:19 +0100 Subject: [PATCH] Fix caching for macOS CI jobs (#7326) * Add architecture to macOS cache keys * Only save Homebrew cache if lock file has changed --- .github/workflows/build.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b80d5df75..eee7ae803 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -95,19 +95,21 @@ jobs: - name: Clean up Homebrew download cache run: rm -rf ~/Library/Caches/Homebrew/downloads - name: Restore Homebrew download cache + id: cache-homebrew uses: actions/cache/restore@v3 with: key: n/a - only restore from restore-keys restore-keys: | - homebrew- + homebrew-${{ matrix.arch }}- path: ~/Library/Caches/Homebrew/downloads - name: Cache ccache data uses: actions/cache@v3 with: - key: ccache-${{ github.job }}-${{ github.ref }}-${{ github.run_id }} + key: "ccache-${{ github.job }}-${{ matrix.arch }}-${{ github.ref }}\ + -${{ github.run_id }}" restore-keys: | - ccache-${{ github.job }}-${{ github.ref }}- - ccache-${{ github.job }}- + ccache-${{ github.job }}-${{ matrix.arch }}-${{ github.ref }}- + ccache-${{ github.job }}-${{ matrix.arch }}- path: ~/Library/Caches/ccache - name: Install dependencies run: | @@ -154,10 +156,14 @@ jobs: env: CCACHE_MAXSIZE: 500MB - name: Save Homebrew download cache + if: ${{ steps.cache-homebrew.outputs.cache-matched-key != env.key }} uses: actions/cache/save@v3 with: - key: homebrew-${{ hashFiles('Brewfile.lock.json') }} + key: ${{ env.key }} path: ~/Library/Caches/Homebrew/downloads + env: + key: "homebrew-${{ matrix.arch }}\ + -${{ hashFiles('Brewfile.lock.json') }}" mingw: strategy: fail-fast: false