mirror of
				https://github.com/actions/cache.git
				synced 2025-10-31 07:16:24 +07:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			test-fast
			...
			enableForG
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 5c0fd51138 | |||
| 8bcf0245bb | 
| @ -9,14 +9,15 @@ | |||||||
|     "plugin:import/errors", |     "plugin:import/errors", | ||||||
|     "plugin:import/warnings", |     "plugin:import/warnings", | ||||||
|     "plugin:import/typescript", |     "plugin:import/typescript", | ||||||
|     "plugin:prettier/recommended" |     "plugin:prettier/recommended", | ||||||
|  |     "prettier/@typescript-eslint" | ||||||
|   ], |   ], | ||||||
|   "plugins": ["@typescript-eslint", "simple-import-sort", "jest"], |   "plugins": ["@typescript-eslint", "simple-import-sort", "jest"], | ||||||
|   "rules": { |   "rules": { | ||||||
|     "import/first": "error", |     "import/first": "error", | ||||||
|     "import/newline-after-import": "error", |     "import/newline-after-import": "error", | ||||||
|     "import/no-duplicates": "error", |     "import/no-duplicates": "error", | ||||||
|     "simple-import-sort/imports": "error", |     "simple-import-sort/sort": "error", | ||||||
|     "sort-imports": "off" |     "sort-imports": "off" | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							| @ -1,2 +1 @@ | |||||||
| .licenses/** -diff linguist-generated=true | .licenses/** -diff linguist-generated=true | ||||||
| * text=auto eol=lf |  | ||||||
							
								
								
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | |||||||
| --- | --- | ||||||
| name: "@actions/cache" | name: "@actions/cache" | ||||||
| version: 1.0.9 | version: 1.0.8 | ||||||
| type: npm | type: npm | ||||||
| summary: Actions cache lib | summary: Actions cache lib | ||||||
| homepage: https://github.com/actions/toolkit/tree/main/packages/cache | homepage: https://github.com/actions/toolkit/tree/main/packages/cache | ||||||
|  | |||||||
							
								
								
									
										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" | name: "@azure/core-http" | ||||||
| version: 2.2.4 | version: 2.2.2 | ||||||
| type: npm | type: npm | ||||||
| summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client | summary: Isomorphic client Runtime for Typescript/node.js/browser javascript client | ||||||
|   libraries generated using AutoRest |   libraries generated using AutoRest | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								.licenses/npm/@azure/core-lro.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@azure/core-lro.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | |||||||
| --- | --- | ||||||
| name: "@azure/core-lro" | name: "@azure/core-lro" | ||||||
| version: 2.2.3 | version: 2.2.1 | ||||||
| type: npm | type: npm | ||||||
| summary: Isomorphic client library for supporting long-running operations in node.js | summary: Isomorphic client library for supporting long-running operations in node.js | ||||||
|   and browser. |   and browser. | ||||||
|  | |||||||
							
								
								
									
										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" | name: "@azure/core-paging" | ||||||
| version: 1.2.1 | version: 1.2.0 | ||||||
| type: npm | type: npm | ||||||
| summary: Core types for paging async iterable iterators | 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 | homepage: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/core-paging/README.md | ||||||
|  | |||||||
							
								
								
									
										6
									
								
								.licenses/npm/@opentelemetry/api.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								.licenses/npm/@opentelemetry/api.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | |||||||
| --- | --- | ||||||
| name: "@opentelemetry/api" | name: "@opentelemetry/api" | ||||||
| version: 1.0.4 | version: 1.0.3 | ||||||
| type: npm | type: npm | ||||||
| summary: Public API for OpenTelemetry | summary: Public API for OpenTelemetry | ||||||
| homepage: https://github.com/open-telemetry/opentelemetry-js-api#readme | homepage: https://github.com/open-telemetry/opentelemetry-js-api#readme | ||||||
| @ -218,6 +218,10 @@ licenses: | |||||||
|     [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions |     [discussions-url]: https://github.com/open-telemetry/opentelemetry-js/discussions | ||||||
|     [license-url]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/LICENSE |     [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 |     [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-url]: https://www.npmjs.com/package/@opentelemetry/api | ||||||
|     [npm-img]: https://badge.fury.io/js/%40opentelemetry%2Fapi.svg |     [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 |     [docs-tracing]: https://github.com/open-telemetry/opentelemetry-js-api/blob/main/docs/tracing.md | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								.licenses/npm/@types/node.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@types/node.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | |||||||
| --- | --- | ||||||
| name: "@types/node" | name: "@types/node" | ||||||
| version: 12.20.42 | version: 12.20.37 | ||||||
| type: npm | type: npm | ||||||
| summary: TypeScript definitions for Node.js | summary: TypeScript definitions for Node.js | ||||||
| homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node | homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node | ||||||
|  | |||||||
							
								
								
									
										2
									
								
								.licenses/npm/node-fetch.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/node-fetch.dep.yml
									
									
									
										generated
									
									
									
								
							| @ -1,6 +1,6 @@ | |||||||
| --- | --- | ||||||
| name: node-fetch | name: node-fetch | ||||||
| version: 2.6.7 | version: 2.6.6 | ||||||
| type: npm | type: npm | ||||||
| summary: A light-weight module that brings window.fetch to node.js | summary: A light-weight module that brings window.fetch to node.js | ||||||
| homepage: https://github.com/bitinn/node-fetch | homepage: https://github.com/bitinn/node-fetch | ||||||
|  | |||||||
| @ -34,8 +34,6 @@ Refer [here](https://github.com/actions/cache/blob/v1/README.md) for previous ve | |||||||
| ### Pre-requisites | ### 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). | 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 | ### 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.  | ||||||
|  | |||||||
| @ -17,24 +17,6 @@ afterEach(() => { | |||||||
|     delete process.env[RefKey]; |     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", () => { | test("isExactKeyMatch with undefined cache key returns false", () => { | ||||||
|     const key = "linux-rust"; |     const key = "linux-rust"; | ||||||
|     const cacheKey = undefined; |     const cacheKey = undefined; | ||||||
|  | |||||||
| @ -32,8 +32,6 @@ beforeAll(() => { | |||||||
| beforeEach(() => { | beforeEach(() => { | ||||||
|     process.env[Events.Key] = Events.Push; |     process.env[Events.Key] = Events.Push; | ||||||
|     process.env[RefKey] = "refs/heads/feature-branch"; |     process.env[RefKey] = "refs/heads/feature-branch"; | ||||||
|  |  | ||||||
|     jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false); |  | ||||||
| }); | }); | ||||||
|  |  | ||||||
| afterEach(() => { | afterEach(() => { | ||||||
| @ -55,23 +53,6 @@ test("restore with invalid event outputs warning", async () => { | |||||||
|     expect(failedMock).toHaveBeenCalledTimes(0); |     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 () => { | test("restore with no path should fail", async () => { | ||||||
|     const failedMock = jest.spyOn(core, "setFailed"); |     const failedMock = jest.spyOn(core, "setFailed"); | ||||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); |     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||||
|  | |||||||
| @ -52,8 +52,6 @@ beforeAll(() => { | |||||||
| beforeEach(() => { | beforeEach(() => { | ||||||
|     process.env[Events.Key] = Events.Push; |     process.env[Events.Key] = Events.Push; | ||||||
|     process.env[RefKey] = "refs/heads/feature-branch"; |     process.env[RefKey] = "refs/heads/feature-branch"; | ||||||
|  |  | ||||||
|     jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false); |  | ||||||
| }); | }); | ||||||
|  |  | ||||||
| afterEach(() => { | afterEach(() => { | ||||||
| @ -101,20 +99,6 @@ test("save with no primary key in state outputs warning", async () => { | |||||||
|     expect(failedMock).toHaveBeenCalledTimes(0); |     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 () => { | test("save with exact match returns early", async () => { | ||||||
|     const infoMock = jest.spyOn(core, "info"); |     const infoMock = jest.spyOn(core, "info"); | ||||||
|     const failedMock = jest.spyOn(core, "setFailed"); |     const failedMock = jest.spyOn(core, "setFailed"); | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										2807
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2807
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										2806
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2806
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -17,7 +17,7 @@ const processStdoutWrite = process.stdout.write.bind(process.stdout); | |||||||
| process.stdout.write = (str, encoding, cb) => { | process.stdout.write = (str, encoding, cb) => { | ||||||
|     // Core library will directly call process.stdout.write for commands |     // Core library will directly call process.stdout.write for commands | ||||||
|     // We don't want :: commands to be executed by the runner during tests |     // 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); |         return processStdoutWrite(str, encoding, cb); | ||||||
|     } |     } | ||||||
| }; | }; | ||||||
|  | |||||||
							
								
								
									
										8722
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										8722
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										30
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										30
									
								
								package.json
									
									
									
									
									
								
							| @ -23,29 +23,29 @@ | |||||||
|   "author": "GitHub", |   "author": "GitHub", | ||||||
|   "license": "MIT", |   "license": "MIT", | ||||||
|   "dependencies": { |   "dependencies": { | ||||||
|     "@actions/cache": "file:actions-cache-1.0.9.tgz", |     "@actions/cache": "^1.0.8", | ||||||
|     "@actions/core": "^1.2.6", |     "@actions/core": "^1.2.6", | ||||||
|     "@actions/exec": "^1.0.1", |     "@actions/exec": "^1.0.1", | ||||||
|     "@actions/io": "^1.1.0" |     "@actions/io": "^1.1.0" | ||||||
|   }, |   }, | ||||||
|   "devDependencies": { |   "devDependencies": { | ||||||
|     "@types/jest": "^27.4.0", |     "@types/jest": "^24.0.13", | ||||||
|     "@types/nock": "^11.1.0", |     "@types/nock": "^11.1.0", | ||||||
|     "@types/node": "^12.20.42", |     "@types/node": "^12.20.7", | ||||||
|     "@typescript-eslint/eslint-plugin": "^5.10.1", |     "@typescript-eslint/eslint-plugin": "^2.7.0", | ||||||
|     "@typescript-eslint/parser": "^5.10.1", |     "@typescript-eslint/parser": "^2.7.0", | ||||||
|     "@zeit/ncc": "^0.20.5", |     "@zeit/ncc": "^0.20.5", | ||||||
|     "eslint": "^8.8.0", |     "eslint": "^6.6.0", | ||||||
|     "eslint-config-prettier": "^8.3.0", |     "eslint-config-prettier": "^6.15.0", | ||||||
|     "eslint-plugin-import": "^2.25.4", |     "eslint-plugin-import": "^2.22.1", | ||||||
|     "eslint-plugin-jest": "^26.0.0", |     "eslint-plugin-jest": "^23.20.0", | ||||||
|     "eslint-plugin-prettier": "^4.0.0", |     "eslint-plugin-prettier": "^3.3.1", | ||||||
|     "eslint-plugin-simple-import-sort": "^7.0.0", |     "eslint-plugin-simple-import-sort": "^5.0.2", | ||||||
|     "jest": "^27.4.7", |     "jest": "^24.8.0", | ||||||
|     "jest-circus": "^27.4.6", |     "jest-circus": "^24.7.1", | ||||||
|     "nock": "^11.7.0", |     "nock": "^11.7.0", | ||||||
|     "prettier": "^2.5.1", |     "prettier": "^1.19.1", | ||||||
|     "ts-jest": "^27.1.3", |     "ts-jest": "^26.5.4", | ||||||
|     "typescript": "^3.9.9" |     "typescript": "^3.9.9" | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  | |||||||
| @ -6,14 +6,6 @@ import * as utils from "./utils/actionUtils"; | |||||||
|  |  | ||||||
| async function run(): Promise<void> { | async function run(): Promise<void> { | ||||||
|     try { |     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 |         // Validate inputs, this can cause task failure | ||||||
|         if (!utils.isValidEvent()) { |         if (!utils.isValidEvent()) { | ||||||
|             utils.logWarning( |             utils.logWarning( | ||||||
|  | |||||||
| @ -11,13 +11,6 @@ process.on("uncaughtException", e => utils.logWarning(e.message)); | |||||||
|  |  | ||||||
| async function run(): Promise<void> { | async function run(): Promise<void> { | ||||||
|     try { |     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()) { |         if (!utils.isValidEvent()) { | ||||||
|             utils.logWarning( |             utils.logWarning( | ||||||
|                 `Event Validation Error: The event type ${ |                 `Event Validation Error: The event type ${ | ||||||
|  | |||||||
| @ -2,13 +2,6 @@ import * as core from "@actions/core"; | |||||||
|  |  | ||||||
| import { Outputs, RefKey, State } from "../constants"; | 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 { | export function isExactKeyMatch(key: string, cacheKey?: string): boolean { | ||||||
|     return !!( |     return !!( | ||||||
|         cacheKey && |         cacheKey && | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	