Merge branch 'main' into allow-use-one-cache-folder

This commit is contained in:
Evgenii Korolevskii 2022-12-19 11:13:33 +01:00
commit 968df316fc
4 changed files with 5971 additions and 5972 deletions

View File

@ -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);
}); });
}); });

5439
dist/cache-save/index.js vendored

File diff suppressed because it is too large Load Diff

6475
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -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;
} }