Skip to content

SDK cache hit can restore an incompatible older layout and still download Flutter #400

Description

@dtussupbayev

Hi. I ran into this while moving a workflow from the temporary .fvmrc support commit to v2.

Setup:

- uses: subosito/flutter-action@v2
  with:
    flutter-version-file: .fvmrc
    cache: true

.fvmrc:

{
  "flutter": "3.35.6"
}

v2 currently resolves to 1a449444c387b1966244ae4d4f8c696479add0b2 / v2.23.0 for me.

What I saw:

  • Cache Flutter reported a hit for the default SDK key, like flutter-linux-stable-3.35.6-x64-....
  • Right after restoring that cache, the setup step still downloaded the Flutter archive again (100 1372M).
  • So the step paid both costs: restoring the SDK cache and downloading/extracting the SDK again.

The relevant log shape was:

Cache hit for: flutter-linux-stable-3.35.6-x64-...
Cache restored successfully
...
$GITHUB_ACTION_PATH/setup.sh ...
100 1372M  100 1372M ...

I checked the action code and I think this is caused by the SDK layout change in the cache path:

  • the temporary commit 6622f58c checks/uses CACHE_PATH/bin/flutter
  • current v2 checks/uses CACHE_PATH/flutter/bin/flutter

The default SDK cache key did not change, so v2 can restore a cache that was created by the older layout. Since that is a primary-key cache hit, actions/cache will not replace it with the new layout at the end of the job.

I verified this by changing only the SDK cache key prefix in our workflow. First run was a cold miss and saved a new cache. The rerun restored the new cache and did not download the Flutter archive again.

Rough timings from the same workflow:

old temporary commit, SDK cache hit:   Set up Flutter ~26s
v2, default key, old cache restored:   Set up Flutter ~1m33s
v2, fresh SDK cache key, rerun hit:    Set up Flutter ~32s

Would it make sense to bump/version the default SDK cache key after the layout change, or handle the old layout as a fallback before downloading the SDK again?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions