drone-cache icon indicating copy to clipboard operation
drone-cache copied to clipboard

Allow excluding files from caching

Open KucharczykL opened this issue 2 years ago • 6 comments

Is your feature request related to a problem? Please describe. I have a folder that I want to cache but not all of its subfolders and files.

Describe the solution you'd like I would like to specify which folders or files not to cache.

Describe alternatives you've considered I can probably manually delete the files in a separate step just before rebuilding the cache.

Additional context GitHub Actions support this using the ! character to indicate excluded files or folders. See https://github.com/actions/cache#v2

KucharczykL avatar Apr 17 '22 13:04 KucharczykL

This may not be too difficult to implement, though I'm not sure how much of an issue this is for others. Is there any specific reason certain files or folders may want to be omitted? Clarifying the justification for why this is a good feature to add to drone-cache would be greatly appreciated!

bdebyl avatar Jul 19 '22 14:07 bdebyl

Generally, the same reason why both blacklists and whitelists exist: sometimes you want everything except for one file, and sometimes you want nothing except for one file. Solving both with only one solution is tedious or even impossible.

More concretely, I have a folder I want to cache but there's another folder inside it that I don't want to cache. The reason for that is that each is built with a different command so caching both at the same time would mean I have to build both if one of them needs rebuilding (kinda invalidating the caching step).

Even more concretely, I rewrote the GitHub Actions template for publishing Dendron, you can see the original here: https://wiki.dendron.so/notes/FnK2ws6w1uaS1YzBUY3BR/#steps---setup-github-actions

There you can see two caching steps: "Restore Node modules cache" and "Restore Next cache".

KucharczykL avatar Jul 19 '22 14:07 KucharczykL

Hmm I see. We've just recently added double-star glob support for mount paths in the settings (e.g. path/**/subpath, path/**, etc.) as part of https://github.com/meltwater/drone-cache/pull/209.

I'll try my hand at implementing this later this afternoon as it shouldn't be too difficult. I may have to add single-star glob matching as well, which should be much more straightforward once #209 is merged. For clarity, this would allow flexible usage of the exclusionary rules. Let me know if this is something you do or do not want.

It may be a bit difficult to add exclusions of specific files due to the simplistic way the mount function works as part of the plugin, but for simple directory exclusions this should be an easy change to make.

Will get back to you and let you know if this will be too challenging to be targeted for the v1.4.0 release of drone-cache :)

bdebyl avatar Jul 19 '22 15:07 bdebyl

Nice, thank you for considering it!

KucharczykL avatar Jul 19 '22 19:07 KucharczykL

No problem @KucharczykL

Seems like this will take a bit more effort than I had time for today. I'll keep you posted but will try to get this done by this week depending on what comes up.

bdebyl avatar Jul 19 '22 20:07 bdebyl

Hi @bdebyl, any luck with this? :slightly_smiling_face:

KucharczykL avatar Oct 05 '22 10:10 KucharczykL