From c4a742cab115ed795e34d4513e2cf7d472deb55f Mon Sep 17 00:00:00 2001 From: n33pm <12273891+n33pm@users.noreply.github.com> Date: Mon, 17 Oct 2022 18:33:22 +0200 Subject: [PATCH] fix(): cache resolve version input (#267) --- __tests__/cache-restore.test.ts | 19 ++++++++++++++++--- dist/setup/index.js | 5 ++--- src/cache-restore.ts | 2 +- src/main.ts | 2 +- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/__tests__/cache-restore.test.ts b/__tests__/cache-restore.test.ts index 717a5ea..98d85a7 100644 --- a/__tests__/cache-restore.test.ts +++ b/__tests__/cache-restore.test.ts @@ -17,6 +17,7 @@ describe('restoreCache', () => { let infoSpy = jest.spyOn(core, 'info'); let setOutputSpy = jest.spyOn(core, 'setOutput'); + const versionSpec = '1.13.1'; const packageManager = 'default'; const cacheDependencyPath = 'path'; @@ -40,7 +41,11 @@ describe('restoreCache', () => { //Act + Assert expect(async () => { - await cacheRestore.restoreCache(packageManager, cacheDependencyPath); + await cacheRestore.restoreCache( + versionSpec, + packageManager, + cacheDependencyPath + ); }).rejects.toThrowError( 'Some specified paths were not resolved, unable to cache dependencies.' ); @@ -61,7 +66,11 @@ describe('restoreCache', () => { }); //Act + Assert - await cacheRestore.restoreCache(packageManager, cacheDependencyPath); + await cacheRestore.restoreCache( + versionSpec, + packageManager, + cacheDependencyPath + ); expect(infoSpy).toBeCalledWith(`Cache is not found`); }); @@ -80,7 +89,11 @@ describe('restoreCache', () => { }); //Act + Assert - await cacheRestore.restoreCache(packageManager, cacheDependencyPath); + await cacheRestore.restoreCache( + versionSpec, + packageManager, + cacheDependencyPath + ); expect(setOutputSpy).toBeCalledWith('cache-hit', true); }); }); diff --git a/dist/setup/index.js b/dist/setup/index.js index 7eefc1f..9c80baa 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63032,10 +63032,9 @@ const path_1 = __importDefault(__nccwpck_require__(1017)); const fs_1 = __importDefault(__nccwpck_require__(7147)); const constants_1 = __nccwpck_require__(9042); const cache_utils_1 = __nccwpck_require__(1678); -exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { +exports.restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager); const platform = process.env.RUNNER_OS; - const versionSpec = core.getInput('go-version'); const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); const dependencyFilePath = cacheDependencyPath ? cacheDependencyPath @@ -63538,7 +63537,7 @@ function run() { if (cache && cache_utils_1.isCacheFeatureAvailable()) { const packageManager = 'default'; const cacheDependencyPath = core.getInput('cache-dependency-path'); - yield cache_restore_1.restoreCache(packageManager, cacheDependencyPath); + yield cache_restore_1.restoreCache(versionSpec, packageManager, cacheDependencyPath); } // add problem matchers const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json'); diff --git a/src/cache-restore.ts b/src/cache-restore.ts index 3e6df51..930122c 100644 --- a/src/cache-restore.ts +++ b/src/cache-restore.ts @@ -9,12 +9,12 @@ import {PackageManagerInfo} from './package-managers'; import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils'; export const restoreCache = async ( + versionSpec: string, packageManager: string, cacheDependencyPath?: string ) => { const packageManagerInfo = await getPackageManagerInfo(packageManager); const platform = process.env.RUNNER_OS; - const versionSpec = core.getInput('go-version'); const cachePaths = await getCacheDirectoryPath(packageManagerInfo); diff --git a/src/main.ts b/src/main.ts index 8648d4d..36a7ce0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -56,7 +56,7 @@ export async function run() { if (cache && isCacheFeatureAvailable()) { const packageManager = 'default'; const cacheDependencyPath = core.getInput('cache-dependency-path'); - await restoreCache(packageManager, cacheDependencyPath); + await restoreCache(versionSpec, packageManager, cacheDependencyPath); } // add problem matchers