diff --git a/__tests__/utils.test.ts b/__tests__/utils.test.ts index 04ec7c51..30fc61cb 100644 --- a/__tests__/utils.test.ts +++ b/__tests__/utils.test.ts @@ -42,14 +42,13 @@ describe('validateVersion', () => { describe('isCacheFeatureAvailable', () => { it('isCacheFeatureAvailable disabled on GHES', () => { jest.spyOn(cache, 'isFeatureAvailable').mockImplementation(() => false); + const infoMock = jest.spyOn(core, 'warning'); + const message = + 'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'; try { process.env['GITHUB_SERVER_URL'] = 'http://example.com'; - isCacheFeatureAvailable(); - } catch (error) { - expect(error).toHaveProperty( - 'message', - 'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.' - ); + expect(isCacheFeatureAvailable()).toBeFalsy(); + expect(infoMock).toHaveBeenCalledWith(message); } finally { delete process.env['GITHUB_SERVER_URL']; } diff --git a/dist/setup/index.js b/dist/setup/index.js index 1901d1a1..2d155710 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -67061,7 +67061,8 @@ function isCacheFeatureAvailable() { return true; } if (isGhes()) { - throw new Error('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.'); + core.warning('Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the 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/utils.ts b/src/utils.ts index bc2e8798..fe32eda9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -110,9 +110,10 @@ export function isCacheFeatureAvailable(): boolean { } if (isGhes()) { - throw new Error( + core.warning( 'Caching is only supported on GHES version >= 3.5. If you are on a version >= 3.5, please check with your GHES admin if the Actions cache service is enabled or not.' ); + return false; } core.warning(