Cache multiple paths and add glob pattern support#212
Cache multiple paths and add glob pattern support#212joshmgross merged 18 commits intoactions:masterfrom
Conversation
remove known failing test Quote tar paths Add salt to test cache Try reading input files from manifest bump salt Run test on macos more testing Run caching tests on 3 platforms Run tests on self-hosted Apparently cant reference hosted runners by name Bump salt wait for some time after save more timing out smarter waiting Cache in tmp dir that won't be deleted Use child_process instead of actions/exec Revert tempDir hack bump salt more logging More console logging Use filepath to with cacheHttpClient Test cache restoration Revert temp dir hack debug logging clean up cache.yml testing Bump salt change debug output build actions
|
Thanks for working on this! We should look at using the |
|
The Also, what should the initial value be? 1.0? |
src/cacheHttpClient.ts
Outdated
| const httpClient = createHttpClient(); | ||
| const resource = `cache?keys=${encodeURIComponent(keys.join(","))}`; | ||
| const version = getCacheVersion(); | ||
| const resource = `cache?version=${version}`; |
There was a problem hiding this comment.
@dhadka I took a stab at using a version to represent a cache. I'm not entirely sure how the endpoints expose this parameter, so I'm happy to revise as needed 😄
There was a problem hiding this comment.
We will still need to provide the keys here. It should be cache?keys=key1,key2,...,keyn&version=....
I also don't think we need to include Key and RestoreKeys in the version. With the version, we only match caches with the exact (key, version) tuple. So having the keys included in the version is redundant.
There was a problem hiding this comment.
Got it - updated to not include the keys in the version and include the keys as url params.
There was a problem hiding this comment.
@dhadka Why do we not need keys here?
I would think you could have an exact match on version but a restore key partial match since version only takes into account the action version and the input paths
|
This is great! Thank you @ethanis! |
|
Can you change to pass the path as Collections? It will be more yaml-like. |
|
@imbsky Lists are currently not supported, see actions/toolkit#184. Ideally, once that is fixed, we would update this to support collections (as well as remain backwards compatible with multiline strings) |
|
I see. Well, I don't think there is a big problem so this looks good. |
joshmgross
left a comment
There was a problem hiding this comment.
Thanks for this!
As far as I can tell there are no breaking changes, but we may need to push this as a v2 update to the action to be safe.
|
@joshmgross is there anything else that needs to be changed in this PR? |
|
this finally makes this actions usable without thousands of unncecessary lines when in a yarn monorepo. |
dhadka
left a comment
There was a problem hiding this comment.
LGTM from the server side.
I'll take a look later today, but should be all good |
|
I would like to have one example added as part of this change that uses multiple paths. @boredland perhaps you have one in mind? |
|
@chrispat I think the lerna example would be helpful: |
|
@boredland do lerna projects have multiple - name: restore lerna
uses: actions/cache@v3
with:
path: |
**/node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} |
|
If I remember correctly, Lerna and yarn workspace have only one lock file at root. |
|
@boredland, @chrispat I added an example for lerna here |
joshmgross
left a comment
There was a problem hiding this comment.
Thanks for this contribution!
The current plan is for this to go in v2
Co-Authored-By: Josh Gross <joshmgross@github.com>
|
Thanks @gcourtemanche! Fixing that here: #242 |
|
Dose is support ignore path somehow ? |
Ignoring paths should be supported. The paths are evaluated by the |
This adds the ability to specify multiple items to cache in a single run (#16, #180). Additionally, the items to cache can be located with glob patterns. Paths/patterns are specified as new-line delimited input to the
pathparameter.Because this adds multiple directories to the tarball that is cached, each path is made relative to the
GITHUB_WORKSPACEenv variable. If paths are outside of this directory, the tarball can contain a backtraced path (e.g.../foo/bar). Because of this the-Pflag is used with tar when unpacking the cache.I have a couple of open questions:
GITHUB_WORKSPACEolder cache entries will not be compatible with these changes. Is there a preferred way to add a salt value to the cache key?Some examples: