help with using actions/cache for caching packages using github actions

Hey,

I am struggling to understand how exactly the github actions/cache works and how to leverage it for package caching after using r-lib/actions/setup-r@v1.

I only need to build on linux, and I am just struggling to figure out how (and when) to use the cache action correctly. The cache action gives me two options, path and key. Path will need to point to the user library that the packages are being installed into, let's assume I set that to ~/my-r-stuff previously. I cannot figure out what the 'key' should be and how it works.

At what point in my workflow do I need to invoke the cache action then to skip installing my packages again - before or after?

I was trying to work through:

Any guidance appreciated!

1 Like

I got one step further, the key is essentially any (dynamic) value and the cache is updated when the key changes (which is why it makes sense to use some form of hash value based on a dependency specification).

One would then have to make sure the cache step runs before the package install step and only run the install step if there was no cache hit...

I see, the trick is to use remotes::install_deps which will not do anything if the packages are restored from cache.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.