Base cache-key on checksum of directory rather than a single file?


#1

We’re working on putting our entire build structure into the Circle 2.0 workflow, which is great. It currently means that a lot of our projects get built more often than they need to (lots of sub-projects across multiple languages and architectures in one repository). We can cache a lot of the dependencies based on e.g. project.clj, Cargo.toml, package.json for these individual projects, but the actual target that’s built could be cached based on the checksum of the directory, and that’d enable us to skip the build step entirely.

Unfortunately, just basing it of of a single (or even a few manually selected) file wouldn’t do the trick.

Is it possible to do e.g. {{ checksum "rust/src/"}}?


#2

I’m assuming that the problem is that the checksum device only takes a file? I’ve not used that before.

If so, you could write your own script that checksums over your Rust source directory, and then writes that to a /tmp/rust-hash.txt. You could then do {{ checksum "/tmp/rust-hash.txt" }} in your cache key.


Can't checksum multiple files with slashes in the file path
#3

That’s a clever idea! Would be nicer if it was provided for me, but I suppose that might do the trick for now


#4

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