mirror of
				https://gitea.com/actions/cache.git
				synced 2025-11-02 07:47:08 +00:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			2gb_issue_
			...
			testEnable
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					8bcf0245bb | 
@@ -9,14 +9,15 @@
 | 
			
		||||
    "plugin:import/errors",
 | 
			
		||||
    "plugin:import/warnings",
 | 
			
		||||
    "plugin:import/typescript",
 | 
			
		||||
    "plugin:prettier/recommended"
 | 
			
		||||
    "plugin:prettier/recommended",
 | 
			
		||||
    "prettier/@typescript-eslint"
 | 
			
		||||
  ],
 | 
			
		||||
  "plugins": ["@typescript-eslint", "simple-import-sort", "jest"],
 | 
			
		||||
  "rules": {
 | 
			
		||||
    "import/first": "error",
 | 
			
		||||
    "import/newline-after-import": "error",
 | 
			
		||||
    "import/no-duplicates": "error",
 | 
			
		||||
    "simple-import-sort/imports": "error",
 | 
			
		||||
    "simple-import-sort/sort": "error",
 | 
			
		||||
    "sort-imports": "off"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							@@ -1,2 +1 @@
 | 
			
		||||
.licenses/** -diff linguist-generated=true
 | 
			
		||||
* text=auto eol=lf
 | 
			
		||||
.licenses/** -diff linguist-generated=true
 | 
			
		||||
							
								
								
									
										2
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/workflow.yml
									
									
									
									
										vendored
									
									
								
							@@ -34,7 +34,7 @@ jobs:
 | 
			
		||||
      run: |
 | 
			
		||||
        echo "::set-output name=dir::$(npm config get cache)"
 | 
			
		||||
    - name: Restore npm cache
 | 
			
		||||
      uses: actions/cache@v3
 | 
			
		||||
      uses: actions/cache@v2
 | 
			
		||||
      with:
 | 
			
		||||
        path: ${{ steps.npm-cache.outputs.dir }}
 | 
			
		||||
        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,9 +1,9 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@actions/cache"
 | 
			
		||||
version: 1.0.10
 | 
			
		||||
version: 1.0.8
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
summary: Actions cache lib
 | 
			
		||||
homepage: https://github.com/actions/toolkit/tree/main/packages/cache
 | 
			
		||||
license: mit
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE.md
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								.licenses/npm/@actions/exec.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								.licenses/npm/@actions/exec.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,9 +1,9 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@actions/exec"
 | 
			
		||||
version: 1.1.1
 | 
			
		||||
version: 1.1.0
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
summary: Actions exec lib
 | 
			
		||||
homepage: https://github.com/actions/toolkit/tree/main/packages/exec
 | 
			
		||||
license: mit
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE.md
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								.licenses/npm/@actions/io.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								.licenses/npm/@actions/io.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,9 +1,9 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@actions/io"
 | 
			
		||||
version: 1.1.2
 | 
			
		||||
version: 1.1.1
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
summary: Actions io lib
 | 
			
		||||
homepage: https://github.com/actions/toolkit/tree/main/packages/io
 | 
			
		||||
license: mit
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE.md
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,9 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@azure/core-asynciterator-polyfill"
 | 
			
		||||
version: 1.0.2
 | 
			
		||||
version: 1.0.0
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
summary: Polyfill for IE/Node 8 for Symbol.asyncIterator
 | 
			
		||||
homepage: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/core/core-asynciterator-polyfill
 | 
			
		||||
license: mit
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								.licenses/npm/@azure/core-http.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@azure/core-http.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@azure/core-http"
 | 
			
		||||
version: 2.2.4
 | 
			
		||||
version: 2.2.2
 | 
			
		||||
type: npm
 | 
			
		||||
summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client
 | 
			
		||||
  libraries generated using AutoRest
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								.licenses/npm/@azure/core-lro.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								.licenses/npm/@azure/core-lro.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,9 +1,10 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@azure/core-lro"
 | 
			
		||||
version: 2.2.4
 | 
			
		||||
version: 2.2.1
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
summary: Isomorphic client library for supporting long-running operations in node.js
 | 
			
		||||
  and browser.
 | 
			
		||||
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-lro/README.md
 | 
			
		||||
license: mit
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								.licenses/npm/@azure/core-paging.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@azure/core-paging.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@azure/core-paging"
 | 
			
		||||
version: 1.2.1
 | 
			
		||||
version: 1.2.0
 | 
			
		||||
type: npm
 | 
			
		||||
summary: Core types for paging async iterable iterators
 | 
			
		||||
homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-paging/README.md
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										7
									
								
								.licenses/npm/@azure/ms-rest-js.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										7
									
								
								.licenses/npm/@azure/ms-rest-js.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,9 +1,10 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@azure/ms-rest-js"
 | 
			
		||||
version: 2.6.1
 | 
			
		||||
version: 2.6.0
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client
 | 
			
		||||
  libraries generated using AutoRest
 | 
			
		||||
homepage: https://github.com/Azure/ms-rest-js
 | 
			
		||||
license: mit
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								.licenses/npm/@azure/storage-blob.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								.licenses/npm/@azure/storage-blob.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,9 +1,9 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@azure/storage-blob"
 | 
			
		||||
version: 12.9.0
 | 
			
		||||
version: 12.8.0
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
summary: Microsoft Azure Storage SDK for JavaScript - Blob
 | 
			
		||||
homepage: https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/storage/storage-blob/
 | 
			
		||||
license: mit
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								.licenses/npm/@opentelemetry/api.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										10
									
								
								.licenses/npm/@opentelemetry/api.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,9 +1,9 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@opentelemetry/api"
 | 
			
		||||
version: 1.1.0
 | 
			
		||||
version: 1.0.3
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
summary: Public API for OpenTelemetry
 | 
			
		||||
homepage: https://github.com/open-telemetry/opentelemetry-js-api#readme
 | 
			
		||||
license: apache-2.0
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE
 | 
			
		||||
@@ -218,6 +218,10 @@ licenses:
 | 
			
		||||
    [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions
 | 
			
		||||
    [license-url]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/LICENSE
 | 
			
		||||
    [license-image]: https://img.shields.io/badge/license-Apache_2.0-green.svg?style=flat
 | 
			
		||||
    [dependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-api.svg
 | 
			
		||||
    [dependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-api
 | 
			
		||||
    [devDependencies-image]: https://status.david-dm.org/gh/open-telemetry/opentelemetry-js-api.svg?type=dev
 | 
			
		||||
    [devDependencies-url]: https://david-dm.org/open-telemetry/opentelemetry-js-api?type=dev
 | 
			
		||||
    [npm-url]: https://www.npmjs.com/package/@opentelemetry/api
 | 
			
		||||
    [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fapi.svg
 | 
			
		||||
    [docs-tracing]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/docs/tracing.md
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								.licenses/npm/@types/node-fetch.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								.licenses/npm/@types/node-fetch.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,9 +1,9 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@types/node-fetch"
 | 
			
		||||
version: 2.6.1
 | 
			
		||||
version: 2.5.12
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
summary: TypeScript definitions for node-fetch
 | 
			
		||||
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node-fetch
 | 
			
		||||
license: mit
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								.licenses/npm/@types/node.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								.licenses/npm/@types/node.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,9 +1,9 @@
 | 
			
		||||
---
 | 
			
		||||
name: "@types/node"
 | 
			
		||||
version: 16.11.26
 | 
			
		||||
version: 12.20.37
 | 
			
		||||
type: npm
 | 
			
		||||
summary: 
 | 
			
		||||
homepage: 
 | 
			
		||||
summary: TypeScript definitions for Node.js
 | 
			
		||||
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node
 | 
			
		||||
license: mit
 | 
			
		||||
licenses:
 | 
			
		||||
- sources: LICENSE
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								.licenses/npm/node-fetch.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/node-fetch.dep.yml
									
									
									
										generated
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
---
 | 
			
		||||
name: node-fetch
 | 
			
		||||
version: 2.6.7
 | 
			
		||||
version: 2.6.6
 | 
			
		||||
type: npm
 | 
			
		||||
summary: A light-weight module that brings window.fetch to node.js
 | 
			
		||||
homepage: https://github.com/bitinn/node-fetch
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										38
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								README.md
									
									
									
									
									
								
							@@ -2,23 +2,19 @@
 | 
			
		||||
 | 
			
		||||
This action allows caching dependencies and build outputs to improve workflow execution time.
 | 
			
		||||
 | 
			
		||||
[](https://github.com/actions/cache/actions/workflows/workflow.yml)
 | 
			
		||||
<a href="https://github.com/actions/cache/actions?query=workflow%3ATests"><img alt="GitHub Actions status" src="https://github.com/actions/cache/workflows/Tests/badge.svg?branch=main&event=push"></a>
 | 
			
		||||
 | 
			
		||||
## Documentation
 | 
			
		||||
 | 
			
		||||
See ["Caching dependencies to speed up workflows"](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows).
 | 
			
		||||
 | 
			
		||||
## What's New
 | 
			
		||||
### v3
 | 
			
		||||
* Updated the minimum runner version support from node 12 -> node 16.
 | 
			
		||||
 | 
			
		||||
### v2
 | 
			
		||||
* Increased the cache size limit to 10 GB.
 | 
			
		||||
* Added support for multiple paths, [glob patterns](https://github.com/actions/toolkit/tree/main/packages/glob), and single file caches.
 | 
			
		||||
* Added support for multiple paths, [glob patterns](https://github.com/actions/toolkit/tree/main/packages/glob), and single file caches. 
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- name: Cache multiple paths
 | 
			
		||||
  uses: actions/cache@v3
 | 
			
		||||
  uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~/cache
 | 
			
		||||
@@ -38,11 +34,9 @@ Refer [here](https://github.com/actions/cache/blob/v1/README.md) for previous ve
 | 
			
		||||
### 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.
 | 
			
		||||
 | 
			
		||||
### Inputs
 | 
			
		||||
 | 
			
		||||
* `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.
 | 
			
		||||
* `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 keys to use for restoring the cache if no cache hit occurred for key
 | 
			
		||||
 | 
			
		||||
@@ -53,7 +47,7 @@ If you are using this inside a container, a POSIX-compliant `tar` needs to be in
 | 
			
		||||
> 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 and branch. The default branch cache is available to other branches.
 | 
			
		||||
The cache is scoped to the key 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.
 | 
			
		||||
 | 
			
		||||
@@ -73,7 +67,7 @@ jobs:
 | 
			
		||||
 | 
			
		||||
    - name: Cache Primes
 | 
			
		||||
      id: cache-primes
 | 
			
		||||
      uses: actions/cache@v3
 | 
			
		||||
      uses: actions/cache@v2
 | 
			
		||||
      with:
 | 
			
		||||
        path: prime-numbers
 | 
			
		||||
        key: ${{ runner.os }}-primes
 | 
			
		||||
@@ -92,13 +86,11 @@ 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)
 | 
			
		||||
- [C# - Nuget](./examples.md#c---nuget)
 | 
			
		||||
- [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)
 | 
			
		||||
@@ -123,11 +115,11 @@ A cache key can include any of the contexts, functions, literals, and operators
 | 
			
		||||
For example, using the [`hashFiles`](https://help.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#hashfiles) function allows you to create a new cache when dependencies change.
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
  - uses: actions/cache@v3
 | 
			
		||||
  - uses: actions/cache@v2
 | 
			
		||||
    with:
 | 
			
		||||
      path: |
 | 
			
		||||
      path: | 
 | 
			
		||||
        path/to/dependencies
 | 
			
		||||
        some/other/dependencies
 | 
			
		||||
        some/other/dependencies 
 | 
			
		||||
      key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@@ -141,7 +133,7 @@ Additionally, you can use arbitrary command output in a cache key, such as a dat
 | 
			
		||||
      echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")"
 | 
			
		||||
    shell: bash
 | 
			
		||||
 | 
			
		||||
  - uses: actions/cache@v3
 | 
			
		||||
  - uses: actions/cache@v2
 | 
			
		||||
    with:
 | 
			
		||||
      path: path/to/dependencies
 | 
			
		||||
      key: ${{ runner.os }}-${{ steps.get-date.outputs.date }}-${{ hashFiles('**/lockfiles') }}
 | 
			
		||||
@@ -162,7 +154,7 @@ Example:
 | 
			
		||||
steps:
 | 
			
		||||
  - uses: actions/checkout@v2
 | 
			
		||||
 | 
			
		||||
  - uses: actions/cache@v3
 | 
			
		||||
  - uses: actions/cache@v2
 | 
			
		||||
    id: cache
 | 
			
		||||
    with:
 | 
			
		||||
      path: path/to/dependencies
 | 
			
		||||
@@ -181,12 +173,6 @@ steps:
 | 
			
		||||
 | 
			
		||||
Since GitHub Enterprise Server uses self-hosted runners, dependencies are typically cached on the runner by whatever dependency management tool is being used (npm, maven, etc.).  This eliminates the need for explicit caching in some scenarios.
 | 
			
		||||
 | 
			
		||||
## Changelog schedule and history 
 | 
			
		||||
 | 
			
		||||
| Status  | Version  | Date  | Highlights  |
 | 
			
		||||
|:---|:---|:---|:---|
 | 
			
		||||
| Published  | v3.0.0  | Mar 21st, 2022 | -  Updated minimum runner version support from node 12 -> node 16 <br>  |
 | 
			
		||||
 | 
			
		||||
## 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.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -17,24 +17,6 @@ afterEach(() => {
 | 
			
		||||
    delete process.env[RefKey];
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("isGhes returns true if server url is not github.com", () => {
 | 
			
		||||
    try {
 | 
			
		||||
        process.env["GITHUB_SERVER_URL"] = "http://example.com";
 | 
			
		||||
        expect(actionUtils.isGhes()).toBe(true);
 | 
			
		||||
    } finally {
 | 
			
		||||
        process.env["GITHUB_SERVER_URL"] = undefined;
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("isGhes returns false when server url is github.com", () => {
 | 
			
		||||
    try {
 | 
			
		||||
        process.env["GITHUB_SERVER_URL"] = "http://github.com";
 | 
			
		||||
        expect(actionUtils.isGhes()).toBe(false);
 | 
			
		||||
    } finally {
 | 
			
		||||
        process.env["GITHUB_SERVER_URL"] = undefined;
 | 
			
		||||
    }
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("isExactKeyMatch with undefined cache key returns false", () => {
 | 
			
		||||
    const key = "linux-rust";
 | 
			
		||||
    const cacheKey = undefined;
 | 
			
		||||
 
 | 
			
		||||
@@ -32,8 +32,6 @@ beforeAll(() => {
 | 
			
		||||
beforeEach(() => {
 | 
			
		||||
    process.env[Events.Key] = Events.Push;
 | 
			
		||||
    process.env[RefKey] = "refs/heads/feature-branch";
 | 
			
		||||
 | 
			
		||||
    jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
afterEach(() => {
 | 
			
		||||
@@ -55,23 +53,6 @@ test("restore with invalid event outputs warning", async () => {
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("restore on GHES should no-op", async () => {
 | 
			
		||||
    jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
 | 
			
		||||
 | 
			
		||||
    const logWarningMock = jest.spyOn(actionUtils, "logWarning");
 | 
			
		||||
    const restoreCacheMock = jest.spyOn(cache, "restoreCache");
 | 
			
		||||
    const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
 | 
			
		||||
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(restoreCacheMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
    expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
 | 
			
		||||
    expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
 | 
			
		||||
    expect(logWarningMock).toHaveBeenCalledWith(
 | 
			
		||||
        "Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"
 | 
			
		||||
    );
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("restore with no path should fail", async () => {
 | 
			
		||||
    const failedMock = jest.spyOn(core, "setFailed");
 | 
			
		||||
    const restoreCacheMock = jest.spyOn(cache, "restoreCache");
 | 
			
		||||
 
 | 
			
		||||
@@ -52,8 +52,6 @@ beforeAll(() => {
 | 
			
		||||
beforeEach(() => {
 | 
			
		||||
    process.env[Events.Key] = Events.Push;
 | 
			
		||||
    process.env[RefKey] = "refs/heads/feature-branch";
 | 
			
		||||
 | 
			
		||||
    jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
afterEach(() => {
 | 
			
		||||
@@ -101,20 +99,6 @@ test("save with no primary key in state outputs warning", async () => {
 | 
			
		||||
    expect(failedMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("save on GHES should no-op", async () => {
 | 
			
		||||
    jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
 | 
			
		||||
 | 
			
		||||
    const logWarningMock = jest.spyOn(actionUtils, "logWarning");
 | 
			
		||||
    const saveCacheMock = jest.spyOn(cache, "saveCache");
 | 
			
		||||
 | 
			
		||||
    await run();
 | 
			
		||||
 | 
			
		||||
    expect(saveCacheMock).toHaveBeenCalledTimes(0);
 | 
			
		||||
    expect(logWarningMock).toHaveBeenCalledWith(
 | 
			
		||||
        "Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"
 | 
			
		||||
    );
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("save with exact match returns early", async () => {
 | 
			
		||||
    const infoMock = jest.spyOn(core, "info");
 | 
			
		||||
    const failedMock = jest.spyOn(core, "setFailed");
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ outputs:
 | 
			
		||||
  cache-hit:
 | 
			
		||||
    description: 'A boolean value to indicate an exact match was found for the primary key'
 | 
			
		||||
runs:
 | 
			
		||||
  using: 'node16'
 | 
			
		||||
  using: 'node12'
 | 
			
		||||
  main: 'dist/restore/index.js'
 | 
			
		||||
  post: 'dist/save/index.js'
 | 
			
		||||
  post-if: 'success()'
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5242
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5242
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										5241
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										5241
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										145
									
								
								examples.md
									
									
									
									
									
								
							
							
						
						
									
										145
									
								
								examples.md
									
									
									
									
									
								
							@@ -4,22 +4,17 @@
 | 
			
		||||
- [D - DUB](#d---dub)
 | 
			
		||||
  - [POSIX](#posix)
 | 
			
		||||
  - [Windows](#windows)
 | 
			
		||||
- [Deno](#deno)
 | 
			
		||||
- [Elixir - Mix](#elixir---mix)
 | 
			
		||||
- [Go - Modules](#go---modules)
 | 
			
		||||
  - [Linux](#linux)
 | 
			
		||||
  - [macOS](#macos)
 | 
			
		||||
  - [Windows](#windows-1)
 | 
			
		||||
- [Elixir - Mix](#elixir---mix)
 | 
			
		||||
- [Go - Modules](#go---modules)
 | 
			
		||||
  - [Linux](#linux-1)
 | 
			
		||||
  - [macOS](#macos-1)
 | 
			
		||||
  - [Windows](#windows-2)
 | 
			
		||||
- [Haskell - Cabal](#haskell---cabal)
 | 
			
		||||
- [Haskell - Stack](#haskell---stack)
 | 
			
		||||
- [Java - Gradle](#java---gradle)
 | 
			
		||||
- [Java - Maven](#java---maven)
 | 
			
		||||
- [Node - npm](#node---npm)
 | 
			
		||||
  - [macOS and Ubuntu](#macos-and-ubuntu)
 | 
			
		||||
  - [Windows](#windows-3)
 | 
			
		||||
  - [Windows](#windows-2)
 | 
			
		||||
  - [Using multiple systems and `npm config`](#using-multiple-systems-and-npm-config)
 | 
			
		||||
- [Node - Lerna](#node---lerna)
 | 
			
		||||
- [Node - Yarn](#node---yarn)
 | 
			
		||||
@@ -33,6 +28,8 @@
 | 
			
		||||
  - [Using pip to get cache location](#using-pip-to-get-cache-location)
 | 
			
		||||
- [Python - pipenv](#python---pipenv)
 | 
			
		||||
- [R - renv](#r---renv)
 | 
			
		||||
  - [Simple example](#simple-example-1)
 | 
			
		||||
  - [Multiple OS's in a workflow](#multiple-oss-in-a-workflow-1)
 | 
			
		||||
- [Ruby - Bundler](#ruby---bundler)
 | 
			
		||||
- [Rust - Cargo](#rust---cargo)
 | 
			
		||||
- [Scala - SBT](#scala---sbt)
 | 
			
		||||
@@ -45,7 +42,7 @@
 | 
			
		||||
Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/package-references-in-project-files#locking-dependencies):
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~/.nuget/packages
 | 
			
		||||
    key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
 | 
			
		||||
@@ -54,10 +51,10 @@ Using [NuGet lock files](https://docs.microsoft.com/nuget/consume-packages/packa
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
Depending on the environment, huge packages might be pre-installed in the global cache folder.
 | 
			
		||||
With `actions/cache@v3` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/main/packages/glob#exclude-patterns)
 | 
			
		||||
With `actions/cache@v2` you can now exclude unwanted packages with [exclude pattern](https://github.com/actions/toolkit/tree/main/packages/glob#exclude-patterns)
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~/.nuget/packages
 | 
			
		||||
@@ -69,12 +66,11 @@ 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
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
env:
 | 
			
		||||
  NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
 | 
			
		||||
steps:
 | 
			
		||||
  - uses: actions/cache@v3
 | 
			
		||||
  - uses: actions/cache@v2
 | 
			
		||||
    with:
 | 
			
		||||
      path: ${{ github.workspace }}/.nuget/packages
 | 
			
		||||
      key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
 | 
			
		||||
@@ -87,7 +83,7 @@ steps:
 | 
			
		||||
### POSIX
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~/.dub
 | 
			
		||||
    key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.json') }}
 | 
			
		||||
@@ -98,7 +94,7 @@ steps:
 | 
			
		||||
### Windows
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~\AppData\Local\dub
 | 
			
		||||
    key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.json') }}
 | 
			
		||||
@@ -106,46 +102,10 @@ steps:
 | 
			
		||||
      ${{ runner.os }}-dub-
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Deno
 | 
			
		||||
 | 
			
		||||
### Linux
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~/.deno
 | 
			
		||||
      ~/.cache/deno
 | 
			
		||||
    key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### macOS
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~/.deno
 | 
			
		||||
      ~/Library/Caches/deno
 | 
			
		||||
    key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Windows
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~\.deno
 | 
			
		||||
      %LocalAppData%\deno
 | 
			
		||||
    key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Elixir - Mix
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      deps
 | 
			
		||||
@@ -160,7 +120,7 @@ steps:
 | 
			
		||||
### Linux
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~/.cache/go-build
 | 
			
		||||
@@ -173,7 +133,7 @@ steps:
 | 
			
		||||
### macOS
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~/Library/Caches/go-build
 | 
			
		||||
@@ -186,11 +146,11 @@ steps:
 | 
			
		||||
### Windows
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~\AppData\Local\go-build
 | 
			
		||||
      ~\go\pkg\mod
 | 
			
		||||
      %LocalAppData%\go-build
 | 
			
		||||
      ~/go/pkg/mod
 | 
			
		||||
    key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
 | 
			
		||||
    restore-keys: |
 | 
			
		||||
      ${{ runner.os }}-go-
 | 
			
		||||
@@ -202,7 +162,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- name: Cache ~/.cabal/packages, ~/.cabal/store and dist-newstyle
 | 
			
		||||
  uses: actions/cache@v3
 | 
			
		||||
  uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~/.cabal/packages
 | 
			
		||||
@@ -212,31 +172,12 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
 | 
			
		||||
    restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Haskell - Stack
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
  name: Cache ~/.stack
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~/.stack
 | 
			
		||||
    key: ${{ runner.os }}-stack-global-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}
 | 
			
		||||
    restore-keys: |
 | 
			
		||||
      ${{ runner.os }}-stack-global-
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
  name: Cache .stack-work
 | 
			
		||||
  with:
 | 
			
		||||
    path: .stack-work
 | 
			
		||||
    key: ${{ runner.os }}-stack-work-${{ hashFiles('stack.yaml') }}-${{ hashFiles('package.yaml') }}-${{ hashFiles('**/*.hs') }}
 | 
			
		||||
    restore-keys: |
 | 
			
		||||
      ${{ runner.os }}-stack-work-
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## 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.
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~/.gradle/caches
 | 
			
		||||
@@ -250,7 +191,7 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- name: Cache local Maven repository
 | 
			
		||||
  uses: actions/cache@v3
 | 
			
		||||
  uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~/.m2/repository
 | 
			
		||||
    key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
 | 
			
		||||
@@ -269,7 +210,7 @@ If using `npm config` to retrieve the cache directory, ensure you run [actions/s
 | 
			
		||||
### macOS and Ubuntu
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~/.npm
 | 
			
		||||
    key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
 | 
			
		||||
@@ -284,7 +225,7 @@ If using `npm config` to retrieve the cache directory, ensure you run [actions/s
 | 
			
		||||
  id: npm-cache
 | 
			
		||||
  run: |
 | 
			
		||||
    echo "::set-output name=dir::$(npm config get cache)"
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ${{ steps.npm-cache.outputs.dir }}
 | 
			
		||||
    key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
 | 
			
		||||
@@ -299,7 +240,7 @@ If using `npm config` to retrieve the cache directory, ensure you run [actions/s
 | 
			
		||||
  id: npm-cache-dir
 | 
			
		||||
  run: |
 | 
			
		||||
    echo "::set-output name=dir::$(npm config get cache)"
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true'
 | 
			
		||||
  with:
 | 
			
		||||
    path: ${{ steps.npm-cache-dir.outputs.dir }}
 | 
			
		||||
@@ -312,9 +253,11 @@ If using `npm config` to retrieve the cache directory, ensure you run [actions/s
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- name: restore lerna
 | 
			
		||||
  uses: actions/cache@v3
 | 
			
		||||
  uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: **/node_modules
 | 
			
		||||
    path: |
 | 
			
		||||
      node_modules
 | 
			
		||||
      */*/node_modules
 | 
			
		||||
    key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
@@ -326,7 +269,7 @@ The yarn cache directory will depend on your operating system and version of `ya
 | 
			
		||||
  id: yarn-cache-dir-path
 | 
			
		||||
  run: echo "::set-output name=dir::$(yarn cache dir)"
 | 
			
		||||
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
 | 
			
		||||
  with:
 | 
			
		||||
    path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
 | 
			
		||||
@@ -344,7 +287,7 @@ The yarn 2 cache directory will depend on your config. See https://yarnpkg.com/c
 | 
			
		||||
  id: yarn-cache-dir-path
 | 
			
		||||
  run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
 | 
			
		||||
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
 | 
			
		||||
  with:
 | 
			
		||||
    path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
 | 
			
		||||
@@ -359,7 +302,7 @@ Esy allows you to export built dependencies and import pre-built dependencies.
 | 
			
		||||
```yaml
 | 
			
		||||
    - name: Restore Cache
 | 
			
		||||
      id: restore-cache
 | 
			
		||||
      uses: actions/cache@v3
 | 
			
		||||
      uses: actions/cache@v2
 | 
			
		||||
      with:
 | 
			
		||||
        path: _export
 | 
			
		||||
        key:  ${{ runner.os }}-esy-${{ hashFiles('esy.lock/index.json') }}
 | 
			
		||||
@@ -388,7 +331,7 @@ Esy allows you to export built dependencies and import pre-built dependencies.
 | 
			
		||||
  id: composer-cache
 | 
			
		||||
  run: |
 | 
			
		||||
    echo "::set-output name=dir::$(composer config cache-files-dir)"
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ${{ steps.composer-cache.outputs.dir }}
 | 
			
		||||
    key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
 | 
			
		||||
@@ -409,7 +352,7 @@ Locations:
 | 
			
		||||
### Simple example
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~/.cache/pip
 | 
			
		||||
    key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
 | 
			
		||||
@@ -422,7 +365,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
 | 
			
		||||
### Multiple OS's in a workflow
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  if: startsWith(runner.os, 'Linux')
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~/.cache/pip
 | 
			
		||||
@@ -430,7 +373,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
 | 
			
		||||
    restore-keys: |
 | 
			
		||||
      ${{ runner.os }}-pip-
 | 
			
		||||
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  if: startsWith(runner.os, 'macOS')
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~/Library/Caches/pip
 | 
			
		||||
@@ -438,7 +381,7 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
 | 
			
		||||
    restore-keys: |
 | 
			
		||||
      ${{ runner.os }}-pip-
 | 
			
		||||
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  if: startsWith(runner.os, 'Windows')
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~\AppData\Local\pip\Cache
 | 
			
		||||
@@ -464,7 +407,7 @@ jobs:
 | 
			
		||||
        - os: windows-latest
 | 
			
		||||
          path: ~\AppData\Local\pip\Cache
 | 
			
		||||
    steps:
 | 
			
		||||
    - uses: actions/cache@v3
 | 
			
		||||
    - uses: actions/cache@v2
 | 
			
		||||
      with:
 | 
			
		||||
        path: ${{ matrix.path }}
 | 
			
		||||
        key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
 | 
			
		||||
@@ -482,7 +425,7 @@ jobs:
 | 
			
		||||
    echo "::set-output name=dir::$(pip cache dir)"
 | 
			
		||||
 | 
			
		||||
- name: pip cache
 | 
			
		||||
  uses: actions/cache@v3
 | 
			
		||||
  uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ${{ steps.pip-cache.outputs.dir }}
 | 
			
		||||
    key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
 | 
			
		||||
@@ -500,7 +443,7 @@ jobs:
 | 
			
		||||
 | 
			
		||||
  ⋮
 | 
			
		||||
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ~/.local/share/virtualenvs
 | 
			
		||||
    key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-pipenv-${{ hashFiles('Pipfile.lock') }}
 | 
			
		||||
@@ -527,7 +470,7 @@ For renv, the cache directory will vary by OS. The `RENV_PATHS_ROOT` environment
 | 
			
		||||
    cat("##[set-output name=r-version;]", R.Version()$version.string, sep = "")
 | 
			
		||||
  shell: Rscript {0}
 | 
			
		||||
- name: Restore Renv package cache
 | 
			
		||||
  uses: actions/cache@v3
 | 
			
		||||
  uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: ${{ env.RENV_PATHS_ROOT }}
 | 
			
		||||
    key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-${{ hashFiles('renv.lock') }}
 | 
			
		||||
@@ -553,7 +496,7 @@ whenever possible:
 | 
			
		||||
## Rust - Cargo
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~/.cargo/bin/
 | 
			
		||||
@@ -568,7 +511,7 @@ whenever possible:
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- name: Cache SBT
 | 
			
		||||
  uses: actions/cache@v3
 | 
			
		||||
  uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: |
 | 
			
		||||
      ~/.ivy2/cache
 | 
			
		||||
@@ -579,7 +522,7 @@ whenever possible:
 | 
			
		||||
## Swift, Objective-C - Carthage
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: Carthage
 | 
			
		||||
    key: ${{ runner.os }}-carthage-${{ hashFiles('**/Cartfile.resolved') }}
 | 
			
		||||
@@ -590,7 +533,7 @@ whenever possible:
 | 
			
		||||
## Swift, Objective-C - CocoaPods
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: Pods
 | 
			
		||||
    key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
 | 
			
		||||
@@ -601,7 +544,7 @@ whenever possible:
 | 
			
		||||
## Swift - Swift Package Manager
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
- uses: actions/cache@v3
 | 
			
		||||
- uses: actions/cache@v2
 | 
			
		||||
  with:
 | 
			
		||||
    path: .build
 | 
			
		||||
    key: ${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ const processStdoutWrite = process.stdout.write.bind(process.stdout);
 | 
			
		||||
process.stdout.write = (str, encoding, cb) => {
 | 
			
		||||
    // Core library will directly call process.stdout.write for commands
 | 
			
		||||
    // We don't want :: commands to be executed by the runner during tests
 | 
			
		||||
    if (!String(str).match(/^::/)) {
 | 
			
		||||
    if (!str.match(/^::/)) {
 | 
			
		||||
        return processStdoutWrite(str, encoding, cb);
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6673
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6673
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										36
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								package.json
									
									
									
									
									
								
							@@ -1,6 +1,6 @@
 | 
			
		||||
{
 | 
			
		||||
  "name": "cache",
 | 
			
		||||
  "version": "3.0.0",
 | 
			
		||||
  "version": "2.1.7",
 | 
			
		||||
  "private": true,
 | 
			
		||||
  "description": "Cache dependencies and build outputs",
 | 
			
		||||
  "main": "dist/restore/index.js",
 | 
			
		||||
@@ -23,29 +23,29 @@
 | 
			
		||||
  "author": "GitHub",
 | 
			
		||||
  "license": "MIT",
 | 
			
		||||
  "dependencies": {
 | 
			
		||||
    "@actions/cache": "file:../toolkit/packages/cache/actions-cache-1.0.10.tgz",
 | 
			
		||||
    "@actions/cache": "^1.0.8",
 | 
			
		||||
    "@actions/core": "^1.2.6",
 | 
			
		||||
    "@actions/exec": "^1.1.1",
 | 
			
		||||
    "@actions/io": "^1.1.2"
 | 
			
		||||
    "@actions/exec": "^1.0.1",
 | 
			
		||||
    "@actions/io": "^1.1.0"
 | 
			
		||||
  },
 | 
			
		||||
  "devDependencies": {
 | 
			
		||||
    "@types/jest": "^27.4.1",
 | 
			
		||||
    "@types/jest": "^24.0.13",
 | 
			
		||||
    "@types/nock": "^11.1.0",
 | 
			
		||||
    "@types/node": "^16.11.26",
 | 
			
		||||
    "@typescript-eslint/eslint-plugin": "^5.15.0",
 | 
			
		||||
    "@typescript-eslint/parser": "^5.15.0",
 | 
			
		||||
    "@types/node": "^12.20.7",
 | 
			
		||||
    "@typescript-eslint/eslint-plugin": "^2.7.0",
 | 
			
		||||
    "@typescript-eslint/parser": "^2.7.0",
 | 
			
		||||
    "@zeit/ncc": "^0.20.5",
 | 
			
		||||
    "eslint": "^8.11.0",
 | 
			
		||||
    "eslint-config-prettier": "^8.5.0",
 | 
			
		||||
    "eslint-plugin-import": "^2.25.4",
 | 
			
		||||
    "eslint-plugin-jest": "^26.1.2",
 | 
			
		||||
    "eslint-plugin-prettier": "^4.0.0",
 | 
			
		||||
    "eslint-plugin-simple-import-sort": "^7.0.0",
 | 
			
		||||
    "jest": "^27.5.1",
 | 
			
		||||
    "jest-circus": "^27.5.1",
 | 
			
		||||
    "eslint": "^6.6.0",
 | 
			
		||||
    "eslint-config-prettier": "^6.15.0",
 | 
			
		||||
    "eslint-plugin-import": "^2.22.1",
 | 
			
		||||
    "eslint-plugin-jest": "^23.20.0",
 | 
			
		||||
    "eslint-plugin-prettier": "^3.3.1",
 | 
			
		||||
    "eslint-plugin-simple-import-sort": "^5.0.2",
 | 
			
		||||
    "jest": "^24.8.0",
 | 
			
		||||
    "jest-circus": "^24.7.1",
 | 
			
		||||
    "nock": "^11.7.0",
 | 
			
		||||
    "prettier": "^2.6.0",
 | 
			
		||||
    "ts-jest": "^27.1.3",
 | 
			
		||||
    "prettier": "^1.19.1",
 | 
			
		||||
    "ts-jest": "^26.5.4",
 | 
			
		||||
    "typescript": "^3.9.9"
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -6,14 +6,6 @@ import * as utils from "./utils/actionUtils";
 | 
			
		||||
 | 
			
		||||
async function run(): Promise<void> {
 | 
			
		||||
    try {
 | 
			
		||||
        if (utils.isGhes()) {
 | 
			
		||||
            utils.logWarning(
 | 
			
		||||
                "Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"
 | 
			
		||||
            );
 | 
			
		||||
            utils.setCacheHitOutput(false);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Validate inputs, this can cause task failure
 | 
			
		||||
        if (!utils.isValidEvent()) {
 | 
			
		||||
            utils.logWarning(
 | 
			
		||||
 
 | 
			
		||||
@@ -11,13 +11,6 @@ process.on("uncaughtException", e => utils.logWarning(e.message));
 | 
			
		||||
 | 
			
		||||
async function run(): Promise<void> {
 | 
			
		||||
    try {
 | 
			
		||||
        if (utils.isGhes()) {
 | 
			
		||||
            utils.logWarning(
 | 
			
		||||
                "Cache action is not supported on GHES. See https://github.com/actions/cache/issues/505 for more details"
 | 
			
		||||
            );
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!utils.isValidEvent()) {
 | 
			
		||||
            utils.logWarning(
 | 
			
		||||
                `Event Validation Error: The event type ${
 | 
			
		||||
 
 | 
			
		||||
@@ -2,13 +2,6 @@ import * as core from "@actions/core";
 | 
			
		||||
 | 
			
		||||
import { Outputs, RefKey, State } from "../constants";
 | 
			
		||||
 | 
			
		||||
export function isGhes(): boolean {
 | 
			
		||||
    const ghUrl = new URL(
 | 
			
		||||
        process.env["GITHUB_SERVER_URL"] || "https://github.com"
 | 
			
		||||
    );
 | 
			
		||||
    return ghUrl.hostname.toUpperCase() !== "GITHUB.COM";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function isExactKeyMatch(key: string, cacheKey?: string): boolean {
 | 
			
		||||
    return !!(
 | 
			
		||||
        cacheKey &&
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user