action-docker-layer-caching icon indicating copy to clipboard operation
action-docker-layer-caching copied to clipboard

Upgrade actions/cache to v2.

Open ewestern opened this issue 4 years ago • 6 comments

Caching using actions/cache v1.x limits cacheable events to push and pull_request as described here: https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache

Using actions/cache v2.x will allow cacheable workflows on any event that has a GITHUB_REF.

At the moment, I can't have a cacheable workflow started by a release event. Making this change would facilitate this workflow.

ewestern avatar Mar 23 '21 18:03 ewestern

This is a bit confusing; this action doesn't use actions/cache (an action), instead it uses @actions/cache (a package on npm).

The actions/cache@v2 action uses the package @actions/[email protected] internally. That's the latest version, and it's the same version being used by this action.

That means this action should already work fine in workflows triggered by any event with a GITHUB_REF. Do you have a workflow run log* where it failed in such a case?

* preferably with ACTIONS_STEP_DEBUG enabled

rcowsill avatar Mar 25 '21 17:03 rcowsill

Oh interesting. Sorry for the misunderstanding there. I'll try to get the debug output. In the meantime, the behavior I am seeing is that:

  • If the action is triggered by on: push, then caching works fine.
  • If, on the other hand, it is triggered by
on:
  release:
    types: [created]

Then the step fails with:

Run satackey/[email protected]
  with:
    key: feed-cache-{hash}
    restore-keys: feed-cache-
  
    concurrency: 4
    skip-save: false
  env:
     ***
Root cache could not be found. aborting.

ewestern avatar Mar 25 '21 17:03 ewestern

Oh interesting. Sorry for the misunderstanding there. I'll try to get the debug output. In the meantime, the behavior I am seeing is that:

  • If the action is triggered by on: push, then caching works fine.
  • If, on the other hand, it is triggered by
on:
  release:
    types: [created]

Then the step fails with:

Run satackey/[email protected]
  with:
    key: feed-cache-{hash}
    restore-keys: feed-cache-
  
    concurrency: 4
    skip-save: false
  env:
     ***
Root cache could not be found. aborting.

Having the same issue here when using with:

`on:
  release:
    types:
      - released
      - prereleased`

amjanoni avatar Apr 20 '21 03:04 amjanoni

Having the same issue here when using with:

`on:
  release:
    types:
      - released
      - prereleased`

Can you share workflow run logs? As well as the on: release run log it would be good to see the log for the run creating the cache you expected it to use.

For both logs it would help a lot if they had ACTIONS_STEP_DEBUG enabled.

rcowsill avatar Apr 20 '21 15:04 rcowsill

Triggering through tags is also uncached:

on:
  push:
    tags:
      - v*

dzervas avatar Mar 25 '22 00:03 dzervas

Apparently the problem was that on each run I had a different env var. When I reran the job the cache was fetched

dzervas avatar Mar 25 '22 00:03 dzervas