MCPcopy
hub / github.com/actions/setup-java / computeCacheKey

Function computeCacheKey

src/cache.ts:91–105  ·  view source on GitHub ↗

* A function that generates a cache key to use. * Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"". * @see https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key

(
  packageManager: PackageManager,
  cacheDependencyPath: string
)

Source from the content-addressed store, hash-verified

89 * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
90 */
91async function computeCacheKey(
92 packageManager: PackageManager,
93 cacheDependencyPath: string
94) {
95 const pattern = cacheDependencyPath
96 ? cacheDependencyPath.trim().split('\n')
97 : packageManager.pattern;
98 const fileHash = await glob.hashFiles(pattern.join('\n'));
99 if (!fileHash) {
100 throw new Error(
101 `No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`
102 );
103 }
104 return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
105}
106
107/**
108 * Restore the dependency cache

Callers 1

restoreFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected