fix(): cache resolve version input (#267)

This commit is contained in:
n33pm 2022-10-17 18:33:22 +02:00 committed by GitHub
parent f556e5b7e0
commit c4a742cab1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 8 deletions

View file

@ -17,6 +17,7 @@ describe('restoreCache', () => {
let infoSpy = jest.spyOn(core, 'info'); let infoSpy = jest.spyOn(core, 'info');
let setOutputSpy = jest.spyOn(core, 'setOutput'); let setOutputSpy = jest.spyOn(core, 'setOutput');
const versionSpec = '1.13.1';
const packageManager = 'default'; const packageManager = 'default';
const cacheDependencyPath = 'path'; const cacheDependencyPath = 'path';
@ -40,7 +41,11 @@ describe('restoreCache', () => {
//Act + Assert //Act + Assert
expect(async () => { expect(async () => {
await cacheRestore.restoreCache(packageManager, cacheDependencyPath); await cacheRestore.restoreCache(
versionSpec,
packageManager,
cacheDependencyPath
);
}).rejects.toThrowError( }).rejects.toThrowError(
'Some specified paths were not resolved, unable to cache dependencies.' 'Some specified paths were not resolved, unable to cache dependencies.'
); );
@ -61,7 +66,11 @@ describe('restoreCache', () => {
}); });
//Act + Assert //Act + Assert
await cacheRestore.restoreCache(packageManager, cacheDependencyPath); await cacheRestore.restoreCache(
versionSpec,
packageManager,
cacheDependencyPath
);
expect(infoSpy).toBeCalledWith(`Cache is not found`); expect(infoSpy).toBeCalledWith(`Cache is not found`);
}); });
@ -80,7 +89,11 @@ describe('restoreCache', () => {
}); });
//Act + Assert //Act + Assert
await cacheRestore.restoreCache(packageManager, cacheDependencyPath); await cacheRestore.restoreCache(
versionSpec,
packageManager,
cacheDependencyPath
);
expect(setOutputSpy).toBeCalledWith('cache-hit', true); expect(setOutputSpy).toBeCalledWith('cache-hit', true);
}); });
}); });

5
dist/setup/index.js vendored
View file

@ -63032,10 +63032,9 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
const fs_1 = __importDefault(__nccwpck_require__(7147)); const fs_1 = __importDefault(__nccwpck_require__(7147));
const constants_1 = __nccwpck_require__(9042); const constants_1 = __nccwpck_require__(9042);
const cache_utils_1 = __nccwpck_require__(1678); 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 packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
const platform = process.env.RUNNER_OS; const platform = process.env.RUNNER_OS;
const versionSpec = core.getInput('go-version');
const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo); const cachePaths = yield cache_utils_1.getCacheDirectoryPath(packageManagerInfo);
const dependencyFilePath = cacheDependencyPath const dependencyFilePath = cacheDependencyPath
? cacheDependencyPath ? cacheDependencyPath
@ -63538,7 +63537,7 @@ function run() {
if (cache && cache_utils_1.isCacheFeatureAvailable()) { if (cache && cache_utils_1.isCacheFeatureAvailable()) {
const packageManager = 'default'; const packageManager = 'default';
const cacheDependencyPath = core.getInput('cache-dependency-path'); 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 // add problem matchers
const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json'); const matchersPath = path_1.default.join(__dirname, '../..', 'matchers.json');

View file

@ -9,12 +9,12 @@ import {PackageManagerInfo} from './package-managers';
import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils'; import {getCacheDirectoryPath, getPackageManagerInfo} from './cache-utils';
export const restoreCache = async ( export const restoreCache = async (
versionSpec: string,
packageManager: string, packageManager: string,
cacheDependencyPath?: string cacheDependencyPath?: string
) => { ) => {
const packageManagerInfo = await getPackageManagerInfo(packageManager); const packageManagerInfo = await getPackageManagerInfo(packageManager);
const platform = process.env.RUNNER_OS; const platform = process.env.RUNNER_OS;
const versionSpec = core.getInput('go-version');
const cachePaths = await getCacheDirectoryPath(packageManagerInfo); const cachePaths = await getCacheDirectoryPath(packageManagerInfo);

View file

@ -56,7 +56,7 @@ export async function run() {
if (cache && isCacheFeatureAvailable()) { if (cache && isCacheFeatureAvailable()) {
const packageManager = 'default'; const packageManager = 'default';
const cacheDependencyPath = core.getInput('cache-dependency-path'); const cacheDependencyPath = core.getInput('cache-dependency-path');
await restoreCache(packageManager, cacheDependencyPath); await restoreCache(versionSpec, packageManager, cacheDependencyPath);
} }
// add problem matchers // add problem matchers