mirror of
				https://github.com/actions/cache.git
				synced 2025-10-31 23:36:22 +07:00 
			
		
		
		
	Compare commits
	
		
			1 Commits
		
	
	
		
			v3.0.4
			...
			vsvipul/te
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 907bb7fbe4 | 
							
								
								
									
										1
									
								
								.github/auto_assign.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.github/auto_assign.yml
									
									
									
									
										vendored
									
									
								
							| @ -10,7 +10,6 @@ reviewers: | ||||
|   - aparna-ravindra | ||||
|   - tiwarishub | ||||
|   - vsvipul | ||||
|   - bishal-pdmsft | ||||
|  | ||||
| # A number of reviewers added to the pull request | ||||
| # Set 0 to add all the reviewers (default: 0) | ||||
|  | ||||
							
								
								
									
										15
									
								
								.github/workflows/auto-assign-issues.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										15
									
								
								.github/workflows/auto-assign-issues.yml
									
									
									
									
										vendored
									
									
								
							| @ -1,15 +0,0 @@ | ||||
| name: Issue assignment | ||||
|  | ||||
| on: | ||||
|     issues: | ||||
|         types: [opened] | ||||
|  | ||||
| jobs: | ||||
|     auto-assign: | ||||
|         runs-on: ubuntu-latest | ||||
|         steps: | ||||
|             - name: 'Auto-assign issue' | ||||
|               uses: pozil/auto-assign-issue@v1.4.0 | ||||
|               with: | ||||
|                   assignees: phantsure,tiwarishub,aparna-ravindra,vsvipul,bishal-pdmsft | ||||
|                   numOfAssignee: 1 | ||||
							
								
								
									
										4
									
								
								.github/workflows/close-inactive-issues.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								.github/workflows/close-inactive-issues.yml
									
									
									
									
										vendored
									
									
								
							| @ -12,10 +12,10 @@ jobs: | ||||
|     steps: | ||||
|       - uses: actions/stale@v3 | ||||
|         with: | ||||
|           days-before-issue-stale: 200 | ||||
|           days-before-issue-stale: 365 | ||||
|           days-before-issue-close: 5 | ||||
|           stale-issue-label: "stale" | ||||
|           stale-issue-message: "This issue is stale because it has been open for 200 days with no activity. Leave a comment to avoid closing this issue in 5 days." | ||||
|           stale-issue-message: "This issue is stale because it has been open for 365 days with no activity. Leave a comment to avoid closing this issue in 5 days." | ||||
|           close-issue-message: "This issue was closed because it has been inactive for 5 days since being marked as stale." | ||||
|           days-before-pr-stale: -1 | ||||
|           days-before-pr-close: -1 | ||||
|  | ||||
							
								
								
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: "@actions/cache" | ||||
| version: 2.0.6 | ||||
| version: 2.0.2 | ||||
| type: npm | ||||
| summary:  | ||||
| homepage:  | ||||
|  | ||||
							
								
								
									
										2
									
								
								.licenses/npm/@actions/core.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/core.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: "@actions/core" | ||||
| version: 1.7.0 | ||||
| version: 1.6.0 | ||||
| type: npm | ||||
| summary: Actions core lib | ||||
| homepage: https://github.com/actions/toolkit/tree/main/packages/core | ||||
|  | ||||
							
								
								
									
										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.33 | ||||
| version: 16.11.26 | ||||
| type: npm | ||||
| summary: TypeScript definitions for Node.js | ||||
| homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node | ||||
| summary:  | ||||
| homepage:  | ||||
| license: mit | ||||
| licenses: | ||||
| - sources: LICENSE | ||||
|  | ||||
							
								
								
									
										79
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										79
									
								
								README.md
									
									
									
									
									
								
							| @ -1,5 +1,6 @@ | ||||
