mirror of
				https://gitea.com/actions/cache.git
				synced 2025-10-29 07:47:12 +00:00 
			
		
		
		
	Compare commits
	
		
			107 Commits
		
	
	
		
			phantsure/
			...
			releases/v
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 64a59d5b55 | ||
|   | b388bcadaf | ||
|   | f9ae5e0028 | ||
|   | 34faf3ad7c | ||
|   | 1d114a8000 | ||
|   | 8955114d15 | ||
|   | 3f0eaf4956 | ||
|   | 770b3a8151 | ||
|   | ed5e94a5f5 | ||
|   | 6277f55919 | ||
|   | c30e6dcb11 | ||
|   | 05c9b49ea4 | ||
|   | da311f75a6 | ||
|   | 7a139a9cec | ||
|   | 930f080bad | ||
|   | 56e956426f | ||
|   | 766d8255cd | ||
|   | 686bf424a8 | ||
|   | fb5b333162 | ||
|   | c11ac6c2fe | ||
|   | d5c949690c | ||
|   | 44df5ab77e | ||
|   | 65057ce6fe | ||
|   | 8031e403b4 | ||
|   | c8d01facfc | ||
|   | 81aaae062b | ||
|   | 9d445b2565 | ||
|   | adecab4b4a | ||
|   | 075ad790b0 | ||
|   | b275c83bd6 | ||
|   | 1ddc49105d | ||
|   | 407044787b | ||
|   | 87a7d01109 | ||
|   | 29d6c7aa7f | ||
|   | df53d3c04b | ||
|   | dd740c87de | ||
|   | 0a6e5b052a | ||
|   | a2137c625c | ||
|   | 5a2b5e5714 | ||
|   | 9e9a19bf5f | ||
|   | 84ea3e177d | ||
|   | 00b72c7e02 | ||
|   | 0cc9c1d4e8 | ||
|   | ccf90c02ed | ||
|   | 4f42dc56c1 | ||
|   | b6604364ae | ||
|   | c0cc8dd60a | ||
|   | 91d7bd61be | ||
|   | 5e7f2c1182 | ||
|   | 3d4af52c52 | ||
|   | d91f5bd2fd | ||
|   | 61aa90bfc3 | ||
|   | 0c2d18e609 | ||
|   | 804322aab0 | ||
|   | f426a0deb2 | ||
|   | be72d0432d | ||
|   | 8ecd00a4be | ||
|   | 12a1a354bd | ||
|   | 782b0bd3df | ||
|   | f33ca902b8 | ||
|   | d48d03435b | ||
|   | 6f77edac15 | ||
|   | 6e12d27152 | ||
|   | c346bf01e0 | ||
|   | 593e91a38b | ||
|   | e4c2242eff | ||
|   | 66ef8a0951 | ||
|   | 657c52f11e | ||
|   | 34e917cb7d | ||
|   | ac8fc97c06 | ||
|   | 86712a0733 | ||
|   | d6e98d9302 | ||
|   | a76826ef46 | ||
|   | e02e5113ed | ||
|   | 85ae5bbcea | ||
|   | cce93fb2c7 | ||
|   | e3d8fb0b34 | ||
|   | 020a412c27 | ||
|   | d95c048983 | ||
|   | 706c369cf1 | ||
|   | 11ab7ccfa2 | ||
|   | 4b5f33df54 | ||
|   | 56a0133650 | ||
|   | 19446b165a | ||
|   | 8a88690a20 | ||
|   | 6e2c6a5916 | ||
|   | 2c9fb32186 | ||
|   | 01d96636a0 | ||
|   | 9c5a42a7c9 | ||
|   | a172494938 | ||
|   | f8717682fb | ||
|   | af1210e2a3 | ||
|   | ab0e7714ce | ||
|   | fb4a5dce60 | ||
|   | 71334c58b2 | ||
|   | 888d454557 | ||
|   | dddd7ce07c | ||
|   | abddc4dd44 | ||
|   | 921c58ee44 | ||
|   | 7f45813c72 | ||
|   | 0769f2e443 | ||
|   | 5fe0b944ef | ||
|   | 69b8227b27 | ||
|   | 515d10b4fd | ||
|   | 669e7536d9 | ||
|   | 29dbbce762 | ||
|   | ea5981db97 | 
							
								
								
									
										40
									
								
								.github/workflows/codeql.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										40
									
								
								.github/workflows/codeql.yml
									
									
									
									
										vendored
									
									
								
							| @@ -8,39 +8,45 @@ on: | ||||
|  | ||||
| jobs: | ||||
|   CodeQL-Build: | ||||
|     # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest | ||||
|     runs-on: ubuntu-latest | ||||
|  | ||||
|     permissions: | ||||
|       # required for all workflows | ||||
|       security-events: write | ||||
|     # CodeQL runs on ubuntu-latest and windows-latest | ||||
|     runs-on: ubuntu-latest | ||||
|  | ||||
|     steps: | ||||
|     - name: Checkout repository | ||||
|       uses: actions/checkout@v3 | ||||
|       with: | ||||
|         # We must fetch at least the immediate parents so that if this is | ||||
|         # a pull request then we can checkout the head. | ||||
|         fetch-depth: 2 | ||||
|  | ||||
|     # If this run was triggered by a pull request event, then checkout | ||||
|     # the head of the pull request instead of the merge commit. | ||||
|     - run: git checkout HEAD^2 | ||||
|       if: ${{ github.event_name == 'pull_request' }} | ||||
|  | ||||
|     # Initializes the CodeQL tools for scanning. | ||||
|     - name: Initialize CodeQL | ||||
|       uses: github/codeql-action/init@v2 | ||||
|       uses: github/codeql-action/init@v1 | ||||
|       # Override language selection by uncommenting this and choosing your languages | ||||
|       # with: | ||||
|       #   languages: go, javascript, csharp, python, cpp, java, ruby | ||||
|       #   languages: go, javascript, csharp, python, cpp, java | ||||
|  | ||||
|     # Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java). | ||||
|     # If this step fails, then you should remove it and run the build manually (see below). | ||||
|     # Autobuild attempts to build any compiled languages  (C/C++, C#, or Java). | ||||
|     # If this step fails, then you should remove it and run the build manually (see below) | ||||
|     - name: Autobuild | ||||
|       uses: github/codeql-action/autobuild@v2 | ||||
|       uses: github/codeql-action/autobuild@v1 | ||||
|  | ||||
|     # ℹ️ Command-line programs to run using the OS shell. | ||||
|     # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun | ||||
|     # 📚 https://git.io/JvXDl | ||||
|  | ||||
|     # ✏️ If the Autobuild fails above, remove it and uncomment the following | ||||
|     #    three lines and modify them (or add more) to build your code if your | ||||
|     #    project uses a compiled language | ||||
|     # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines | ||||
|     #    and modify them (or add more) to build your code if your project | ||||
|     #    uses a compiled language | ||||
|  | ||||
|     #- run: | | ||||
|     #     make bootstrap | ||||
|     #     make release | ||||
|     #   make bootstrap | ||||
|     #   make release | ||||
|  | ||||
|     - name: Perform CodeQL Analysis | ||||
|       uses: github/codeql-action/analyze@v2 | ||||
|       uses: github/codeql-action/analyze@v1 | ||||
|   | ||||
							
								
								
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								.licenses/npm/@actions/cache.dep.yml
									
									
									
										generated
									
									
									
								
							| @@ -1,6 +1,6 @@ | ||||
