CLI to modify files mtime (modification data time) based on the hash of the file content. This make it deterministic regardless of when the file was created or modified.
go install github.com/slsyy/mtimehash/cmd/mtimehash@latest
go test
uses mtimes to determine, if files opened during tests has changed and thus: tests need to be re-run.
Unfortunately in a typical CI workflow modifications times are random as git
does not preserve them. This makes caching
for those tests ineffective, which slows down the test execution
The trick is to set mtime based on the file content hash. This way the mtime is deterministic regardless when the repository was modified/clone, so hit ratio should be much higher.
Pass a list of files to modify via stdin:
find . -type f | mtimehash