mikehardy/buildcache-action

After using the action, the cache is stil empty.

Closed this issue ยท 4 comments

Hi, thanks for providing such a cool project ๐Ÿ˜„

I tried to set up the action and integrate it into our build. However, I am having some trouble to get it to work, I am not sure if the issue is me (most probably), the action, or buildcache itself.

I made this PR to enable the usage on my project:
https://github.com/continental/ecal/pull/503/files

For CMake I am enabling buildcache with CMake variables, like suggested in the buildcache docs.

I build first the branch, then the PR. I assumed that the branch build would store the Cache. Then the PR build could use.

On my Ubuntu build, it says a cache has been stored, but then none was retrieved in the consecutive build.

On Windows, it seems that even after the build, the cache is empty.

Are there any suggestions for me or other resources? Do additional steps need to be taken to successfully restore the cache? Under what circumstances does it work on Window?

Thanks a lot!

Hi there - unfortunately I have none of the answers to your questions ๐Ÿ˜… - I have never used on windows, and when I hit issues I always just turned on debugging then used upload artifacts github action to upload the log so I could inspect

Hi thanks for you help.
Ok, so problem on windows is, it's not using Ninja as CMake generator.

For ubuntu, I get these logs:

buildcache: saving cache with key "buildcache-Ubuntu20-2022-02-01T17:25:38.033Z"
buildcache: no cache for key buildcache-Ubuntu20-2022-02-01T19:22:11.611Z or buildcache-Ubuntu20 - cold cache or invalid key
buildcache: saving cache with key "buildcache-Ubuntu20-2022-02-01T19:34:38.621Z"

Notice that the times are all different. How does it work? Or I shouldn't give a name for the cache?

    - name: BuildCache
      uses: mikehardy/buildcache-action@v1
      with:
        cache_key: Ubuntu20 

Hmm - I don't think the cache keys being different is bad, rather I think that is actually important otherwise the cache is never updated since they are immutable, and it's saved against three keys at the same time with increasing specificity - in your case as "buildcache", "buildcache-Ubuntu20" then "buildcache-Ubuntu20-"

export function getCacheKeys(): {
base: string
withInput: string
unique: string
} {
const base = 'buildcache'
// TODO - remove `key` here and from action.yaml in v2, deprecated as of v1.1.1
const inputKey = core.getInput('cache_key') ?? core.getInput('key')
let withInput = base
if (inputKey) {
withInput = `${base}-${inputKey}`
}
// Key generation is important. Always specify a unique primary key to github because caches are immutable.
// A unique primary key means a new cache with updated contents will be saved for future runs.
// But specifying a good base restore key means a previous cache will be restored as fallback
// https://github.com/actions/cache/issues/342#issuecomment-673371329
const unique = `${withInput}-${new Date().toISOString()}`
return {
base,
withInput,
unique
}
}

Clearly something isn't working but I don't think it's the cache keys. That said I do not think PR or branch caches are used in main branch caches, however you indicate you are building branch then PR and to my understanding that should cache

ah ok, I see. Then I will try some more. I expected it to work across branches.