| # cache | ||||
|  | ||||
| Test for autoassign. | ||||
| This action allows caching dependencies and build outputs to improve workflow execution time. | ||||
|  | ||||
| [](https://github.com/actions/cache/actions/workflows/workflow.yml) | ||||
| @ -13,10 +14,27 @@ See ["Caching dependencies to speed up workflows"](https://help.github.com/githu | ||||
| * Added support for caching from 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. | ||||
| * Fixed tar creation error while trying to create tar with path as `~/` home folder on `ubuntu-latest`. | ||||
|  | ||||
| Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions | ||||
| ### 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. | ||||
|  | ||||
| ```yaml | ||||
| - name: Cache multiple paths | ||||
|   uses: actions/cache@v3 | ||||
|   with: | ||||
|     path: | | ||||
|       ~/cache | ||||
|       !~/cache/exclude | ||||
|     key: ${{ runner.os }}-${{ hashFiles('**/lockfiles') }} | ||||
| ``` | ||||
|  | ||||
| * Increased performance and improved cache sizes using `zstd` compression for Linux and macOS runners | ||||
| * Allowed caching for all events with a ref. See [events that trigger workflow](https://help.github.com/en/actions/reference/events-that-trigger-workflows) for info on which events do not have a `GITHUB_REF` | ||||
| * Released the [`@actions/cache`](https://github.com/actions/toolkit/tree/main/packages/cache) npm package to allow other actions to utilize caching | ||||
| * Added a best-effort cleanup step to delete the archive after extraction to reduce storage space | ||||
|  | ||||
| Refer [here](https://github.com/actions/cache/blob/v1/README.md) for previous versions | ||||
|  | ||||
| ## Usage | ||||
|  | ||||
| @ -29,8 +47,7 @@ If you are using this inside a container, a POSIX-compliant `tar` needs to be in | ||||
|  | ||||
| * `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 stale cache if no cache hit occurred for key. Note | ||||
| `cache-hit` returns false in this case. | ||||
| * `restore-keys` - An ordered list of keys to use for restoring the cache if no cache hit occurred for key | ||||
|  | ||||
| ### Outputs | ||||
|  | ||||
| @ -161,58 +178,6 @@ steps: | ||||
|  | ||||
| > 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 unique for a combination of compression tool used for compression of cache (Gzip, Zstd, etc based on runner OS) and the path of directories being cached. If two caches have different versions, they are identified as unique cache entries. This also means that a cache created on `windows-latest` runner can't be restored on `ubuntu-latest` as cache `Version`s are different.  | ||||
|  | ||||
| Example: Below example will create 3 unique caches with same keys. Ubuntu and windows runners will use different compression technique and hence create two different caches. And `build-linux` will create two different caches as the `paths` are different. | ||||
|  | ||||
| ```yaml | ||||
| jobs: | ||||
|   build-linux: | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|     - uses: actions/checkout@v3 | ||||
|  | ||||
|     - name: Cache Primes | ||||
|       id: cache-primes | ||||
|       uses: actions/cache@v3 | ||||
|       with: | ||||
|         path: prime-numbers | ||||
|         key: primes | ||||
|  | ||||
|     - name: Generate Prime Numbers | ||||
|       if: steps.cache-primes.outputs.cache-hit != 'true' | ||||
|       run: ./generate-primes.sh -d prime-numbers | ||||
|        | ||||
|     - name: Cache Numbers | ||||
|       id: cache-numbers | ||||
|       uses: actions/cache@v3 | ||||
|       with: | ||||
|         path: numbers | ||||
|         key: primes | ||||
|  | ||||
|     - name: Generate Numbers | ||||
|       if: steps.cache-numbers.outputs.cache-hit != 'true' | ||||
|       run: ./generate-primes.sh -d numbers | ||||
|        | ||||
|    build-windows: | ||||
|       runs-on: windows-latest | ||||
|       steps: | ||||
|       - uses: actions/checkout@v3 | ||||
|  | ||||
|       - name: Cache Primes | ||||
|         id: cache-primes | ||||
|         uses: actions/cache@v3 | ||||
|         with: | ||||
|           path: prime-numbers | ||||
|           key: primes | ||||
|  | ||||
|       - name: Generate Prime Numbers | ||||
|         if: steps.cache-primes.outputs.cache-hit != 'true' | ||||
|         run: ./generate-primes -d prime-numbers | ||||
| ``` | ||||
|  | ||||
| ## 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. | ||||
|  | ||||
|  | ||||
| @ -6,12 +6,3 @@ | ||||
| ### 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)) | ||||
| @ -9,7 +9,7 @@ inputs: | ||||
|     description: 'An explicit key for restoring and saving the cache' | ||||
|     required: true | ||||
|   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.' | ||||
|     description: 'An ordered list of keys to use for restoring the cache if no cache hit occurred for key' | ||||
|     required: false | ||||
|   upload-chunk-size: | ||||
|     description: 'The chunk size used to split up large files during upload, in bytes' | ||||
|  | ||||
							
								
								
									
										1095
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1095
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1099
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1099
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										53
									
								
								examples.md
									
									
									
									
									
								
							
							
						
						
									
										53
									
								
								examples.md
									
									
									
									
									
								
							| @ -9,7 +9,6 @@ | ||||
|   - [macOS](#macos) | ||||
|   - [Windows](#windows-1) | ||||
| - [Elixir - Mix](#elixir---mix) | ||||
| - [Erlang - Rebar3](#erlang--rebar3) | ||||
| - [Go - Modules](#go---modules) | ||||
|   - [Linux](#linux-1) | ||||
|   - [macOS](#macos-1) | ||||
| @ -19,6 +18,9 @@ | ||||
| - [Java - Gradle](#java---gradle) | ||||
| - [Java - Maven](#java---maven) | ||||
| - [Node - npm](#node---npm) | ||||
|   - [macOS and Ubuntu](#macos-and-ubuntu) | ||||
|   - [Windows](#windows-3) | ||||
|   - [Using multiple systems and `npm config`](#using-multiple-systems-and-npm-config) | ||||
| - [Node - Lerna](#node---lerna) | ||||
| - [Node - Yarn](#node---yarn) | ||||
| - [Node - Yarn 2](#node---yarn-2) | ||||
| @ -88,7 +90,7 @@ steps: | ||||
| - uses: actions/cache@v3 | ||||
|   with: | ||||
|     path: ~/.dub | ||||
|     key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.selections.json') }} | ||||
|     key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.json') }} | ||||
|     restore-keys: | | ||||
|       ${{ runner.os }}-dub- | ||||
| ``` | ||||
| @ -99,7 +101,7 @@ steps: | ||||
| - uses: actions/cache@v3 | ||||
|   with: | ||||
|     path: ~\AppData\Local\dub | ||||
|     key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.selections.json') }} | ||||
|     key: ${{ runner.os }}-dub-${{ hashFiles('**/dub.json') }} | ||||
|     restore-keys: | | ||||
|       ${{ runner.os }}-dub- | ||||
| ``` | ||||
| @ -135,10 +137,11 @@ steps: | ||||
|   with: | ||||
|     path: | | ||||
|       ~\.deno | ||||
|       ~\AppData\Local\deno | ||||
|       %LocalAppData%\deno | ||||
|     key: ${{ runner.os }}-deno-${{ hashFiles('**/deps.ts') }} | ||||
| ``` | ||||
|  | ||||
|  | ||||
| ## Elixir - Mix | ||||
|  | ||||
| ```yaml | ||||
| @ -152,18 +155,6 @@ steps: | ||||
|       ${{ runner.os }}-mix- | ||||
| ``` | ||||
|  | ||||
| ## Erlang - Rebar3 | ||||
| ```yaml | ||||
| - uses: actions/cache@v2 | ||||
|   with: | ||||
|     path: | | ||||
|       ~/.cache/rebar3 | ||||
|       _build | ||||
|     key: ${{ runner.os }}-erlang-${{ env.OTP_VERSION }}-${{ hashFiles('**/*rebar.lock') }} | ||||
|     restore-keys: | | ||||
|       ${{ runner.os }}-erlang-${{ env.OTP_VERSION }}- | ||||
| ``` | ||||
|  | ||||
| ## Go - Modules | ||||
|  | ||||
| ### Linux | ||||
| @ -269,12 +260,40 @@ We cache the elements of the Cabal store separately, as the entirety of `~/.caba | ||||
|  | ||||
| ## Node - npm | ||||
|  | ||||
| For npm, cache files are stored in `~/.npm` on Posix, or `~\AppData\npm-cache` on Windows, but it's possible to use `npm config get cache` to find the path on any platform. See [the npm docs](https://docs.npmjs.com/cli/cache#cache) for more details. | ||||
| For npm, cache files are stored in `~/.npm` on Posix, or `%AppData%/npm-cache` on Windows. See https://docs.npmjs.com/cli/cache#cache | ||||
|  | ||||
| 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. | ||||
|  | ||||
| >Note: It is not recommended to cache `node_modules`, as it can break across Node versions and won't work with `npm ci` | ||||
|  | ||||
| ### macOS and Ubuntu | ||||
|  | ||||
| ```yaml | ||||
| - uses: actions/cache@v3 | ||||
|   with: | ||||
|     path: ~/.npm | ||||
|     key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||||
|     restore-keys: | | ||||
|       ${{ runner.os }}-node- | ||||
| ``` | ||||
|  | ||||
| ### Windows | ||||
|  | ||||
| ```yaml | ||||
| - name: Get npm cache directory | ||||
|   id: npm-cache | ||||
|   run: | | ||||
|     echo "::set-output name=dir::$(npm config get cache)" | ||||
| - uses: actions/cache@v3 | ||||
|   with: | ||||
|     path: ${{ steps.npm-cache.outputs.dir }} | ||||
|     key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||||
|     restore-keys: | | ||||
|       ${{ runner.os }}-node- | ||||
| ``` | ||||
|  | ||||
| ### Using multiple systems and `npm config` | ||||
|  | ||||
| ```yaml | ||||
| - name: Get npm cache directory | ||||
|   id: npm-cache-dir | ||||
|  | ||||
							
								
								
									
										13398
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										13398
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										30
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								package.json
									
									
									
									
									
								
							| @ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "cache", | ||||
|   "version": "3.0.4", | ||||
|   "version": "3.0.2", | ||||
|   "private": true, | ||||
|   "description": "Cache dependencies and build outputs", | ||||
|   "main": "dist/restore/index.js", | ||||
| @ -23,29 +23,29 @@ | ||||
|   "author": "GitHub", | ||||
|   "license": "MIT", | ||||
|   "dependencies": { | ||||
|     "@actions/cache": "^2.0.6", | ||||
|     "@actions/core": "^1.7.0", | ||||
|     "@actions/cache": "^2.0.2", | ||||
|     "@actions/core": "^1.2.6", | ||||
|     "@actions/exec": "^1.1.1", | ||||
|     "@actions/io": "^1.1.2" | ||||
|   }, | ||||
|   "devDependencies": { | ||||
|     "@types/jest": "^27.5.0", | ||||
|     "@types/jest": "^27.4.1", | ||||
|     "@types/nock": "^11.1.0", | ||||
|     "@types/node": "^16.11.33", | ||||
|     "@typescript-eslint/eslint-plugin": "^5.22.0", | ||||
|     "@typescript-eslint/parser": "^5.22.0", | ||||
|     "@types/node": "^16.11.26", | ||||
|     "@typescript-eslint/eslint-plugin": "^5.16.0", | ||||
|     "@typescript-eslint/parser": "^5.16.0", | ||||
|     "@zeit/ncc": "^0.20.5", | ||||
|     "eslint": "^8.14.0", | ||||
|     "eslint": "^8.11.0", | ||||
|     "eslint-config-prettier": "^8.5.0", | ||||
|     "eslint-plugin-import": "^2.26.0", | ||||
|     "eslint-plugin-jest": "^26.1.5", | ||||
|     "eslint-plugin-import": "^2.25.4", | ||||
|     "eslint-plugin-jest": "^26.1.3", | ||||
|     "eslint-plugin-prettier": "^4.0.0", | ||||
|     "eslint-plugin-simple-import-sort": "^7.0.0", | ||||
|     "jest": "^28.0.3", | ||||
|     "jest": "^27.5.1", | ||||
|     "jest-circus": "^27.5.1", | ||||
|     "nock": "^13.2.4", | ||||
|     "prettier": "^2.6.2", | ||||
|     "ts-jest": "^28.0.2", | ||||
|     "typescript": "^4.6.4" | ||||
|     "nock": "^11.7.0", | ||||
|     "prettier": "^2.6.1", | ||||
|     "ts-jest": "^27.1.4", | ||||
|     "typescript": "^3.9.9" | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -52,17 +52,16 @@ async function run(): Promise<void> { | ||||
|             utils.setCacheHitOutput(isExactKeyMatch); | ||||
|  | ||||
|             core.info(`Cache restored from key: ${cacheKey}`); | ||||
|         } catch (error: unknown) { | ||||
|             const typedError = error as Error; | ||||
|             if (typedError.name === cache.ValidationError.name) { | ||||
|         } catch (error) { | ||||
|             if (error.name === cache.ValidationError.name) { | ||||
|                 throw error; | ||||
|             } else { | ||||
|                 utils.logWarning(typedError.message); | ||||
|                 utils.logWarning(error.message); | ||||
|                 utils.setCacheHitOutput(false); | ||||
|             } | ||||
|         } | ||||
|     } catch (error: unknown) { | ||||
|         core.setFailed((error as Error).message); | ||||
|     } catch (error) { | ||||
|         core.setFailed(error.message); | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
							
								
								
									
										15
									
								
								src/save.ts
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								src/save.ts
									
									
									
									
									
								
							| @ -49,18 +49,17 @@ async function run(): Promise<void> { | ||||
|                 uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize) | ||||
|             }); | ||||
|             core.info(`Cache saved with key: ${primaryKey}`); | ||||
|         } catch (error: unknown) { | ||||
|             const typedError = error as Error; | ||||
|             if (typedError.name === cache.ValidationError.name) { | ||||
|         } catch (error) { | ||||
|             if (error.name === cache.ValidationError.name) { | ||||
|                 throw error; | ||||
|             } else if (typedError.name === cache.ReserveCacheError.name) { | ||||
|                 core.info(typedError.message); | ||||
|             } else if (error.name === cache.ReserveCacheError.name) { | ||||
|                 core.info(error.message); | ||||
|             } else { | ||||
|                 utils.logWarning(typedError.message); | ||||
|                 utils.logWarning(error.message); | ||||
|             } | ||||
|         } | ||||
|     } catch (error: unknown) { | ||||
|         utils.logWarning((error as Error).message); | ||||
|     } catch (error) { | ||||
|         utils.logWarning(error.message); | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	