mirror of https://github.com/actions/setup-go.git
Merge branch 'main' into allow-use-one-cache-folder
This commit is contained in:
commit
968df316fc
|
@ -197,7 +197,7 @@ describe('isCacheFeatureAvailable', () => {
|
||||||
expect(functionResult).toBeFalsy();
|
expect(functionResult).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should throw when cache feature is unavailable and GHES is used', () => {
|
it('should warn when cache feature is unavailable and GHES is used', () => {
|
||||||
//Arrange
|
//Arrange
|
||||||
isFeatureAvailableSpy.mockImplementation(() => {
|
isFeatureAvailableSpy.mockImplementation(() => {
|
||||||
return false;
|
return false;
|
||||||
|
@ -205,10 +205,11 @@ describe('isCacheFeatureAvailable', () => {
|
||||||
|
|
||||||
process.env['GITHUB_SERVER_URL'] = 'https://nongithub.com';
|
process.env['GITHUB_SERVER_URL'] = 'https://nongithub.com';
|
||||||
|
|
||||||
let errorMessage =
|
let warningMessage =
|
||||||
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.';
|
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.';
|
||||||
|
|
||||||
//Act + Assert
|
//Act + Assert
|
||||||
expect(() => cacheUtils.isCacheFeatureAvailable()).toThrow(errorMessage);
|
expect(cacheUtils.isCacheFeatureAvailable()).toBeFalsy();
|
||||||
|
expect(warningSpy).toHaveBeenCalledWith(warningMessage);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -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* () {
|
||||||
const pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command)));
|
let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command)));
|
||||||
const cachePaths = pathList.filter(item => item);
|
const emptyPaths = pathList.filter(item => !item);
|
||||||
if (!cachePaths.length) {
|
if (emptyPaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
}
|
}
|
||||||
return cachePaths;
|
return pathList;
|
||||||
});
|
});
|
||||||
exports.getCacheDirectoryPath = getCacheDirectoryPath;
|
exports.getCacheDirectoryPath = getCacheDirectoryPath;
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
|
@ -60471,16 +60471,15 @@ function isGhes() {
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isCacheFeatureAvailable() {
|
function isCacheFeatureAvailable() {
|
||||||
if (!cache.isFeatureAvailable()) {
|
if (cache.isFeatureAvailable()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (isGhes()) {
|
if (isGhes()) {
|
||||||
throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
|
core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
|
||||||
}
|
|
||||||
else {
|
|
||||||
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
||||||
|
|
||||||
|
|
|
@ -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* () {
|
||||||
const pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command)));
|
let pathList = yield Promise.all(packageManagerInfo.cacheFolderCommandList.map(command => exports.getCommandOutput(command)));
|
||||||
const cachePaths = pathList.filter(item => item);
|
const emptyPaths = pathList.filter(item => !item);
|
||||||
if (!cachePaths.length) {
|
if (emptyPaths.length) {
|
||||||
throw new Error(`Could not get cache folder paths.`);
|
throw new Error(`Could not get cache folder paths.`);
|
||||||
}
|
}
|
||||||
return cachePaths;
|
return pathList;
|
||||||
});
|
});
|
||||||
exports.getCacheDirectoryPath = getCacheDirectoryPath;
|
exports.getCacheDirectoryPath = getCacheDirectoryPath;
|
||||||
function isGhes() {
|
function isGhes() {
|
||||||
|
@ -63144,16 +63144,15 @@ function isGhes() {
|
||||||
}
|
}
|
||||||
exports.isGhes = isGhes;
|
exports.isGhes = isGhes;
|
||||||
function isCacheFeatureAvailable() {
|
function isCacheFeatureAvailable() {
|
||||||
if (!cache.isFeatureAvailable()) {
|
if (cache.isFeatureAvailable()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (isGhes()) {
|
if (isGhes()) {
|
||||||
throw new Error('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
|
core.warning('Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.');
|
||||||
}
|
|
||||||
else {
|
|
||||||
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
exports.isCacheFeatureAvailable = isCacheFeatureAvailable;
|
||||||
|
|
||||||
|
|
|
@ -57,19 +57,19 @@ export function isGhes(): boolean {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isCacheFeatureAvailable(): boolean {
|
export function isCacheFeatureAvailable(): boolean {
|
||||||
if (!cache.isFeatureAvailable()) {
|
if (cache.isFeatureAvailable()) {
|
||||||
if (isGhes()) {
|
return true;
|
||||||
throw new Error(
|
|
||||||
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
core.warning(
|
|
||||||
'The runner was not able to contact the cache service. Caching will be skipped'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isGhes()) {
|
||||||
|
core.warning(
|
||||||
|
'Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not.'
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
core.warning(
|
||||||
|
'The runner was not able to contact the cache service. Caching will be skipped'
|
||||||
|
);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue