Compare commits
72 Commits
phantsure/
...
main
Author | SHA1 | Date |
---|---|---|
Bethany | 704facf57e | |
bethanyj28 | 17e2888746 | |
bethanyj28 | 667d8fdfa2 | |
Chad Kimes | f7ebb81a3f | |
Johanan Idicula | 67b839edb6 | |
Jason Orendorff | 57f0e3f198 | |
Vipul | 04f198bf0b | |
Vipul | bd9b49b6c3 | |
Lovepreet Singh | ea0503788c | |
Lovepreet Singh | 6a1a45d49b | |
Vipul | 9c7b3e90bd | |
Michael Vorburger ⛑️ | 8f2671f18e | |
Michael Vorburger ⛑️ | 6f1f1e10f3 | |
Bishal Prasad | 5cb4bb86c0 | |
Sankalp Kotewar | 84995e0d91 | |
Bishal Prasad | bf96a3f9d8 | |
Michael Vorburger ⛑️ | 4b8460cbff | |
Sankalp Kotewar | 57014a2baa | |
Sankalp Kotewar | cb865c1889 | |
Bishal Prasad | 4e7c82221f | |
Sankalp Kotewar | 88522ab9f3 | |
Michael Vorburger | ef11f54eee | |
David Bernard | 4b381be638 | |
Bishal Prasad | 7893481812 | |
Marc Mueller | 940f3d7cf1 | |
Kotokaze | e0d62270e2 | |
Lovepreet Singh | 77eb7eb198 | |
Lovepreet Singh | 69d9d449ac | |
Lovepreet Singh | 8d3a1e02aa | |
Lovepreet Singh | b1db4b4897 | |
Lovepreet Singh | 7d4d6f7ffd | |
Lovepreet Singh | 8f7fa5d715 | |
Lovepreet Singh | 95b455a0fb | |
Deepak Dahiya | 81b7281936 | |
Sampark Sharma | 6998d139dd | |
Sankalp Kotewar | 2b8105bdae | |
Sankalp Kotewar | e08330827d | |
Josh Soref | 22d3da765b | |
Marc Mueller | 627f0f41f6 | |
Lovepreet Singh | 8e3048d0f7 | |
Malte Brunnlieb | 1b004e8a69 | |
Malte Brunnlieb | 75b110bc85 | |
Kevin P. Fleming | 2b5a782c64 | |
Lovepreet Singh | 6c2de3ba98 | |
Philip | b63536828e | |
Philip | cd2aaa9df8 | |
Pallav Dhobley | 9b7ef12f3e | |
Pallav Dhobley | 3c08cab74f | |
Pallav Dhobley | 8315026919 | |
Jongwoo Han | 4791017169 | |
Ruud Kamphuis | 22cbf49050 | |
Tanuj Kumar Mishra | 5868318cdc | |
Tanuj Kumar Mishra | 804b679d21 | |
Kurt McKee | c9869a589f | |
Tanuj Kumar Mishra | 003f5452bf | |
Lovepreet Singh | efacb0248b | |
Lovepreet Singh | 76ee6bdfdc | |
Sankalp Kotewar | 9183691e97 | |
Lovepreet Singh | 094a24099d | |
Vipul | 87396fe6b4 | |
Vipul | e630eda107 | |
Sampark Sharma | 58c146cc91 | |
Sampark Sharma | 6fd2d4538c | |
Sankalp Kotewar | 1f414295fe | |
Tanuj Kumar Mishra | 365406cb70 | |
uhooi | d6217569d5 | |
uhooi | 84e54000da | |
Lovepreet Singh | d0e7eb01c9 | |
Sampark Sharma | 4723a57e26 | |
SIGUI Kessé Emmanuel | d70353d8a4 | |
uhooi | 35f35f44e8 | |
uhooi | ca1c035094 |
|
@ -1,9 +1,3 @@
|
|||
# `dist/index.js` is a special file in Actions.
|
||||
# When you reference an action with `uses:` in a workflow,
|
||||
# `index.js` is the code that will run.
|
||||
# For our project, we generate this file through a build process
|
||||
# from other source files.
|
||||
# We need to make sure the checked-in `index.js` actually matches what we expect it to be.
|
||||
name: Check dist/
|
||||
|
||||
on:
|
||||
|
@ -18,33 +12,6 @@ on:
|
|||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
check-dist:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Setup Node.js 16.x
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 16.x
|
||||
cache: npm
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
- name: Rebuild the dist/ directory
|
||||
run: npm run build
|
||||
|
||||
- name: Compare the expected and actual dist/ directories
|
||||
run: |
|
||||
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
|
||||
echo "Detected uncommitted changes after build. See status below:"
|
||||
git diff
|
||||
exit 1
|
||||
fi
|
||||
id: diff
|
||||
|
||||
# If index.js was different than expected, upload the expected version as an artifact
|
||||
- uses: actions/upload-artifact@v3
|
||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||
with:
|
||||
name: dist
|
||||
path: dist/
|
||||
call-check-dist:
|
||||
name: Check dist/
|
||||
uses: actions/reusable-workflows/.github/workflows/check-dist.yml@main
|
||||
|
|
|
@ -7,18 +7,9 @@ on:
|
|||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
name: Check licenses
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: npm ci
|
||||
- name: Install licensed
|
||||
run: |
|
||||
cd $RUNNER_TEMP
|
||||
curl -Lfs -o licensed.tar.gz https://github.com/github/licensed/releases/download/2.12.2/licensed-2.12.2-linux-x64.tar.gz
|
||||
sudo tar -xzf licensed.tar.gz
|
||||
sudo mv licensed /usr/local/bin/licensed
|
||||
- run: licensed status
|
||||
call-licensed:
|
||||
name: Licensed
|
||||
uses: actions/reusable-workflows/.github/workflows/licensed.yml@main
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
179
README.md
179
README.md
|
@ -1,12 +1,10 @@
|
|||
# cache
|
||||
# Cache action
|
||||
|
||||
This action allows caching dependencies and build outputs to improve workflow execution time.
|
||||
|
||||
In addition to this `cache` action, other two actions are also available
|
||||
|
||||
[Restore action](./restore/README.md)
|
||||
|
||||
[Save action](./save/README.md)
|
||||
>Two other actions are available in addition to the primary `cache` action:
|
||||
>* [Restore action](./restore/README.md)
|
||||
>* [Save action](./save/README.md)
|
||||
|
||||
[![Tests](https://github.com/actions/cache/actions/workflows/workflow.yml/badge.svg)](https://github.com/actions/cache/actions/workflows/workflow.yml)
|
||||
|
||||
|
@ -14,10 +12,11 @@ In addition to this `cache` action, other two actions are also available
|
|||
|
||||
See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows).
|
||||
|
||||
|
||||
## What's New
|
||||
|
||||
### v3
|
||||
* Added support for caching from GHES 3.5.
|
||||
|
||||
* Added support for caching in GHES 3.5+.
|
||||
* Fixed download issue for files > 2GB during restore.
|
||||
* Updated the minimum runner version support from node 12 -> node 16.
|
||||
* Fixed avoiding empty cache save when no files are available for caching.
|
||||
|
@ -26,42 +25,56 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac
|
|||
* Fixed cache not working with github workspace directory or current directory.
|
||||
* Fixed the download stuck problem by introducing a timeout of 1 hour for cache downloads.
|
||||
* Fix zstd not working for windows on gnu tar in issues.
|
||||
* Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes.
|
||||
* Two new actions available for granular control over caches - [restore](restore/action.yml) and [save](save/action.yml)
|
||||
* Add support for cross os caching. For example, a cache saved on windows can be restored on ubuntu and vice versa.
|
||||
* Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 10 minutes.
|
||||
* New actions are available for granular control over caches - [restore](restore/action.yml) and [save](save/action.yml).
|
||||
* Support cross-os caching as an opt-in feature. See [Cross OS caching](./tips-and-workarounds.md#cross-os-cache) for more info.
|
||||
* Added option to fail job on cache miss. See [Exit workflow on cache miss](./restore/README.md#exit-workflow-on-cache-miss) for more info.
|
||||
* Fix zstd not being used after zstd version upgrade to 1.5.4 on hosted runners
|
||||
* Added option to lookup cache without downloading it.
|
||||
* Reduced segment size to 128MB and segment timeout to 10 minutes to fail fast in case the cache download is stuck.
|
||||
|
||||
Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions
|
||||
See the [v2 README.md](https://github.com/actions/cache/blob/v2/README.md) for older updates.
|
||||
|
||||
## Usage
|
||||
|
||||
### Pre-requisites
|
||||
Create a workflow `.yml` file in your repositories `.github/workflows` directory. An [example workflow](#example-workflow) is available below. For more information, reference the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).
|
||||
|
||||
If you are using this inside a container, a POSIX-compliant `tar` needs to be included and accessible in the execution path.
|
||||
Create a workflow `.yml` file in your repository's `.github/workflows` directory. An [example workflow](#example-cache-workflow) is available below. For more information, see the GitHub Help Documentation for [Creating a workflow file](https://help.github.com/en/articles/configuring-a-workflow#creating-a-workflow-file).
|
||||
|
||||
If you are using this inside a container, a POSIX-compliant `tar` needs to be included and accessible from the execution path.
|
||||
|
||||
If you are using a `self-hosted` Windows runner, `GNU tar` and `zstd` are required for [Cross-OS caching](https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cross-os-cache) to work. They are also recommended to be installed in general so the performance is on par with `hosted` Windows runners.
|
||||
|
||||
### Inputs
|
||||
|
||||
* `key` - An explicit key for a cache entry. See [creating a cache key](#creating-a-cache-key).
|
||||
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
||||
* `key` - An explicit key for restoring and saving the cache
|
||||
* `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key.
|
||||
* `enableCrossOsArchive` - An optional boolean when enabled, allows Windows runners to save or restore caches that can be restored or saved respectively on other platforms. Default: `false`
|
||||
* `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false`
|
||||
* `lookup-only` - If true, only checks if cache entry exists and skips download. Does not change save cache behavior. Default: `false`
|
||||
|
||||
#### Environment Variables
|
||||
* `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](https://github.com/actions/cache/blob/main/workarounds.md#cache-segment-restore-timeout)
|
||||
|
||||
* `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `10`) to abort download of the segment if not completed in the defined number of minutes. [Read more](https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout)
|
||||
|
||||
### Outputs
|
||||
|
||||
* `cache-hit` - A boolean value to indicate an exact match was found for the key.
|
||||
|
||||
> Note: `cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`.
|
||||
> **Note** `cache-hit` will only be set to `true` when a cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`.
|
||||
|
||||
See [Skipping steps based on cache-hit](#skipping-steps-based-on-cache-hit) for info on using this output
|
||||
|
||||
### Cache scopes
|
||||
The cache is scoped to the key, [version](#cache-version) and branch. The default branch cache is available to other branches.
|
||||
|
||||
The cache is scoped to the key, [version](#cache-version), and branch. The default branch cache is available to other branches.
|
||||
|
||||
See [Matching a cache key](https://help.github.com/en/actions/configuring-and-managing-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key) for more info.
|
||||
|
||||
### Example workflow
|
||||
### Example cache workflow
|
||||
|
||||
#### Restoring and saving cache using a single action
|
||||
|
||||
```yaml
|
||||
name: Caching Primes
|
||||
|
@ -90,7 +103,49 @@ jobs:
|
|||
run: /primes.sh -d prime-numbers
|
||||
```
|
||||
|
||||
> Note: You must use the `cache` action in your workflow before you need to use the files that might be restored from the cache. If the provided `key` matches an existing cache, a new cache is not created and if the provided `key` doesn't match an existing cache, a new cache is automatically created provided the job completes successfully.
|
||||
The `cache` action provides a `cache-hit` output which is set to `true` when the cache is restored using the primary `key` and `false` when the cache is restored using `restore-keys` or no cache is restored.
|
||||
|
||||
#### Using a combination of restore and save actions
|
||||
|
||||
```yaml
|
||||
name: Caching Primes
|
||||
|
||||
on: push
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Restore cached Primes
|
||||
id: cache-primes-restore
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
key: ${{ runner.os }}-primes
|
||||
.
|
||||
. //intermediate workflow steps
|
||||
.
|
||||
- name: Save Primes
|
||||
id: cache-primes-save
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
key: ${{ steps.cache-primes-restore.outputs.cache-primary-key }}
|
||||
```
|
||||
|
||||
> **Note**
|
||||
> You must use the `cache` or `restore` action in your workflow before you need to use the files that might be restored from the cache. If the provided `key` matches an existing cache, a new cache is not created and if the provided `key` doesn't match an existing cache, a new cache is automatically created provided the job completes successfully.
|
||||
|
||||
## Caching Strategies
|
||||
|
||||
With the introduction of the `restore` and `save` actions, a lot of caching use cases can now be achieved. Please see the [caching strategies](./caching-strategies.md) document for understanding how you can use the actions strategically to achieve the desired goal.
|
||||
|
||||
## Implementation Examples
|
||||
|
||||
|
@ -98,30 +153,31 @@ Every programming language and framework has its own way of caching.
|
|||
|
||||
See [Examples](examples.md) for a list of `actions/cache` implementations for use with:
|
||||
|
||||
- [C# - NuGet](./examples.md#c---nuget)
|
||||
- [Clojure - Lein Deps](./examples.md#clojure---lein-deps)
|
||||
- [D - DUB](./examples.md#d---dub)
|
||||
- [Deno](./examples.md#deno)
|
||||
- [Elixir - Mix](./examples.md#elixir---mix)
|
||||
- [Go - Modules](./examples.md#go---modules)
|
||||
- [Haskell - Cabal](./examples.md#haskell---cabal)
|
||||
- [Haskell - Stack](./examples.md#haskell---stack)
|
||||
- [Java - Gradle](./examples.md#java---gradle)
|
||||
- [Java - Maven](./examples.md#java---maven)
|
||||
- [Node - npm](./examples.md#node---npm)
|
||||
- [Node - Lerna](./examples.md#node---lerna)
|
||||
- [Node - Yarn](./examples.md#node---yarn)
|
||||
- [OCaml/Reason - esy](./examples.md#ocamlreason---esy)
|
||||
- [PHP - Composer](./examples.md#php---composer)
|
||||
- [Python - pip](./examples.md#python---pip)
|
||||
- [Python - pipenv](./examples.md#python---pipenv)
|
||||
- [R - renv](./examples.md#r---renv)
|
||||
- [Ruby - Bundler](./examples.md#ruby---bundler)
|
||||
- [Rust - Cargo](./examples.md#rust---cargo)
|
||||
- [Scala - SBT](./examples.md#scala---sbt)
|
||||
- [Swift, Objective-C - Carthage](./examples.md#swift-objective-c---carthage)
|
||||
- [Swift, Objective-C - CocoaPods](./examples.md#swift-objective-c---cocoapods)
|
||||
- [Swift - Swift Package Manager](./examples.md#swift---swift-package-manager)
|
||||
* [C# - NuGet](./examples.md#c---nuget)
|
||||
* [Clojure - Lein Deps](./examples.md#clojure---lein-deps)
|
||||
* [D - DUB](./examples.md#d---dub)
|
||||
* [Deno](./examples.md#deno)
|
||||
* [Elixir - Mix](./examples.md#elixir---mix)
|
||||
* [Go - Modules](./examples.md#go---modules)
|
||||
* [Haskell - Cabal](./examples.md#haskell---cabal)
|
||||
* [Haskell - Stack](./examples.md#haskell---stack)
|
||||
* [Java - Gradle](./examples.md#java---gradle)
|
||||
* [Java - Maven](./examples.md#java---maven)
|
||||
* [Node - npm](./examples.md#node---npm)
|
||||
* [Node - Lerna](./examples.md#node---lerna)
|
||||
* [Node - Yarn](./examples.md#node---yarn)
|
||||
* [OCaml/Reason - esy](./examples.md#ocamlreason---esy)
|
||||
* [PHP - Composer](./examples.md#php---composer)
|
||||
* [Python - pip](./examples.md#python---pip)
|
||||
* [Python - pipenv](./examples.md#python---pipenv)
|
||||
* [R - renv](./examples.md#r---renv)
|
||||
* [Ruby - Bundler](./examples.md#ruby---bundler)
|
||||
* [Rust - Cargo](./examples.md#rust---cargo)
|
||||
* [Scala - SBT](./examples.md#scala---sbt)
|
||||
* [Swift, Objective-C - Carthage](./examples.md#swift-objective-c---carthage)
|
||||
* [Swift, Objective-C - CocoaPods](./examples.md#swift-objective-c---cocoapods)
|
||||
* [Swift - Swift Package Manager](./examples.md#swift---swift-package-manager)
|
||||
* [Swift - Mint](./examples.md#swift---mint)
|
||||
|
||||
## Creating a cache key
|
||||
|
||||
|
@ -145,7 +201,7 @@ Additionally, you can use arbitrary command output in a cache key, such as a dat
|
|||
- name: Get Date
|
||||
id: get-date
|
||||
run: |
|
||||
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
|
||||
echo "date=$(/bin/date -u "+%Y%m%d")" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
|
||||
- uses: actions/cache@v3
|
||||
|
@ -162,9 +218,10 @@ A repository can have up to 10GB of caches. Once the 10GB limit is reached, olde
|
|||
|
||||
## Skipping steps based on cache-hit
|
||||
|
||||
Using the `cache-hit` output, subsequent steps (such as install or build) can be skipped when a cache hit occurs on the key. It is recommended to install the missing/updated dependencies in case of a partial key match when the key is dependent on the `hash` of the package file.
|
||||
Using the `cache-hit` output, subsequent steps (such as install or build) can be skipped when a cache hit occurs on the key. It is recommended to install missing/updated dependencies in case of a partial key match when the key is dependent on the `hash` of the package file.
|
||||
|
||||
Example:
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
@ -180,13 +237,13 @@ steps:
|
|||
run: /install.sh
|
||||
```
|
||||
|
||||
> Note: The `id` defined in `actions/cache` must match the `id` in the `if` statement (i.e. `steps.[ID].outputs.cache-hit`)
|
||||
|
||||
> **Note** The `id` defined in `actions/cache` must match the `id` in the `if` statement (i.e. `steps.[ID].outputs.cache-hit`)
|
||||
|
||||
## Cache Version
|
||||
Cache version is a hash [generated](https://github.com/actions/toolkit/blob/500d0b42fee2552ae9eeb5933091fe2fbf14e72d/packages/cache/src/internal/cacheHttpClient.ts#L73-L90) for a combination of compression tool used (Gzip, Zstd, etc. based on the runner OS) and the `path` of directories being cached. If two caches have different versions, they are identified as unique caches while matching. This for example, means that a cache created on `windows-latest` runner can't be restored on `ubuntu-latest` as cache `Version`s are different.
|
||||
|
||||
> Pro tip: [List caches](https://docs.github.com/en/rest/actions/cache#list-github-actions-caches-for-a-repository) API can be used to get the version of a cache. This can be helpful to troubleshoot cache miss due to version.
|
||||
Cache version is a hash [generated](https://github.com/actions/toolkit/blob/500d0b42fee2552ae9eeb5933091fe2fbf14e72d/packages/cache/src/internal/cacheHttpClient.ts#L73-L90) for a combination of compression tool used (Gzip, Zstd, etc. based on the runner OS) and the `path` of directories being cached. If two caches have different versions, they are identified as unique caches while matching. This, for example, means that a cache created on a `windows-latest` runner can't be restored on `ubuntu-latest` as cache `Version`s are different.
|
||||
|
||||
> Pro tip: The [list caches](https://docs.github.com/en/rest/actions/cache#list-github-actions-caches-for-a-repository) API can be used to get the version of a cache. This can be helpful to troubleshoot cache miss due to version.
|
||||
|
||||
<details>
|
||||
<summary>Example</summary>
|
||||
|
@ -237,21 +294,27 @@ jobs:
|
|||
if: steps.cache-primes.outputs.cache-hit != 'true'
|
||||
run: ./generate-primes -d prime-numbers
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## Known practices and workarounds
|
||||
Following are some of the known practices/workarounds which community has used to fulfill specific requirements. You may choose to use them if suits your use case. Note these are not necessarily the only or the recommended solution.
|
||||
|
||||
- [Cache segment restore timeout](./tips-and-workarounds.md#cache-segment-restore-timeout)
|
||||
- [Update a cache](./tips-and-workarounds.md#update-a-cache)
|
||||
- [Use cache across feature branches](./tips-and-workarounds.md#use-cache-across-feature-branches)
|
||||
- [Force deletion of caches overriding default cache eviction policy](./tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy)
|
||||
There are a number of community practices/workarounds to fulfill specific requirements. You may choose to use them if they suit your use case. Note these are not necessarily the only solution or even a recommended solution.
|
||||
|
||||
#### Windows environment variables
|
||||
Please note that Windows environment variables (like `%LocalAppData%`) will NOT be expanded by this action. Instead, prefer using `~` in your paths which will expand to HOME directory. For example, instead of `%LocalAppData%`, use `~\AppData\Local`. For a list of supported default environment variables, see [this](https://docs.github.com/en/actions/learn-github-actions/environment-variables) page.
|
||||
* [Cache segment restore timeout](./tips-and-workarounds.md#cache-segment-restore-timeout)
|
||||
* [Update a cache](./tips-and-workarounds.md#update-a-cache)
|
||||
* [Use cache across feature branches](./tips-and-workarounds.md#use-cache-across-feature-branches)
|
||||
* [Cross OS cache](./tips-and-workarounds.md#cross-os-cache)
|
||||
* [Force deletion of caches overriding default cache eviction policy](./tips-and-workarounds.md#force-deletion-of-caches-overriding-default-cache-eviction-policy)
|
||||
|
||||
### Windows environment variables
|
||||
|
||||
Please note that Windows environment variables (like `%LocalAppData%`) will NOT be expanded by this action. Instead, prefer using `~` in your paths which will expand to the HOME directory. For example, instead of `%LocalAppData%`, use `~\AppData\Local`. For a list of supported default environment variables, see the [Learn GitHub Actions: Variables](https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables) page.
|
||||
|
||||
## Contributing
|
||||
We would love for you to contribute to `actions/cache`, pull requests are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
|
||||
|
||||
We would love for you to contribute to `actions/cache`. Pull requests are welcome! Please see the [CONTRIBUTING.md](CONTRIBUTING.md) for more information.
|
||||
|
||||
## License
|
||||
|
||||
The scripts and documentation in this project are released under the [MIT License](LICENSE)
|
||||
|
|
51
RELEASES.md
51
RELEASES.md
|
@ -1,62 +1,113 @@
|
|||
# Releases
|
||||
|
||||
### 3.0.0
|
||||
|
||||
- Updated minimum runner version support from node 12 -> node 16
|
||||
|
||||
### 3.0.1
|
||||
|
||||
- Added support for caching from GHES 3.5.
|
||||
- Fixed download issue for files > 2GB during restore.
|
||||
|
||||
### 3.0.2
|
||||
|
||||
- Added support for dynamic cache size cap on GHES.
|
||||
|
||||
### 3.0.3
|
||||
|
||||
- Fixed avoiding empty cache save when no files are available for caching. ([issue](https://github.com/actions/cache/issues/624))
|
||||
|
||||
### 3.0.4
|
||||
|
||||
- Fixed tar creation error while trying to create tar with path as `~/` home folder on `ubuntu-latest`. ([issue](https://github.com/actions/cache/issues/689))
|
||||
|
||||
### 3.0.5
|
||||
|
||||
- Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit. ([PR](https://github.com/actions/cache/pull/834))
|
||||
|
||||
### 3.0.6
|
||||
|
||||
- Fixed [#809](https://github.com/actions/cache/issues/809) - zstd -d: no such file or directory error
|
||||
- Fixed [#833](https://github.com/actions/cache/issues/833) - cache doesn't work with github workspace directory
|
||||
|
||||
### 3.0.7
|
||||
|
||||
- Fixed [#810](https://github.com/actions/cache/issues/810) - download stuck issue. A new timeout is introduced in the download process to abort the download if it gets stuck and doesn't finish within an hour.
|
||||
|
||||
### 3.0.8
|
||||
|
||||
- Fix zstd not working for windows on gnu tar in issues [#888](https://github.com/actions/cache/issues/888) and [#891](https://github.com/actions/cache/issues/891).
|
||||
- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes.
|
||||
|
||||
### 3.0.9
|
||||
|
||||
- Enhanced the warning message for cache unavailablity in case of GHES.
|
||||
|
||||
### 3.0.10
|
||||
|
||||
- Fix a bug with sorting inputs.
|
||||
- Update definition for restore-keys in README.md
|
||||
|
||||
### 3.0.11
|
||||
|
||||
- Update toolkit version to 3.0.5 to include `@actions/core@^1.10.0`
|
||||
- Update `@actions/cache` to use updated `saveState` and `setOutput` functions from `@actions/core@^1.10.0`
|
||||
|
||||
### 3.1.0-beta.1
|
||||
|
||||
- Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984))
|
||||
|
||||
### 3.1.0-beta.2
|
||||
|
||||
- Added support for fallback to gzip to restore old caches on windows.
|
||||
|
||||
### 3.1.0-beta.3
|
||||
|
||||
- Bug fixes for bsdtar fallback if gnutar not available and gzip fallback if cache saved using old cache action on windows.
|
||||
|
||||
### 3.2.0-beta.1
|
||||
|
||||
- Added two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache.
|
||||
|
||||
### 3.2.0
|
||||
|
||||
- Released the two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache
|
||||
|
||||
### 3.2.1
|
||||
|
||||
- Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984))
|
||||
- Added support for fallback to gzip to restore old caches on windows.
|
||||
- Added logs for cache version in case of a cache miss.
|
||||
|
||||
### 3.2.2
|
||||
|
||||
- Reverted the changes made in 3.2.1 to use gnu tar and zstd by default on windows.
|
||||
|
||||
### 3.2.3
|
||||
|
||||
- Support cross os caching on Windows as an opt-in feature.
|
||||
- Fix issue with symlink restoration on Windows for cross-os caches.
|
||||
|
||||
### 3.2.4
|
||||
|
||||
- Added option to fail job on cache miss.
|
||||
|
||||
### 3.2.5
|
||||
|
||||
- Added fix to prevent from setting MYSYS environment variable globally.
|
||||
|
||||
### 3.2.6
|
||||
|
||||
- Fix zstd not being used after zstd version upgrade to 1.5.4 on hosted runners.
|
||||
|
||||
### 3.3.0
|
||||
|
||||
- Added option to lookup cache without downloading it.
|
||||
|
||||
### 3.3.1
|
||||
|
||||
- Reduced segment size to 128MB and segment timeout to 10 minutes to fail fast in case the cache download is stuck.
|
||||
|
||||
### 3.3.2
|
||||
|
||||
- Fixes bug with Azure SDK causing blob downloads to get stuck.
|
||||
|
|
|
@ -174,6 +174,26 @@ test("getInputAsInt throws if required and value missing", () => {
|
|||
).toThrowError();
|
||||
});
|
||||
|
||||
test("getInputAsBool returns false if input not set", () => {
|
||||
expect(actionUtils.getInputAsBool("undefined")).toBe(false);
|
||||
});
|
||||
|
||||
test("getInputAsBool returns value if input is valid", () => {
|
||||
testUtils.setInput("foo", "true");
|
||||
expect(actionUtils.getInputAsBool("foo")).toBe(true);
|
||||
});
|
||||
|
||||
test("getInputAsBool returns false if input is invalid or NaN", () => {
|
||||
testUtils.setInput("foo", "bar");
|
||||
expect(actionUtils.getInputAsBool("foo")).toBe(false);
|
||||
});
|
||||
|
||||
test("getInputAsBool throws if required and value missing", () => {
|
||||
expect(() =>
|
||||
actionUtils.getInputAsBool("undefined2", { required: true })
|
||||
).toThrowError();
|
||||
});
|
||||
|
||||
test("isCacheFeatureAvailable for ac enabled", () => {
|
||||
jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => true);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as cache from "@actions/cache";
|
|||
import * as core from "@actions/core";
|
||||
|
||||
import { Events, RefKey } from "../src/constants";
|
||||
import run from "../src/restore";
|
||||
import { restoreRun } from "../src/restoreImpl";
|
||||
import * as actionUtils from "../src/utils/actionUtils";
|
||||
import * as testUtils from "../src/utils/testUtils";
|
||||
|
||||
|
@ -27,9 +27,17 @@ beforeAll(() => {
|
|||
return actualUtils.getInputAsArray(name, options);
|
||||
}
|
||||
);
|
||||
|
||||
jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
|
||||
(name, options) => {
|
||||
const actualUtils = jest.requireActual("../src/utils/actionUtils");
|
||||
return actualUtils.getInputAsBool(name, options);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
process.env[Events.Key] = Events.Push;
|
||||
process.env[RefKey] = "refs/heads/feature-branch";
|
||||
|
||||
|
@ -50,7 +58,8 @@ test("restore with no cache found", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key
|
||||
key,
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -62,10 +71,18 @@ test("restore with no cache found", async () => {
|
|||
return Promise.resolve(undefined);
|
||||
});
|
||||
|
||||
await run();
|
||||
await restoreRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(stateMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -84,7 +101,8 @@ test("restore with restore keys and no cache found", async () => {
|
|||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey]
|
||||
restoreKeys: [restoreKey],
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -96,10 +114,18 @@ test("restore with restore keys and no cache found", async () => {
|
|||
return Promise.resolve(undefined);
|
||||
});
|
||||
|
||||
await run();
|
||||
await restoreRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[restoreKey],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(stateMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -116,7 +142,8 @@ test("restore with cache found for key", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key
|
||||
key,
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -129,10 +156,18 @@ test("restore with cache found for key", async () => {
|
|||
return Promise.resolve(key);
|
||||
});
|
||||
|
||||
await run();
|
||||
await restoreRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
|
||||
|
@ -152,7 +187,8 @@ test("restore with cache found for restore key", async () => {
|
|||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey]
|
||||
restoreKeys: [restoreKey],
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -165,10 +201,18 @@ test("restore with cache found for restore key", async () => {
|
|||
return Promise.resolve(restoreKey);
|
||||
});
|
||||
|
||||
await run();
|
||||
await restoreRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[restoreKey],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
|
||||
|
@ -181,3 +225,134 @@ test("restore with cache found for restore key", async () => {
|
|||
);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test("Fail restore when fail on cache miss is enabled and primary + restore keys not found", async () => {
|
||||
const path = "node_modules";
|
||||
const key = "node-test";
|
||||
const restoreKey = "node-";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey],
|
||||
failOnCacheMiss: true
|
||||
});
|
||||
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
const stateMock = jest.spyOn(core, "saveState");
|
||||
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
|
||||
const restoreCacheMock = jest
|
||||
.spyOn(cache, "restoreCache")
|
||||
.mockImplementationOnce(() => {
|
||||
return Promise.resolve(undefined);
|
||||
});
|
||||
|
||||
await restoreRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[restoreKey],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0);
|
||||
|
||||
expect(failedMock).toHaveBeenCalledWith(
|
||||
`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}`
|
||||
);
|
||||
expect(failedMock).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test("restore when fail on cache miss is enabled and primary key doesn't match restored key", async () => {
|
||||
const path = "node_modules";
|
||||
const key = "node-test";
|
||||
const restoreKey = "node-";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey],
|
||||
failOnCacheMiss: true
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
const stateMock = jest.spyOn(core, "saveState");
|
||||
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
|
||||
const restoreCacheMock = jest
|
||||
.spyOn(cache, "restoreCache")
|
||||
.mockImplementationOnce(() => {
|
||||
return Promise.resolve(restoreKey);
|
||||
});
|
||||
|
||||
await restoreRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[restoreKey],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
|
||||
expect(stateMock).toHaveBeenCalledTimes(2);
|
||||
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(
|
||||
`Cache restored from key: ${restoreKey}`
|
||||
);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test("restore with fail on cache miss disabled and no cache found", async () => {
|
||||
const path = "node_modules";
|
||||
const key = "node-test";
|
||||
const restoreKey = "node-";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey],
|
||||
failOnCacheMiss: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
const stateMock = jest.spyOn(core, "saveState");
|
||||
const restoreCacheMock = jest
|
||||
.spyOn(cache, "restoreCache")
|
||||
.mockImplementationOnce(() => {
|
||||
return Promise.resolve(undefined);
|
||||
});
|
||||
|
||||
await restoreRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[restoreKey],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(stateMock).toHaveBeenCalledTimes(1);
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(
|
||||
`Cache not found for input keys: ${key}, ${restoreKey}`
|
||||
);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as cache from "@actions/cache";
|
|||
import * as core from "@actions/core";
|
||||
|
||||
import { Events, Inputs, RefKey } from "../src/constants";
|
||||
import run from "../src/restoreImpl";
|
||||
import { restoreImpl } from "../src/restoreImpl";
|
||||
import { StateProvider } from "../src/stateProvider";
|
||||
import * as actionUtils from "../src/utils/actionUtils";
|
||||
import * as testUtils from "../src/utils/testUtils";
|
||||
|
@ -28,9 +28,17 @@ beforeAll(() => {
|
|||
return actualUtils.getInputAsArray(name, options);
|
||||
}
|
||||
);
|
||||
|
||||
jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
|
||||
(name, options) => {
|
||||
const actualUtils = jest.requireActual("../src/utils/actionUtils");
|
||||
return actualUtils.getInputAsBool(name, options);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
process.env[Events.Key] = Events.Push;
|
||||
process.env[RefKey] = "refs/heads/feature-branch";
|
||||
|
||||
|
@ -52,7 +60,7 @@ test("restore with invalid event outputs warning", async () => {
|
|||
const invalidEvent = "commit_comment";
|
||||
process.env[Events.Key] = invalidEvent;
|
||||
delete process.env[RefKey];
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
expect(logWarningMock).toHaveBeenCalledWith(
|
||||
`Event Validation Error: The event type ${invalidEvent} is not supported because it's not tied to a branch or tag ref.`
|
||||
);
|
||||
|
@ -68,7 +76,7 @@ test("restore without AC available should no-op", async () => {
|
|||
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
|
||||
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
|
||||
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -84,7 +92,7 @@ test("restore on GHES without AC available should no-op", async () => {
|
|||
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
|
||||
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
|
||||
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -97,7 +105,8 @@ test("restore on GHES with AC available ", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key
|
||||
key,
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -110,10 +119,18 @@ test("restore on GHES with AC available ", async () => {
|
|||
return Promise.resolve(key);
|
||||
});
|
||||
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -126,7 +143,7 @@ test("restore on GHES with AC available ", async () => {
|
|||
test("restore with no path should fail", async () => {
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
|
||||
// this input isn't necessary for restore b/c tarball contains entries relative to workspace
|
||||
expect(failedMock).not.toHaveBeenCalledWith(
|
||||
|
@ -138,7 +155,7 @@ test("restore with no key", async () => {
|
|||
testUtils.setInput(Inputs.Path, "node_modules");
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
|
||||
expect(failedMock).toHaveBeenCalledWith(
|
||||
"Input required and not supplied: key"
|
||||
|
@ -152,13 +169,22 @@ test("restore with too many keys should fail", async () => {
|
|||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
restoreKeys
|
||||
restoreKeys,
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, restoreKeys);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
restoreKeys,
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
expect(failedMock).toHaveBeenCalledWith(
|
||||
`Key Validation Error: Keys are limited to a maximum of 10.`
|
||||
);
|
||||
|
@ -169,13 +195,22 @@ test("restore with large key should fail", async () => {
|
|||
const key = "foo".repeat(512); // Over the 512 character limit
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key
|
||||
key,
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
expect(failedMock).toHaveBeenCalledWith(
|
||||
`Key Validation Error: ${key} cannot be larger than 512 characters.`
|
||||
);
|
||||
|
@ -186,13 +221,22 @@ test("restore with invalid key should fail", async () => {
|
|||
const key = "comma,comma";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key
|
||||
key,
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
expect(failedMock).toHaveBeenCalledWith(
|
||||
`Key Validation Error: ${key} cannot contain commas.`
|
||||
);
|
||||
|
@ -203,7 +247,8 @@ test("restore with no cache found", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key
|
||||
key,
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -215,10 +260,18 @@ test("restore with no cache found", async () => {
|
|||
return Promise.resolve(undefined);
|
||||
});
|
||||
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
|
@ -235,7 +288,8 @@ test("restore with restore keys and no cache found", async () => {
|
|||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey]
|
||||
restoreKeys: [restoreKey],
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -247,10 +301,18 @@ test("restore with restore keys and no cache found", async () => {
|
|||
return Promise.resolve(undefined);
|
||||
});
|
||||
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[restoreKey],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
|
@ -265,7 +327,8 @@ test("restore with cache found for key", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key
|
||||
key,
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -278,10 +341,18 @@ test("restore with cache found for key", async () => {
|
|||
return Promise.resolve(key);
|
||||
});
|
||||
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -298,7 +369,8 @@ test("restore with cache found for restore key", async () => {
|
|||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey]
|
||||
restoreKeys: [restoreKey],
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -311,10 +383,18 @@ test("restore with cache found for restore key", async () => {
|
|||
return Promise.resolve(restoreKey);
|
||||
});
|
||||
|
||||
await run(new StateProvider());
|
||||
await restoreImpl(new StateProvider());
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[restoreKey],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -324,3 +404,48 @@ test("restore with cache found for restore key", async () => {
|
|||
);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
||||
test("restore with lookup-only set", async () => {
|
||||
const path = "node_modules";
|
||||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
lookupOnly: true
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
const failedMock = jest.spyOn(core, "setFailed");
|
||||
const stateMock = jest.spyOn(core, "saveState");
|
||||
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
|
||||
const restoreCacheMock = jest
|
||||
.spyOn(cache, "restoreCache")
|
||||
.mockImplementationOnce(() => {
|
||||
return Promise.resolve(key);
|
||||
});
|
||||
|
||||
await restoreImpl(new StateProvider());
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[],
|
||||
{
|
||||
lookupOnly: true
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
|
||||
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
|
||||
expect(stateMock).toHaveBeenCalledTimes(2);
|
||||
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
|
||||
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");
|
||||
|
||||
expect(infoMock).toHaveBeenCalledWith(
|
||||
`Cache found and can be restored from key: ${key}`
|
||||
);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@ import * as cache from "@actions/cache";
|
|||
import * as core from "@actions/core";
|
||||
|
||||
import { Events, RefKey } from "../src/constants";
|
||||
import run from "../src/restoreOnly";
|
||||
import { restoreOnlyRun } from "../src/restoreImpl";
|
||||
import * as actionUtils from "../src/utils/actionUtils";
|
||||
import * as testUtils from "../src/utils/testUtils";
|
||||
|
||||
|
@ -27,9 +27,18 @@ beforeAll(() => {
|
|||
return actualUtils.getInputAsArray(name, options);
|
||||
}
|
||||
);
|
||||
|
||||
jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
|
||||
(name, options) => {
|
||||
return jest
|
||||
.requireActual("../src/utils/actionUtils")
|
||||
.getInputAsBool(name, options);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
process.env[Events.Key] = Events.Push;
|
||||
process.env[RefKey] = "refs/heads/feature-branch";
|
||||
|
||||
|
@ -50,7 +59,8 @@ test("restore with no cache found", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key
|
||||
key,
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -62,10 +72,18 @@ test("restore with no cache found", async () => {
|
|||
return Promise.resolve(undefined);
|
||||
});
|
||||
|
||||
await run();
|
||||
await restoreOnlyRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
|
||||
expect(outputMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -83,7 +101,8 @@ test("restore with restore keys and no cache found", async () => {
|
|||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey]
|
||||
restoreKeys: [restoreKey],
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -95,10 +114,18 @@ test("restore with restore keys and no cache found", async () => {
|
|||
return Promise.resolve(undefined);
|
||||
});
|
||||
|
||||
await run();
|
||||
await restoreOnlyRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[restoreKey],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
|
@ -113,7 +140,8 @@ test("restore with cache found for key", async () => {
|
|||
const key = "node-test";
|
||||
testUtils.setInputs({
|
||||
path: path,
|
||||
key
|
||||
key,
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -125,10 +153,18 @@ test("restore with cache found for key", async () => {
|
|||
return Promise.resolve(key);
|
||||
});
|
||||
|
||||
await run();
|
||||
await restoreOnlyRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-hit", "true");
|
||||
|
@ -147,7 +183,8 @@ test("restore with cache found for restore key", async () => {
|
|||
testUtils.setInputs({
|
||||
path: path,
|
||||
key,
|
||||
restoreKeys: [restoreKey]
|
||||
restoreKeys: [restoreKey],
|
||||
enableCrossOsArchive: false
|
||||
});
|
||||
|
||||
const infoMock = jest.spyOn(core, "info");
|
||||
|
@ -159,10 +196,18 @@ test("restore with cache found for restore key", async () => {
|
|||
return Promise.resolve(restoreKey);
|
||||
});
|
||||
|
||||
await run();
|
||||
await restoreOnlyRun();
|
||||
|
||||
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);
|
||||
expect(restoreCacheMock).toHaveBeenCalledWith(
|
||||
[path],
|
||||
key,
|
||||
[restoreKey],
|
||||
{
|
||||
lookupOnly: false
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key);
|
||||
expect(outputMock).toHaveBeenCalledWith("cache-hit", "false");
|
||||
|
|
|
@ -35,6 +35,14 @@ beforeAll(() => {
|
|||
}
|
||||
);
|
||||
|
||||
jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
|
||||
(name, options) => {
|
||||
return jest
|
||||
.requireActual("../src/utils/actionUtils")
|
||||
.getInputAsBool(name, options);
|
||||
}
|
||||
);
|
||||
|
||||
jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
|
||||
(key, cacheResult) => {
|
||||
return jest
|
||||
|
@ -95,9 +103,14 @@ test("save with valid inputs uploads a cache", async () => {
|
|||
await run();
|
||||
|
||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
|
||||
uploadChunkSize: 4000000
|
||||
});
|
||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||
[inputPath],
|
||||
primaryKey,
|
||||
{
|
||||
uploadChunkSize: 4000000
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
|
|
@ -32,6 +32,14 @@ beforeAll(() => {
|
|||
}
|
||||
);
|
||||
|
||||
jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
|
||||
(name, options) => {
|
||||
return jest
|
||||
.requireActual("../src/utils/actionUtils")
|
||||
.getInputAsBool(name, options);
|
||||
}
|
||||
);
|
||||
|
||||
jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
|
||||
(key, cacheResult) => {
|
||||
return jest
|
||||
|
@ -47,6 +55,7 @@ beforeAll(() => {
|
|||
});
|
||||
|
||||
beforeEach(() => {
|
||||
jest.restoreAllMocks();
|
||||
process.env[Events.Key] = Events.Push;
|
||||
process.env[RefKey] = "refs/heads/feature-branch";
|
||||
|
||||
|
@ -155,9 +164,14 @@ test("save on GHES with AC available", async () => {
|
|||
await run(new StateProvider());
|
||||
|
||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
|
||||
uploadChunkSize: 4000000
|
||||
});
|
||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||
[inputPath],
|
||||
primaryKey,
|
||||
{
|
||||
uploadChunkSize: 4000000
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
@ -251,7 +265,8 @@ test("save with large cache outputs warning", async () => {
|
|||
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||
[inputPath],
|
||||
primaryKey,
|
||||
expect.anything()
|
||||
expect.anything(),
|
||||
false
|
||||
);
|
||||
|
||||
expect(logWarningMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -297,7 +312,8 @@ test("save with reserve cache failure outputs warning", async () => {
|
|||
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||
[inputPath],
|
||||
primaryKey,
|
||||
expect.anything()
|
||||
expect.anything(),
|
||||
false
|
||||
);
|
||||
|
||||
expect(logWarningMock).toHaveBeenCalledWith(
|
||||
|
@ -339,7 +355,8 @@ test("save with server error outputs warning", async () => {
|
|||
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||
[inputPath],
|
||||
primaryKey,
|
||||
expect.anything()
|
||||
expect.anything(),
|
||||
false
|
||||
);
|
||||
|
||||
expect(logWarningMock).toHaveBeenCalledTimes(1);
|
||||
|
@ -378,9 +395,14 @@ test("save with valid inputs uploads a cache", async () => {
|
|||
await run(new StateProvider());
|
||||
|
||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
|
||||
uploadChunkSize: 4000000
|
||||
});
|
||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||
[inputPath],
|
||||
primaryKey,
|
||||
{
|
||||
uploadChunkSize: 4000000
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
|
|
@ -35,6 +35,14 @@ beforeAll(() => {
|
|||
}
|
||||
);
|
||||
|
||||
jest.spyOn(actionUtils, "getInputAsBool").mockImplementation(
|
||||
(name, options) => {
|
||||
return jest
|
||||
.requireActual("../src/utils/actionUtils")
|
||||
.getInputAsBool(name, options);
|
||||
}
|
||||
);
|
||||
|
||||
jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation(
|
||||
(key, cacheResult) => {
|
||||
return jest
|
||||
|
@ -85,9 +93,14 @@ test("save with valid inputs uploads a cache", async () => {
|
|||
await run();
|
||||
|
||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
|
||||
uploadChunkSize: 4000000
|
||||
});
|
||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||
[inputPath],
|
||||
primaryKey,
|
||||
{
|
||||
uploadChunkSize: 4000000
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(failedMock).toHaveBeenCalledTimes(0);
|
||||
});
|
||||
|
@ -112,9 +125,14 @@ test("save failing logs the warning message", async () => {
|
|||
await run();
|
||||
|
||||
expect(saveCacheMock).toHaveBeenCalledTimes(1);
|
||||
expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, {
|
||||
uploadChunkSize: 4000000
|
||||
});
|
||||
expect(saveCacheMock).toHaveBeenCalledWith(
|
||||
[inputPath],
|
||||
primaryKey,
|
||||
{
|
||||
uploadChunkSize: 4000000
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
expect(warningMock).toHaveBeenCalledTimes(1);
|
||||
expect(warningMock).toHaveBeenCalledWith("Cache save failed.");
|
||||
|
|
12
action.yml
12
action.yml
|
@ -14,6 +14,18 @@ inputs:
|
|||
upload-chunk-size:
|
||||
description: 'The chunk size used to split up large files during upload, in bytes'
|
||||
required: false
|
||||
enableCrossOsArchive:
|
||||
description: 'An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms'
|
||||
default: 'false'
|
||||
required: false
|
||||
fail-on-cache-miss:
|
||||
description: 'Fail the workflow if cache entry is not found'
|
||||
default: 'false'
|
||||
required: false
|
||||
lookup-only:
|
||||
description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache'
|
||||
default: 'false'
|
||||
required: false
|
||||
outputs:
|
||||
cache-hit:
|
||||
description: 'A boolean value to indicate an exact match was found for the primary key'
|
||||
|
|
|
@ -0,0 +1,306 @@
|
|||
# Caching Strategies
|
||||
|
||||
This document lists some of the strategies (and example workflows if possible) which can be used to ...
|
||||
|
||||
- use an effective cache key and/or path
|
||||
- solve some common use cases around saving and restoring caches
|
||||
- leverage the step inputs and outputs more effectively
|
||||
|
||||
## Choosing the right key
|
||||
|
||||
```yaml
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
key: ${{ some-metadata }}-cache
|
||||
```
|
||||
|
||||
In your workflows, you can use different strategies to name your key depending on your use case so that the cache is scoped appropriately for your need. For example, you can have cache specific to OS, or based on the lockfile or commit SHA or even workflow run.
|
||||
|
||||
### Updating cache for any change in the dependencies
|
||||
|
||||
One of the most common use case is to use hash for lockfile as key. This way, same cache will be restored for a lockfile until there's a change in dependencies listed in lockfile.
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
key: cache-${{ hashFiles('**/lockfiles') }}
|
||||
```
|
||||
|
||||
### Using restore keys to download the closest matching cache
|
||||
|
||||
If cache is not found matching the primary key, restore keys can be used to download the closest matching cache that was recently created. This ensures that the build/install step will need to additionally fetch just a handful of newer dependencies, and hence saving build time.
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
key: cache-npm-${{ hashFiles('**/lockfiles') }}
|
||||
restore-keys: |
|
||||
cache-npm-
|
||||
```
|
||||
|
||||
The restore keys can be provided as a complete name, or a prefix, read more [here](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key) on how a cache key is matched using restore keys.
|
||||
|
||||
### Separate caches by Operating System
|
||||
|
||||
In case of workflows with matrix running for multiple Operating Systems, the caches can be stored separately for each of them. This can be used in combination with hashfiles in case multiple caches are being generated per OS.
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
key: ${{ runner.os }}-cache
|
||||
```
|
||||
|
||||
### Creating a short lived cache
|
||||
|
||||
Caches scoped to the particular workflow run id or run attempt can be stored and referred by using the run id/attempt. This is an effective way to have a short lived cache.
|
||||
|
||||
```yaml
|
||||
key: cache-${{ github.run_id }}-${{ github.run_attempt }}
|
||||
```
|
||||
|
||||
On similar lines, commit sha can be used to create a very specialized and short lived cache.
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
key: cache-${{ github.sha }}
|
||||
```
|
||||
|
||||
### Using multiple factors while forming a key depening on the need
|
||||
|
||||
Cache key can be formed by combination of more than one metadata, evaluated info.
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
```
|
||||
|
||||
The [GitHub Context](https://docs.github.com/en/actions/learn-github-actions/contexts#github-context) can be used to create keys using the workflows metadata.
|
||||
|
||||
## Restoring Cache
|
||||
|
||||
### Understanding how to choose path
|
||||
|
||||
While setting paths for caching dependencies it is important to give correct path depending on the hosted runner you are using or whether the action is running in a container job. Assigning different `path` for save and restore will result in cache miss.
|
||||
|
||||
Below are GiHub hosted runner specific paths one should take care of when writing a workflow which saves/restores caches across OS.
|
||||
|
||||
#### Ubuntu Paths
|
||||
|
||||
Home directory (`~/`) = `/home/runner`
|
||||
|
||||
`${{ github.workspace }}` = `/home/runner/work/repo/repo`
|
||||
|
||||
`process.env['RUNNER_TEMP']`=`/home/runner/work/_temp`
|
||||
|
||||
`process.cwd()` = `/home/runner/work/repo/repo`
|
||||
|
||||
#### Windows Paths
|
||||
|
||||
Home directory (`~/`) = `C:\Users\runneradmin`
|
||||
|
||||
`${{ github.workspace }}` = `D:\a\repo\repo`
|
||||
|
||||
`process.env['RUNNER_TEMP']` = `D:\a\_temp`
|
||||
|
||||
`process.cwd()` = `D:\a\repo\repo`
|
||||
|
||||
#### macOS Paths
|
||||
|
||||
Home directory (`~/`) = `/Users/runner`
|
||||
|
||||
`${{ github.workspace }}` = `/Users/runner/work/repo/repo`
|
||||
|
||||
`process.env['RUNNER_TEMP']` = `/Users/runner/work/_temp`
|
||||
|
||||
`process.cwd()` = `/Users/runner/work/repo/repo`
|
||||
|
||||
Where:
|
||||
|
||||
`cwd()` = Current working directory where the repository code resides.
|
||||
|
||||
`RUNNER_TEMP` = Environment variable defined for temporary storage location.
|
||||
|
||||
### Make cache read only / Reuse cache from centralized job
|
||||
|
||||
In case you are using a centralized job to create and save your cache that can be reused by other jobs in your repository, this action will take care of your restore only needs and make the cache read-only.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/cache/restore@v3
|
||||
id: cache
|
||||
with:
|
||||
path: path/to/dependencies
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
|
||||
- name: Install Dependencies
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: /install.sh
|
||||
|
||||
- name: Build
|
||||
run: /build.sh
|
||||
|
||||
- name: Publish package to public
|
||||
run: /publish.sh
|
||||
```
|
||||
|
||||
### Failing/Exiting the workflow if cache with exact key is not found
|
||||
|
||||
You can use the output of this action to exit the workflow on cache miss. This way you can restrict your workflow to only initiate the build when `cache-hit` occurs, in other words, cache with exact key is found.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/cache/restore@v3
|
||||
id: cache
|
||||
with:
|
||||
path: path/to/dependencies
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
|
||||
- name: Check cache hit
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: exit 1
|
||||
|
||||
- name: Build
|
||||
run: /build.sh
|
||||
```
|
||||
|
||||
## Saving cache
|
||||
|
||||
### Reusing primary key from restore cache as input to save action
|
||||
|
||||
If you want to avoid re-computing the cache key again in `save` action, the outputs from `restore` action can be used as input to the `save` action.
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache/restore@v3
|
||||
id: restore-cache
|
||||
with:
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
.
|
||||
.
|
||||
.
|
||||
- uses: actions/cache/save@v3
|
||||
with:
|
||||
path: |
|
||||
path/to/dependencies
|
||||
some/other/dependencies
|
||||
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
|
||||
```
|
||||
|
||||
### Re-evaluate cache key while saving cache
|
||||
|
||||
On the other hand, the key can also be explicitly re-computed while executing the save action. This helps in cases where the lockfiles are generated during the build.
|
||||
|
||||
Let's say we have a restore step that computes key at runtime
|
||||
|
||||
```yaml
|
||||
uses: actions/cache/restore@v3
|
||||
id: restore-cache
|
||||
with:
|
||||
key: cache-${{ hashFiles('**/lockfiles') }}
|
||||
```
|
||||
|
||||
Case 1: Where an user would want to reuse the key as it is
|
||||
|
||||
```yaml
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
|
||||
```
|
||||
|
||||
Case 2: Where the user would want to re-evaluate the key
|
||||
|
||||
```yaml
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
key: npm-cache-${{hashfiles(package-lock.json)}}
|
||||
```
|
||||
|
||||
### Saving cache even if the build fails
|
||||
|
||||
There can be cases where a cache should be saved even if the build job fails. For example, a job can fail due to flaky tests but the caches can still be re-used. You can use `actions/cache/save` action to save the cache by using `if: always()` condition.
|
||||
|
||||
Similarly, `actions/cache/save` action can be conditionally used based on the output of the previous steps. This way you get more control on when to save the cache.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
.
|
||||
. // restore if need be
|
||||
.
|
||||
- name: Build
|
||||
run: /build.sh
|
||||
- uses: actions/cache/save@v3
|
||||
if: always() // or any other condition to invoke the save action
|
||||
with:
|
||||
path: path/to/dependencies
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
```
|
||||
|
||||
### Saving cache once and reusing in multiple workflows
|
||||
|
||||
In case of multi-module projects, where the built artifact of one project needs to be reused in subsequent child modules, the need of rebuilding the parent module again and again with every build can be eliminated. The `actions/cache` or `actions/cache/save` action can be used to build and save the parent module artifact once, and restored multiple times while building the child modules.
|
||||
|
||||
#### Step 1 - Build the parent module and save it
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build
|
||||
run: ./build-parent-module.sh
|
||||
|
||||
- uses: actions/cache/save@v3
|
||||
id: cache
|
||||
with:
|
||||
path: path/to/dependencies
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
```
|
||||
|
||||
#### Step 2 - Restore the built artifact from cache using the same key and path
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- uses: actions/cache/restore@v3
|
||||
id: cache
|
||||
with:
|
||||
path: path/to/dependencies
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
|
||||
- name: Install Dependencies
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: ./install.sh
|
||||
|
||||
- name: Build
|
||||
run: ./build-child-module.sh
|
||||
|
||||
- name: Publish package to public
|
||||
run: ./publish.sh
|
||||
```
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
65
examples.md
65
examples.md
|
@ -38,6 +38,8 @@
|
|||
- [Swift, Objective-C - Carthage](#swift-objective-c---carthage)
|
||||
- [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods)
|
||||
- [Swift - Swift Package Manager](#swift---swift-package-manager)
|
||||
- [Swift - Mint](#swift---mint)
|
||||
- [* - Bazel](#---bazel)
|
||||
|
||||
## C# - NuGet
|
||||
|
||||
|
@ -67,7 +69,7 @@ With `actions/cache@v3` you can now exclude unwanted packages with [exclude patt
|
|||
```
|
||||
|
||||
Or you could move the cache folder like below.
|
||||
>Note: This workflow does not work for projects that require files to be placed in user profile package folder
|
||||
> **Note** This workflow does not work for projects that require files to be placed in user profile package folder
|
||||
|
||||
```yaml
|
||||
env:
|
||||
|
@ -279,7 +281,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
|
|||
|
||||
## Java - Gradle
|
||||
|
||||
>Note: Ensure no Gradle daemons are running anymore when your workflow completes. Creating the cache package might fail due to locks being held by Gradle. Refer to the [Gradle Daemon documentation](https://docs.gradle.org/current/userguide/gradle_daemon.html) on how to disable or stop the Gradle Daemons.
|
||||
> **Note** Ensure no Gradle daemons are running anymore when your workflow completes. Creating the cache package might fail due to locks being held by Gradle. Refer to the [Gradle Daemon documentation](https://docs.gradle.org/current/userguide/gradle_daemon.html) on how to disable or stop the Gradle Daemons.
|
||||
|
||||
```yaml
|
||||
- uses: actions/cache@v3
|
||||
|
@ -311,7 +313,7 @@ For npm, cache files are stored in `~/.npm` on Posix, or `~\AppData\npm-cache` o
|
|||
If using `npm config` to retrieve the cache directory, ensure you run [actions/setup-node](https://github.com/actions/setup-node) first to ensure your `npm` version is correct.
|
||||
After [deprecation](https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/) of save-state and set-output commands, the correct way to set output is using `${GITHUB_OUTPUT}`. For linux, we can use `${GITHUB_OUTPUT}` whereas for windows we need to use `${env:GITHUB_OUTPUT}` due to two different default shells in these two different OS ie `bash` and `pwsh` respectively.
|
||||
|
||||
>Note: It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci`
|
||||
> **Note** It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci`
|
||||
|
||||
### **Get npm cache directory using same shell**
|
||||
### Bash shell
|
||||
|
@ -357,7 +359,7 @@ The yarn cache directory will depend on your operating system and version of `ya
|
|||
```yaml
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/cache@v3
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
|
@ -375,7 +377,7 @@ The yarn 2 cache directory will depend on your config. See https://yarnpkg.com/c
|
|||
```yaml
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
|
||||
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
|
||||
|
||||
- uses: actions/cache@v3
|
||||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
|
||||
|
@ -420,7 +422,7 @@ Esy allows you to export built dependencies and import pre-built dependencies.
|
|||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
|
@ -507,12 +509,12 @@ jobs:
|
|||
|
||||
### Using pip to get cache location
|
||||
|
||||
> Note: This requires pip 20.1+
|
||||
> **Note** This requires pip 20.1+
|
||||
```yaml
|
||||
- name: Get pip cache dir
|
||||
id: pip-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: pip cache
|
||||
uses: actions/cache@v3
|
||||
|
@ -641,3 +643,50 @@ whenever possible:
|
|||
restore-keys: |
|
||||
${{ runner.os }}-spm-
|
||||
```
|
||||
|
||||
## Swift - Mint
|
||||
|
||||
```yaml
|
||||
env:
|
||||
MINT_PATH: .mint/lib
|
||||
MINT_LINK_PATH: .mint/bin
|
||||
steps:
|
||||
- uses: actions/cache@v3
|
||||
with:
|
||||
path: .mint
|
||||
key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-mint-
|
||||
```
|
||||
|
||||
## * - Bazel
|
||||
|
||||
[`bazelisk`](https://github.com/bazelbuild/bazelisk) does not have be to separately downloaded and installed because it's already included in GitHub's `ubuntu-latest` and `macos-latest` base images.
|
||||
|
||||
### Linux
|
||||
|
||||
```yaml
|
||||
- name: Cache Bazel
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cache/bazel
|
||||
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-bazel-
|
||||
- run: bazelisk test //...
|
||||
```
|
||||
|
||||
### macOS
|
||||
|
||||
```yaml
|
||||
- name: Cache Bazel
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
/private/var/tmp/_bazel_runner/
|
||||
key: ${{ runner.os }}-bazel-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-bazel-
|
||||
- run: bazelisk test //...
|
||||
```
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
{
|
||||
"name": "cache",
|
||||
"version": "3.2.1",
|
||||
"version": "3.3.2",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "cache",
|
||||
"version": "3.2.1",
|
||||
"version": "3.3.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^3.1.0",
|
||||
"@actions/cache": "^3.2.2",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/io": "^1.1.2"
|
||||
|
@ -36,18 +36,18 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@actions/cache": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0.tgz",
|
||||
"integrity": "sha512-wKGJkpK3uFTgwy+KA0fxz0H3/ZPymdi0IlyhMmyoMeWd+CIv8xVPWdGlrPDDdN9bFgve2yvEPZVaKRb43Uwtyg==",
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.2.2.tgz",
|
||||
"integrity": "sha512-6D0Jq5JrLZRQ3VApeQwQkkV20ZZXjXsHNYXd9VjNUdi9E0h93wESpxfMJ2JWLCUCgHNLcfY0v3GjNM+2FdRMlg==",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@actions/glob": "^0.1.0",
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@actions/http-client": "^2.1.1",
|
||||
"@actions/io": "^1.0.1",
|
||||
"@azure/abort-controller": "^1.1.0",
|
||||
"@azure/ms-rest-js": "^2.6.0",
|
||||
"@azure/storage-blob": "^12.8.0",
|
||||
"@azure/storage-blob": "^12.13.0",
|
||||
"semver": "^6.1.0",
|
||||
"uuid": "^3.3.3"
|
||||
}
|
||||
|
@ -87,9 +87,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@actions/http-client": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.1.tgz",
|
||||
"integrity": "sha512-qhrkRMB40bbbLo7gF+0vu+X+UawOvQQqNAA/5Unx774RS8poaOhThDOG6BGmxvAnxhQnDp2BG/ZUm65xZILTpw==",
|
||||
"dependencies": {
|
||||
"tunnel": "^0.0.6"
|
||||
}
|
||||
|
@ -127,14 +127,6 @@
|
|||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
},
|
||||
"node_modules/@azure/core-asynciterator-polyfill": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-asynciterator-polyfill/-/core-asynciterator-polyfill-1.0.2.tgz",
|
||||
"integrity": "sha512-3rkP4LnnlWawl0LZptJOdXNrT/fHp2eQMadoasa6afspXdpGrtPZuAQc2PD0cpgyuoXtUWyC3tv7xfntjGS5Dw==",
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/core-auth": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.3.2.tgz",
|
||||
|
@ -153,28 +145,27 @@
|
|||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
},
|
||||
"node_modules/@azure/core-http": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.2.4.tgz",
|
||||
"integrity": "sha512-QmmJmexXKtPyc3/rsZR/YTLDvMatzbzAypJmLzvlfxgz/SkgnqV/D4f6F2LsK6tBj1qhyp8BoXiOebiej0zz3A==",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-3.0.0.tgz",
|
||||
"integrity": "sha512-BxI2SlGFPPz6J1XyZNIVUf0QZLBKFX+ViFjKOkzqD18J1zOINIQ8JSBKKr+i+v8+MB6LacL6Nn/sP/TE13+s2Q==",
|
||||
"dependencies": {
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"@azure/core-asynciterator-polyfill": "^1.0.0",
|
||||
"@azure/core-auth": "^1.3.0",
|
||||
"@azure/core-tracing": "1.0.0-preview.13",
|
||||
"@azure/core-util": "^1.1.1",
|
||||
"@azure/logger": "^1.0.0",
|
||||
"@types/node-fetch": "^2.5.0",
|
||||
"@types/tunnel": "^0.0.3",
|
||||
"form-data": "^4.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"process": "^0.11.10",
|
||||
"tough-cookie": "^4.0.0",
|
||||
"tslib": "^2.2.0",
|
||||
"tunnel": "^0.0.6",
|
||||
"uuid": "^8.3.0",
|
||||
"xml2js": "^0.4.19"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/core-http/node_modules/form-data": {
|
||||
|
@ -190,23 +181,10 @@
|
|||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/core-http/node_modules/tough-cookie": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz",
|
||||
"integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==",
|
||||
"dependencies": {
|
||||
"psl": "^1.1.33",
|
||||
"punycode": "^2.1.1",
|
||||
"universalify": "^0.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/core-http/node_modules/tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
},
|
||||
"node_modules/@azure/core-http/node_modules/uuid": {
|
||||
"version": "8.3.2",
|
||||
|
@ -217,40 +195,38 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@azure/core-lro": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.2.4.tgz",
|
||||
"integrity": "sha512-e1I2v2CZM0mQo8+RSix0x091Av493e4bnT22ds2fcQGslTHzM2oTbswkB65nP4iEpCxBrFxOSDPKExmTmjCVtQ==",
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.5.1.tgz",
|
||||
"integrity": "sha512-JHQy/bA3NOz2WuzOi5zEk6n/TJdAropupxUT521JIJvW7EXV2YN2SFYZrf/2RHeD28QAClGdynYadZsbmP+nyQ==",
|
||||
"dependencies": {
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"@azure/core-tracing": "1.0.0-preview.13",
|
||||
"@azure/logger": "^1.0.0",
|
||||
"tslib": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/core-lro/node_modules/tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
},
|
||||
"node_modules/@azure/core-paging": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.2.1.tgz",
|
||||
"integrity": "sha512-UtH5iMlYsvg+nQYIl4UHlvvSrsBjOlRF4fs0j7mxd3rWdAStrKYrh2durOpHs5C9yZbVhsVDaisoyaf/lL1EVA==",
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.5.0.tgz",
|
||||
"integrity": "sha512-zqWdVIt+2Z+3wqxEOGzR5hXFZ8MGKK52x4vFLw8n58pR6ZfKRx3EXYTxTaYxYHc/PexPUTyimcTWFJbji9Z6Iw==",
|
||||
"dependencies": {
|
||||
"@azure/core-asynciterator-polyfill": "^1.0.0",
|
||||
"tslib": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/core-paging/node_modules/tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
},
|
||||
"node_modules/@azure/core-tracing": {
|
||||
"version": "1.0.0-preview.13",
|
||||
|
@ -265,25 +241,42 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@azure/core-tracing/node_modules/tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
},
|
||||
"node_modules/@azure/core-util": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.2.0.tgz",
|
||||
"integrity": "sha512-ffGIw+Qs8bNKNLxz5UPkz4/VBM/EZY07mPve1ZYFqYUdPwFqRj0RPk0U7LZMOfT7GCck9YjuT1Rfp1PApNl1ng==",
|
||||
"dependencies": {
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"tslib": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/core-util/node_modules/tslib": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
},
|
||||
"node_modules/@azure/logger": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.3.tgz",
|
||||
"integrity": "sha512-aK4s3Xxjrx3daZr3VylxejK3vG5ExXck5WOHDJ8in/k9AqlfIyFMMT1uG7u8mNjX+QRILTIn0/Xgschfh/dQ9g==",
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.4.tgz",
|
||||
"integrity": "sha512-ustrPY8MryhloQj7OWGe+HrYx+aoiOxzbXTtgblbV3xwCqpzUK36phH3XNHQKj3EPonyFUuDTfR3qFhTEAuZEg==",
|
||||
"dependencies": {
|
||||
"tslib": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/logger/node_modules/tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
},
|
||||
"node_modules/@azure/ms-rest-js": {
|
||||
"version": "2.6.1",
|
||||
|
@ -310,12 +303,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@azure/storage-blob": {
|
||||
"version": "12.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.9.0.tgz",
|
||||
"integrity": "sha512-ank38FdCLfJ+EoeMzCz3hkYJuZAd63ARvDKkxZYRDb+beBYf+/+gx8jNTqkq/hfyUl4dJQ/a7tECU0Y0F98CHg==",
|
||||
"version": "12.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.13.0.tgz",
|
||||
"integrity": "sha512-t3Q2lvBMJucgTjQcP5+hvEJMAsJSk0qmAnjDLie2td017IiduZbbC9BOcFfmwzR6y6cJdZOuewLCNFmEx9IrXA==",
|
||||
"dependencies": {
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"@azure/core-http": "^2.0.0",
|
||||
"@azure/core-http": "^3.0.0",
|
||||
"@azure/core-lro": "^2.2.0",
|
||||
"@azure/core-paging": "^1.1.1",
|
||||
"@azure/core-tracing": "1.0.0-preview.13",
|
||||
|
@ -324,13 +317,13 @@
|
|||
"tslib": "^2.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.0.0"
|
||||
"node": ">=14.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@azure/storage-blob/node_modules/tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
},
|
||||
"node_modules/@babel/code-frame": {
|
||||
"version": "7.16.7",
|
||||
|
@ -2649,9 +2642,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@opentelemetry/api": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.4.tgz",
|
||||
"integrity": "sha512-BuJuXRSJNQ3QoKA6GWWDyuLpOUck+9hAXNMCnrloc1aWVoy6Xq6t9PUV08aBZ4Lutqq2LEHM486bpZqoViScog==",
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.4.0.tgz",
|
||||
"integrity": "sha512-IgMK9i3sFGNUqPMbjABm0G26g0QCKCUBfglhQ7rQq6WcxbKfEHRcmwsoER4hZcuYqJgkYn2OeuoJIv7Jsftp7g==",
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
|
@ -2792,9 +2785,9 @@
|
|||
"integrity": "sha512-jh6m0QUhIRcZpNv7Z/rpN+ZWXOicUUQbSoWks7Htkbb9IjFQj4kzcX/xFCkjstCj5flMsN8FiSvt+q+Tcs4Llg=="
|
||||
},
|
||||
"node_modules/@types/node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==",
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz",
|
||||
"integrity": "sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==",
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"form-data": "^3.0.0"
|
||||
|
@ -8146,9 +8139,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/json5": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
|
||||
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
||||
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"json5": "lib/cli.js"
|
||||
|
@ -8811,7 +8804,7 @@
|
|||
"node_modules/process": {
|
||||
"version": "0.11.10",
|
||||
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
|
||||
"integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=",
|
||||
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
|
||||
"engines": {
|
||||
"node": ">= 0.6.0"
|
||||
}
|
||||
|
@ -9406,9 +9399,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/tsconfig-paths/node_modules/json5": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
|
||||
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
|
||||
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"minimist": "^1.2.0"
|
||||
|
@ -9521,14 +9514,6 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
|
||||
"engines": {
|
||||
"node": ">= 4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
@ -9722,18 +9707,18 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@actions/cache": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0.tgz",
|
||||
"integrity": "sha512-wKGJkpK3uFTgwy+KA0fxz0H3/ZPymdi0IlyhMmyoMeWd+CIv8xVPWdGlrPDDdN9bFgve2yvEPZVaKRb43Uwtyg==",
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.2.2.tgz",
|
||||
"integrity": "sha512-6D0Jq5JrLZRQ3VApeQwQkkV20ZZXjXsHNYXd9VjNUdi9E0h93wESpxfMJ2JWLCUCgHNLcfY0v3GjNM+2FdRMlg==",
|
||||
"requires": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.0.1",
|
||||
"@actions/glob": "^0.1.0",
|
||||
"@actions/http-client": "^2.0.1",
|
||||
"@actions/http-client": "^2.1.1",
|
||||
"@actions/io": "^1.0.1",
|
||||
"@azure/abort-controller": "^1.1.0",
|
||||
"@azure/ms-rest-js": "^2.6.0",
|
||||
"@azure/storage-blob": "^12.8.0",
|
||||
"@azure/storage-blob": "^12.13.0",
|
||||
"semver": "^6.1.0",
|
||||
"uuid": "^3.3.3"
|
||||
}
|
||||
|
@ -9772,9 +9757,9 @@
|
|||
}
|
||||
},
|
||||
"@actions/http-client": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
|
||||
"integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.1.1.tgz",
|
||||
"integrity": "sha512-qhrkRMB40bbbLo7gF+0vu+X+UawOvQQqNAA/5Unx774RS8poaOhThDOG6BGmxvAnxhQnDp2BG/ZUm65xZILTpw==",
|
||||
"requires": {
|
||||
"tunnel": "^0.0.6"
|
||||
}
|
||||
|
@ -9808,11 +9793,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"@azure/core-asynciterator-polyfill": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-asynciterator-polyfill/-/core-asynciterator-polyfill-1.0.2.tgz",
|
||||
"integrity": "sha512-3rkP4LnnlWawl0LZptJOdXNrT/fHp2eQMadoasa6afspXdpGrtPZuAQc2PD0cpgyuoXtUWyC3tv7xfntjGS5Dw=="
|
||||
},
|
||||
"@azure/core-auth": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-auth/-/core-auth-1.3.2.tgz",
|
||||
|
@ -9830,21 +9810,20 @@
|
|||
}
|
||||
},
|
||||
"@azure/core-http": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-2.2.4.tgz",
|
||||
"integrity": "sha512-QmmJmexXKtPyc3/rsZR/YTLDvMatzbzAypJmLzvlfxgz/SkgnqV/D4f6F2LsK6tBj1qhyp8BoXiOebiej0zz3A==",
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-http/-/core-http-3.0.0.tgz",
|
||||
"integrity": "sha512-BxI2SlGFPPz6J1XyZNIVUf0QZLBKFX+ViFjKOkzqD18J1zOINIQ8JSBKKr+i+v8+MB6LacL6Nn/sP/TE13+s2Q==",
|
||||
"requires": {
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"@azure/core-asynciterator-polyfill": "^1.0.0",
|
||||
"@azure/core-auth": "^1.3.0",
|
||||
"@azure/core-tracing": "1.0.0-preview.13",
|
||||
"@azure/core-util": "^1.1.1",
|
||||
"@azure/logger": "^1.0.0",
|
||||
"@types/node-fetch": "^2.5.0",
|
||||
"@types/tunnel": "^0.0.3",
|
||||
"form-data": "^4.0.0",
|
||||
"node-fetch": "^2.6.7",
|
||||
"process": "^0.11.10",
|
||||
"tough-cookie": "^4.0.0",
|
||||
"tslib": "^2.2.0",
|
||||
"tunnel": "^0.0.6",
|
||||
"uuid": "^8.3.0",
|
||||
|
@ -9861,20 +9840,10 @@
|
|||
"mime-types": "^2.1.12"
|
||||
}
|
||||
},
|
||||
"tough-cookie": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.0.0.tgz",
|
||||
"integrity": "sha512-tHdtEpQCMrc1YLrMaqXXcj6AxhYi/xgit6mZu1+EDWUn+qhUf8wMQoFIy9NXuq23zAwtcB0t/MjACGR18pcRbg==",
|
||||
"requires": {
|
||||
"psl": "^1.1.33",
|
||||
"punycode": "^2.1.1",
|
||||
"universalify": "^0.1.2"
|
||||
}
|
||||
},
|
||||
"tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "8.3.2",
|
||||
|
@ -9884,36 +9853,34 @@
|
|||
}
|
||||
},
|
||||
"@azure/core-lro": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.2.4.tgz",
|
||||
"integrity": "sha512-e1I2v2CZM0mQo8+RSix0x091Av493e4bnT22ds2fcQGslTHzM2oTbswkB65nP4iEpCxBrFxOSDPKExmTmjCVtQ==",
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-lro/-/core-lro-2.5.1.tgz",
|
||||
"integrity": "sha512-JHQy/bA3NOz2WuzOi5zEk6n/TJdAropupxUT521JIJvW7EXV2YN2SFYZrf/2RHeD28QAClGdynYadZsbmP+nyQ==",
|
||||
"requires": {
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"@azure/core-tracing": "1.0.0-preview.13",
|
||||
"@azure/logger": "^1.0.0",
|
||||
"tslib": "^2.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@azure/core-paging": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.2.1.tgz",
|
||||
"integrity": "sha512-UtH5iMlYsvg+nQYIl4UHlvvSrsBjOlRF4fs0j7mxd3rWdAStrKYrh2durOpHs5C9yZbVhsVDaisoyaf/lL1EVA==",
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-paging/-/core-paging-1.5.0.tgz",
|
||||
"integrity": "sha512-zqWdVIt+2Z+3wqxEOGzR5hXFZ8MGKK52x4vFLw8n58pR6ZfKRx3EXYTxTaYxYHc/PexPUTyimcTWFJbji9Z6Iw==",
|
||||
"requires": {
|
||||
"@azure/core-asynciterator-polyfill": "^1.0.0",
|
||||
"tslib": "^2.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -9927,24 +9894,40 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@azure/core-util": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/core-util/-/core-util-1.2.0.tgz",
|
||||
"integrity": "sha512-ffGIw+Qs8bNKNLxz5UPkz4/VBM/EZY07mPve1ZYFqYUdPwFqRj0RPk0U7LZMOfT7GCck9YjuT1Rfp1PApNl1ng==",
|
||||
"requires": {
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"tslib": "^2.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"@azure/logger": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.3.tgz",
|
||||
"integrity": "sha512-aK4s3Xxjrx3daZr3VylxejK3vG5ExXck5WOHDJ8in/k9AqlfIyFMMT1uG7u8mNjX+QRILTIn0/Xgschfh/dQ9g==",
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@azure/logger/-/logger-1.0.4.tgz",
|
||||
"integrity": "sha512-ustrPY8MryhloQj7OWGe+HrYx+aoiOxzbXTtgblbV3xwCqpzUK36phH3XNHQKj3EPonyFUuDTfR3qFhTEAuZEg==",
|
||||
"requires": {
|
||||
"tslib": "^2.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -9972,12 +9955,12 @@
|
|||
}
|
||||
},
|
||||
"@azure/storage-blob": {
|
||||
"version": "12.9.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.9.0.tgz",
|
||||
"integrity": "sha512-ank38FdCLfJ+EoeMzCz3hkYJuZAd63ARvDKkxZYRDb+beBYf+/+gx8jNTqkq/hfyUl4dJQ/a7tECU0Y0F98CHg==",
|
||||
"version": "12.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@azure/storage-blob/-/storage-blob-12.13.0.tgz",
|
||||
"integrity": "sha512-t3Q2lvBMJucgTjQcP5+hvEJMAsJSk0qmAnjDLie2td017IiduZbbC9BOcFfmwzR6y6cJdZOuewLCNFmEx9IrXA==",
|
||||
"requires": {
|
||||
"@azure/abort-controller": "^1.0.0",
|
||||
"@azure/core-http": "^2.0.0",
|
||||
"@azure/core-http": "^3.0.0",
|
||||
"@azure/core-lro": "^2.2.0",
|
||||
"@azure/core-paging": "^1.1.1",
|
||||
"@azure/core-tracing": "1.0.0-preview.13",
|
||||
|
@ -9987,9 +9970,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"tslib": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.3.1.tgz",
|
||||
"integrity": "sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw=="
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz",
|
||||
"integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -11837,9 +11820,9 @@
|
|||
}
|
||||
},
|
||||
"@opentelemetry/api": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.0.4.tgz",
|
||||
"integrity": "sha512-BuJuXRSJNQ3QoKA6GWWDyuLpOUck+9hAXNMCnrloc1aWVoy6Xq6t9PUV08aBZ4Lutqq2LEHM486bpZqoViScog=="
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.4.0.tgz",
|
||||
"integrity": "sha512-IgMK9i3sFGNUqPMbjABm0G26g0QCKCUBfglhQ7rQq6WcxbKfEHRcmwsoER4hZcuYqJgkYn2OeuoJIv7Jsftp7g=="
|
||||
},
|
||||
"@sinclair/typebox": {
|
||||
"version": "0.24.51",
|
||||
|
@ -11976,9 +11959,9 @@
|
|||
"integrity": "sha512-jh6m0QUhIRcZpNv7Z/rpN+ZWXOicUUQbSoWks7Htkbb9IjFQj4kzcX/xFCkjstCj5flMsN8FiSvt+q+Tcs4Llg=="
|
||||
},
|
||||
"@types/node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==",
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.2.tgz",
|
||||
"integrity": "sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==",
|
||||
"requires": {
|
||||
"@types/node": "*",
|
||||
"form-data": "^3.0.0"
|
||||
|
@ -16062,9 +16045,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"json5": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz",
|
||||
"integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==",
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
|
||||
"integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
|
||||
"dev": true
|
||||
},
|
||||
"kleur": {
|
||||
|
@ -16554,7 +16537,7 @@
|
|||
"process": {
|
||||
"version": "0.11.10",
|
||||
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
|
||||
"integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI="
|
||||
"integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A=="
|
||||
},
|
||||
"prompts": {
|
||||
"version": "2.4.2",
|
||||
|
@ -16967,9 +16950,9 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"json5": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
|
||||
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
|
||||
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"minimist": "^1.2.0"
|
||||
|
@ -17050,11 +17033,6 @@
|
|||
"which-boxed-primitive": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"universalify": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
|
||||
},
|
||||
"uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "cache",
|
||||
"version": "3.2.1",
|
||||
"version": "3.3.2",
|
||||
"private": true,
|
||||
"description": "Cache dependencies and build outputs",
|
||||
"main": "dist/restore/index.js",
|
||||
|
@ -23,7 +23,7 @@
|
|||
"author": "GitHub",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/cache": "^3.1.0",
|
||||
"@actions/cache": "^3.2.2",
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/exec": "^1.1.1",
|
||||
"@actions/io": "^1.1.2"
|
||||
|
|
|
@ -1,24 +1,29 @@
|
|||
# Restore action
|
||||
|
||||
The restore action, as the name suggest, restores a cache. It acts similar to the`cache` action except that it doesn't have a post step to save the cache. This action can provide you a granular control to only restore a cache without having to necessarily save it. It accepts the same set of inputs as the `cache` action.
|
||||
The restore action restores a cache. It works similarly to the `cache` action except that it doesn't have a post step to save the cache. This action provides granular ability to restore a cache without having to save it. It accepts the same set of inputs as the `cache` action.
|
||||
|
||||
## Inputs
|
||||
## Documentation
|
||||
|
||||
* `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
||||
* `key` - String used while saving cache for restoring the cache
|
||||
### Inputs
|
||||
|
||||
* `key` - An explicit key for a cache entry. See [creating a cache key](../README.md#creating-a-cache-key).
|
||||
* `path` - A list of files, directories, and wildcard patterns to restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
||||
* `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key.
|
||||
* `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false`
|
||||
* `lookup-only` - If true, only checks if cache entry exists and skips download. Default: `false`
|
||||
|
||||
## Outputs
|
||||
### Outputs
|
||||
|
||||
* `cache-hit` - A boolean value to indicate an exact match was found for the key.
|
||||
* `cache-primary-key` - Cache primary key passed in the input to use in subsequent steps of the workflow.
|
||||
* `cache-matched-key` - Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys.
|
||||
* `cache-matched-key` - Key of the cache that was restored, it could either be the primary key on cache-hit or a partial/complete match of one of the restore keys.
|
||||
|
||||
> **Note**
|
||||
`cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`.
|
||||
|
||||
### Environment Variables
|
||||
* `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](https://github.com/actions/cache/blob/main/workarounds.md#cache-segment-restore-timeout)
|
||||
|
||||
* `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `10`) to abort download of the segment if not completed in the defined number of minutes. [Read more](https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout)
|
||||
|
||||
## Use cases
|
||||
|
||||
|
@ -26,7 +31,7 @@ As this is a newly introduced action to give users more control in their workflo
|
|||
|
||||
### Only restore cache
|
||||
|
||||
In case you are using another workflow to create and save your cache that can be reused by other jobs in your repository, this action will take care of your restore only needs.
|
||||
If you are using separate jobs to create and save your cache(s) to be reused by other jobs in a repository, this action will take care of your cache restoring needs.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
|
@ -49,14 +54,14 @@ steps:
|
|||
run: /publish.sh
|
||||
```
|
||||
|
||||
Once the cache is restored, this action won't run any post step to do post-processing like `actions/cache` and the rest of the workflow will run as usual.
|
||||
Once the cache is restored, unlike `actions/cache`, this action won't run a post step to do post-processing, and the rest of the workflow will run as usual.
|
||||
|
||||
### Save intermediate private build artifacts
|
||||
|
||||
In case of multi-module projects, where the built artifact of one project needs to be reused in subsequent child modules, the need of rebuilding the parent module again and again with every build can be eliminated. The `actions/cache` or `actions/cache/save` action can be used to build and save the parent module artifact once, and restored multiple times while building the child modules.
|
||||
|
||||
In case of multi-module projects, where the built artifact of one project needs to be reused in subsequent child modules, the need to rebuild the parent module again and again with every build can be eliminated. The `actions/cache` or `actions/cache/save` action can be used to build and save the parent module artifact once, and it can be restored multiple times while building the child modules.
|
||||
|
||||
#### Step 1 - Build the parent module and save it
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
@ -72,6 +77,7 @@ steps:
|
|||
```
|
||||
|
||||
#### Step 2 - Restore the built artifact from cache using the same key and path
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
@ -95,7 +101,9 @@ steps:
|
|||
|
||||
### Exit workflow on cache miss
|
||||
|
||||
You can use the output of this action to exit the workflow on cache miss. This way you can restrict your workflow to only initiate the build when `cache-hit` occurs, in other words, cache with exact key is found.
|
||||
You can use `fail-on-cache-miss: true` to exit a workflow on a cache miss. This way you can restrict your workflow to only build when there is a `cache-hit`.
|
||||
|
||||
To fail if there is no cache hit for the primary key, leave `restore-keys` empty!
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
|
@ -106,10 +114,7 @@ steps:
|
|||
with:
|
||||
path: path/to/dependencies
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
|
||||
|
||||
- name: Check cache hit
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: exit 1
|
||||
fail-on-cache-miss: true
|
||||
|
||||
- name: Build
|
||||
run: /build.sh
|
||||
|
@ -117,15 +122,14 @@ steps:
|
|||
|
||||
## Tips
|
||||
|
||||
### Reusing primary key and restored key in the save action
|
||||
|
||||
#### Reusing primary key and restored key in the save action
|
||||
Usually you may want to use the same `key` with both `actions/cache/restore` and `actions/cache/save` actions. To achieve this, use `outputs` from the `restore` action to reuse the same primary key (or the key of the cache that was restored).
|
||||
|
||||
Usually you may want to use same `key` in both `actions/cache/restore` and `actions/cache/save` action. To achieve this, use `outputs` from the restore action to reuse the same primary key (or the key of the cache that was restored).
|
||||
|
||||
#### Using restore action outputs to make save action behave just like the cache action
|
||||
### Using restore action outputs to make save action behave just like the cache action
|
||||
|
||||
The outputs `cache-primary-key` and `cache-matched-key` can be used to check if the restored cache is same as the given primary key. Alternatively, the `cache-hit` output can also be used to check if the restored was a complete match or a partially restored cache.
|
||||
|
||||
#### Ensuring proper restores and save happen across the actions
|
||||
### Ensuring proper restores and save happen across the actions
|
||||
|
||||
It is very important to use the same `key` and `path` that were used by either `actions/cache` or `actions/cache/save` while saving the cache. Learn more about cache key [naming](https://github.com/actions/cache#creating-a-cache-key) and [versioning](https://github.com/actions/cache#cache-version) here.
|
||||
|
|
|
@ -11,6 +11,18 @@ inputs:
|
|||
restore-keys:
|
||||
description: 'An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.'
|
||||
required: false
|
||||
enableCrossOsArchive:
|
||||
description: 'An optional boolean when enabled, allows windows runners to restore caches that were saved on other platforms'
|
||||
default: 'false'
|
||||
required: false
|
||||
fail-on-cache-miss:
|
||||
description: 'Fail the workflow if cache entry is not found'
|
||||
default: 'false'
|
||||
required: false
|
||||
lookup-only:
|
||||
description: 'Check if a cache entry exists for the given input(s) (key, restore-keys) without downloading the cache'
|
||||
default: 'false'
|
||||
required: false
|
||||
outputs:
|
||||
cache-hit:
|
||||
description: 'A boolean value to indicate an exact match was found for the primary key'
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
# Save action
|
||||
|
||||
The save action, as the name suggest, saves a cache. It acts similar to the `cache` action except that it doesn't necessarily first do a restore. This action can provide you a granular control to only save a cache without having to necessarily restore it, or to do a restore anywhere in the workflow job and not only in post phase.
|
||||
The save action saves a cache. It works similarly to the `cache` action except that it doesn't first do a restore. This action provides granular ability to save a cache without having to restore it, or to do a save at any stage of the workflow job -- not only in post phase.
|
||||
|
||||
## Inputs
|
||||
## Documentation
|
||||
|
||||
* `key` - 'An explicit key for saving the cache'
|
||||
* `path` - 'A list of files, directories, and wildcard patterns to cache'
|
||||
* `upload-chunk-size` - 'The chunk size used to split up large files during upload, in bytes'
|
||||
### Inputs
|
||||
|
||||
## Outputs
|
||||
* `key` - An explicit key for a cache entry. See [creating a cache key](../README.md#creating-a-cache-key).
|
||||
* `path` - A list of files, directories, and wildcard patterns to cache. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns.
|
||||
* `upload-chunk-size` - The chunk size used to split up large files during upload, in bytes
|
||||
|
||||
### Outputs
|
||||
|
||||
This action has no outputs.
|
||||
|
||||
|
@ -17,17 +19,16 @@ This action has no outputs.
|
|||
|
||||
### Only save cache
|
||||
|
||||
In case you are using separate jobs for generating common artifacts and sharing them across different jobs, this action will help you with your save only needs.
|
||||
If you are using separate jobs for generating common artifacts and sharing them across jobs, this action will take care of your cache saving needs.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Install Dependencies
|
||||
if: steps.cache.outputs.cache-hit != 'true'
|
||||
run: /install.sh
|
||||
|
||||
- name: Build common artifacts
|
||||
- name: Build artifacts
|
||||
run: /build.sh
|
||||
|
||||
- uses: actions/cache/save@v3
|
||||
|
@ -39,9 +40,11 @@ steps:
|
|||
|
||||
### Re-evaluate cache key while saving
|
||||
|
||||
With save action, the key can now be re-evaluated while executing the action. This helps in cases where the lockfiles are generated during the build.
|
||||
With this save action, the key can now be re-evaluated while executing the action. This helps in cases where lockfiles are generated during the build.
|
||||
|
||||
Let's say we have a restore step that computes key at runtime
|
||||
Let's say we have a restore step that computes a key at runtime.
|
||||
|
||||
#### Restore a cache
|
||||
|
||||
```yaml
|
||||
uses: actions/cache/restore@v3
|
||||
|
@ -50,14 +53,15 @@ with:
|
|||
key: cache-${{ hashFiles('**/lockfiles') }}
|
||||
```
|
||||
|
||||
Case 1: Where an user would want to reuse the key as it is
|
||||
#### Case 1 - Where a user would want to reuse the key as it is
|
||||
```yaml
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
key: ${{ steps.restore-cache.outputs.key }}
|
||||
key: ${{ steps.restore-cache.outputs.cache-primary-key }}
|
||||
```
|
||||
|
||||
Case 2: Where the user would want to re-evaluate the key
|
||||
#### Case 2 - Where the user would want to re-evaluate the key
|
||||
|
||||
```yaml
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
|
@ -66,7 +70,7 @@ with:
|
|||
|
||||
### Always save cache
|
||||
|
||||
There are instances where some flaky test cases would fail the entire workflow and users would get frustrated because the builds would run for hours and the cache couldn't get saved as the workflow failed in between. For such use-cases, users would now have the ability to use `actions/cache/save` action to save the cache by using `if: always()` condition. This way the cache will always be saved if generated, or a warning will be thrown that nothing is found on the cache path. Users can also use the `if` condition to only execute the `actions/cache/save` action depending on the output of the previous steps. This way they get more control on when to save the cache.
|
||||
There are instances where some flaky test cases would fail the entire workflow and users would get frustrated because the builds would run for hours and the cache couldn't be saved as the workflow failed in between. For such use-cases, users now have the ability to use the `actions/cache/save` action to save the cache by using an `if: always()` condition. This way the cache will always be saved if generated, or a warning will be generated that nothing is found on the cache path. Users can also use the `if` condition to only execute the `actions/cache/save` action depending on the output of previous steps. This way they get more control of when to save the cache.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
|
|
|
@ -11,6 +11,10 @@ inputs:
|
|||
upload-chunk-size:
|
||||
description: 'The chunk size used to split up large files during upload, in bytes'
|
||||
required: false
|
||||
enableCrossOsArchive:
|
||||
description: 'An optional boolean when enabled, allows windows runners to save caches that can be restored on other platforms'
|
||||
default: 'false'
|
||||
required: false
|
||||
runs:
|
||||
using: 'node16'
|
||||
main: '../dist/save-only/index.js'
|
||||
|
|
|
@ -2,7 +2,10 @@ export enum Inputs {
|
|||
Key = "key", // Input for cache, restore, save action
|
||||
Path = "path", // Input for cache, restore, save action
|
||||
RestoreKeys = "restore-keys", // Input for cache, restore action
|
||||
UploadChunkSize = "upload-chunk-size" // Input for cache, save action
|
||||
UploadChunkSize = "upload-chunk-size", // Input for cache, save action
|
||||
EnableCrossOsArchive = "enableCrossOsArchive", // Input for cache, restore, save action
|
||||
FailOnCacheMiss = "fail-on-cache-miss", // Input for cache, restore action
|
||||
LookupOnly = "lookup-only" // Input for cache, restore action
|
||||
}
|
||||
|
||||
export enum Outputs {
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
import restoreImpl from "./restoreImpl";
|
||||
import { StateProvider } from "./stateProvider";
|
||||
import { restoreRun } from "./restoreImpl";
|
||||
|
||||
async function run(): Promise<void> {
|
||||
await restoreImpl(new StateProvider());
|
||||
}
|
||||
|
||||
run();
|
||||
|
||||
export default run;
|
||||
restoreRun(true);
|
||||
|
|
|
@ -2,10 +2,14 @@ import * as cache from "@actions/cache";
|
|||
import * as core from "@actions/core";
|
||||
|
||||
import { Events, Inputs, Outputs, State } from "./constants";
|
||||
import { IStateProvider } from "./stateProvider";
|
||||
import {
|
||||
IStateProvider,
|
||||
NullStateProvider,
|
||||
StateProvider
|
||||
} from "./stateProvider";
|
||||
import * as utils from "./utils/actionUtils";
|
||||
|
||||
async function restoreImpl(
|
||||
export async function restoreImpl(
|
||||
stateProvider: IStateProvider
|
||||
): Promise<string | undefined> {
|
||||
try {
|
||||
|
@ -31,14 +35,26 @@ async function restoreImpl(
|
|||
const cachePaths = utils.getInputAsArray(Inputs.Path, {
|
||||
required: true
|
||||
});
|
||||
const enableCrossOsArchive = utils.getInputAsBool(
|
||||
Inputs.EnableCrossOsArchive
|
||||
);
|
||||
const failOnCacheMiss = utils.getInputAsBool(Inputs.FailOnCacheMiss);
|
||||
const lookupOnly = utils.getInputAsBool(Inputs.LookupOnly);
|
||||
|
||||
const cacheKey = await cache.restoreCache(
|
||||
cachePaths,
|
||||
primaryKey,
|
||||
restoreKeys
|
||||
restoreKeys,
|
||||
{ lookupOnly: lookupOnly },
|
||||
enableCrossOsArchive
|
||||
);
|
||||
|
||||
if (!cacheKey) {
|
||||
if (failOnCacheMiss) {
|
||||
throw new Error(
|
||||
`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`
|
||||
);
|
||||
}
|
||||
core.info(
|
||||
`Cache not found for input keys: ${[
|
||||
primaryKey,
|
||||
|
@ -58,7 +74,11 @@ async function restoreImpl(
|
|||
);
|
||||
|
||||
core.setOutput(Outputs.CacheHit, isExactKeyMatch.toString());
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
if (lookupOnly) {
|
||||
core.info(`Cache found and can be restored from key: ${cacheKey}`);
|
||||
} else {
|
||||
core.info(`Cache restored from key: ${cacheKey}`);
|
||||
}
|
||||
|
||||
return cacheKey;
|
||||
} catch (error: unknown) {
|
||||
|
@ -66,4 +86,37 @@ async function restoreImpl(
|
|||
}
|
||||
}
|
||||
|
||||
export default restoreImpl;
|
||||
async function run(
|
||||
stateProvider: IStateProvider,
|
||||
earlyExit: boolean | undefined
|
||||
): Promise<void> {
|
||||
try {
|
||||
await restoreImpl(stateProvider);
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
if (earlyExit) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// node will stay alive if any promises are not resolved,
|
||||
// which is a possibility if HTTP requests are dangling
|
||||
// due to retries or timeouts. We know that if we got here
|
||||
// that all promises that we care about have successfully
|
||||
// resolved, so simply exit with success.
|
||||
if (earlyExit) {
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
export async function restoreOnlyRun(
|
||||
earlyExit?: boolean | undefined
|
||||
): Promise<void> {
|
||||
await run(new NullStateProvider(), earlyExit);
|
||||
}
|
||||
|
||||
export async function restoreRun(
|
||||
earlyExit?: boolean | undefined
|
||||
): Promise<void> {
|
||||
await run(new StateProvider(), earlyExit);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,3 @@
|
|||
import restoreImpl from "./restoreImpl";
|
||||
import { NullStateProvider } from "./stateProvider";
|
||||
import { restoreOnlyRun } from "./restoreImpl";
|
||||
|
||||
async function run(): Promise<void> {
|
||||
await restoreImpl(new NullStateProvider());
|
||||
}
|
||||
|
||||
run();
|
||||
|
||||
export default run;
|
||||
restoreOnlyRun(true);
|
||||
|
|
|
@ -52,9 +52,16 @@ async function saveImpl(stateProvider: IStateProvider): Promise<number | void> {
|
|||
required: true
|
||||
});
|
||||
|
||||
cacheId = await cache.saveCache(cachePaths, primaryKey, {
|
||||
uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize)
|
||||
});
|
||||
const enableCrossOsArchive = utils.getInputAsBool(
|
||||
Inputs.EnableCrossOsArchive
|
||||
);
|
||||
|
||||
cacheId = await cache.saveCache(
|
||||
cachePaths,
|
||||
primaryKey,
|
||||
{ uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize) },
|
||||
enableCrossOsArchive
|
||||
);
|
||||
|
||||
if (cacheId != -1) {
|
||||
core.info(`Cache saved with key: ${primaryKey}`);
|
||||
|
|
|
@ -52,6 +52,14 @@ export function getInputAsInt(
|
|||
return value;
|
||||
}
|
||||
|
||||
export function getInputAsBool(
|
||||
name: string,
|
||||
options?: core.InputOptions
|
||||
): boolean {
|
||||
const result = core.getInput(name, options);
|
||||
return result.toLowerCase() === "true";
|
||||
}
|
||||
|
||||
export function isCacheFeatureAvailable(): boolean {
|
||||
if (cache.isFeatureAvailable()) {
|
||||
return true;
|
||||
|
|
|
@ -13,6 +13,9 @@ interface CacheInput {
|
|||
path: string;
|
||||
key: string;
|
||||
restoreKeys?: string[];
|
||||
enableCrossOsArchive?: boolean;
|
||||
failOnCacheMiss?: boolean;
|
||||
lookupOnly?: boolean;
|
||||
}
|
||||
|
||||
export function setInputs(input: CacheInput): void {
|
||||
|
@ -20,6 +23,15 @@ export function setInputs(input: CacheInput): void {
|
|||
setInput(Inputs.Key, input.key);
|
||||
input.restoreKeys &&
|
||||
setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n"));
|
||||
input.enableCrossOsArchive !== undefined &&
|
||||
setInput(
|
||||
Inputs.EnableCrossOsArchive,
|
||||
input.enableCrossOsArchive.toString()
|
||||
);
|
||||
input.failOnCacheMiss !== undefined &&
|
||||
setInput(Inputs.FailOnCacheMiss, input.failOnCacheMiss.toString());
|
||||
input.lookupOnly !== undefined &&
|
||||
setInput(Inputs.LookupOnly, input.lookupOnly.toString());
|
||||
}
|
||||
|
||||
export function clearInputs(): void {
|
||||
|
@ -27,4 +39,7 @@ export function clearInputs(): void {
|
|||
delete process.env[getInputName(Inputs.Key)];
|
||||
delete process.env[getInputName(Inputs.RestoreKeys)];
|
||||
delete process.env[getInputName(Inputs.UploadChunkSize)];
|
||||
delete process.env[getInputName(Inputs.EnableCrossOsArchive)];
|
||||
delete process.env[getInputName(Inputs.FailOnCacheMiss)];
|
||||
delete process.env[getInputName(Inputs.LookupOnly)];
|
||||
}
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
# Tips and workarounds
|
||||
|
||||
## Cache segment restore timeout
|
||||
|
||||
A cache gets downloaded in multiple segments of fixed sizes (`1GB` for a `32-bit` runner and `2GB` for a `64-bit` runner). Sometimes, a segment download gets stuck which causes the workflow job to be stuck forever and fail. Version `v3.0.8` of `actions/cache` introduces a segment download timeout. The segment download timeout will allow the segment download to get aborted and hence allow the job to proceed with a cache miss.
|
||||
|
||||
Default value of this timeout is 60 minutes and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with timeout value in minutes.
|
||||
Default value of this timeout is 10 minutes and can be customized by specifying an [environment variable](https://docs.github.com/en/actions/learn-github-actions/environment-variables) named `SEGMENT_DOWNLOAD_TIMEOUT_MINS` with timeout value in minutes.
|
||||
|
||||
## Update a cache
|
||||
|
||||
A cache today is immutable and cannot be updated. But some use cases require the cache to be saved even though there was a "hit" during restore. To do so, use a `key` which is unique for every run and use `restore-keys` to restore the nearest cache. For example:
|
||||
|
||||
```yaml
|
||||
- name: update cache on every commit
|
||||
uses: actions/cache@v3
|
||||
|
@ -14,12 +19,24 @@ A cache today is immutable and cannot be updated. But some use cases require the
|
|||
restore-keys: |
|
||||
primes-${{ runner.os }}
|
||||
```
|
||||
|
||||
Please note that this will create a new cache on every run and hence will consume the cache [quota](./README.md#cache-limits).
|
||||
|
||||
## Use cache across feature branches
|
||||
|
||||
Reusing cache across feature branches is not allowed today to provide cache [isolation](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache). However if both feature branches are from the default branch, a good way to achieve this is to ensure that the default branch has a cache. This cache will then be consumable by both feature branches.
|
||||
|
||||
## Cross OS cache
|
||||
|
||||
From `v3.2.3` cache is cross-os compatible when `enableCrossOsArchive` input is passed as true. This means that a cache created on `ubuntu-latest` or `mac-latest` can be used by `windows-latest` and vice versa, provided the workflow which runs on `windows-latest` have input `enableCrossOsArchive` as true. This is useful to cache dependencies which are independent of the runner platform. This will help reduce the consumption of the cache quota and help build for multiple platforms from the same cache. Things to keep in mind while using this feature:
|
||||
|
||||
- Only cache files that are compatible across OSs.
|
||||
- Caching symlinks might cause issues while restoring them as they behave differently on different OSs.
|
||||
- Be mindful when caching files from outside your github workspace directory as the directory is located at different places across OS.
|
||||
- Avoid using directory pointers such as `${{ github.workspace }}` or `~` (home) which eventually evaluate to an absolute path that does not match across OSs.
|
||||
|
||||
## Force deletion of caches overriding default cache eviction policy
|
||||
|
||||
Caches have [branch scope restriction](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#restrictions-for-accessing-a-cache) in place. This means that if caches for a specific branch are using a lot of storage quota, it may result into more frequently used caches from `default` branch getting thrashed. For example, if there are many pull requests happening on a repo and are creating caches, these cannot be used in default branch scope but will still occupy a lot of space till they get cleaned up by [eviction policy](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy). But sometime we want to clean them up on a faster cadence so as to ensure default branch is not thrashing. In order to achieve this, [gh-actions-cache cli](https://github.com/actions/gh-actions-cache/) can be used to delete caches for specific branches.
|
||||
|
||||
This workflow uses `gh-actions-cache` to delete all the caches created by a branch.
|
||||
|
@ -37,6 +54,11 @@ on:
|
|||
jobs:
|
||||
cleanup:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# `actions:write` permission is required to delete caches
|
||||
# See also: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#delete-a-github-actions-cache-for-a-repository-using-a-cache-id
|
||||
actions: write
|
||||
contents: read
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v3
|
||||
|
@ -46,7 +68,7 @@ jobs:
|
|||
gh extension install actions/gh-actions-cache
|
||||
|
||||
REPO=${{ github.repository }}
|
||||
BRANCH=${{ github.ref }}
|
||||
BRANCH=refs/pull/${{ github.event.pull_request.number }}/merge
|
||||
|
||||
echo "Fetching list of cache key"
|
||||
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
|
||||
|
@ -62,4 +84,5 @@ jobs:
|
|||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
</details>
|
Loading…
Reference in New Issue