From fff60808d0327ec0c3730d93e90e858c59413a1f Mon Sep 17 00:00:00 2001 From: jongwooo Date: Tue, 13 Dec 2022 00:18:08 +0900 Subject: [PATCH] fix: Replace throw with warn Signed-off-by: jongwooo --- __tests__/cache-utils.test.ts | 7 ++++--- dist/cache-save/index.js | 3 ++- dist/setup/index.js | 3 ++- src/cache-utils.ts | 3 ++- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/__tests__/cache-utils.test.ts b/__tests__/cache-utils.test.ts index 1bf7ca3..a21d3aa 100644 --- a/__tests__/cache-utils.test.ts +++ b/__tests__/cache-utils.test.ts @@ -162,7 +162,7 @@ describe('isCacheFeatureAvailable', () => { 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 isFeatureAvailableSpy.mockImplementation(() => { return false; @@ -170,10 +170,11 @@ describe('isCacheFeatureAvailable', () => { 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.'; //Act + Assert - expect(() => cacheUtils.isCacheFeatureAvailable()).toThrow(errorMessage); + expect(cacheUtils.isCacheFeatureAvailable()).toBeFalsy(); + expect(warningSpy).toHaveBeenCalledWith(warningMessage); }); }); diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 338e2ca..1c09127 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -60475,7 +60475,8 @@ function isCacheFeatureAvailable() { 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.'); + 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 2d3ab78..7c0c8e3 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -63148,7 +63148,8 @@ function isCacheFeatureAvailable() { 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.'); + 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 91b3bae..44192bf 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -62,9 +62,10 @@ export function isCacheFeatureAvailable(): boolean { } if (isGhes()) { - throw new Error( + 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(