batches: Add caching for file mounts
Created by: Piszmog
Part of #37216 (closed).
A MountsMetadata
is added to the object that is hashed to create the cache key. The metadata is made up of the path
, size
, and modification date of the files that are being mounted.
A followup PR will be opened with src-cli
to point to latest sourcegraph/sourcegraph
when this is merged.
A note on the unit tests, I completely redid the existing unit tests for the cache to cover more cases and be more easily extensible. I wanted to cover all the implementations of Keyer
for this change.
Test plan
Go Tests and manual testing (see examples).
Examples
No File Mount
The use case before file mounts. Ensures that caching still works as expected.
File Mount
A single file is mounted. In this use case, check to see if the second run uses the cache. Then if the file being mounted changes, does src-cli
run with again without using the cache.
The file is "updated", and src-cli
does not reuse the cache.
Directory Mount
A director is mounted. In this use case, check to see if the second run uses the cache. Then if a file in the directory being mounted changes, does src-cli
run with again without using the cache.
A file in the directory is "updated", and src-cli
does not reuse the cache.