Skip to content

Commit

Permalink
fix(): cache resolve version input (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
n33pm authored Oct 17, 2022
1 parent f556e5b commit c4a742c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 8 deletions.
19 changes: 16 additions & 3 deletions __tests__/cache-restore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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.'
);
Expand All @@ -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`);
});

Expand All @@ -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);
});
});
5 changes: 2 additions & 3 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/cache-restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c4a742c

Please sign in to comment.