mirror of
https://codeberg.org/actions/setup-go.git
synced 2024-01-07 17:16:05 +00:00
fix(): cache resolve version input (#267)
This commit is contained in:
parent
f556e5b7e0
commit
c4a742cab1
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
5
dist/setup/index.js
vendored
5
dist/setup/index.js
vendored
|
@ -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');
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue