Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(): cache resolve version input #267

Merged
merged 1 commit into from Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 16 additions & 3 deletions __tests__/cache-restore.test.ts
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
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
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
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