Can't store using hashFiles if files don't exist yet
See original GitHub issueFor example, in a Rust project, the target
directory is almost never committed as it includes build artifacts. I’d like to cache it between builds, but using
name: Cache target dir
uses: actions/cache@v1
with:
path: target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('target') }} # also tried variants of `target/**`...
triggers a failure that prevents the build from continuing:
##[error]The template is not valid. hashFiles('/home/runner/work/.../.../target') failed. Search pattern '/home/runner/work/.../.../target' doesn't match any file under '/home/runner/work/.../...'
which does make sense! After checking out, there is not yet a target
directory. In fact, that’s what I aim to create (maybe) when I restore from the cache. So storing would work with this template, but restoring would not, since the key can’t be computed.
If I supply restore-keys
, though, I still get the same error. It seems to me like something (maybe not in this codebase) is just dying early because the template isn’t fully computable, instead of trying to fall back on the restore-keys
first.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:19 (4 by maintainers)
Top Results From Across the Web
Using Hashing to prevent file duplicates and save storage
This article aims to show a method of preventing duplicate files and saving storage space by using hashing algorithms.
Read more >How to associate a file to an hash code, and use it to find the ...
Locating the file using the hash would involve a simple key lookup in the database. Moving the file would involve updating the database....
Read more >HTTP Spec: PUT without data transfer, since hash of data is ...
Client computes the ETag for the file/resource to upload. Client sends a PUT request to the server (location doesn't matter) with the header...
Read more >Reasons Your Checksum Doesn't Match the Original
Whether you've downloaded a file, or need a helpful link for troubleshooting hashing issues, below we cover a couple of reasons your checksum ......
Read more >An introduction to hashing and checksums in Linux - Red Hat
Always wondered how to make use of a checksum? This introduction shows you what they mean, and how to use the proper tools...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@rye perhaps we could update hashFiles with an additional parameter that you could set that would have it not fail if it didn’t find any files. I suppose the other option is to simply warn rather than fail, however, that would mean in your case that you would perpetually have a warning on your jobs that you could likely never get rid of.
I do agree that the current error form makes things stricter, but I don’t think the strictness is helpful—a
hashFiles
error (due to files not existing) seems to be causing a parsing error, i.e.restore_keys
is not even used at all; the cache restore just completely fails. My use case would be satisfied ifrestore_keys
was used in such cases.Of course, I could leave off the
hashFiles
in my key, but then I would basically have a persistent cache that never got updated if things changed.