Update 0279-hashFiles-expression-function.md (#1107)

This commit is contained in:
Josh Soref
2021-05-26 06:04:24 -04:00
committed by GitHub
parent e0643c694c
commit f21e280b5c

View File

@@ -5,7 +5,7 @@
**Status**: Accepted **Status**: Accepted
## Context ## Context
First party action `actions/cache` needs a input which is an explicit `key` used for restoring and saving the cache. For packages caching, the most comment `key` might be the hash result of contents from all `package-lock.json` under `node_modules` folder. First party action `actions/cache` needs a input which is an explicit `key` used for restoring and saving the cache. For packages caching, the most common `key` might be the hash result of contents from all `package-lock.json` under `node_modules` folder.
There are serval different ways to get the hash `key` input for `actions/cache` action. There are serval different ways to get the hash `key` input for `actions/cache` action.
@@ -38,7 +38,7 @@ There are serval different ways to get the hash `key` input for `actions/cache`
`hashFiles()` will only support hashing files under the `$GITHUB_WORKSPACE` since the expression evaluated on the runner, if customer use job container or container action, the runner won't have access to file system inside the container. `hashFiles()` will only support hashing files under the `$GITHUB_WORKSPACE` since the expression evaluated on the runner, if customer use job container or container action, the runner won't have access to file system inside the container.
`hashFiles()` will only take 1 parameters: `hashFiles()` will only take 1 parameters:
- `hashFiles('**/package-lock.json')` // Search files under $GITHUB_WORKSPACE and calculate a hash for them - `hashFiles('**/package-lock.json')` // Search files under `$GITHUB_WORKSPACE` and calculate a hash for them
**Question: Do we need to support more than one match patterns?** **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')` Ex: `hashFiles('**/package-lock.json', '!toolkit/core/package-lock.json', '!toolkit/io/package-lock.json')`
@@ -52,7 +52,7 @@ This will help customer has better experience with the `actions/cache` action's
key: ${{hashFiles('**/package-lock.json')}}-${{github.ref}}-${{runner.os}} key: ${{hashFiles('**/package-lock.json')}}-${{github.ref}}-${{runner.os}}
``` ```
For search pattern, we will use basic globbing (`*` `?` and `[]`) and globstar (`**`). For search pattern, we will use basic globbing (`*`, `?`, and `[]`) and globstar (`**`).
Additional pattern details: Additional pattern details:
- Root relative paths with `github.workspace` (the main repo) - Root relative paths with `github.workspace` (the main repo)
@@ -68,4 +68,4 @@ Hashing logic:
5. Use SHA256 to hash all stored files' hash results to get the final 64 chars hash result. 5. Use SHA256 to hash all stored files' hash results to get the final 64 chars hash result.
**Question: Should we include the folder structure info into the hash?** **Question: Should we include the folder structure info into the hash?**
Answer: No Answer: No