Cache: Documentation on multiple caches in a single script

Created on 1 May 2020  路  4Comments  路  Source: actions/cache

The caching action is amazing -- thank you!

A documentation question/request

I'd like to use 2+ caches in my script. The top-level documentation (README.md) for this repo does not provide an example. I'll learn how to do this via trial-and-error, and would like an example in the documentation.

Use case 1

My JVM-based project provides both Maven and Gradle build scripts. The user decides which they prefer. I'd like caching for both ~/.m2 and ~/.gradle.

Use case 2

I have a local build script for my project, and I provide a https://github.com/batect/batect script for use in CI/CD pipelines (or when a dev wants to locally investigate CI/CD failures). I'd like caching for both the local build system, and for `~/.batect'.

Most helpful comment

For now, you'll need to create two separate cache steps with two different keys and paths. An example of using multiple cache steps is here: https://github.com/actions/cache/blob/master/examples.md#haskell---cabal.

Support for multiple paths in a single cache was added in PR https://github.com/actions/cache/pull/212 and will be included in @v2 of this action. However, it hasn't been published yet as we are still working on a few other features.

All 4 comments

I have a similar situation; my project uses Clojure with the tools.deps toolkit for dependency management. That toolkit is able to retrieve artifacts from Maven repositories and it鈥檚 also able to retrieve libraries as source from remote Git repositories, e.g. those hosted on GitHub. It stores the former in ~/.m2 and the latter in ~/.gitlibs.

My project specifies both types of dependencies, so I鈥檇 like to be able to cache both of those directories.

It鈥檇 be ideal if I could do so by specifying paths instead of path, and just supply both paths to the one action invocation/instance. (This is how my CircleCI jobs work.) But if I have to invoke/instantiate/specify the cache action twice, I can live with that 鈥斅燽ut I have no idea whether it鈥檒l work. I鈥檒l try it out, but my point is: I agree it鈥檇 be great if the docs would address this sort of scenario.

For now, you'll need to create two separate cache steps with two different keys and paths. An example of using multiple cache steps is here: https://github.com/actions/cache/blob/master/examples.md#haskell---cabal.

Support for multiple paths in a single cache was added in PR https://github.com/actions/cache/pull/212 and will be included in @v2 of this action. However, it hasn't been published yet as we are still working on a few other features.

Great, thanks @dhadka!

Closing this issue as v2 has been released

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Lyeeedar picture Lyeeedar  路  5Comments

thisismydesign picture thisismydesign  路  4Comments

aleks-ivanov picture aleks-ivanov  路  5Comments

Cerberus picture Cerberus  路  5Comments

Fatme picture Fatme  路  3Comments