diff --git a/.gitattributes b/.gitattributes index bff632d..cb954fe 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,3 @@ dist/index.js -diff -merge dist/index.js linguist-generated=true -.licenses/** -diff linguist-generated=true +.licenses/** -diff linguist-generated=true \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json index a2f723b..c3f97b7 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,11 +1,12 @@ { + "arrowParens": "avoid", + "bracketSpacing": true, + "endOfLine": "auto", + "parser": "typescript", "printWidth": 100, - "tabWidth": 2, - "useTabs": false, "semi": true, "singleQuote": true, + "tabWidth": 2, "trailingComma": "none", - "bracketSpacing": true, - "arrowParens": "avoid", - "parser": "typescript" + "useTabs": false } diff --git a/__tests__/cache.test.ts b/__tests__/cache.test.ts index b748e80..fc2edcf 100644 --- a/__tests__/cache.test.ts +++ b/__tests__/cache.test.ts @@ -90,7 +90,9 @@ describe('dependency cache', () => { await restore('maven'); expect(spyCacheRestore).toBeCalled(); expect(spyWarning).not.toBeCalled(); - expect(spyInfo).toBeCalledWith('maven cache is not found'); + expect(spyInfo).toBeCalledWith( + `Cache not found for input keys: ${process.env['RUNNER_OS']}-setup-java-maven-5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456, ${process.env['RUNNER_OS']}-setup-java-maven-, ${process.env['RUNNER_OS']}-setup-java-` + ); }); }); describe('for gradle', () => { @@ -107,7 +109,9 @@ describe('dependency cache', () => { await restore('gradle'); expect(spyCacheRestore).toBeCalled(); expect(spyWarning).not.toBeCalled(); - expect(spyInfo).toBeCalledWith('gradle cache is not found'); + expect(spyInfo).toBeCalledWith( + `Cache not found for input keys: ${process.env['RUNNER_OS']}-setup-java-gradle-5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456, ${process.env['RUNNER_OS']}-setup-java-gradle-, ${process.env['RUNNER_OS']}-setup-java-` + ); }); it('downloads cache based on build.gradle.kts', async () => { createFile(join(workspace, 'build.gradle.kts')); @@ -115,7 +119,9 @@ describe('dependency cache', () => { await restore('gradle'); expect(spyCacheRestore).toBeCalled(); expect(spyWarning).not.toBeCalled(); - expect(spyInfo).toBeCalledWith('gradle cache is not found'); + expect(spyInfo).toBeCalledWith( + `Cache not found for input keys: ${process.env['RUNNER_OS']}-setup-java-gradle-5df6e0e2761359d30a8275058e299fcc0381534545f55cf43e41983f5d4c9456, ${process.env['RUNNER_OS']}-setup-java-gradle-, ${process.env['RUNNER_OS']}-setup-java-` + ); }); }); }); diff --git a/dist/cleanup/index.js b/dist/cleanup/index.js index bbc6529..7fbafcd 100644 --- a/dist/cleanup/index.js +++ b/dist/cleanup/index.js @@ -64575,7 +64575,7 @@ function findPackageManager(id) { function computeCacheKey(packageManager) { return __awaiter(this, void 0, void 0, function* () { const hash = yield glob.hashFiles(packageManager.pattern.join('\n')); - return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; + return `${process.env.RUNNER_OS}-${CACHE_KEY_PREFIX}-${packageManager.id}-${hash}`; }); } /** @@ -64591,15 +64591,17 @@ function restore(id) { if (primaryKey.endsWith('-')) { throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`); } - const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [ - `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}` - ]); + const restoreKeys = [ + `${process.env.RUNNER_OS}-${CACHE_KEY_PREFIX}-${id}-`, + `${process.env.RUNNER_OS}-${CACHE_KEY_PREFIX}-` + ]; + const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, restoreKeys); if (matchedKey) { core.saveState(CACHE_MATCHED_KEY, matchedKey); core.info(`Cache restored from key: ${matchedKey}`); } else { - core.info(`${packageManager.id} cache is not found`); + core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(', ')}`); } }); } diff --git a/dist/setup/index.js b/dist/setup/index.js index d8f0e77..3ad3439 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -18962,7 +18962,7 @@ function findPackageManager(id) { function computeCacheKey(packageManager) { return __awaiter(this, void 0, void 0, function* () { const hash = yield glob.hashFiles(packageManager.pattern.join('\n')); - return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; + return `${process.env.RUNNER_OS}-${CACHE_KEY_PREFIX}-${packageManager.id}-${hash}`; }); } /** @@ -18978,15 +18978,17 @@ function restore(id) { if (primaryKey.endsWith('-')) { throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`); } - const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [ - `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}` - ]); + const restoreKeys = [ + `${process.env.RUNNER_OS}-${CACHE_KEY_PREFIX}-${id}-`, + `${process.env.RUNNER_OS}-${CACHE_KEY_PREFIX}-` + ]; + const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, restoreKeys); if (matchedKey) { core.saveState(CACHE_MATCHED_KEY, matchedKey); core.info(`Cache restored from key: ${matchedKey}`); } else { - core.info(`${packageManager.id} cache is not found`); + core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(', ')}`); } }); } diff --git a/package.json b/package.json index c14f855..a720a48 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "format-check": "prettier --check \"{,!(node_modules)/**/}*.ts\"", "prerelease": "npm run-script build", "release": "git add -f dist/setup/index.js dist/cleanup/index.js", - "test": "jest" + "test": "jest", + "pre-checkin": "npm run format && npm run build && npm test" }, "repository": { "type": "git", diff --git a/src/cache.ts b/src/cache.ts index fb97fb0..bd3179a 100644 --- a/src/cache.ts +++ b/src/cache.ts @@ -51,7 +51,7 @@ function findPackageManager(id: string): PackageManager { */ async function computeCacheKey(packageManager: PackageManager) { const hash = await glob.hashFiles(packageManager.pattern.join('\n')); - return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; + return `${process.env.RUNNER_OS}-${CACHE_KEY_PREFIX}-${packageManager.id}-${hash}`; } /** @@ -72,14 +72,16 @@ export async function restore(id: string) { ); } - const matchedKey = await cache.restoreCache(packageManager.path, primaryKey, [ - `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}` - ]); + const restoreKeys = [ + `${process.env.RUNNER_OS}-${CACHE_KEY_PREFIX}-${id}-`, + `${process.env.RUNNER_OS}-${CACHE_KEY_PREFIX}-` + ]; + const matchedKey = await cache.restoreCache(packageManager.path, primaryKey, restoreKeys); if (matchedKey) { core.saveState(CACHE_MATCHED_KEY, matchedKey); core.info(`Cache restored from key: ${matchedKey}`); } else { - core.info(`${packageManager.id} cache is not found`); + core.info(`Cache not found for input keys: ${[primaryKey, ...restoreKeys].join(', ')}`); } }