mirror of
				https://github.com/actions/setup-java.git
				synced 2025-11-04 08:20:54 +00:00 
			
		
		
		
	add a prefix to the cache key
https://github.com/actions/setup-java/pull/193/files#r669521434
This commit is contained in:
		
					parent
					
						
							
								0591f86118
							
						
					
				
			
			
				commit
				
					
						f537562e33
					
				
			
		
					 3 changed files with 12 additions and 8 deletions
				
			
		
							
								
								
									
										6
									
								
								dist/cleanup/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								dist/cleanup/index.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -64534,6 +64534,7 @@ const core = __importStar(__webpack_require__(470));
 | 
				
			||||||
const glob = __importStar(__webpack_require__(281));
 | 
					const glob = __importStar(__webpack_require__(281));
 | 
				
			||||||
const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key';
 | 
					const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key';
 | 
				
			||||||
const CACHE_MATCHED_KEY = 'cache-matched-key';
 | 
					const CACHE_MATCHED_KEY = 'cache-matched-key';
 | 
				
			||||||
 | 
					const CACHE_KEY_PREFIX = 'setup-java';
 | 
				
			||||||
const supportedPackageManager = [
 | 
					const supportedPackageManager = [
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        id: 'maven',
 | 
					        id: 'maven',
 | 
				
			||||||
| 
						 | 
					@ -64563,7 +64564,8 @@ function findPackageManager(id) {
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
function computeCacheKey(packageManager) {
 | 
					function computeCacheKey(packageManager) {
 | 
				
			||||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
					    return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
        return `${process.env['RUNNER_OS']}-${packageManager.id}-${yield glob.hashFiles(packageManager.pattern.join('\n'))}`;
 | 
					        const hash = yield glob.hashFiles(packageManager.pattern.join('\n'));
 | 
				
			||||||
 | 
					        return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -64581,7 +64583,7 @@ function restore(id) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [
 | 
					        const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [
 | 
				
			||||||
            `${process.env['RUNNER_OS']}-${id}`
 | 
					            `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}`
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
        if (matchedKey) {
 | 
					        if (matchedKey) {
 | 
				
			||||||
            core.saveState(CACHE_MATCHED_KEY, matchedKey);
 | 
					            core.saveState(CACHE_MATCHED_KEY, matchedKey);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										6
									
								
								dist/setup/index.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										6
									
								
								dist/setup/index.js
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -18930,6 +18930,7 @@ const core = __importStar(__webpack_require__(470));
 | 
				
			||||||
const glob = __importStar(__webpack_require__(281));
 | 
					const glob = __importStar(__webpack_require__(281));
 | 
				
			||||||
const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key';
 | 
					const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key';
 | 
				
			||||||
const CACHE_MATCHED_KEY = 'cache-matched-key';
 | 
					const CACHE_MATCHED_KEY = 'cache-matched-key';
 | 
				
			||||||
 | 
					const CACHE_KEY_PREFIX = 'setup-java';
 | 
				
			||||||
const supportedPackageManager = [
 | 
					const supportedPackageManager = [
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        id: 'maven',
 | 
					        id: 'maven',
 | 
				
			||||||
| 
						 | 
					@ -18959,7 +18960,8 @@ function findPackageManager(id) {
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
function computeCacheKey(packageManager) {
 | 
					function computeCacheKey(packageManager) {
 | 
				
			||||||
    return __awaiter(this, void 0, void 0, function* () {
 | 
					    return __awaiter(this, void 0, void 0, function* () {
 | 
				
			||||||
        return `${process.env['RUNNER_OS']}-${packageManager.id}-${yield glob.hashFiles(packageManager.pattern.join('\n'))}`;
 | 
					        const hash = yield glob.hashFiles(packageManager.pattern.join('\n'));
 | 
				
			||||||
 | 
					        return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`;
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -18977,7 +18979,7 @@ function restore(id) {
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [
 | 
					        const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [
 | 
				
			||||||
            `${process.env['RUNNER_OS']}-${id}`
 | 
					            `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}`
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
        if (matchedKey) {
 | 
					        if (matchedKey) {
 | 
				
			||||||
            core.saveState(CACHE_MATCHED_KEY, matchedKey);
 | 
					            core.saveState(CACHE_MATCHED_KEY, matchedKey);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -10,6 +10,7 @@ import * as glob from '@actions/glob';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key';
 | 
					const STATE_CACHE_PRIMARY_KEY = 'cache-primary-key';
 | 
				
			||||||
const CACHE_MATCHED_KEY = 'cache-matched-key';
 | 
					const CACHE_MATCHED_KEY = 'cache-matched-key';
 | 
				
			||||||
 | 
					const CACHE_KEY_PREFIX = 'setup-java';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface PackageManager {
 | 
					interface PackageManager {
 | 
				
			||||||
  id: 'maven' | 'gradle';
 | 
					  id: 'maven' | 'gradle';
 | 
				
			||||||
| 
						 | 
					@ -49,9 +50,8 @@ function findPackageManager(id: string): PackageManager {
 | 
				
			||||||
 * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
 | 
					 * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
async function computeCacheKey(packageManager: PackageManager) {
 | 
					async function computeCacheKey(packageManager: PackageManager) {
 | 
				
			||||||
  return `${process.env['RUNNER_OS']}-${packageManager.id}-${await glob.hashFiles(
 | 
					  const hash = await glob.hashFiles(packageManager.pattern.join('\n'));
 | 
				
			||||||
    packageManager.pattern.join('\n')
 | 
					  return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`;
 | 
				
			||||||
  )}`;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
| 
						 | 
					@ -74,7 +74,7 @@ export async function restore(id: string) {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const matchedKey = await cache.restoreCache(packageManager.path, primaryKey, [
 | 
					  const matchedKey = await cache.restoreCache(packageManager.path, primaryKey, [
 | 
				
			||||||
    `${process.env['RUNNER_OS']}-${id}`
 | 
					    `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}`
 | 
				
			||||||
  ]);
 | 
					  ]);
 | 
				
			||||||
  if (matchedKey) {
 | 
					  if (matchedKey) {
 | 
				
			||||||
    core.saveState(CACHE_MATCHED_KEY, matchedKey);
 | 
					    core.saveState(CACHE_MATCHED_KEY, matchedKey);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue