From b28830cbe242f8218618bacd97758c82c162a981 Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Fri, 9 Dec 2022 12:05:59 +0100 Subject: [PATCH] replace throw with warn --- __tests__/cache-utils.test.ts | 3 ++- __tests__/installer.test.ts | 5 +++-- dist/cache-save/index.js | 6 ++++-- dist/setup/index.js | 6 ++++-- src/cache-utils.ts | 6 ++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/__tests__/cache-utils.test.ts b/__tests__/cache-utils.test.ts index d8934eba..9e8d653d 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 3c3105e2..2a74f78f 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 5f499403..d099eecb 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -61187,8 +61187,10 @@ exports.isGhes = isGhes; function isCacheFeatureAvailable() { if (cache.isFeatureAvailable()) return true; - 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.'); + 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; + } core.warning('The runner was not able to contact the cache service. Caching will be skipped'); return false; } diff --git a/dist/setup/index.js b/dist/setup/index.js index af122147..01a4548b 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -73141,8 +73141,10 @@ exports.isGhes = isGhes; function isCacheFeatureAvailable() { if (cache.isFeatureAvailable()) return true; - 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.'); + 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; + } core.warning('The runner was not able to contact the cache service. Caching will be skipped'); return false; } diff --git a/src/cache-utils.ts b/src/cache-utils.ts index 065d347e..5df3e718 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -107,10 +107,12 @@ export function isGhes(): boolean { export function isCacheFeatureAvailable(): boolean { if (cache.isFeatureAvailable()) return true; - if (isGhes()) - throw new Error( + 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; + } core.warning( 'The runner was not able to contact the cache service. Caching will be skipped'