j3t / jenkins-pipeline-cache-plugin

A cloud native file cache for Jenkins build pipelines which uses an S3-Bucket as storage provider.
MIT License
15 stars 2 forks source link

feature discussion: hooks / cleanup step before cache saving? #30

Closed rbtcollins closed 1 year ago

rbtcollins commented 1 year ago

Currently I'm passing in a helper closure with a try/finally - not strictly needed since the cache isn't saved on failure, but anyhow - here's the scenario. Consider https://github.com/marketplace/actions/rust-cache - note that it cleans the cache dir of:

Possibly having these layered closures is the right way to do it, but I was pondering whether some hook-style interface might permit simpler code.

j3t commented 1 year ago

I don't really understand what you are trying to achieve. Could you please provide an example and the expected outcome. Do you want to filter the files?

rbtcollins commented 1 year ago

Yes.

In ~/.cargo/bin there are two distinct sets of files. 1) hardlinks provided by rustup proxies: rustc, cargo and the like. These are immutable and should not be cached. 2) binaries installed by cargo install such as cargo-audit. These should be cached, because building takes time and cargo will detect freshness automatically (if we cache all of `~/.cargo/ to get the freshness metadata files).

Right now I mv the files in set (1) out of the way right before the cache is saved, then restore them afterwards. It would be nicer to be able to just not save them in the cache.

j3t commented 1 year ago

Right now I mv the files in set (1) out of the way right before the cache is saved, then restore them afterwards. It would be nicer to be able to just not save them in the cache.

Makes sense. An exclude filter would solve the issue, right?

rbtcollins commented 1 year ago

Yes, An exclude filter would work (as long as its a list of rules, not a single rule); or a closure to evaluate each file, or whatever.

j3t commented 1 year ago

This would be a breaking change but I guess it makes sense. Is #33 working for you?