mirror of
https://code.forgejo.org/actions/setup-go.git
synced 2024-12-26 06:52:18 -05:00
Allow to use only GOCACHE for cache (#305)
This commit is contained in:
parent
bb5ff97ab9
commit
17106403fa
4 changed files with 5089 additions and 5054 deletions
|
@ -93,6 +93,41 @@ describe('getCacheDirectoryPath', () => {
|
||||||
.then(data => expect(data).toEqual(expectedResult));
|
.then(data => expect(data).toEqual(expectedResult));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return path to the cache folder if one command return empty str', async () => {
|
||||||
|
//Arrange
|
||||||
|
getExecOutputSpy.mockImplementationOnce((commandLine: string) => {
|
||||||
|
return new Promise<exec.ExecOutput>(resolve => {
|
||||||
|
resolve({exitCode: 0, stdout: 'path/to/cache/folder', stderr: ''});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
getExecOutputSpy.mockImplementationOnce((commandLine: string) => {
|
||||||
|
return new Promise<exec.ExecOutput>(resolve => {
|
||||||
|
resolve({exitCode: 0, stdout: '', stderr: ''});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const expectedResult = ['path/to/cache/folder'];
|
||||||
|
|
||||||
|
//Act + Assert
|
||||||
|
return cacheUtils
|
||||||
|
.getCacheDirectoryPath(validPackageManager)
|
||||||
|
.then(data => expect(data).toEqual(expectedResult));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should throw if the both commands return empty str', async () => {
|
||||||
|
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
||||||
|
return new Promise<exec.ExecOutput>(resolve => {
|
||||||
|
resolve({exitCode: 10, stdout: '', stderr: ''});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
//Act + Assert
|
||||||
|
expect(async () => {
|
||||||
|
await cacheUtils.getCacheDirectoryPath(validPackageManager);
|
||||||
|
}).rejects.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
it('should throw if the specified package name is invalid', async () => {
|
it('should throw if the specified package name is invalid', async () => {
|
||||||
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
getExecOutputSpy.mockImplementation((commandLine: string) => {
|
||||||
return new Promise<exec.ExecOutput>(resolve => {
|
return new Promise<exec.ExecOutput>(resolve => {
|
||||||
|
|
8
dist/cache-save/index.js
vendored
8
dist/cache-save/index.js
vendored
|
@ -60457,12 +60457,12 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
|
||||||
});
|
});
|
||||||
exports.getPackageManagerInfo = getPackageManagerInfo;
|
exports.getPackageManagerInfo = getPackageManagerInfo;
|
||||||
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command)));
|
const pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command)));
|
||||||
const emptyPaths = pathList.filter(item => !item);
|
const cachePaths = pathList.filter(item => item);
|
||||||
if (emptyPaths.length) {
|
if (!cachePaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
}
|
}
|
||||||
return pathList;
|
return cachePaths;
|
||||||
});
|
});
|
||||||
exports.getCacheDirectoryPath = getCacheDirectoryPath;
|
exports.getCacheDirectoryPath = getCacheDirectoryPath;
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
|
|
8
dist/setup/index.js
vendored
8
dist/setup/index.js
vendored
|
@ -63130,12 +63130,12 @@ const getPackageManagerInfo = (packageManager) => __awaiter(void 0, void 0, void
|
||||||
});
|
});
|
||||||
exports.getPackageManagerInfo = getPackageManagerInfo;
|
exports.getPackageManagerInfo = getPackageManagerInfo;
|
||||||
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, void 0, function* () {
|
||||||
let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command)));
|
const pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command)));
|
||||||
const emptyPaths = pathList.filter(item => !item);
|
const cachePaths = pathList.filter(item => item);
|
||||||
if (emptyPaths.length) {
|
if (!cachePaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
}
|
}
|
||||||
return pathList;
|
return cachePaths;
|
||||||
});
|
});
|
||||||
exports.getCacheDirectoryPath = getCacheDirectoryPath;
|
exports.getCacheDirectoryPath = getCacheDirectoryPath;
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
|
|
|
@ -34,19 +34,19 @@ export const getPackageManagerInfo = async (packageManager: string) => {
|
||||||
export const getCacheDirectoryPath = async (
|
export const getCacheDirectoryPath = async (
|
||||||
packageManagerInfo: PackageManagerInfo
|
packageManagerInfo: PackageManagerInfo
|
||||||
) => {
|
) => {
|
||||||
let pathList = await Promise.all(
|
const pathList = await Promise.all(
|
||||||
packageManagerInfo.cacheFolderCommandList.map(command =>
|
packageManagerInfo.cacheFolderCommandList.map(command =>
|
||||||
getCommandOutput(command)
|
getCommandOutput(command)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
const emptyPaths = pathList.filter(item => !item);
|
const cachePaths = pathList.filter(item => item);
|
||||||
|
|
||||||
if (emptyPaths.length) {
|
if (!cachePaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return pathList;
|
return cachePaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isGhes(): boolean {
|
export function isGhes(): boolean {
|
||||||
|
|
Loading…
Reference in a new issue