mirror of
				https://github.com/actions/cache.git
				synced 2025-10-31 02:14:19 +08:00 
			
		
		
		
	Merge branch 'main' into todgru/v4-documentation-update
This commit is contained in:
		
						commit
						c4ee99a3bd
					
				| @ -54,7 +54,7 @@ If you are using a `self-hosted` Windows runner, `GNU tar` and `zstd` are requir | |||||||
| 
 | 
 | ||||||
| * `key` - An explicit key for a cache entry. See [creating a cache key](#creating-a-cache-key). | * `key` - An explicit key for a cache entry. See [creating a cache key](#creating-a-cache-key). | ||||||
| * `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns. | * `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns. | ||||||
| * `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key. | * `restore-keys` - An ordered multiline string listing the prefix-matched keys, that are used for restoring stale cache if no cache hit occurred for key. | ||||||
| * `enableCrossOsArchive` - An optional boolean when enabled, allows Windows runners to save or restore caches that can be restored or saved respectively on other platforms. Default: `false` | * `enableCrossOsArchive` - An optional boolean when enabled, allows Windows runners to save or restore caches that can be restored or saved respectively on other platforms. Default: `false` | ||||||
| * `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false` | * `fail-on-cache-miss` - Fail the workflow if cache entry is not found. Default: `false` | ||||||
| * `lookup-only` - If true, only checks if cache entry exists and skips download. Does not change save cache behavior. Default: `false` | * `lookup-only` - If true, only checks if cache entry exists and skips download. Does not change save cache behavior. Default: `false` | ||||||
|  | |||||||
| @ -260,7 +260,7 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys | |||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); |     expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); | ||||||
|     expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0); |     expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); | ||||||
| 
 | 
 | ||||||
|     expect(failedMock).toHaveBeenCalledWith( |     expect(failedMock).toHaveBeenCalledWith( | ||||||
|         `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}` |         `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}` | ||||||
|  | |||||||
| @ -86,7 +86,8 @@ test("restore with no cache found", async () => { | |||||||
|     ); |     ); | ||||||
| 
 | 
 | ||||||
|     expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); |     expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); | ||||||
|     expect(outputMock).toHaveBeenCalledTimes(1); |     expect(outputMock).toHaveBeenCalledWith("cache-hit", "false"); | ||||||
|  |     expect(outputMock).toHaveBeenCalledTimes(2); | ||||||
|     expect(failedMock).toHaveBeenCalledTimes(0); |     expect(failedMock).toHaveBeenCalledTimes(0); | ||||||
| 
 | 
 | ||||||
|     expect(infoMock).toHaveBeenCalledWith( |     expect(infoMock).toHaveBeenCalledWith( | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ inputs: | |||||||
|     description: 'An explicit key for restoring and saving the cache' |     description: 'An explicit key for restoring and saving the cache' | ||||||
|     required: true |     required: true | ||||||
|   restore-keys: |   restore-keys: | ||||||
|     description: 'An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.' |     description: 'An ordered multiline string listing the prefix-matched keys, that are used for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.' | ||||||
|     required: false |     required: false | ||||||
|   upload-chunk-size: |   upload-chunk-size: | ||||||
|     description: 'The chunk size used to split up large files during upload, in bytes' |     description: 'The chunk size used to split up large files during upload, in bytes' | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								dist/restore-only/index.js
									
									
									
									
										vendored
									
									
								
							| @ -59415,6 +59415,7 @@ function restoreImpl(stateProvider, earlyExit) { | |||||||
|             const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly); |             const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly); | ||||||
|             const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive); |             const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive); | ||||||
|             if (!cacheKey) { |             if (!cacheKey) { | ||||||
|  |                 core.setOutput(constants_1.Outputs.CacheHit, false.toString()); | ||||||
|                 if (failOnCacheMiss) { |                 if (failOnCacheMiss) { | ||||||
|                     throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`); |                     throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`); | ||||||
|                 } |                 } | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								dist/restore/index.js
									
									
									
									
										vendored
									
									
								
							| @ -59415,6 +59415,7 @@ function restoreImpl(stateProvider, earlyExit) { | |||||||
|             const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly); |             const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly); | ||||||
|             const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive); |             const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive); | ||||||
|             if (!cacheKey) { |             if (!cacheKey) { | ||||||
|  |                 core.setOutput(constants_1.Outputs.CacheHit, false.toString()); | ||||||
|                 if (failOnCacheMiss) { |                 if (failOnCacheMiss) { | ||||||
|                     throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`); |                     throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`); | ||||||
|                 } |                 } | ||||||
|  | |||||||
| @ -513,6 +513,7 @@ jobs: | |||||||
| ```yaml | ```yaml | ||||||
| - name: Get pip cache dir | - name: Get pip cache dir | ||||||
|   id: pip-cache |   id: pip-cache | ||||||
|  |   shell: bash | ||||||
|   run: | |   run: | | ||||||
|     echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT |     echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -9,7 +9,7 @@ inputs: | |||||||
|     description: 'An explicit key for restoring the cache' |     description: 'An explicit key for restoring the cache' | ||||||
|     required: true |     required: true | ||||||
|   restore-keys: |   restore-keys: | ||||||
|     description: 'An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.' |     description: 'An ordered multiline string listing the prefix-matched keys, that are used for restoring stale cache if no cache hit occurred for key. Note `cache-hit` returns false in this case.' | ||||||
|     required: false |     required: false | ||||||
|   enableCrossOsArchive: |   enableCrossOsArchive: | ||||||
|     description: 'An optional boolean when enabled, allows windows runners to restore caches that were saved on other platforms' |     description: 'An optional boolean when enabled, allows windows runners to restore caches that were saved on other platforms' | ||||||
|  | |||||||
| @ -51,6 +51,7 @@ export async function restoreImpl( | |||||||
|         ); |         ); | ||||||
| 
 | 
 | ||||||
|         if (!cacheKey) { |         if (!cacheKey) { | ||||||
|  |             core.setOutput(Outputs.CacheHit, false.toString()); | ||||||
|             if (failOnCacheMiss) { |             if (failOnCacheMiss) { | ||||||
|                 throw new Error( |                 throw new Error( | ||||||
|                     `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}` |                     `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}` | ||||||
| @ -62,7 +63,6 @@ export async function restoreImpl( | |||||||
|                     ...restoreKeys |                     ...restoreKeys | ||||||
|                 ].join(", ")}` |                 ].join(", ")}` | ||||||
|             ); |             ); | ||||||
| 
 |  | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Bassem Dghaidi
						Bassem Dghaidi