diff --git a/__tests__/cache-utils.test.ts b/__tests__/cache-utils.test.ts index d8934eba..a8c1112c 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( + isCacheFeatureAvailable(); + 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 5a3ad553..6bba9810 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -644,8 +644,8 @@ 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( + '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/src/cache-utils.ts b/src/cache-utils.ts index b71bcc8a..587e788e 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -107,7 +107,7 @@ export function isGhes(): boolean { export function isCacheFeatureAvailable(): boolean { if (!cache.isFeatureAvailable()) { 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.' ); } else { diff --git a/src/main.ts b/src/main.ts index 3c5661b5..9ec73213 100644 --- a/src/main.ts +++ b/src/main.ts @@ -16,7 +16,6 @@ export async function run() { let version = resolveVersionInput(); let arch = core.getInput('architecture'); - const cache = core.getInput('cache'); // if architecture supplied but node-version is not // if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant. @@ -39,6 +38,13 @@ export async function run() { await installer.getNode(version, stable, checkLatest, auth, arch); } + } catch (err) { + core.setFailed(err.message); + } + + try { + const cache = core.getInput('cache'); + const registryUrl: string = core.getInput('registry-url'); const alwaysAuth: string = core.getInput('always-auth'); if (registryUrl) { @@ -59,7 +65,7 @@ export async function run() { `##[add-matcher]${path.join(matchersPath, 'eslint-compact.json')}` ); } catch (err) { - core.setFailed(err.message); + core.warning(err.message); } }