hashFiles() function should accept multiple patterns
See original GitHub issueDescribe the enhancement
I’m using actions/cache
with the hashFiles()
function as documented. But when multiple match patterns are required for an adequate cache key, it’s gets tedious to write all the functions and I end up with a very long key:
- name: Restore NuGet package cache
uses: actions/cache@v1
with:
path: ${{ github.workspace }}/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('global.json') }}-${{ hashFiles('**/nuget.config') }}-${{ hashFiles('**/*proj') }}-${{ hashFiles('**/*.props') }}-${{ hashFiles('**/*.targets') }}
What I’d like instead is to simplify the key to just:
key: ${{ runner.os }}-nuget-${{ hashFiles('global.json;**/nuget.config;**/*proj;**/*.props;**/*.targets') }}
Notice how I only have to call hashFiles
once and the result is a single hash in the key instead of many hyphenated hashes.
Additional information
Jamie Cansdale from GitHub support looked this up for me and reported:
I’ve managed to turn up some documentation for the hashFiles function here: https://github.com/actions/runner/blob/master/docs/adrs/0279-hashFiles-expression-function.md
Unfortunately it includes the following note:
Question: Do we need to support more than one match patterns? Ex: hashFiles(‘**/package-lock.json’, ‘!toolkit/core/package-lock.json’, ‘!toolkit/io/package-lock.json’) Answer: Only support single match pattern for GA, we can always add later.
I looks like the globber uses newlines as a delimiter 😢 https://github.com/actions/toolkit/blob/master/packages/glob/src/glob.ts#L9
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:9 (1 by maintainers)
Top GitHub Comments
@sagikazarmark
hashFiles
accepts multiple parameters now. I forgot to update the issue.We’re planning to add as separate parameters:
hashFiles('**/package-lock.json', '!toolkit/core/package-lock.json', ...)
. Hopefully will get to this soon