diff --git a/__tests__/cache-utils.test.ts b/__tests__/cache-utils.test.ts index d8934eb..9e8d653 100644 --- a/__tests__/cache-utils.test.ts +++ b/__tests__/cache-utils.test.ts @@ -46,7 +46,8 @@ describe('cache-utils', () => { isFeatureAvailable.mockImplementation(() => false); process.env['GITHUB_SERVER_URL'] = 'https://www.test.com'; - expect(() => isCacheFeatureAvailable()).toThrowError( + expect(isCacheFeatureAvailable()).toBeFalsy(); + expect(warningSpy).toHaveBeenCalledWith( '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.' ); }); diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index 3c3105e..2a74f78 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -728,8 +728,9 @@ describe('setup-node', () => { await main.run(); - expect(cnSpy).toHaveBeenCalledWith( - `::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.${osm.EOL}` + expect(warningSpy).toHaveBeenCalledWith( + // `::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.${osm.EOL}` + '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.' ); }); diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 876629e..d099eec 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -61185,16 +61185,14 @@ function isGhes() { } exports.isGhes = isGhes; function isCacheFeatureAvailable() { - if (!cache.isFeatureAvailable()) { - 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.'); - } - else { - core.warning('The runner was not able to contact the cache service. Caching will be skipped'); - } + if (cache.isFeatureAvailable()) + return true; + 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 true; + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + return false; } exports.isCacheFeatureAvailable = isCacheFeatureAvailable; diff --git a/dist/setup/index.js b/dist/setup/index.js index b6c3e23..01a4548 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -73139,16 +73139,14 @@ function isGhes() { } exports.isGhes = isGhes; function isCacheFeatureAvailable() { - if (!cache.isFeatureAvailable()) { - 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.'); - } - else { - core.warning('The runner was not able to contact the cache service. Caching will be skipped'); - } + if (cache.isFeatureAvailable()) + return true; + 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 true; + core.warning('The runner was not able to contact the cache service. Caching will be skipped'); + return false; } exports.isCacheFeatureAvailable = isCacheFeatureAvailable; diff --git a/src/cache-utils.ts b/src/cache-utils.ts index ccd4e98..5df3e71 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -105,19 +105,18 @@ export function isGhes(): boolean { } export function isCacheFeatureAvailable(): boolean { - if (!cache.isFeatureAvailable()) { - 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.' - ); - } else { - core.warning( - 'The runner was not able to contact the cache service. Caching will be skipped' - ); - } + if (cache.isFeatureAvailable()) return true; + 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 true; + core.warning( + 'The runner was not able to contact the cache service. Caching will be skipped' + ); + + return false; }