subosito/flutter-action

Pub cache returns old cache

Opened this issue · 0 comments

When using the default configuration for pub-cache-key: "flutter-pub:os:-:channel:-:version:-:arch:-:hash:" that action returns unexpected old caches.

The setup of the actions/cache@v4 enables this with:

        key: ${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}
        restore-keys: |
          ${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}-${{ hashFiles('**/pubspec.lock') }}
          ${{ steps.flutter-action.outputs.PUB-CACHE-KEY }}

the first restore-key has the same value as the actual key and could therefore be removed. The second value find the lastest created, but considering the pubspec.lock files.

The cache with the most recent creation date would be used.

according to: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key

My suggestion is to remove those restore-keys to make the caching behaviour more predictable.