Filtering Files
Mint caches tasks based on the contents of the file system (docs on caching).
However, some tasks may only need to use a subset of the files.
When defining a Mint task, you can add a filter
so that only the specified files will be present on disk.
This will result in more frequent cache hits.
Example
tasks:
- key: write-files
run: |
echo ${{ mint.run.id }} | tee changes-every-time.txt
echo static file contents | tee stays-the-same.txt
- key: hash-files
use: [write-files]
run: sha256sum *.txt
- key: hash-static-files
use: [write-files]
filter:
- stays-the-same.txt
run: sha256sum *.txt
The output of hash-files
will look like this:
09ebb220c8a4997acd2b9f9f99aaf200d9861b689ffcc26a3cd10c15efead761 changes-every-time.txt
672939a0624c8c668ffa85ea007e600e3c4ba503dfcf00ca1b603b7cb5c6c56b stays-the-same.txt
The output of hash-static-files
will look like this:
672939a0624c8c668ffa85ea007e600e3c4ba503dfcf00ca1b603b7cb5c6c56b stays-the-same.txt
And if you run these tasks again, write-files
and hash-files
will always produce a cache miss, whereas hash-static-files
will always produce a cache hit!
Workspace
Mint uses the contents of the entire file system for determining the cache key.
However, the filter
only applies to the workspace directory, which is /var/mint-workspace
.
If any files change outside of the workspace, such as with system dependencies or configuration, it'll always result in a different cache key.