hendrikmuhs / ccache-action

github action to speedup building using ccache
MIT License
114 stars 52 forks source link

Cache only if `compile` step succeeds #149

Open shi-scala opened 1 year ago

shi-scala commented 1 year ago

I've noticed an issue, where if the compilation step fails for any reason, the cache is still created. Since created caches are not overwritten, partial builds are written and can not be overwritten.

I can use some combination of append-timestamp and restore-keys but this feels awkward and brittle.

Is there a way to signal ccache-action to only save if an env variable is set or something similar?

hendrikmuhs commented 1 year ago

That's by design: https://github.com/hendrikmuhs/ccache-action/pull/4

The cache doesn't work like a build, a cache is:

  1. restored (from a previous build)
  2. updated during build
  3. written back

If an error occurs in step 2, the cache still contains the cache objects from step 1, the previous, potentially successful build.

shi-scala commented 1 year ago

Is there a way I can signal ccache-action not to cache results in case of failure?