| --- | ||||
| name: "@actions/cache" | ||||
| version: 3.1.2 | ||||
| version: 3.0.5 | ||||
| type: npm | ||||
| summary: | ||||
| homepage: | ||||
|   | ||||
| @@ -27,7 +27,6 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac | ||||
| * Fixed the download stuck problem by introducing a timeout of 1 hour for cache downloads. | ||||
| * Fix zstd not working for windows on gnu tar in issues. | ||||
| * Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes. | ||||
| * Two new actions available for granular control over caches - [restore](restore/action.yml) and [save](save/action.yml) | ||||
|  | ||||
| Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions | ||||
|  | ||||
| @@ -45,7 +44,7 @@ If you are using this inside a container, a POSIX-compliant `tar` needs to be in | ||||
| * `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key. | ||||
|  | ||||
| #### Environment Variables | ||||
| * `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](https://github.com/actions/cache/blob/main/tips-and-workarounds.md#cache-segment-restore-timeout) | ||||
| * `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](https://github.com/actions/cache/blob/main/workarounds.md#cache-segment-restore-timeout) | ||||
|  | ||||
| ### Outputs | ||||
|  | ||||
| @@ -121,7 +120,6 @@ See [Examples](examples.md) for a list of `actions/cache` implementations for us | ||||
| - [Swift, Objective-C - Carthage](./examples.md#swift-objective-c---carthage) | ||||
| - [Swift, Objective-C - CocoaPods](./examples.md#swift-objective-c---cocoapods) | ||||
| - [Swift - Swift Package Manager](./examples.md#swift---swift-package-manager) | ||||
| - [Swift - Mint](./examples.md#swift---mint) | ||||
|  | ||||
| ## Creating a cache key | ||||
|  | ||||
|   | ||||
							
								
								
									
										11
									
								
								RELEASES.md
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								RELEASES.md
									
									
									
									
									
								
							| @@ -52,14 +52,3 @@ | ||||
|  | ||||
| ### 3.2.0-beta.1 | ||||
| - Added two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache. | ||||
|  | ||||
| ### 3.2.0 | ||||
| - Released the two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache | ||||
|  | ||||
| ### 3.2.1 | ||||
| - Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984)) | ||||
| - Added support for fallback to gzip to restore old caches on windows. | ||||
| - Added logs for cache version in case of a cache miss. | ||||
|  | ||||
| ### 3.2.2 | ||||
| - Reverted the changes made in 3.2.1 to use gnu tar and zstd by default on windows. | ||||
| @@ -174,26 +174,6 @@ test("getInputAsInt throws if required and value missing", () => { | ||||
|     ).toThrowError(); | ||||
| }); | ||||
|  | ||||
| test("getInputAsBool returns false if input not set", () => { | ||||
|     expect(actionUtils.getInputAsBool("undefined")).toBe(false); | ||||
| }); | ||||
|  | ||||
| test("getInputAsBool returns value if input is valid", () => { | ||||
|     testUtils.setInput("foo", "true"); | ||||
|     expect(actionUtils.getInputAsBool("foo")).toBe(true); | ||||
| }); | ||||
|  | ||||
| test("getInputAsBool returns false if input is invalid or NaN", () => { | ||||
|     testUtils.setInput("foo", "bar"); | ||||
|     expect(actionUtils.getInputAsBool("foo")).toBe(false); | ||||
| }); | ||||
|  | ||||
| test("getInputAsBool throws if required and value missing", () => { | ||||
|     expect(() => | ||||
|         actionUtils.getInputAsBool("undefined2", { required: true }) | ||||
|     ).toThrowError(); | ||||
| }); | ||||
|  | ||||
| test("isCacheFeatureAvailable for ac enabled", () => { | ||||
|     jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => true); | ||||
|  | ||||
|   | ||||
| @@ -27,17 +27,9 @@ beforeAll(() => { | ||||
|             return actualUtils.getInputAsArray(name, options); | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     jest.spyOn(actionUtils, "getInputAsBool").mockImplementation( | ||||
|         (name, options) => { | ||||
|             const actualUtils = jest.requireActual("../src/utils/actionUtils"); | ||||
|             return actualUtils.getInputAsBool(name, options); | ||||
|         } | ||||
|     ); | ||||
| }); | ||||
|  | ||||
| beforeEach(() => { | ||||
|     jest.restoreAllMocks(); | ||||
|     process.env[Events.Key] = Events.Push; | ||||
|     process.env[RefKey] = "refs/heads/feature-branch"; | ||||
|  | ||||
| @@ -58,8 +50,7 @@ test("restore with no cache found", async () => { | ||||
|     const key = "node-test"; | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|         key | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -74,7 +65,7 @@ test("restore with no cache found", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|  | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); | ||||
|     expect(stateMock).toHaveBeenCalledTimes(1); | ||||
| @@ -93,8 +84,7 @@ test("restore with restore keys and no cache found", async () => { | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         restoreKeys: [restoreKey], | ||||
|         enableCrossOsArchive: false | ||||
|         restoreKeys: [restoreKey] | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -109,13 +99,7 @@ test("restore with restore keys and no cache found", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
|         key, | ||||
|         [restoreKey], | ||||
|         {}, | ||||
|         false | ||||
|     ); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]); | ||||
|  | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); | ||||
|     expect(stateMock).toHaveBeenCalledTimes(1); | ||||
| @@ -132,8 +116,7 @@ test("restore with cache found for key", async () => { | ||||
|     const key = "node-test"; | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|         key | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -149,7 +132,7 @@ test("restore with cache found for key", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|  | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key); | ||||
| @@ -169,8 +152,7 @@ test("restore with cache found for restore key", async () => { | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         restoreKeys: [restoreKey], | ||||
|         enableCrossOsArchive: false | ||||
|         restoreKeys: [restoreKey] | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -186,13 +168,7 @@ test("restore with cache found for restore key", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
|         key, | ||||
|         [restoreKey], | ||||
|         {}, | ||||
|         false | ||||
|     ); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]); | ||||
|  | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey); | ||||
|   | ||||
| @@ -28,17 +28,9 @@ beforeAll(() => { | ||||
|             return actualUtils.getInputAsArray(name, options); | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     jest.spyOn(actionUtils, "getInputAsBool").mockImplementation( | ||||
|         (name, options) => { | ||||
|             const actualUtils = jest.requireActual("../src/utils/actionUtils"); | ||||
|             return actualUtils.getInputAsBool(name, options); | ||||
|         } | ||||
|     ); | ||||
| }); | ||||
|  | ||||
| beforeEach(() => { | ||||
|     jest.restoreAllMocks(); | ||||
|     process.env[Events.Key] = Events.Push; | ||||
|     process.env[RefKey] = "refs/heads/feature-branch"; | ||||
|  | ||||
| @@ -105,8 +97,7 @@ test("restore on GHES with AC available ", async () => { | ||||
|     const key = "node-test"; | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|         key | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -122,7 +113,7 @@ test("restore on GHES with AC available ", async () => { | ||||
|     await run(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|  | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); | ||||
|     expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); | ||||
| @@ -161,20 +152,13 @@ test("restore with too many keys should fail", async () => { | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         restoreKeys, | ||||
|         enableCrossOsArchive: false | ||||
|         restoreKeys | ||||
|     }); | ||||
|     const failedMock = jest.spyOn(core, "setFailed"); | ||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||
|     await run(new StateProvider()); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
|         key, | ||||
|         restoreKeys, | ||||
|         {}, | ||||
|         false | ||||
|     ); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, restoreKeys); | ||||
|     expect(failedMock).toHaveBeenCalledWith( | ||||
|         `Key Validation Error: Keys are limited to a maximum of 10.` | ||||
|     ); | ||||
| @@ -185,14 +169,13 @@ test("restore with large key should fail", async () => { | ||||
|     const key = "foo".repeat(512); // Over the 512 character limit | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|         key | ||||
|     }); | ||||
|     const failedMock = jest.spyOn(core, "setFailed"); | ||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||
|     await run(new StateProvider()); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|     expect(failedMock).toHaveBeenCalledWith( | ||||
|         `Key Validation Error: ${key} cannot be larger than 512 characters.` | ||||
|     ); | ||||
| @@ -203,14 +186,13 @@ test("restore with invalid key should fail", async () => { | ||||
|     const key = "comma,comma"; | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|         key | ||||
|     }); | ||||
|     const failedMock = jest.spyOn(core, "setFailed"); | ||||
|     const restoreCacheMock = jest.spyOn(cache, "restoreCache"); | ||||
|     await run(new StateProvider()); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|     expect(failedMock).toHaveBeenCalledWith( | ||||
|         `Key Validation Error: ${key} cannot contain commas.` | ||||
|     ); | ||||
| @@ -221,8 +203,7 @@ test("restore with no cache found", async () => { | ||||
|     const key = "node-test"; | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|         key | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -237,7 +218,7 @@ test("restore with no cache found", async () => { | ||||
|     await run(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|  | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); | ||||
|     expect(failedMock).toHaveBeenCalledTimes(0); | ||||
| @@ -254,8 +235,7 @@ test("restore with restore keys and no cache found", async () => { | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         restoreKeys: [restoreKey], | ||||
|         enableCrossOsArchive: false | ||||
|         restoreKeys: [restoreKey] | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -270,13 +250,7 @@ test("restore with restore keys and no cache found", async () => { | ||||
|     await run(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
|         key, | ||||
|         [restoreKey], | ||||
|         {}, | ||||
|         false | ||||
|     ); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]); | ||||
|  | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); | ||||
|     expect(failedMock).toHaveBeenCalledTimes(0); | ||||
| @@ -291,8 +265,7 @@ test("restore with cache found for key", async () => { | ||||
|     const key = "node-test"; | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|         key | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -308,7 +281,7 @@ test("restore with cache found for key", async () => { | ||||
|     await run(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|  | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); | ||||
|     expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); | ||||
| @@ -325,8 +298,7 @@ test("restore with cache found for restore key", async () => { | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         restoreKeys: [restoreKey], | ||||
|         enableCrossOsArchive: false | ||||
|         restoreKeys: [restoreKey] | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -342,13 +314,7 @@ test("restore with cache found for restore key", async () => { | ||||
|     await run(new StateProvider()); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
|         key, | ||||
|         [restoreKey], | ||||
|         {}, | ||||
|         false | ||||
|     ); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]); | ||||
|  | ||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); | ||||
|     expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); | ||||
|   | ||||
| @@ -27,18 +27,9 @@ beforeAll(() => { | ||||
|             return actualUtils.getInputAsArray(name, options); | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     jest.spyOn(actionUtils, "getInputAsBool").mockImplementation( | ||||
|         (name, options) => { | ||||
|             return jest | ||||
|                 .requireActual("../src/utils/actionUtils") | ||||
|                 .getInputAsBool(name, options); | ||||
|         } | ||||
|     ); | ||||
| }); | ||||
|  | ||||
| beforeEach(() => { | ||||
|     jest.restoreAllMocks(); | ||||
|     process.env[Events.Key] = Events.Push; | ||||
|     process.env[RefKey] = "refs/heads/feature-branch"; | ||||
|  | ||||
| @@ -59,8 +50,7 @@ test("restore with no cache found", async () => { | ||||
|     const key = "node-test"; | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|         key | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -75,7 +65,7 @@ test("restore with no cache found", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|  | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); | ||||
|     expect(outputMock).toHaveBeenCalledTimes(1); | ||||
| @@ -93,8 +83,7 @@ test("restore with restore keys and no cache found", async () => { | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         restoreKeys: [restoreKey], | ||||
|         enableCrossOsArchive: false | ||||
|         restoreKeys: [restoreKey] | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -109,13 +98,7 @@ test("restore with restore keys and no cache found", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
|         key, | ||||
|         [restoreKey], | ||||
|         {}, | ||||
|         false | ||||
|     ); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]); | ||||
|  | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); | ||||
|     expect(failedMock).toHaveBeenCalledTimes(0); | ||||
| @@ -130,8 +113,7 @@ test("restore with cache found for key", async () => { | ||||
|     const key = "node-test"; | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         enableCrossOsArchive: false | ||||
|         key | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -146,7 +128,7 @@ test("restore with cache found for key", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [], {}, false); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []); | ||||
|  | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-hit", "true"); | ||||
| @@ -165,8 +147,7 @@ test("restore with cache found for restore key", async () => { | ||||
|     testUtils.setInputs({ | ||||
|         path: path, | ||||
|         key, | ||||
|         restoreKeys: [restoreKey], | ||||
|         enableCrossOsArchive: false | ||||
|         restoreKeys: [restoreKey] | ||||
|     }); | ||||
|  | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| @@ -181,13 +162,7 @@ test("restore with cache found for restore key", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(restoreCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith( | ||||
|         [path], | ||||
|         key, | ||||
|         [restoreKey], | ||||
|         {}, | ||||
|         false | ||||
|     ); | ||||
|     expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]); | ||||
|  | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); | ||||
|     expect(outputMock).toHaveBeenCalledWith("cache-hit", "false"); | ||||
|   | ||||
| @@ -35,14 +35,6 @@ beforeAll(() => { | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     jest.spyOn(actionUtils, "getInputAsBool").mockImplementation( | ||||
|         (name, options) => { | ||||
|             return jest | ||||
|                 .requireActual("../src/utils/actionUtils") | ||||
|                 .getInputAsBool(name, options); | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation( | ||||
|         (key, cacheResult) => { | ||||
|             return jest | ||||
| @@ -103,14 +95,9 @@ test("save with valid inputs uploads a cache", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|         [inputPath], | ||||
|         primaryKey, | ||||
|         { | ||||
|             uploadChunkSize: 4000000 | ||||
|         }, | ||||
|         false | ||||
|     ); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, { | ||||
|         uploadChunkSize: 4000000 | ||||
|     }); | ||||
|  | ||||
|     expect(failedMock).toHaveBeenCalledTimes(0); | ||||
| }); | ||||
|   | ||||
| @@ -32,14 +32,6 @@ beforeAll(() => { | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     jest.spyOn(actionUtils, "getInputAsBool").mockImplementation( | ||||
|         (name, options) => { | ||||
|             return jest | ||||
|                 .requireActual("../src/utils/actionUtils") | ||||
|                 .getInputAsBool(name, options); | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation( | ||||
|         (key, cacheResult) => { | ||||
|             return jest | ||||
| @@ -55,7 +47,6 @@ beforeAll(() => { | ||||
| }); | ||||
|  | ||||
| beforeEach(() => { | ||||
|     jest.restoreAllMocks(); | ||||
|     process.env[Events.Key] = Events.Push; | ||||
|     process.env[RefKey] = "refs/heads/feature-branch"; | ||||
|  | ||||
| @@ -164,14 +155,9 @@ test("save on GHES with AC available", async () => { | ||||
|     await run(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|         [inputPath], | ||||
|         primaryKey, | ||||
|         { | ||||
|             uploadChunkSize: 4000000 | ||||
|         }, | ||||
|         false | ||||
|     ); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, { | ||||
|         uploadChunkSize: 4000000 | ||||
|     }); | ||||
|  | ||||
|     expect(failedMock).toHaveBeenCalledTimes(0); | ||||
| }); | ||||
| @@ -265,8 +251,7 @@ test("save with large cache outputs warning", async () => { | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|         [inputPath], | ||||
|         primaryKey, | ||||
|         expect.anything(), | ||||
|         false | ||||
|         expect.anything() | ||||
|     ); | ||||
|  | ||||
|     expect(logWarningMock).toHaveBeenCalledTimes(1); | ||||
| @@ -312,8 +297,7 @@ test("save with reserve cache failure outputs warning", async () => { | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|         [inputPath], | ||||
|         primaryKey, | ||||
|         expect.anything(), | ||||
|         false | ||||
|         expect.anything() | ||||
|     ); | ||||
|  | ||||
|     expect(logWarningMock).toHaveBeenCalledWith( | ||||
| @@ -355,8 +339,7 @@ test("save with server error outputs warning", async () => { | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|         [inputPath], | ||||
|         primaryKey, | ||||
|         expect.anything(), | ||||
|         false | ||||
|         expect.anything() | ||||
|     ); | ||||
|  | ||||
|     expect(logWarningMock).toHaveBeenCalledTimes(1); | ||||
| @@ -395,14 +378,9 @@ test("save with valid inputs uploads a cache", async () => { | ||||
|     await run(new StateProvider()); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|         [inputPath], | ||||
|         primaryKey, | ||||
|         { | ||||
|             uploadChunkSize: 4000000 | ||||
|         }, | ||||
|         false | ||||
|     ); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, { | ||||
|         uploadChunkSize: 4000000 | ||||
|     }); | ||||
|  | ||||
|     expect(failedMock).toHaveBeenCalledTimes(0); | ||||
| }); | ||||
|   | ||||
| @@ -35,14 +35,6 @@ beforeAll(() => { | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     jest.spyOn(actionUtils, "getInputAsBool").mockImplementation( | ||||
|         (name, options) => { | ||||
|             return jest | ||||
|                 .requireActual("../src/utils/actionUtils") | ||||
|                 .getInputAsBool(name, options); | ||||
|         } | ||||
|     ); | ||||
|  | ||||
|     jest.spyOn(actionUtils, "isExactKeyMatch").mockImplementation( | ||||
|         (key, cacheResult) => { | ||||
|             return jest | ||||
| @@ -93,14 +85,9 @@ test("save with valid inputs uploads a cache", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|         [inputPath], | ||||
|         primaryKey, | ||||
|         { | ||||
|             uploadChunkSize: 4000000 | ||||
|         }, | ||||
|         false | ||||
|     ); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, { | ||||
|         uploadChunkSize: 4000000 | ||||
|     }); | ||||
|  | ||||
|     expect(failedMock).toHaveBeenCalledTimes(0); | ||||
| }); | ||||
| @@ -125,14 +112,9 @@ test("save failing logs the warning message", async () => { | ||||
|     await run(); | ||||
|  | ||||
|     expect(saveCacheMock).toHaveBeenCalledTimes(1); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith( | ||||
|         [inputPath], | ||||
|         primaryKey, | ||||
|         { | ||||
|             uploadChunkSize: 4000000 | ||||
|         }, | ||||
|         false | ||||
|     ); | ||||
|     expect(saveCacheMock).toHaveBeenCalledWith([inputPath], primaryKey, { | ||||
|         uploadChunkSize: 4000000 | ||||
|     }); | ||||
|  | ||||
|     expect(warningMock).toHaveBeenCalledTimes(1); | ||||
|     expect(warningMock).toHaveBeenCalledWith("Cache save failed."); | ||||
|   | ||||
| @@ -14,10 +14,6 @@ inputs: | ||||
|   upload-chunk-size: | ||||
|     description: 'The chunk size used to split up large files during upload, in bytes' | ||||
|     required: false | ||||
|   enableCrossOsArchive: | ||||
|     description: 'An optional boolean when enabled, allows windows runners to save or restore caches that can be restored or saved respectively on other platforms' | ||||
|     default: 'false' | ||||
|     required: false | ||||
| outputs: | ||||
|   cache-hit: | ||||
|     description: 'A boolean value to indicate an exact match was found for the primary key' | ||||
|   | ||||
							
								
								
									
										99
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										99
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -3383,6 +3383,7 @@ const crypto = __importStar(__webpack_require__(417)); | ||||
| const fs = __importStar(__webpack_require__(747)); | ||||
| const url_1 = __webpack_require__(414); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const downloadUtils_1 = __webpack_require__(251); | ||||
| const options_1 = __webpack_require__(538); | ||||
| const requestUtils_1 = __webpack_require__(899); | ||||
| @@ -3412,17 +3413,10 @@ function createHttpClient() { | ||||
|     const bearerCredentialHandler = new auth_1.BearerCredentialHandler(token); | ||||
|     return new http_client_1.HttpClient('actions/cache', [bearerCredentialHandler], getRequestOptions()); | ||||
| } | ||||
| function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) { | ||||
|     const components = paths; | ||||
|     // Add compression method to cache version to restore
 | ||||
|     // compressed cache as per compression method
 | ||||
|     if (compressionMethod) { | ||||
|         components.push(compressionMethod); | ||||
|     } | ||||
|     // Only check for windows platforms if enableCrossOsArchive is false
 | ||||
|     if (process.platform === 'win32' && !enableCrossOsArchive) { | ||||
|         components.push('windows-only'); | ||||
|     } | ||||
| function getCacheVersion(paths, compressionMethod) { | ||||
|     const components = paths.concat(!compressionMethod || compressionMethod === constants_1.CompressionMethod.Gzip | ||||
|         ? [] | ||||
|         : [compressionMethod]); | ||||
|     // Add salt to cache version to support breaking changes in cache entry
 | ||||
|     components.push(versionSalt); | ||||
|     return crypto | ||||
| @@ -3434,15 +3428,11 @@ exports.getCacheVersion = getCacheVersion; | ||||
| function getCacheEntry(keys, paths, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const httpClient = createHttpClient(); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); | ||||
|         const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         // Cache not found
 | ||||
|         if (response.statusCode === 204) { | ||||
|             // List cache for primary key only if cache miss occurs
 | ||||
|             if (core.isDebug()) { | ||||
|                 yield printCachesListForDiagnostics(keys[0], httpClient, version); | ||||
|             } | ||||
|             // Cache not found
 | ||||
|             return null; | ||||
|         } | ||||
|         if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) { | ||||
| @@ -3461,22 +3451,6 @@ function getCacheEntry(keys, paths, options) { | ||||
|     }); | ||||
| } | ||||
| exports.getCacheEntry = getCacheEntry; | ||||
| function printCachesListForDiagnostics(key, httpClient, version) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const resource = `caches?key=${encodeURIComponent(key)}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('listCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         if (response.statusCode === 200) { | ||||
|             const cacheListResult = response.result; | ||||
|             const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; | ||||
|             if (totalCount && totalCount > 0) { | ||||
|                 core.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env['GITHUB_REF']}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key \nOther caches with similar key:`); | ||||
|                 for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { | ||||
|                     core.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| function downloadCache(archiveLocation, archivePath, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const archiveUrl = new url_1.URL(archiveLocation); | ||||
| @@ -3497,7 +3471,7 @@ exports.downloadCache = downloadCache; | ||||
| function reserveCache(key, paths, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const httpClient = createHttpClient(); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); | ||||
|         const reserveCacheRequest = { | ||||
|             key, | ||||
|             version, | ||||
| @@ -4977,8 +4951,7 @@ var Inputs; | ||||
|     Inputs["Key"] = "key"; | ||||
|     Inputs["Path"] = "path"; | ||||
|     Inputs["RestoreKeys"] = "restore-keys"; | ||||
|     Inputs["UploadChunkSize"] = "upload-chunk-size"; | ||||
|     Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; // Input for cache, restore, save action
 | ||||
|     Inputs["UploadChunkSize"] = "upload-chunk-size"; // Input for cache, save action
 | ||||
| })(Inputs = exports.Inputs || (exports.Inputs = {})); | ||||
| var Outputs; | ||||
| (function (Outputs) { | ||||
| @@ -10074,7 +10047,7 @@ var __importStar = (this && this.__importStar) || function (mod) { | ||||
|     return result; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| exports.isCacheFeatureAvailable = exports.getInputAsBool = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0; | ||||
| exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0; | ||||
| const cache = __importStar(__webpack_require__(692)); | ||||
| const core = __importStar(__webpack_require__(470)); | ||||
| const constants_1 = __webpack_require__(196); | ||||
| @@ -10117,11 +10090,6 @@ function getInputAsInt(name, options) { | ||||
|     return value; | ||||
| } | ||||
| exports.getInputAsInt = getInputAsInt; | ||||
| function getInputAsBool(name, options) { | ||||
|     const result = core.getInput(name, options); | ||||
|     return result.toLowerCase() === "true"; | ||||
| } | ||||
| exports.getInputAsBool = getInputAsBool; | ||||
| function isCacheFeatureAvailable() { | ||||
|     if (cache.isFeatureAvailable()) { | ||||
|         return true; | ||||
| @@ -38229,14 +38197,12 @@ var __importStar = (this && this.__importStar) || function (mod) { | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const exec_1 = __webpack_require__(986); | ||||
| const core_1 = __webpack_require__(470); | ||||
| const io = __importStar(__webpack_require__(1)); | ||||
| const fs_1 = __webpack_require__(747); | ||||
| const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const IS_WINDOWS = process.platform === 'win32'; | ||||
| core_1.exportVariable('MSYS', 'winsymlinks:nativestrict'); | ||||
| // Returns tar path and type: BSD or GNU
 | ||||
| function getTarPath() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
| @@ -38363,7 +38329,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --long=30 --force -o', | ||||
|                         'zstd -d --long=30 -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
| @@ -38374,7 +38340,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --force -o', | ||||
|                         'zstd -d -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
| @@ -38400,7 +38366,7 @@ function getCompressionProgram(tarPath, compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --long=30 --force -o', | ||||
|                         'zstd -T0 --long=30 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
| @@ -38411,7 +38377,7 @@ function getCompressionProgram(tarPath, compressionMethod) { | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --force -o', | ||||
|                         'zstd -T0 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
| @@ -47209,6 +47175,7 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const cacheHttpClient = __importStar(__webpack_require__(114)); | ||||
| const tar_1 = __webpack_require__(434); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| class ValidationError extends Error { | ||||
|     constructor(message) { | ||||
|         super(message); | ||||
| @@ -47255,10 +47222,9 @@ exports.isFeatureAvailable = isFeatureAvailable; | ||||
|  * @param primaryKey an explicit key for restoring the cache | ||||
|  * @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key | ||||
|  * @param downloadOptions cache download options | ||||
|  * @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform | ||||
|  * @returns string returns the key for the cache hit, otherwise returns undefined | ||||
|  */ | ||||
| function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { | ||||
| function restoreCache(paths, primaryKey, restoreKeys, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         checkPaths(paths); | ||||
|         restoreKeys = restoreKeys || []; | ||||
| @@ -47271,17 +47237,31 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch | ||||
|         for (const key of keys) { | ||||
|             checkKey(key); | ||||
|         } | ||||
|         const compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let cacheEntry; | ||||
|         let compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let archivePath = ''; | ||||
|         try { | ||||
|             // path are needed to compute version
 | ||||
|             const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod, | ||||
|                 enableCrossOsArchive | ||||
|             cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod | ||||
|             }); | ||||
|             if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                 // Cache not found
 | ||||
|                 return undefined; | ||||
|                 // This is to support the old cache entry created by gzip on windows.
 | ||||
|                 if (process.platform === 'win32' && | ||||
|                     compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     compressionMethod = constants_1.CompressionMethod.Gzip; | ||||
|                     cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                         compressionMethod | ||||
|                     }); | ||||
|                     if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                         return undefined; | ||||
|                     } | ||||
|                     core.debug("Couldn't find cache entry with zstd compression, falling back to gzip compression."); | ||||
|                 } | ||||
|                 else { | ||||
|                     // Cache not found
 | ||||
|                     return undefined; | ||||
|                 } | ||||
|             } | ||||
|             archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); | ||||
|             core.debug(`Archive Path: ${archivePath}`); | ||||
| @@ -47324,11 +47304,10 @@ exports.restoreCache = restoreCache; | ||||
|  * | ||||
|  * @param paths a list of file paths to be cached | ||||
|  * @param key an explicit key for restoring the cache | ||||
|  * @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform | ||||
|  * @param options cache upload options | ||||
|  * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails | ||||
|  */ | ||||
| function saveCache(paths, key, options, enableCrossOsArchive = false) { | ||||
| function saveCache(paths, key, options) { | ||||
|     var _a, _b, _c, _d, _e; | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         checkPaths(paths); | ||||
| @@ -47359,7 +47338,6 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) { | ||||
|             core.debug('Reserving Cache'); | ||||
|             const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { | ||||
|                 compressionMethod, | ||||
|                 enableCrossOsArchive, | ||||
|                 cacheSize: archiveFileSize | ||||
|             }); | ||||
|             if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) { | ||||
| @@ -50494,8 +50472,7 @@ function restoreImpl(stateProvider) { | ||||
|             const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, { | ||||
|                 required: true | ||||
|             }); | ||||
|             const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive); | ||||
|             const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, {}, enableCrossOsArchive); | ||||
|             const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys); | ||||
|             if (!cacheKey) { | ||||
|                 core.info(`Cache not found for input keys: ${[ | ||||
|                     primaryKey, | ||||
|   | ||||
							
								
								
									
										99
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										99
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -3383,6 +3383,7 @@ const crypto = __importStar(__webpack_require__(417)); | ||||
| const fs = __importStar(__webpack_require__(747)); | ||||
| const url_1 = __webpack_require__(414); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const downloadUtils_1 = __webpack_require__(251); | ||||
| const options_1 = __webpack_require__(538); | ||||
| const requestUtils_1 = __webpack_require__(899); | ||||
| @@ -3412,17 +3413,10 @@ function createHttpClient() { | ||||
|     const bearerCredentialHandler = new auth_1.BearerCredentialHandler(token); | ||||
|     return new http_client_1.HttpClient('actions/cache', [bearerCredentialHandler], getRequestOptions()); | ||||
| } | ||||
| function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) { | ||||
|     const components = paths; | ||||
|     // Add compression method to cache version to restore
 | ||||
|     // compressed cache as per compression method
 | ||||
|     if (compressionMethod) { | ||||
|         components.push(compressionMethod); | ||||
|     } | ||||
|     // Only check for windows platforms if enableCrossOsArchive is false
 | ||||
|     if (process.platform === 'win32' && !enableCrossOsArchive) { | ||||
|         components.push('windows-only'); | ||||
|     } | ||||
| function getCacheVersion(paths, compressionMethod) { | ||||
|     const components = paths.concat(!compressionMethod || compressionMethod === constants_1.CompressionMethod.Gzip | ||||
|         ? [] | ||||
|         : [compressionMethod]); | ||||
|     // Add salt to cache version to support breaking changes in cache entry
 | ||||
|     components.push(versionSalt); | ||||
|     return crypto | ||||
| @@ -3434,15 +3428,11 @@ exports.getCacheVersion = getCacheVersion; | ||||
| function getCacheEntry(keys, paths, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const httpClient = createHttpClient(); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); | ||||
|         const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         // Cache not found
 | ||||
|         if (response.statusCode === 204) { | ||||
|             // List cache for primary key only if cache miss occurs
 | ||||
|             if (core.isDebug()) { | ||||
|                 yield printCachesListForDiagnostics(keys[0], httpClient, version); | ||||
|             } | ||||
|             // Cache not found
 | ||||
|             return null; | ||||
|         } | ||||
|         if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) { | ||||
| @@ -3461,22 +3451,6 @@ function getCacheEntry(keys, paths, options) { | ||||
|     }); | ||||
| } | ||||
| exports.getCacheEntry = getCacheEntry; | ||||
| function printCachesListForDiagnostics(key, httpClient, version) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const resource = `caches?key=${encodeURIComponent(key)}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('listCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         if (response.statusCode === 200) { | ||||
|             const cacheListResult = response.result; | ||||
|             const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; | ||||
|             if (totalCount && totalCount > 0) { | ||||
|                 core.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env['GITHUB_REF']}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key \nOther caches with similar key:`); | ||||
|                 for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { | ||||
|                     core.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| function downloadCache(archiveLocation, archivePath, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const archiveUrl = new url_1.URL(archiveLocation); | ||||
| @@ -3497,7 +3471,7 @@ exports.downloadCache = downloadCache; | ||||
| function reserveCache(key, paths, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const httpClient = createHttpClient(); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); | ||||
|         const reserveCacheRequest = { | ||||
|             key, | ||||
|             version, | ||||
| @@ -4977,8 +4951,7 @@ var Inputs; | ||||
|     Inputs["Key"] = "key"; | ||||
|     Inputs["Path"] = "path"; | ||||
|     Inputs["RestoreKeys"] = "restore-keys"; | ||||
|     Inputs["UploadChunkSize"] = "upload-chunk-size"; | ||||
|     Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; // Input for cache, restore, save action
 | ||||
|     Inputs["UploadChunkSize"] = "upload-chunk-size"; // Input for cache, save action
 | ||||
| })(Inputs = exports.Inputs || (exports.Inputs = {})); | ||||
| var Outputs; | ||||
| (function (Outputs) { | ||||
| @@ -38137,14 +38110,12 @@ var __importStar = (this && this.__importStar) || function (mod) { | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const exec_1 = __webpack_require__(986); | ||||
| const core_1 = __webpack_require__(470); | ||||
| const io = __importStar(__webpack_require__(1)); | ||||
| const fs_1 = __webpack_require__(747); | ||||
| const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const IS_WINDOWS = process.platform === 'win32'; | ||||
| core_1.exportVariable('MSYS', 'winsymlinks:nativestrict'); | ||||
| // Returns tar path and type: BSD or GNU
 | ||||
| function getTarPath() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
| @@ -38271,7 +38242,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --long=30 --force -o', | ||||
|                         'zstd -d --long=30 -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
| @@ -38282,7 +38253,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --force -o', | ||||
|                         'zstd -d -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
| @@ -38308,7 +38279,7 @@ function getCompressionProgram(tarPath, compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --long=30 --force -o', | ||||
|                         'zstd -T0 --long=30 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
| @@ -38319,7 +38290,7 @@ function getCompressionProgram(tarPath, compressionMethod) { | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --force -o', | ||||
|                         'zstd -T0 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
| @@ -38602,7 +38573,7 @@ var __importStar = (this && this.__importStar) || function (mod) { | ||||
|     return result; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| exports.isCacheFeatureAvailable = exports.getInputAsBool = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0; | ||||
| exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0; | ||||
| const cache = __importStar(__webpack_require__(692)); | ||||
| const core = __importStar(__webpack_require__(470)); | ||||
| const constants_1 = __webpack_require__(196); | ||||
| @@ -38645,11 +38616,6 @@ function getInputAsInt(name, options) { | ||||
|     return value; | ||||
| } | ||||
| exports.getInputAsInt = getInputAsInt; | ||||
| function getInputAsBool(name, options) { | ||||
|     const result = core.getInput(name, options); | ||||
|     return result.toLowerCase() === "true"; | ||||
| } | ||||
| exports.getInputAsBool = getInputAsBool; | ||||
| function isCacheFeatureAvailable() { | ||||
|     if (cache.isFeatureAvailable()) { | ||||
|         return true; | ||||
| @@ -47180,6 +47146,7 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const cacheHttpClient = __importStar(__webpack_require__(114)); | ||||
| const tar_1 = __webpack_require__(434); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| class ValidationError extends Error { | ||||
|     constructor(message) { | ||||
|         super(message); | ||||
| @@ -47226,10 +47193,9 @@ exports.isFeatureAvailable = isFeatureAvailable; | ||||
|  * @param primaryKey an explicit key for restoring the cache | ||||
|  * @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key | ||||
|  * @param downloadOptions cache download options | ||||
|  * @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform | ||||
|  * @returns string returns the key for the cache hit, otherwise returns undefined | ||||
|  */ | ||||
| function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { | ||||
| function restoreCache(paths, primaryKey, restoreKeys, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         checkPaths(paths); | ||||
|         restoreKeys = restoreKeys || []; | ||||
| @@ -47242,17 +47208,31 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch | ||||
|         for (const key of keys) { | ||||
|             checkKey(key); | ||||
|         } | ||||
|         const compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let cacheEntry; | ||||
|         let compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let archivePath = ''; | ||||
|         try { | ||||
|             // path are needed to compute version
 | ||||
|             const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod, | ||||
|                 enableCrossOsArchive | ||||
|             cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod | ||||
|             }); | ||||
|             if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                 // Cache not found
 | ||||
|                 return undefined; | ||||
|                 // This is to support the old cache entry created by gzip on windows.
 | ||||
|                 if (process.platform === 'win32' && | ||||
|                     compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     compressionMethod = constants_1.CompressionMethod.Gzip; | ||||
|                     cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                         compressionMethod | ||||
|                     }); | ||||
|                     if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                         return undefined; | ||||
|                     } | ||||
|                     core.debug("Couldn't find cache entry with zstd compression, falling back to gzip compression."); | ||||
|                 } | ||||
|                 else { | ||||
|                     // Cache not found
 | ||||
|                     return undefined; | ||||
|                 } | ||||
|             } | ||||
|             archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); | ||||
|             core.debug(`Archive Path: ${archivePath}`); | ||||
| @@ -47295,11 +47275,10 @@ exports.restoreCache = restoreCache; | ||||
|  * | ||||
|  * @param paths a list of file paths to be cached | ||||
|  * @param key an explicit key for restoring the cache | ||||
|  * @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform | ||||
|  * @param options cache upload options | ||||
|  * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails | ||||
|  */ | ||||
| function saveCache(paths, key, options, enableCrossOsArchive = false) { | ||||
| function saveCache(paths, key, options) { | ||||
|     var _a, _b, _c, _d, _e; | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         checkPaths(paths); | ||||
| @@ -47330,7 +47309,6 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) { | ||||
|             core.debug('Reserving Cache'); | ||||
|             const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { | ||||
|                 compressionMethod, | ||||
|                 enableCrossOsArchive, | ||||
|                 cacheSize: archiveFileSize | ||||
|             }); | ||||
|             if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) { | ||||
| @@ -50494,8 +50472,7 @@ function restoreImpl(stateProvider) { | ||||
|             const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, { | ||||
|                 required: true | ||||
|             }); | ||||
|             const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive); | ||||
|             const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, {}, enableCrossOsArchive); | ||||
|             const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys); | ||||
|             if (!cacheKey) { | ||||
|                 core.info(`Cache not found for input keys: ${[ | ||||
|                     primaryKey, | ||||
|   | ||||
							
								
								
									
										101
									
								
								dist/save-only/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										101
									
								
								dist/save-only/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -3439,6 +3439,7 @@ const crypto = __importStar(__webpack_require__(417)); | ||||
| const fs = __importStar(__webpack_require__(747)); | ||||
| const url_1 = __webpack_require__(835); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const downloadUtils_1 = __webpack_require__(251); | ||||
| const options_1 = __webpack_require__(538); | ||||
| const requestUtils_1 = __webpack_require__(899); | ||||
| @@ -3468,17 +3469,10 @@ function createHttpClient() { | ||||
|     const bearerCredentialHandler = new auth_1.BearerCredentialHandler(token); | ||||
|     return new http_client_1.HttpClient('actions/cache', [bearerCredentialHandler], getRequestOptions()); | ||||
| } | ||||
| function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) { | ||||
|     const components = paths; | ||||
|     // Add compression method to cache version to restore
 | ||||
|     // compressed cache as per compression method
 | ||||
|     if (compressionMethod) { | ||||
|         components.push(compressionMethod); | ||||
|     } | ||||
|     // Only check for windows platforms if enableCrossOsArchive is false
 | ||||
|     if (process.platform === 'win32' && !enableCrossOsArchive) { | ||||
|         components.push('windows-only'); | ||||
|     } | ||||
| function getCacheVersion(paths, compressionMethod) { | ||||
|     const components = paths.concat(!compressionMethod || compressionMethod === constants_1.CompressionMethod.Gzip | ||||
|         ? [] | ||||
|         : [compressionMethod]); | ||||
|     // Add salt to cache version to support breaking changes in cache entry
 | ||||
|     components.push(versionSalt); | ||||
|     return crypto | ||||
| @@ -3490,15 +3484,11 @@ exports.getCacheVersion = getCacheVersion; | ||||
| function getCacheEntry(keys, paths, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const httpClient = createHttpClient(); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); | ||||
|         const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         // Cache not found
 | ||||
|         if (response.statusCode === 204) { | ||||
|             // List cache for primary key only if cache miss occurs
 | ||||
|             if (core.isDebug()) { | ||||
|                 yield printCachesListForDiagnostics(keys[0], httpClient, version); | ||||
|             } | ||||
|             // Cache not found
 | ||||
|             return null; | ||||
|         } | ||||
|         if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) { | ||||
| @@ -3517,22 +3507,6 @@ function getCacheEntry(keys, paths, options) { | ||||
|     }); | ||||
| } | ||||
| exports.getCacheEntry = getCacheEntry; | ||||
| function printCachesListForDiagnostics(key, httpClient, version) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const resource = `caches?key=${encodeURIComponent(key)}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('listCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         if (response.statusCode === 200) { | ||||
|             const cacheListResult = response.result; | ||||
|             const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; | ||||
|             if (totalCount && totalCount > 0) { | ||||
|                 core.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env['GITHUB_REF']}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key \nOther caches with similar key:`); | ||||
|                 for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { | ||||
|                     core.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| function downloadCache(archiveLocation, archivePath, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const archiveUrl = new url_1.URL(archiveLocation); | ||||
| @@ -3553,7 +3527,7 @@ exports.downloadCache = downloadCache; | ||||
| function reserveCache(key, paths, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const httpClient = createHttpClient(); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); | ||||
|         const reserveCacheRequest = { | ||||
|             key, | ||||
|             version, | ||||
| @@ -5033,8 +5007,7 @@ var Inputs; | ||||
|     Inputs["Key"] = "key"; | ||||
|     Inputs["Path"] = "path"; | ||||
|     Inputs["RestoreKeys"] = "restore-keys"; | ||||
|     Inputs["UploadChunkSize"] = "upload-chunk-size"; | ||||
|     Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; // Input for cache, restore, save action
 | ||||
|     Inputs["UploadChunkSize"] = "upload-chunk-size"; // Input for cache, save action
 | ||||
| })(Inputs = exports.Inputs || (exports.Inputs = {})); | ||||
| var Outputs; | ||||
| (function (Outputs) { | ||||
| @@ -38188,14 +38161,12 @@ var __importStar = (this && this.__importStar) || function (mod) { | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const exec_1 = __webpack_require__(986); | ||||
| const core_1 = __webpack_require__(470); | ||||
| const io = __importStar(__webpack_require__(1)); | ||||
| const fs_1 = __webpack_require__(747); | ||||
| const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const IS_WINDOWS = process.platform === 'win32'; | ||||
| core_1.exportVariable('MSYS', 'winsymlinks:nativestrict'); | ||||
| // Returns tar path and type: BSD or GNU
 | ||||
| function getTarPath() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
| @@ -38322,7 +38293,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --long=30 --force -o', | ||||
|                         'zstd -d --long=30 -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
| @@ -38333,7 +38304,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --force -o', | ||||
|                         'zstd -d -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
| @@ -38359,7 +38330,7 @@ function getCompressionProgram(tarPath, compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --long=30 --force -o', | ||||
|                         'zstd -T0 --long=30 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
| @@ -38370,7 +38341,7 @@ function getCompressionProgram(tarPath, compressionMethod) { | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --force -o', | ||||
|                         'zstd -T0 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
| @@ -38653,7 +38624,7 @@ var __importStar = (this && this.__importStar) || function (mod) { | ||||
|     return result; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| exports.isCacheFeatureAvailable = exports.getInputAsBool = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0; | ||||
| exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0; | ||||
| const cache = __importStar(__webpack_require__(692)); | ||||
| const core = __importStar(__webpack_require__(470)); | ||||
| const constants_1 = __webpack_require__(196); | ||||
| @@ -38696,11 +38667,6 @@ function getInputAsInt(name, options) { | ||||
|     return value; | ||||
| } | ||||
| exports.getInputAsInt = getInputAsInt; | ||||
| function getInputAsBool(name, options) { | ||||
|     const result = core.getInput(name, options); | ||||
|     return result.toLowerCase() === "true"; | ||||
| } | ||||
| exports.getInputAsBool = getInputAsBool; | ||||
| function isCacheFeatureAvailable() { | ||||
|     if (cache.isFeatureAvailable()) { | ||||
|         return true; | ||||
| @@ -41180,8 +41146,9 @@ function saveImpl(stateProvider) { | ||||
|             const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, { | ||||
|                 required: true | ||||
|             }); | ||||
|             const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive); | ||||
|             cacheId = yield cache.saveCache(cachePaths, primaryKey, { uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) }, enableCrossOsArchive); | ||||
|             cacheId = yield cache.saveCache(cachePaths, primaryKey, { | ||||
|                 uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) | ||||
|             }); | ||||
|             if (cacheId != -1) { | ||||
|                 core.info(`Cache saved with key: ${primaryKey}`); | ||||
|             } | ||||
| @@ -47321,6 +47288,7 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const cacheHttpClient = __importStar(__webpack_require__(114)); | ||||
| const tar_1 = __webpack_require__(434); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| class ValidationError extends Error { | ||||
|     constructor(message) { | ||||
|         super(message); | ||||
| @@ -47367,10 +47335,9 @@ exports.isFeatureAvailable = isFeatureAvailable; | ||||
|  * @param primaryKey an explicit key for restoring the cache | ||||
|  * @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key | ||||
|  * @param downloadOptions cache download options | ||||
|  * @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform | ||||
|  * @returns string returns the key for the cache hit, otherwise returns undefined | ||||
|  */ | ||||
| function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { | ||||
| function restoreCache(paths, primaryKey, restoreKeys, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         checkPaths(paths); | ||||
|         restoreKeys = restoreKeys || []; | ||||
| @@ -47383,17 +47350,31 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch | ||||
|         for (const key of keys) { | ||||
|             checkKey(key); | ||||
|         } | ||||
|         const compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let cacheEntry; | ||||
|         let compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let archivePath = ''; | ||||
|         try { | ||||
|             // path are needed to compute version
 | ||||
|             const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod, | ||||
|                 enableCrossOsArchive | ||||
|             cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod | ||||
|             }); | ||||
|             if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                 // Cache not found
 | ||||
|                 return undefined; | ||||
|                 // This is to support the old cache entry created by gzip on windows.
 | ||||
|                 if (process.platform === 'win32' && | ||||
|                     compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     compressionMethod = constants_1.CompressionMethod.Gzip; | ||||
|                     cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                         compressionMethod | ||||
|                     }); | ||||
|                     if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                         return undefined; | ||||
|                     } | ||||
|                     core.debug("Couldn't find cache entry with zstd compression, falling back to gzip compression."); | ||||
|                 } | ||||
|                 else { | ||||
|                     // Cache not found
 | ||||
|                     return undefined; | ||||
|                 } | ||||
|             } | ||||
|             archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); | ||||
|             core.debug(`Archive Path: ${archivePath}`); | ||||
| @@ -47436,11 +47417,10 @@ exports.restoreCache = restoreCache; | ||||
|  * | ||||
|  * @param paths a list of file paths to be cached | ||||
|  * @param key an explicit key for restoring the cache | ||||
|  * @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform | ||||
|  * @param options cache upload options | ||||
|  * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails | ||||
|  */ | ||||
| function saveCache(paths, key, options, enableCrossOsArchive = false) { | ||||
| function saveCache(paths, key, options) { | ||||
|     var _a, _b, _c, _d, _e; | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         checkPaths(paths); | ||||
| @@ -47471,7 +47451,6 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) { | ||||
|             core.debug('Reserving Cache'); | ||||
|             const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { | ||||
|                 compressionMethod, | ||||
|                 enableCrossOsArchive, | ||||
|                 cacheSize: archiveFileSize | ||||
|             }); | ||||
|             if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) { | ||||
|   | ||||
							
								
								
									
										101
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										101
									
								
								dist/save/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -3383,6 +3383,7 @@ const crypto = __importStar(__webpack_require__(417)); | ||||
| const fs = __importStar(__webpack_require__(747)); | ||||
| const url_1 = __webpack_require__(835); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const downloadUtils_1 = __webpack_require__(251); | ||||
| const options_1 = __webpack_require__(538); | ||||
| const requestUtils_1 = __webpack_require__(899); | ||||
| @@ -3412,17 +3413,10 @@ function createHttpClient() { | ||||
|     const bearerCredentialHandler = new auth_1.BearerCredentialHandler(token); | ||||
|     return new http_client_1.HttpClient('actions/cache', [bearerCredentialHandler], getRequestOptions()); | ||||
| } | ||||
| function getCacheVersion(paths, compressionMethod, enableCrossOsArchive = false) { | ||||
|     const components = paths; | ||||
|     // Add compression method to cache version to restore
 | ||||
|     // compressed cache as per compression method
 | ||||
|     if (compressionMethod) { | ||||
|         components.push(compressionMethod); | ||||
|     } | ||||
|     // Only check for windows platforms if enableCrossOsArchive is false
 | ||||
|     if (process.platform === 'win32' && !enableCrossOsArchive) { | ||||
|         components.push('windows-only'); | ||||
|     } | ||||
| function getCacheVersion(paths, compressionMethod) { | ||||
|     const components = paths.concat(!compressionMethod || compressionMethod === constants_1.CompressionMethod.Gzip | ||||
|         ? [] | ||||
|         : [compressionMethod]); | ||||
|     // Add salt to cache version to support breaking changes in cache entry
 | ||||
|     components.push(versionSalt); | ||||
|     return crypto | ||||
| @@ -3434,15 +3428,11 @@ exports.getCacheVersion = getCacheVersion; | ||||
| function getCacheEntry(keys, paths, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const httpClient = createHttpClient(); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); | ||||
|         const resource = `cache?keys=${encodeURIComponent(keys.join(','))}&version=${version}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('getCacheEntry', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         // Cache not found
 | ||||
|         if (response.statusCode === 204) { | ||||
|             // List cache for primary key only if cache miss occurs
 | ||||
|             if (core.isDebug()) { | ||||
|                 yield printCachesListForDiagnostics(keys[0], httpClient, version); | ||||
|             } | ||||
|             // Cache not found
 | ||||
|             return null; | ||||
|         } | ||||
|         if (!requestUtils_1.isSuccessStatusCode(response.statusCode)) { | ||||
| @@ -3461,22 +3451,6 @@ function getCacheEntry(keys, paths, options) { | ||||
|     }); | ||||
| } | ||||
| exports.getCacheEntry = getCacheEntry; | ||||
| function printCachesListForDiagnostics(key, httpClient, version) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const resource = `caches?key=${encodeURIComponent(key)}`; | ||||
|         const response = yield requestUtils_1.retryTypedResponse('listCache', () => __awaiter(this, void 0, void 0, function* () { return httpClient.getJson(getCacheApiUrl(resource)); })); | ||||
|         if (response.statusCode === 200) { | ||||
|             const cacheListResult = response.result; | ||||
|             const totalCount = cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.totalCount; | ||||
|             if (totalCount && totalCount > 0) { | ||||
|                 core.debug(`No matching cache found for cache key '${key}', version '${version} and scope ${process.env['GITHUB_REF']}. There exist one or more cache(s) with similar key but they have different version or scope. See more info on cache matching here: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#matching-a-cache-key \nOther caches with similar key:`); | ||||
|                 for (const cacheEntry of (cacheListResult === null || cacheListResult === void 0 ? void 0 : cacheListResult.artifactCaches) || []) { | ||||
|                     core.debug(`Cache Key: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheKey}, Cache Version: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.cacheVersion}, Cache Scope: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.scope}, Cache Created: ${cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.creationTime}`); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| function downloadCache(archiveLocation, archivePath, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const archiveUrl = new url_1.URL(archiveLocation); | ||||
| @@ -3497,7 +3471,7 @@ exports.downloadCache = downloadCache; | ||||
| function reserveCache(key, paths, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         const httpClient = createHttpClient(); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod, options === null || options === void 0 ? void 0 : options.enableCrossOsArchive); | ||||
|         const version = getCacheVersion(paths, options === null || options === void 0 ? void 0 : options.compressionMethod); | ||||
|         const reserveCacheRequest = { | ||||
|             key, | ||||
|             version, | ||||
| @@ -4977,8 +4951,7 @@ var Inputs; | ||||
|     Inputs["Key"] = "key"; | ||||
|     Inputs["Path"] = "path"; | ||||
|     Inputs["RestoreKeys"] = "restore-keys"; | ||||
|     Inputs["UploadChunkSize"] = "upload-chunk-size"; | ||||
|     Inputs["EnableCrossOsArchive"] = "enableCrossOsArchive"; // Input for cache, restore, save action
 | ||||
|     Inputs["UploadChunkSize"] = "upload-chunk-size"; // Input for cache, save action
 | ||||
| })(Inputs = exports.Inputs || (exports.Inputs = {})); | ||||
| var Outputs; | ||||
| (function (Outputs) { | ||||
| @@ -38132,14 +38105,12 @@ var __importStar = (this && this.__importStar) || function (mod) { | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| const exec_1 = __webpack_require__(986); | ||||
| const core_1 = __webpack_require__(470); | ||||
| const io = __importStar(__webpack_require__(1)); | ||||
| const fs_1 = __webpack_require__(747); | ||||
| const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| const IS_WINDOWS = process.platform === 'win32'; | ||||
| core_1.exportVariable('MSYS', 'winsymlinks:nativestrict'); | ||||
| // Returns tar path and type: BSD or GNU
 | ||||
| function getTarPath() { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
| @@ -38266,7 +38237,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --long=30 --force -o', | ||||
|                         'zstd -d --long=30 -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
| @@ -38277,7 +38248,7 @@ function getDecompressionProgram(tarPath, compressionMethod, archivePath) { | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -d --force -o', | ||||
|                         'zstd -d -o', | ||||
|                         constants_1.TarFilename, | ||||
|                         archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/') | ||||
|                     ] | ||||
| @@ -38303,7 +38274,7 @@ function getCompressionProgram(tarPath, compressionMethod) { | ||||
|             case constants_1.CompressionMethod.Zstd: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --long=30 --force -o', | ||||
|                         'zstd -T0 --long=30 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
| @@ -38314,7 +38285,7 @@ function getCompressionProgram(tarPath, compressionMethod) { | ||||
|             case constants_1.CompressionMethod.ZstdWithoutLong: | ||||
|                 return BSD_TAR_ZSTD | ||||
|                     ? [ | ||||
|                         'zstd -T0 --force -o', | ||||
|                         'zstd -T0 -o', | ||||
|                         cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'), | ||||
|                         constants_1.TarFilename | ||||
|                     ] | ||||
| @@ -38597,7 +38568,7 @@ var __importStar = (this && this.__importStar) || function (mod) { | ||||
|     return result; | ||||
| }; | ||||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||||
| exports.isCacheFeatureAvailable = exports.getInputAsBool = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0; | ||||
| exports.isCacheFeatureAvailable = exports.getInputAsInt = exports.getInputAsArray = exports.isValidEvent = exports.logWarning = exports.isExactKeyMatch = exports.isGhes = void 0; | ||||
| const cache = __importStar(__webpack_require__(692)); | ||||
| const core = __importStar(__webpack_require__(470)); | ||||
| const constants_1 = __webpack_require__(196); | ||||
| @@ -38640,11 +38611,6 @@ function getInputAsInt(name, options) { | ||||
|     return value; | ||||
| } | ||||
| exports.getInputAsInt = getInputAsInt; | ||||
| function getInputAsBool(name, options) { | ||||
|     const result = core.getInput(name, options); | ||||
|     return result.toLowerCase() === "true"; | ||||
| } | ||||
| exports.getInputAsBool = getInputAsBool; | ||||
| function isCacheFeatureAvailable() { | ||||
|     if (cache.isFeatureAvailable()) { | ||||
|         return true; | ||||
| @@ -41124,8 +41090,9 @@ function saveImpl(stateProvider) { | ||||
|             const cachePaths = utils.getInputAsArray(constants_1.Inputs.Path, { | ||||
|                 required: true | ||||
|             }); | ||||
|             const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive); | ||||
|             cacheId = yield cache.saveCache(cachePaths, primaryKey, { uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) }, enableCrossOsArchive); | ||||
|             cacheId = yield cache.saveCache(cachePaths, primaryKey, { | ||||
|                 uploadChunkSize: utils.getInputAsInt(constants_1.Inputs.UploadChunkSize) | ||||
|             }); | ||||
|             if (cacheId != -1) { | ||||
|                 core.info(`Cache saved with key: ${primaryKey}`); | ||||
|             } | ||||
| @@ -47294,6 +47261,7 @@ const path = __importStar(__webpack_require__(622)); | ||||
| const utils = __importStar(__webpack_require__(15)); | ||||
| const cacheHttpClient = __importStar(__webpack_require__(114)); | ||||
| const tar_1 = __webpack_require__(434); | ||||
| const constants_1 = __webpack_require__(931); | ||||
| class ValidationError extends Error { | ||||
|     constructor(message) { | ||||
|         super(message); | ||||
| @@ -47340,10 +47308,9 @@ exports.isFeatureAvailable = isFeatureAvailable; | ||||
|  * @param primaryKey an explicit key for restoring the cache | ||||
|  * @param restoreKeys an optional ordered list of keys to use for restoring the cache if no cache hit occurred for key | ||||
|  * @param downloadOptions cache download options | ||||
|  * @param enableCrossOsArchive an optional boolean enabled to restore on windows any cache created on any platform | ||||
|  * @returns string returns the key for the cache hit, otherwise returns undefined | ||||
|  */ | ||||
| function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArchive = false) { | ||||
| function restoreCache(paths, primaryKey, restoreKeys, options) { | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         checkPaths(paths); | ||||
|         restoreKeys = restoreKeys || []; | ||||
| @@ -47356,17 +47323,31 @@ function restoreCache(paths, primaryKey, restoreKeys, options, enableCrossOsArch | ||||
|         for (const key of keys) { | ||||
|             checkKey(key); | ||||
|         } | ||||
|         const compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let cacheEntry; | ||||
|         let compressionMethod = yield utils.getCompressionMethod(); | ||||
|         let archivePath = ''; | ||||
|         try { | ||||
|             // path are needed to compute version
 | ||||
|             const cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod, | ||||
|                 enableCrossOsArchive | ||||
|             cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                 compressionMethod | ||||
|             }); | ||||
|             if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                 // Cache not found
 | ||||
|                 return undefined; | ||||
|                 // This is to support the old cache entry created by gzip on windows.
 | ||||
|                 if (process.platform === 'win32' && | ||||
|                     compressionMethod !== constants_1.CompressionMethod.Gzip) { | ||||
|                     compressionMethod = constants_1.CompressionMethod.Gzip; | ||||
|                     cacheEntry = yield cacheHttpClient.getCacheEntry(keys, paths, { | ||||
|                         compressionMethod | ||||
|                     }); | ||||
|                     if (!(cacheEntry === null || cacheEntry === void 0 ? void 0 : cacheEntry.archiveLocation)) { | ||||
|                         return undefined; | ||||
|                     } | ||||
|                     core.debug("Couldn't find cache entry with zstd compression, falling back to gzip compression."); | ||||
|                 } | ||||
|                 else { | ||||
|                     // Cache not found
 | ||||
|                     return undefined; | ||||
|                 } | ||||
|             } | ||||
|             archivePath = path.join(yield utils.createTempDirectory(), utils.getCacheFileName(compressionMethod)); | ||||
|             core.debug(`Archive Path: ${archivePath}`); | ||||
| @@ -47409,11 +47390,10 @@ exports.restoreCache = restoreCache; | ||||
|  * | ||||
|  * @param paths a list of file paths to be cached | ||||
|  * @param key an explicit key for restoring the cache | ||||
|  * @param enableCrossOsArchive an optional boolean enabled to save cache on windows which could be restored on any platform | ||||
|  * @param options cache upload options | ||||
|  * @returns number returns cacheId if the cache was saved successfully and throws an error if save fails | ||||
|  */ | ||||
| function saveCache(paths, key, options, enableCrossOsArchive = false) { | ||||
| function saveCache(paths, key, options) { | ||||
|     var _a, _b, _c, _d, _e; | ||||
|     return __awaiter(this, void 0, void 0, function* () { | ||||
|         checkPaths(paths); | ||||
| @@ -47444,7 +47424,6 @@ function saveCache(paths, key, options, enableCrossOsArchive = false) { | ||||
|             core.debug('Reserving Cache'); | ||||
|             const reserveCacheResponse = yield cacheHttpClient.reserveCache(key, paths, { | ||||
|                 compressionMethod, | ||||
|                 enableCrossOsArchive, | ||||
|                 cacheSize: archiveFileSize | ||||
|             }); | ||||
|             if ((_a = reserveCacheResponse === null || reserveCacheResponse === void 0 ? void 0 : reserveCacheResponse.result) === null || _a === void 0 ? void 0 : _a.cacheId) { | ||||
|   | ||||
							
								
								
									
										16
									
								
								examples.md
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								examples.md
									
									
									
									
									
								
							| @@ -38,7 +38,6 @@ | ||||
| - [Swift, Objective-C - Carthage](#swift-objective-c---carthage) | ||||
| - [Swift, Objective-C - CocoaPods](#swift-objective-c---cocoapods) | ||||
| - [Swift - Swift Package Manager](#swift---swift-package-manager) | ||||
| - [Swift - Mint](#swift---mint) | ||||
|  | ||||
| ## C# - NuGet | ||||
|  | ||||
| @@ -642,18 +641,3 @@ whenever possible: | ||||
|     restore-keys: | | ||||
|       ${{ runner.os }}-spm- | ||||
| ``` | ||||
|  | ||||
| ## Swift - Mint | ||||
|  | ||||
| ```yaml | ||||
| env: | ||||
|   MINT_PATH: .mint/lib | ||||
|   MINT_LINK_PATH: .mint/bin | ||||
| steps: | ||||
|   - uses: actions/cache@v3 | ||||
|     with: | ||||
|       path: .mint | ||||
|       key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }} | ||||
|       restore-keys: | | ||||
|         ${{ runner.os }}-mint- | ||||
| ``` | ||||
|   | ||||
							
								
								
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										18
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @@ -1,15 +1,15 @@ | ||||
| { | ||||
|   "name": "cache", | ||||
|   "version": "3.2.2", | ||||
|   "version": "3.2.0-beta.1", | ||||
|   "lockfileVersion": 2, | ||||
|   "requires": true, | ||||
|   "packages": { | ||||
|     "": { | ||||
|       "name": "cache", | ||||
|       "version": "3.2.2", | ||||
|       "version": "3.2.0-beta.1", | ||||
|       "license": "MIT", | ||||
|       "dependencies": { | ||||
|         "@actions/cache": "^3.1.2", | ||||
|         "@actions/cache": "3.1.0-beta.3", | ||||
|         "@actions/core": "^1.10.0", | ||||
|         "@actions/exec": "^1.1.1", | ||||
|         "@actions/io": "^1.1.2" | ||||
| @@ -36,9 +36,9 @@ | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@actions/cache": { | ||||
|       "version": "3.1.2", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.2.tgz", | ||||
|       "integrity": "sha512-3XeKcXIonfIbqvW7gPm/VLOhv1RHQ1dtTgSBCH6OUhCgSTii9bEVgu0PIms7UbLnXeMCKFzECfpbud8fJEvBbQ==", | ||||
|       "version": "3.1.0-beta.3", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0-beta.3.tgz", | ||||
|       "integrity": "sha512-71S1vd0WKLbC2lAe04pCYqTLBjSa8gURtiqnVBCYAt8QVBjOfwa2D3ESf2m8K2xjUxman/Yimdp7CPJDyFnxZg==", | ||||
|       "dependencies": { | ||||
|         "@actions/core": "^1.10.0", | ||||
|         "@actions/exec": "^1.0.1", | ||||
| @@ -9722,9 +9722,9 @@ | ||||
|   }, | ||||
|   "dependencies": { | ||||
|     "@actions/cache": { | ||||
|       "version": "3.1.2", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.2.tgz", | ||||
|       "integrity": "sha512-3XeKcXIonfIbqvW7gPm/VLOhv1RHQ1dtTgSBCH6OUhCgSTii9bEVgu0PIms7UbLnXeMCKFzECfpbud8fJEvBbQ==", | ||||
|       "version": "3.1.0-beta.3", | ||||
|       "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.1.0-beta.3.tgz", | ||||
|       "integrity": "sha512-71S1vd0WKLbC2lAe04pCYqTLBjSa8gURtiqnVBCYAt8QVBjOfwa2D3ESf2m8K2xjUxman/Yimdp7CPJDyFnxZg==", | ||||
|       "requires": { | ||||
|         "@actions/core": "^1.10.0", | ||||
|         "@actions/exec": "^1.0.1", | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "cache", | ||||
|   "version": "3.2.2", | ||||
|   "version": "3.2.0-beta.1", | ||||
|   "private": true, | ||||
|   "description": "Cache dependencies and build outputs", | ||||
|   "main": "dist/restore/index.js", | ||||
| @@ -23,7 +23,7 @@ | ||||
|   "author": "GitHub", | ||||
|   "license": "MIT", | ||||
|   "dependencies": { | ||||
|     "@actions/cache": "^3.1.2", | ||||
|     "@actions/cache": "3.1.0-beta.3", | ||||
|     "@actions/core": "^1.10.0", | ||||
|     "@actions/exec": "^1.1.1", | ||||
|     "@actions/io": "^1.1.2" | ||||
|   | ||||
| @@ -120,7 +120,7 @@ steps: | ||||
|  | ||||
| #### Reusing primary key and restored key in the save action | ||||
|  | ||||
| Usually you may want to use same `key` in both `actions/cache/restore` and `actions/cache/save` action. To achieve this, use `outputs` from the restore action to reuse the same primary key (or the key of the cache that was restored). | ||||
| Usually you may want to use same `key` in both actions/cache/restore` and `actions/cache/save` action. To achieve this, use `outputs` from the restore action to reuse the same primary key (or the key of the cache that was restored). | ||||
|  | ||||
| #### Using restore action outputs to make save action behave just like the cache action | ||||
|  | ||||
|   | ||||
| @@ -11,10 +11,6 @@ inputs: | ||||
|   restore-keys: | ||||
|     description: 'An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.' | ||||
|     required: false | ||||
|   enableCrossOsArchive: | ||||
|     description: 'An optional boolean when enabled, allows windows runners to restore caches that were saved on other platforms' | ||||
|     default: 'false' | ||||
|     required: false | ||||
| outputs: | ||||
|   cache-hit: | ||||
|     description: 'A boolean value to indicate an exact match was found for the primary key' | ||||
|   | ||||
| @@ -54,7 +54,7 @@ Case 1: Where an user would want to reuse the key as it is | ||||
| ```yaml | ||||
| uses: actions/cache/save@v3 | ||||
| with: | ||||
|     key: ${{ steps.restore-cache.outputs.key }} | ||||
|     key: steps.restore-cache.output.key | ||||
| ``` | ||||
|  | ||||
| Case 2: Where the user would want to re-evaluate the key | ||||
|   | ||||
| @@ -11,10 +11,6 @@ inputs: | ||||
|   upload-chunk-size: | ||||
|     description: 'The chunk size used to split up large files during upload, in bytes' | ||||
|     required: false | ||||
|   enableCrossOsArchive: | ||||
|     description: 'An optional boolean when enabled, allows windows runners to save caches that can be restored on other platforms' | ||||
|     default: 'false' | ||||
|     required: false | ||||
| runs: | ||||
|   using: 'node16' | ||||
|   main: '../dist/save-only/index.js' | ||||
|   | ||||
| @@ -2,8 +2,7 @@ export enum Inputs { | ||||
|     Key = "key", // Input for cache, restore, save action | ||||
|     Path = "path", // Input for cache, restore, save action | ||||
|     RestoreKeys = "restore-keys", // Input for cache, restore action | ||||
|     UploadChunkSize = "upload-chunk-size", // Input for cache, save action | ||||
|     EnableCrossOsArchive = "enableCrossOsArchive" // Input for cache, restore, save action | ||||
|     UploadChunkSize = "upload-chunk-size" // Input for cache, save action | ||||
| } | ||||
|  | ||||
| export enum Outputs { | ||||
|   | ||||
| @@ -31,16 +31,11 @@ async function restoreImpl( | ||||
|         const cachePaths = utils.getInputAsArray(Inputs.Path, { | ||||
|             required: true | ||||
|         }); | ||||
|         const enableCrossOsArchive = utils.getInputAsBool( | ||||
|             Inputs.EnableCrossOsArchive | ||||
|         ); | ||||
|  | ||||
|         const cacheKey = await cache.restoreCache( | ||||
|             cachePaths, | ||||
|             primaryKey, | ||||
|             restoreKeys, | ||||
|             {}, | ||||
|             enableCrossOsArchive | ||||
|             restoreKeys | ||||
|         ); | ||||
|  | ||||
|         if (!cacheKey) { | ||||
|   | ||||
| @@ -52,16 +52,9 @@ async function saveImpl(stateProvider: IStateProvider): Promise<number | void> { | ||||
|             required: true | ||||
|         }); | ||||
|  | ||||
|         const enableCrossOsArchive = utils.getInputAsBool( | ||||
|             Inputs.EnableCrossOsArchive | ||||
|         ); | ||||
|  | ||||
|         cacheId = await cache.saveCache( | ||||
|             cachePaths, | ||||
|             primaryKey, | ||||
|             { uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize) }, | ||||
|             enableCrossOsArchive | ||||
|         ); | ||||
|         cacheId = await cache.saveCache(cachePaths, primaryKey, { | ||||
|             uploadChunkSize: utils.getInputAsInt(Inputs.UploadChunkSize) | ||||
|         }); | ||||
|  | ||||
|         if (cacheId != -1) { | ||||
|             core.info(`Cache saved with key: ${primaryKey}`); | ||||
|   | ||||
| @@ -52,14 +52,6 @@ export function getInputAsInt( | ||||
|     return value; | ||||
| } | ||||
|  | ||||
| export function getInputAsBool( | ||||
|     name: string, | ||||
|     options?: core.InputOptions | ||||
| ): boolean { | ||||
|     const result = core.getInput(name, options); | ||||
|     return result.toLowerCase() === "true"; | ||||
| } | ||||
|  | ||||
| export function isCacheFeatureAvailable(): boolean { | ||||
|     if (cache.isFeatureAvailable()) { | ||||
|         return true; | ||||
|   | ||||
| @@ -13,7 +13,6 @@ interface CacheInput { | ||||
|     path: string; | ||||
|     key: string; | ||||
|     restoreKeys?: string[]; | ||||
|     enableCrossOsArchive?: boolean; | ||||
| } | ||||
|  | ||||
| export function setInputs(input: CacheInput): void { | ||||
| @@ -21,11 +20,6 @@ export function setInputs(input: CacheInput): void { | ||||
|     setInput(Inputs.Key, input.key); | ||||
|     input.restoreKeys && | ||||
|         setInput(Inputs.RestoreKeys, input.restoreKeys.join("\n")); | ||||
|     input.enableCrossOsArchive !== undefined && | ||||
|         setInput( | ||||
|             Inputs.EnableCrossOsArchive, | ||||
|             input.enableCrossOsArchive.toString() | ||||
|         ); | ||||
| } | ||||
|  | ||||
| export function clearInputs(): void { | ||||
| @@ -33,5 +27,4 @@ export function clearInputs(): void { | ||||
|     delete process.env[getInputName(Inputs.Key)]; | ||||
|     delete process.env[getInputName(Inputs.RestoreKeys)]; | ||||
|     delete process.env[getInputName(Inputs.UploadChunkSize)]; | ||||
|     delete process.env[getInputName(Inputs.EnableCrossOsArchive)]; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user